linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Wolfram Sang <wsa@the-dreams.de>, Jean Delvare <jdelvare@suse.de>,
	Corey Minyard <minyard@acm.org>,
	Guenter Roeck <linux@roeck-us.net>,
	lm-sensors@lm-sensors.org,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: benjamin.tissoires@gmail.com, linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>
Subject: [PATCH v3 1/3] i2c: add a protocol parameter to the alert callback
Date: Thu,  9 Jul 2015 13:59:11 -0400	[thread overview]
Message-ID: <1436464751-2475-1-git-send-email-benjamin.tissoires@redhat.com> (raw)
In-Reply-To: <1436463052-6944-2-git-send-email-benjamin.tissoires@redhat.com>

.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().

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---

Hi again,

of course, you send the patch series[1], switch to something else, and you realize
that you have a new warning...
Sorry, I missed the lm90 driver in the v2.

Adding also in CC the maintainers of LM90 and IPMI.

Cheers,
Benjamin

[1] http://marc.info/?l=linux-i2c&m=143646306528808&w=2

new in v2

changes in v3:
- added also lm90.c to support the new API

 drivers/char/ipmi/ipmi_ssif.c | 6 +++++-
 drivers/hwmon/lm90.c          | 3 ++-
 drivers/i2c/i2c-smbus.c       | 3 ++-
 include/linux/i2c.h           | 7 ++++++-
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index 207689c..1d4cece 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -567,12 +567,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 protocol, unsigned int data)
 {
 	struct ssif_info *ssif_info = i2c_get_clientdata(client);
 	unsigned long oflags, *flags;
 	bool do_get = false;
 
+	if (protocol != 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..2b77dbd 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -1624,7 +1624,8 @@ 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;
 
diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c
index 94765a8..abad351 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 e83a738..6764734 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -123,6 +123,10 @@ extern s32 i2c_smbus_write_i2c_block_data(const struct i2c_client *client,
 					  const 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)
@@ -178,7 +182,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.
-- 
2.4.3

  reply	other threads:[~2015-07-09 17:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-09 17:30 [PATCH v2 0/3] I2C/SMBus: add support for Host Notify (in i2c_i801) Benjamin Tissoires
2015-07-09 17:30 ` [PATCH v2 2/3] i2c-smbus: add SMBus Host Notify support Benjamin Tissoires
     [not found] ` <1436463052-6944-1-git-send-email-benjamin.tissoires-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-07-09 17:30   ` [PATCH v2 1/3] i2c: add a protocol parameter to the alert callback Benjamin Tissoires
2015-07-09 17:59     ` Benjamin Tissoires [this message]
2015-07-09 17:30   ` [PATCH v2 3/3] i2c: i801: add support of Host Notify Benjamin Tissoires
     [not found]     ` <1436463052-6944-4-git-send-email-benjamin.tissoires-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-07-21 21:24       ` Benjamin Tissoires
     [not found]         ` <20150721212455.GA7565-/m+UfqrgI5QNLKR9yMNcA1aTQe2KTcn/@public.gmane.org>
2015-07-25 16:11           ` Jean Delvare
     [not found]             ` <20150725181128.3da38c70-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2015-07-25 16:22               ` Benjamin Tissoires
     [not found]                 ` <CAN+gG=H4ebn6=gLX1aGkQNXYF888CRSvaQnsnuTy9qi2LOeENA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-25 21:38                   ` Jean Delvare
     [not found]                     ` <20150725233807.2c209817-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2015-07-29 14:58                       ` Benjamin Tissoires
     [not found]                         ` <CAN+gG=FYZGTaPxxVJh0QOSrY3xsBN42j0=ymONxTG=WW56q0Cg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-29 16:08                           ` Jean Delvare

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1436464751-2475-1-git-send-email-benjamin.tissoires@redhat.com \
    --to=benjamin.tissoires@redhat.com \
    --cc=benjamin.tissoires@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jdelvare@suse.de \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lm-sensors@lm-sensors.org \
    --cc=minyard@acm.org \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).