FAILED: patch "[PATCH] power: supply: max17040: drop incorrect I2C functionality" failed to apply to 5.10-stable tree
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 4e4b9f5ce9dfb8ed4b8d1262a504b8043ac09d87
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090306-rabid-rug-adb0@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 4e4b9f5ce9dfb8ed4b8d1262a504b8043ac09d87 Mon Sep 17 00:00:00 2001
From: Jianing Li <[email protected]>
Date: Fri, 31 Jul 2026 16:42:59 +0800
Subject: [PATCH] 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.
drivers/power/supply/max17040_battery.c +0 -4
@@ -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 ;
Sasha Levin
maintainerPATCH 1/3 i2c: core: Introduce i2c_client_get_device_id helper function
From: Angel Iglesias <[email protected]>
[ Upstream commit 662233731d66cf41e7494e532e702849c8ce18f3 ]
Introduces new helper function to aid in .probe_new() refactors. In order to use existing i2c_get_device_id() on the probe callback, the device match table needs to be accessible in that function, which would require bigger refactors in some drivers using the deprecated .probe callback.
This issue was discussed in more detail in the IIO mailing list.
Stable-dep-of: 4e4b9f5ce9df ("power: supply: max17040: drop incorrect I2C functionality check")
--- drivers/i2c/i2c-core-base.c | 14 ++++++++++++++ include/linux/i2c.h | 1 + 2 files changed, 15 insertions(+)
drivers/i2c/i2c-core-base.c +14 -0
@@ -2222,6 +2222,20 @@ int i2c_get_device_id(const struct i2c_client *client, }EXPORT_SYMBOL_GPL (i2c_get_device_id); +/** +* i2c_client_get_device_id - get the driver match table entry of a device +* @client: the device to query. The device must be bound to a driver +* +* Returns a pointer to the matching entry if found, NULL otherwise. +*/ +const struct i2c_device_id *i2c_client_get_device_id (const struct i2c_client *client) +{ +const struct i2c_driver *drv =to_i2c_driver (client->dev.driver); + +return i2c_match_id (drv->id_table, client); +} +EXPORT_SYMBOL_GPL (i2c_client_get_device_id); +/* ---------------------------------------------------- * the i2c address scanning function * Will not work for 10-bit addresses!
include/linux/i2c.h +1 -0
@@ -183,6 +183,7 @@ s32 i2c_smbus_read_i2c_block_data_or_emulated(const struct i2c_client *client, u8 *values);int i2c_get_device_id (const struct i2c_client *client,struct i2c_device_identity *id); +const struct i2c_device_id *i2c_client_get_device_id (const struct i2c_client *client);#endif /* I2C */ /**
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/3 power: supply: max17040: Convert to i2c's .probe_new()
From: Uwe Kleine-König <[email protected]>
[ Upstream commit a07fca69378c26ea034826feb0011256e25ad237 ]
.probe_new() doesn't get the i2c_device_id * parameter, so determine that explicitly in the probe function.
Stable-dep-of: 4e4b9f5ce9df ("power: supply: max17040: drop incorrect I2C functionality check")
--- drivers/power/supply/max17040_battery.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/power/supply/max17040_battery.c +3 -3
@@ -462,9 +462,9 @@ static const struct power_supply_desc max17040_battery_desc = { .num_properties = ARRAY_SIZE(max17040_battery_props), }; -static int max17040_probe (struct i2c_client *client, -const struct i2c_device_id *id) +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;
@@ -633,7 +633,7 @@ static struct i2c_driver max17040_i2c_driver = { .of_match_table = max17040_of_match, .pm = MAX17040_PM_OPS, }, - .probe = max17040_probe, + .probe_new = max17040_probe, .id_table = max17040_id, };module_i2c_driver (max17040_i2c_driver);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/3 power: supply: max17040: drop incorrect I2C functionality check
In reply to Sasha LevinFrom: Jianing Li <[email protected]>
[ Upstream commit 4e4b9f5ce9dfb8ed4b8d1262a504b8043ac09d87 ]
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.
--- drivers/power/supply/max17040_battery.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/power/supply/max17040_battery.c +0 -4
@@ -465,16 +465,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.53.0