From patchwork Tue Jan 19 17:14:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 59990 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2697604lbb; Tue, 19 Jan 2016 09:14:33 -0800 (PST) X-Received: by 10.98.13.195 with SMTP id 64mr45951123pfn.164.1453223673026; Tue, 19 Jan 2016 09:14:33 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 68si48653902pfo.112.2016.01.19.09.14.32; Tue, 19 Jan 2016 09:14:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755691AbcASROb (ORCPT + 1 other); Tue, 19 Jan 2016 12:14:31 -0500 Received: from vms173023pub.verizon.net ([206.46.173.23]:42166 "EHLO vms173023pub.verizon.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755297AbcASROb (ORCPT ); Tue, 19 Jan 2016 12:14:31 -0500 X-Greylist: delayed 781 seconds by postgrey-1.27 at vger.kernel.org; Tue, 19 Jan 2016 12:14:31 EST Received: from serve.minyard.net ([173.57.176.17]) by vms173023.mailsrvcs.net (Oracle Communications Messaging Server 7.0.5.32.0 64bit (built Jul 16 2014)) with ESMTPA id <0O170098XMJSNMC0@vms173023.mailsrvcs.net> for linux-i2c@vger.kernel.org; Tue, 19 Jan 2016 11:14:17 -0600 (CST) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=WpDWSorv c=1 sm=1 tr=0 a=bXmWQgKa9n63w7XTPFb8JQ==:117 a=N54-gffFAAAA:8 a=HL3alpDKAAAA:8 a=oR5dmqMzAAAA:8 a=xqWC_Br6kY4A:10 a=7aQ_Q-yQQ-AA:10 a=fk1lIlRQAAAA:8 a=_eG8g2X6eKyGPlSJkYcA:9 Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:8d:b94b:720b:cc15]) by serve.minyard.net (Postfix) with ESMTPA id C385E1E5D; Tue, 19 Jan 2016 11:14:16 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id F0B8430076D; Tue, 19 Jan 2016 11:14:15 -0600 (CST) From: minyard@acm.org To: Wolfram Sang , linux-i2c@vger.kernel.org Cc: Corey Minyard Subject: [PATCH 2/3] ipmi: Handle I2C parms in the SSIF driver. Date: Tue, 19 Jan 2016 11:14:13 -0600 Message-id: <1453223654-20724-3-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.5.0 In-reply-to: <1453223654-20724-1-git-send-email-minyard@acm.org> References: <1453223654-20724-1-git-send-email-minyard@acm.org> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Corey Minyard Signed-off-by: Corey Minyard --- drivers/char/ipmi/ipmi_ssif.c | 62 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c index 8b3be8b..740fdea 100644 --- a/drivers/char/ipmi/ipmi_ssif.c +++ b/drivers/char/ipmi/ipmi_ssif.c @@ -200,7 +200,7 @@ struct ssif_info { struct ipmi_smi_msg *waiting_msg; struct ipmi_smi_msg *curr_msg; enum ssif_intf_state ssif_state; - unsigned long ssif_debug; + unsigned int ssif_debug; struct ipmi_smi_handlers handlers; @@ -1386,6 +1386,60 @@ restart: return found; } +static int ssif_parse_parms(struct ssif_info *ssif_info, + const char *parms, u8 *slave_addr) +{ + int rv; + char end; + + if (!parms) + return 0; + + while (*parms) { + const char *next = parms; + const char *val; + int parmlen; + + while (*next && !isspace(*next) && *next != '=') + next++; + + if (*next != '=') { + pr_err("IPMI SSIF invalid parm starting at %s\n", + parms); + return -EINVAL; + } + + parmlen = next - parms; + next++; + val = next; + while (*next && !isspace(*next)) + next++; + + if (strncmp(parms, "ipmb", parmlen) == 0) { + rv = sscanf(val, "%hhx%c", slave_addr, &end); + if ((rv < 1) || ((rv > 1) && !isspace(end))) { + pr_err("Invalid ipmb address: %s\n", val); + return -EINVAL; + } + } else if (strncmp(parms, "debug", parmlen) == 0) { + rv = sscanf(val, "%i%c", &ssif_info->ssif_debug, &end); + if ((rv < 1) || ((rv > 1) && !isspace(end))) { + pr_err("Invalid debug value: %s\n", val); + return -EINVAL; + } + } else { + pr_err("Invalid IPMI SSIF parameter: %s\n", parms); + return -EINVAL; + } + + while (*next && isspace(*next)) + next++; + parms = next; + } + + return 0; +} + static bool check_acpi(struct ssif_info *ssif_info, struct device *dev) { #ifdef CONFIG_ACPI @@ -1435,6 +1489,12 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id) if (!addr_info) { /* Must have come in through sysfs. */ ssif_info->addr_source = SI_HOTMOD; + rv = ssif_parse_parms(ssif_info, client->parms, + &slave_addr); + if (rv) { + pr_err(PFX "Unable to parse parms from i2c\n"); + goto out; + } } else { ssif_info->addr_source = addr_info->addr_src; ssif_info->ssif_debug = addr_info->debug;