From patchwork Tue May 31 10:03:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 628114 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3rJpxf1yCjz9t3s for ; Tue, 31 May 2016 20:04:38 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751033AbcEaKDR (ORCPT ); Tue, 31 May 2016 06:03:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55023 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750966AbcEaKDO (ORCPT ); Tue, 31 May 2016 06:03:14 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26873C049D5C; Tue, 31 May 2016 10:03:13 +0000 (UTC) Received: from plouf.banquise.eu.com (ovpn-116-134.ams2.redhat.com [10.36.116.134]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4VA37Ei018405; Tue, 31 May 2016 06:03:10 -0400 From: Benjamin Tissoires To: Wolfram Sang , Jonathan Corbet , Corey Minyard , Jean Delvare , Guenter Roeck , Dmitry Torokhov , Andrew Duggan , Christopher Heiny Cc: linux-i2c@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH v7 1/4] i2c: add a protocol parameter to the alert callback Date: Tue, 31 May 2016 12:03:02 +0200 Message-Id: <1464688985-19102-2-git-send-email-benjamin.tissoires@redhat.com> In-Reply-To: <1464688985-19102-1-git-send-email-benjamin.tissoires@redhat.com> References: <1464688985-19102-1-git-send-email-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 31 May 2016 10:03:13 +0000 (UTC) Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org .alert() is meant to be generic, but there is currently no way for the device driver to know which protocol generated the alert. Add a parameter in .alert() to help the device driver to understand what is given in data. This patch is required to have the support of SMBus Host Notify protocol through .alert(). Tested-by: Andrew Duggan For IPMI: Acked-by: Corey Minyard Signed-off-by: Benjamin Tissoires --- new in v2 changes in v3: - added also lm90.c to support the new API no changes in v4 no changes in v5 changes in v6: - made sure lm90 also checks for the type of alert first no changes in v7 drivers/char/ipmi/ipmi_ssif.c | 6 +++++- drivers/hwmon/lm90.c | 6 +++++- drivers/i2c/i2c-smbus.c | 3 ++- include/linux/i2c.h | 7 ++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c index 8b3be8b..10a2365 100644 --- a/drivers/char/ipmi/ipmi_ssif.c +++ b/drivers/char/ipmi/ipmi_ssif.c @@ -568,12 +568,16 @@ static void retry_timeout(unsigned long data) } -static void ssif_alert(struct i2c_client *client, unsigned int data) +static void ssif_alert(struct i2c_client *client, enum i2c_alert_protocol type, + unsigned int data) { struct ssif_info *ssif_info = i2c_get_clientdata(client); unsigned long oflags, *flags; bool do_get = false; + if (type != I2C_PROTOCOL_SMBUS_ALERT) + return; + ssif_inc_stat(ssif_info, alerts); flags = ipmi_ssif_lock_cond(ssif_info, &oflags); diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index c9ff08d..a00fd38 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -1624,10 +1624,14 @@ static int lm90_remove(struct i2c_client *client) return 0; } -static void lm90_alert(struct i2c_client *client, unsigned int flag) +static void lm90_alert(struct i2c_client *client, enum i2c_alert_protocol type, + unsigned int flag) { u16 alarms; + if (type != I2C_PROTOCOL_SMBUS_ALERT) + return; + if (lm90_is_tripped(client, &alarms)) { /* * Disable ALERT# output, because these chips don't implement diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c index abb55d3..3b6765a 100644 --- a/drivers/i2c/i2c-smbus.c +++ b/drivers/i2c/i2c-smbus.c @@ -56,7 +56,8 @@ static int smbus_do_alert(struct device *dev, void *addrp) if (client->dev.driver) { driver = to_i2c_driver(client->dev.driver); if (driver->alert) - driver->alert(client, data->flag); + driver->alert(client, I2C_PROTOCOL_SMBUS_ALERT, + data->flag); else dev_warn(&client->dev, "no driver alert()!\n"); } else diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 200cf13b..baae02a 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -126,6 +126,10 @@ i2c_smbus_read_i2c_block_data_or_emulated(const struct i2c_client *client, u8 command, u8 length, u8 *values); #endif /* I2C */ +enum i2c_alert_protocol { + I2C_PROTOCOL_SMBUS_ALERT, +}; + /** * struct i2c_driver - represent an I2C device driver * @class: What kind of i2c device we instantiate (for detect) @@ -181,7 +185,8 @@ struct i2c_driver { * For the SMBus alert protocol, there is a single bit of data passed * as the alert response's low bit ("event flag"). */ - void (*alert)(struct i2c_client *, unsigned int data); + void (*alert)(struct i2c_client *, enum i2c_alert_protocol protocol, + unsigned int data); /* a ioctl like command that can be used to perform specific functions * with the device.