Skip to contentSkip to conversation

i2c: fix device_init_wakeup place

RFC PATCH Applied Marc Pignat 2 participants 2 messages Aug 11, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

device_init_wakeup must be called after device_register.

---

Hi all!

The current i2c code calls device_init_wakeup() before device_register, but device_register (by calling device_initialize) will disable device wakeup.

This patch (against 2.6.27-rc2) move the device_init_wakeup() call in the bus probe function, just before the probe call.

This patch also include a small functionnal change: the I2C_CLIENT_WAKE is no more removed from the client flags, but this should't hurt.

Changes from v1:
- patch against 2.6.24-rc2
- call to device_init_wakeup depends on !device_can_wakeup (suggested by David Brownell)

Best regards

Marc

drivers/i2c/i2c-core.c +4 -2
index 7bf38c4..0039bd9 100644
@@ -108,6 +108,9 @@ static int i2c_device_probe(struct device *dev)
 	if (!driver->probe || !driver->id_table)
 		return -ENODEV;
 	client->driver = driver;
+	if (!device_can_wakeup(&client->dev))
+		device_init_wakeup(&client->dev,
+					client->flags & I2C_CLIENT_WAKE);
 	dev_dbg(dev, "probe\n");
 
 	status = driver->probe(client, i2c_match_id(driver->id_table, client));
@@ -262,9 +265,8 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
 	client->adapter = adap;
 
 	client->dev.platform_data = info->platform_data;
-	device_init_wakeup(&client->dev, info->flags & I2C_CLIENT_WAKE);
 
-	client->flags = info->flags & ~I2C_CLIENT_WAKE;
+	client->flags = info->flags;
 	client->addr = info->addr;
 	client->irq = info->irq;
 
Applied
#1 lore raw
Quoted 41 lines · Marc Pignat

device_init_wakeup must be called after device_register.

---

Hi all!

The current i2c code calls device_init_wakeup() before device_register, but device_register (by calling device_initialize) will disable device wakeup.

This patch (against 2.6.27-rc2) move the device_init_wakeup() call in the bus probe function, just before the probe call.

This patch also include a small functionnal change: the I2C_CLIENT_WAKE is no more removed from the client flags, but this should't hurt.

Changes from v1:
- patch against 2.6.24-rc2
- call to device_init_wakeup depends on !device_can_wakeup (suggested by David Brownell)

Best regards

Marc

drivers/i2c/i2c-core.c +3 -0
index 7bf38c4..0039bd9 100644
@@ -108,6 +108,9 @@ static int i2c_device_probe(struct device *dev)
 	if (!driver->probe || !driver->id_table)
 		return -ENODEV;
 	client->driver = driver;
+	if (!device_can_wakeup(&client->dev))
+		device_init_wakeup(&client->dev,
+					client->flags & I2C_CLIENT_WAKE);
 	dev_dbg(dev, "probe\n");
 
 	status = driver->probe(client, i2c_match_id(driver->id_table, client));

drivers/i2c/i2c-core.c i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) · line 272

Quoted 10 lines
drivers/i2c/i2c-core.c +1 -2
@@ -262,9 +265,8 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
 	client->adapter = adap;
 
 	client->dev.platform_data = info->platform_data;
-	device_init_wakeup(&client->dev, info->flags & I2C_CLIENT_WAKE);
 
-	client->flags = info->flags & ~I2C_CLIENT_WAKE;
+	client->flags = info->flags;
 	client->addr = info->addr;
 	client->irq = info->irq;
 

Applied, thanks.

Signature · 1 line
Jean Delvare