Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: add a protocol parameter to the alert callback

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

authored by

Benjamin Tissoires and committed by
Wolfram Sang
b4f21054 33c77abc

+18 -4
+5 -1
drivers/char/ipmi/ipmi_ssif.c
··· 568 568 } 569 569 570 570 571 - static void ssif_alert(struct i2c_client *client, unsigned int data) 571 + static void ssif_alert(struct i2c_client *client, enum i2c_alert_protocol type, 572 + unsigned int data) 572 573 { 573 574 struct ssif_info *ssif_info = i2c_get_clientdata(client); 574 575 unsigned long oflags, *flags; 575 576 bool do_get = false; 577 + 578 + if (type != I2C_PROTOCOL_SMBUS_ALERT) 579 + return; 576 580 577 581 ssif_inc_stat(ssif_info, alerts); 578 582
+5 -1
drivers/hwmon/lm90.c
··· 1624 1624 return 0; 1625 1625 } 1626 1626 1627 - static void lm90_alert(struct i2c_client *client, unsigned int flag) 1627 + static void lm90_alert(struct i2c_client *client, enum i2c_alert_protocol type, 1628 + unsigned int flag) 1628 1629 { 1629 1630 u16 alarms; 1631 + 1632 + if (type != I2C_PROTOCOL_SMBUS_ALERT) 1633 + return; 1630 1634 1631 1635 if (lm90_is_tripped(client, &alarms)) { 1632 1636 /*
+2 -1
drivers/i2c/i2c-smbus.c
··· 56 56 if (client->dev.driver) { 57 57 driver = to_i2c_driver(client->dev.driver); 58 58 if (driver->alert) 59 - driver->alert(client, data->flag); 59 + driver->alert(client, I2C_PROTOCOL_SMBUS_ALERT, 60 + data->flag); 60 61 else 61 62 dev_warn(&client->dev, "no driver alert()!\n"); 62 63 } else
+6 -1
include/linux/i2c.h
··· 126 126 u8 command, u8 length, u8 *values); 127 127 #endif /* I2C */ 128 128 129 + enum i2c_alert_protocol { 130 + I2C_PROTOCOL_SMBUS_ALERT, 131 + }; 132 + 129 133 /** 130 134 * struct i2c_driver - represent an I2C device driver 131 135 * @class: What kind of i2c device we instantiate (for detect) ··· 185 181 * For the SMBus alert protocol, there is a single bit of data passed 186 182 * as the alert response's low bit ("event flag"). 187 183 */ 188 - void (*alert)(struct i2c_client *, unsigned int data); 184 + void (*alert)(struct i2c_client *, enum i2c_alert_protocol protocol, 185 + unsigned int data); 189 186 190 187 /* a ioctl like command that can be used to perform specific functions 191 188 * with the device.