From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Wolfram Sang <wsa@the-dreams.de>,
Jonathan Corbet <corbet@lwn.net>, Corey Minyard <minyard@acm.org>,
Jean Delvare <jdelvare@suse.de>,
Guenter Roeck <linux@roeck-us.net>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Andrew Duggan <aduggan@synaptics.com>,
Christopher Heiny <cheiny@synaptics.com>
Cc: linux-i2c@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Subject: [PATCH v8 1/4] i2c: add a protocol parameter to the alert callback
Date: Thu, 9 Jun 2016 16:53:47 +0200 [thread overview]
Message-ID: <1465484030-28838-2-git-send-email-benjamin.tissoires@redhat.com> (raw)
In-Reply-To: <1465484030-28838-1-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().
Tested-by: Andrew Duggan <aduggan@synaptics.com>
For hwmon:
Acked-by: Guenter Roeck <linux@roeck-us.net>
For IPMI:
Acked-by: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
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
changes in v8:
- fixed Andrew's email address
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 097c868..5673fff 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 96a25ae..29a2d3b7c 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.
--
2.5.0
next prev parent reply other threads:[~2016-06-09 14:53 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-09 14:53 [PATCH v8 0/4] i2c-smbus: add support for HOST NOTIFY Benjamin Tissoires
2016-06-09 14:53 ` Benjamin Tissoires [this message]
2016-06-17 11:26 ` [PATCH v8 1/4] i2c: add a protocol parameter to the alert callback Wolfram Sang
2016-06-09 14:53 ` [PATCH v8 2/4] i2c-smbus: add SMBus Host Notify support Benjamin Tissoires
2016-06-17 11:26 ` Wolfram Sang
2016-07-18 9:37 ` Jean Delvare
2016-07-18 15:59 ` Benjamin Tissoires
2016-07-18 16:47 ` Jean Delvare
2016-07-18 14:31 ` Jean Delvare
2016-07-18 16:35 ` Benjamin Tissoires
2016-07-18 20:47 ` Jean Delvare
2016-06-09 14:53 ` [PATCH v8 3/4] i2c: i801: add support of Host Notify Benjamin Tissoires
2016-06-15 8:12 ` Benjamin Tissoires
2016-06-16 6:09 ` Wolfram Sang
2016-06-16 12:55 ` Benjamin Tissoires
2016-06-16 14:31 ` Wolfram Sang
2016-06-23 20:55 ` Dmitry Torokhov
2016-06-23 21:46 ` Wolfram Sang
2016-06-23 22:57 ` Dmitry Torokhov
2016-06-09 14:53 ` [PATCH v8 4/4] Input: synaptics-rmi4 - add SMBus support Benjamin Tissoires
2016-06-23 23:06 ` Dmitry Torokhov
2016-06-24 7:19 ` Benjamin Tissoires
2016-06-24 23:35 ` Dmitry Torokhov
2016-06-27 15:03 ` Benjamin Tissoires
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=1465484030-28838-2-git-send-email-benjamin.tissoires@redhat.com \
--to=benjamin.tissoires@redhat.com \
--cc=aduggan@synaptics.com \
--cc=cheiny@synaptics.com \
--cc=corbet@lwn.net \
--cc=dmitry.torokhov@gmail.com \
--cc=jdelvare@suse.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--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).