From patchwork Tue May 10 16:11:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 67467 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2212157qge; Tue, 10 May 2016 09:11:51 -0700 (PDT) X-Received: by 10.66.199.66 with SMTP id ji2mr59479576pac.34.1462896709555; Tue, 10 May 2016 09:11:49 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yx4si3568837pac.109.2016.05.10.09.11.49; Tue, 10 May 2016 09:11:49 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@gmail.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 S1752256AbcEJQLs (ORCPT + 1 other); Tue, 10 May 2016 12:11:48 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:33095 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752011AbcEJQLr (ORCPT ); Tue, 10 May 2016 12:11:47 -0400 Received: by mail-pa0-f67.google.com with SMTP id gh9so1205595pac.0 for ; Tue, 10 May 2016 09:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=KYG8rTcWTegpHa5erpzg6HKq3oeR+3+P3f2urNNxH4w=; b=MZM6bk9ShAL0at09ynE2zBPNDExCChEg3dcwNGlIZI8fwaSVkXyRXr5QtHGvW7AD+W GVciY2c0Ysa2dcLPBnwEpkU5KBLq0g25CWPskBMfGyoQhIqn4sWJDIlZEH5bXsxhvihf gJXTDD90XuUcvTa70L5/AKQbiDRy/EviefOAC4fY+9UilrXA+lTkLTLIX3ueTlT61dh+ TgI2YXGsuK4TyFXl+RfXK+XFy0yvx1uZKy/aePSlbdcEVHRZKkFwV5YEzO8VOqBmWus4 6z8RpNBQzshQXYDrUedMyQAB+Su7WjzAkLiuKOb+2eqrURlCwH8us29S4Hp+FTp8ZXvm WfmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=KYG8rTcWTegpHa5erpzg6HKq3oeR+3+P3f2urNNxH4w=; b=mtPSU70RQvFkXxW+t+SfXeajHIfNhSHbo6C/BmyXTqPqRHM/+TI47ht+P0obbOLc4b ISga4uCKwbdSE/lTBmDGqU4vwKW5K9qZZEk/c6o/uGnMd5Id+OR2TZuXsvjo0lCpQff2 f47yayuQ0YRLuwsOiFzohAANgT93BqE+gkzCff/UCSX0fae2U19IGb+GGh4+uQd0LYDn v4MUDT0E8AiCzFDk2F66G3SHt6gQ6PVdDDGXSUrfXUNsxzVPGKzotL48PENKjjkETGW7 DX9xg9WbYmZtAG1FtYziflwzHNcHtKe5GnliQ383T1hWebw0j4ksvWiYQoB1YCRCjQce JAjQ== X-Gm-Message-State: AOPr4FUn3HSorCOcLPMSxxGtmSuNqPsCjuJv2HM/HoWS6z8diwfbWBWlclNpfRmqkULUoQ== X-Received: by 10.66.65.169 with SMTP id y9mr59836548pas.102.1462896706304; Tue, 10 May 2016 09:11:46 -0700 (PDT) Received: from serve.minyard.net ([108.19.215.157]) by smtp.gmail.com with ESMTPSA id s23sm5545338pfj.86.2016.05.10.09.11.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 May 2016 09:11:45 -0700 (PDT) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 73C4F183B; Tue, 10 May 2016 11:11:43 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id 1ED91300536; Tue, 10 May 2016 11:11:41 -0500 (CDT) From: minyard@acm.org To: Wolfram Sang , linux-i2c@vger.kernel.org, Jean Delvare Cc: minyard@acm.org, Corey Minyard Subject: [PATCH v2 3/3] ipmi: Handle I2C parms in the SSIF driver. Date: Tue, 10 May 2016 11:11:39 -0500 Message-Id: <1462896699-1627-4-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1462896699-1627-1-git-send-email-minyard@acm.org> References: <1462896699-1627-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.7.4 -- 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 097c868..bbd9744 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;