Skip to contentSkip to conversation

power: supply: max17040: drop incorrect I2C functionality check

PATCH Applied Jianing Li 2 participants 2 messages Jul 31 – Aug 1

Subsystems (3)
lore
Share & tools
lore

Jianing Li

author
#0 lore raw

PATCH 1/1 power: supply: max17040: drop incorrect I2C functionality check

max17040_probe() rejects adapters that do not advertise I2C_FUNC_SMBUS_BYTE. The driver does not issue SMBus byte transactions, however. Its regmap has 8-bit registers and 16-bit big-endian values, for which regmap-i2c supports either raw I2C transfers or SMBus word-data transactions.

Consequently, an adapter providing raw I2C transfers or SMBus word data but not SMBus byte transactions is rejected even though regmap can access the device. Conversely, the current check can pass an adapter that regmap cannot use.

Drop the stale check and let devm_regmap_init_i2c() validate and select the supported transfer method.

Fixes c6f4a42de60b ("Add MAX17040 Fuel Gauge driver")
---
 drivers/power/supply/max17040_battery.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/power/supply/max17040_battery.c +0 -4
index 98d34d5f3c80..b641d7387311 100644
@@ -470,16 +470,12 @@ static const struct power_supply_desc max17040_battery_desc = {
 static int max17040_probe(struct i2c_client *client)
 {
 	const struct i2c_device_id *id = i2c_client_get_device_id(client);
-	struct i2c_adapter *adapter = client->adapter;
 	struct power_supply_config psy_cfg = {};
 	struct max17040_chip *chip;
 	enum chip_id chip_id;
 	bool enable_irq = false;
 	int ret;
 
-	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
-		return -EIO;
-
 	chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
 	if (!chip)
 		return -ENOMEM;
Signature · 1 line
2.50.1
#1 lore raw
Quoted 6 lines · Jianing Li

max17040_probe() rejects adapters that do not advertise I2C_FUNC_SMBUS_BYTE. The driver does not issue SMBus byte transactions, however. Its regmap has 8-bit registers and 16-bit big-endian values, for which regmap-i2c supports either raw I2C transfers or SMBus word-data transactions.

Quoted 6 lines

Consequently, an adapter providing raw I2C transfers or SMBus word data but not SMBus byte transactions is rejected even though regmap can access the device. Conversely, the current check can pass an adapter that regmap cannot use.

[...]

Applied, thanks!

[1/1] power: supply: max17040: drop incorrect I2C functionality check

      commit: 4e4b9f5ce9dfb8ed4b8d1262a504b8043ac09d87

Best regards,

Signature · 1 line
Sebastian Reichel <[email protected]>