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
568568 }
569569
570570
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)
572573 {
573574 struct ssif_info *ssif_info = i2c_get_clientdata(client);
574575 unsigned long oflags, *flags;
575576 bool do_get = false;
576577
578+ if (type != I2C_PROTOCOL_SMBUS_ALERT)
579+ return;
580+
577581 ssif_inc_stat(ssif_info, alerts);
578582
579583 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
16241624 return 0;
16251625 }
16261626
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)
16281629 {
16291630 u16 alarms;
16301631
1632+ if (type != I2C_PROTOCOL_SMBUS_ALERT)
1633+ return;
1634+
16311635 if (lm90_is_tripped(client, &alarms)) {
16321636 /*
16331637 * 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
5656 if (client->dev.driver) {
5757 driver = to_i2c_driver(client->dev.driver);
5858 if (driver->alert)
59− driver->alert(client, data->flag);
59+ driver->alert(client, I2C_PROTOCOL_SMBUS_ALERT,
60+ data->flag);
6061 else
6162 dev_warn(&client->dev, "no driver alert()!\n");
6263 } 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
126126 u8 command, u8 length, u8 *values);
127127 #endif /* I2C */
128128
129+enum i2c_alert_protocol {
130+ I2C_PROTOCOL_SMBUS_ALERT,
131+};
132+
129133 /**
130134 * struct i2c_driver - represent an I2C device driver
131135 * @class: What kind of i2c device we instantiate (for detect)
@@ -181,7 +185,8 @@ struct i2c_driver { · 49 unmodified lines
181185 * For the SMBus alert protocol, there is a single bit of data passed
182186 * as the alert response's low bit ("event flag").
183187 */
184− void (*alert)(struct i2c_client *, unsigned int data);
188+ void (*alert)(struct i2c_client *, enum i2c_alert_protocol protocol,
189+ unsigned int data);
185190
186191 /* a ioctl like command that can be used to perform specific functions
187192 * 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