i2c: add a protocol parameter to the alert callback
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Thu, 9 Jun 2016 14:53:47 +0000 (16:53 +0200)
committerWolfram Sang <wsa@the-dreams.de>
Fri, 17 Jun 2016 10:41:25 +0000 (12:41 +0200)
.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>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/char/ipmi/ipmi_ssif.c
drivers/hwmon/lm90.c
drivers/i2c/i2c-smbus.c
include/linux/i2c.h

index 097c868986086ee6a598a41ce49c5f353d283427..5673ffff00be7438e49d157d2b17a935ee9abb01 100644 (file)
@@ -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);
index e30a5939dc0d5566ae76ef31e790a578d8b0877c..5b62c57e8bfc669eed03e7439053419a253cad3a 100644 (file)
@@ -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
index abb55d3e76f33a97ca6d550484abb4b6d41d721b..3b6765a4ebe9a5a03ecc6bd3847bb1d575262bb4 100644 (file)
@@ -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
index 6df7bad8c26c72fc72ba5602772db4fdc6f68b03..37a45dcd65928cdd612a2587c8c23145552d52cc 100644 (file)
@@ -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.