History

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

Benjamin Tissoires committed 10 years ago

Commit b4f21051 parent 33c77ab4 files · +18 −4Browse files

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t