FAILED: patch "[PATCH] hwmon: chipcap2: disable device after hwmon teardown" failed to apply to 6.12-stable tree
Subsystems (3)
Sasha Levin
maintainerThe patch below does not apply to the 6.12-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-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 4724ac5556ce63f01a3f5d61fc7fcc20f4ddef3f
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 4724ac5556ce63f01a3f5d61fc7fcc20f4ddef3f Mon Sep 17 00:00:00 2001
From: Javier Carrasco <[email protected]>
Date: Wed, 14 Oct 2026 19:34:05 +0200
Subject: [PATCH] hwmon: chipcap2: disable device after hwmon teardown
cc2_remove() disables the device while the device-managed hwmon device is still registered. A concurrent sysfs callback can then enable the device after it has been disabled during removal.
Register a device-managed disable action before registering the hwmon device, so devres unregisters the hwmon device before disabling the physical device.
--- drivers/hwmon/chipcap2.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/hwmon/chipcap2.c +9 -8
@@ -152,6 +152,11 @@ static void cc2_disable(struct cc2_data *data) } } +static void cc2_disable_action (void *data) +{ +cc2_disable (data); +} +static int cc2_cmd_response_diagnostic (struct device *dev,u8 status) {int resp;
@@ -744,6 +749,10 @@ static int cc2_probe(struct i2c_client *client)if (ret)return dev_err_probe (dev, ret,"Failed to get IRQs\n" ); + ret =devm_add_action_or_reset (dev, cc2_disable_action, data); +if (ret) +return ret; + ret =cc2_request_data_ready (data, dev);if (ret)return dev_err_probe (dev, ret,"Failed to request ready irq\n" );
@@ -762,13 +771,6 @@ static int cc2_probe(struct i2c_client *client)return 0 ; } -static void cc2_remove (struct i2c_client *client) -{ -struct cc2_data *data =i2c_get_clientdata (client); - -cc2_disable (data); -} -static const struct i2c_device_id cc2_id[] = { { .name ="cc2d23" }, { .name ="cc2d23s" },
@@ -801,7 +803,6 @@ static struct i2c_driver cc2_driver = { .of_match_table = cc2_of_match, }, .probe = cc2_probe, - .remove = cc2_remove, .id_table = cc2_id, };module_i2c_driver (cc2_driver);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/2 hwmon: chipcap2: fix IRQ teardown ordering
From: Javier Carrasco <[email protected]>
[ Upstream commit d2a66c515d7730fd453485ffb306c412f1f46d72 ]
The threaded IRQs are currently requested before the hwmon device is registered. Since devres releases resources in reverse order, the hwmon device is unregistered before the IRQs are freed during driver teardown. An IRQ may therefore still run after the hwmon device has been released and access the stale data->hwmon pointer.
Separate IRQ discovery from IRQ registration so that the IRQ numbers and alarm visibility flags are initialized before registering the hwmon device while the IRQs are released before the hwmon device during devres cleanup.
The label-property access is omitted because the driver has no label support. Reuse the two existing IRQ helpers for discovery and data-ready registration, and request alarm IRQs directly in probe after registering hwmon. This preserves the teardown ordering without adding a helper.
Stable-dep-of: 4724ac5556ce ("hwmon: chipcap2: disable device after hwmon teardown")
--- drivers/hwmon/chipcap2.c | 79 ++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 39 deletions(-)
drivers/hwmon/chipcap2.c +40 -39
@@ -663,58 +663,39 @@ static int cc2_write(struct device *dev, enum hwmon_sensor_types type, u32 attr,return ret; } -static int cc2_request_ready_irq (struct cc2_data *data,struct device *dev) +static int cc2_get_irqs (struct cc2_data *data,struct device *dev) { -int ret =0 ; - data->irq_ready =fwnode_irq_get_byname (dev_fwnode (dev),"ready" );if (data->irq_ready == -EPROBE_DEFER )return data->irq_ready; -if (data->irq_ready >0 ) { +if (data->irq_ready >0 )init_completion (&data->complete); - ret =devm_request_threaded_irq (dev, data->irq_ready,NULL , - cc2_ready_interrupt, -IRQF_ONESHOT | -IRQF_TRIGGER_RISING , -dev_name (dev), data); - } - -return ret; -} - -static int cc2_request_alarm_irqs (struct cc2_data *data,struct device *dev) -{ -int ret =0 ; data->irq_low =fwnode_irq_get_byname (dev_fwnode (dev),"low" );if (data->irq_low == -EPROBE_DEFER )return data->irq_low; -if (data->irq_low >0 ) { - ret =devm_request_threaded_irq (dev, data->irq_low,NULL , - cc2_low_interrupt, -IRQF_ONESHOT | -IRQF_TRIGGER_RISING , -dev_name (dev), data); -if (ret) -return ret; - +if (data->irq_low >0 ) data->rh_alarm.low_alarm_visible = true; - } data->irq_high =fwnode_irq_get_byname (dev_fwnode (dev),"high" );if (data->irq_high == -EPROBE_DEFER )return data->irq_high; -if (data->irq_high >0 ) { - ret =devm_request_threaded_irq (dev, data->irq_high,NULL , - cc2_high_interrupt, +if (data->irq_high >0 ) + data->rh_alarm.high_alarm_visible = true; + +return 0 ; +} + +static int cc2_request_data_ready (struct cc2_data *data,struct device *dev) +{ +int ret =0 ; + +if (data->irq_ready >0 ) + ret =devm_request_threaded_irq (dev, data->irq_ready,NULL , + cc2_ready_interrupt,IRQF_ONESHOT |IRQF_TRIGGER_RISING ,dev_name (dev), data); -if (ret) -return ret; - - data->rh_alarm.high_alarm_visible = true; - }return ret; }
@@ -762,13 +743,13 @@ static int cc2_probe(struct i2c_client *client)return dev_err_probe (dev,PTR_ERR (data->regulator),"Failed to get regulator\n" ); - ret =cc2_request_ready_irq (data, dev); + ret =cc2_get_irqs (data, dev);if (ret) -return dev_err_probe (dev, ret,"Failed to request ready irq\n" ); +return dev_err_probe (dev, ret,"Failed to get IRQs\n" ); - ret =cc2_request_alarm_irqs (data, dev); + ret =cc2_request_data_ready (data, dev);if (ret) -return dev_err_probe (dev, ret,"Failed to request alarm irqs\n" ); +return dev_err_probe (dev, ret,"Failed to request ready irq\n" ); data->hwmon = devm_hwmon_device_register_with_info(dev, client->name, data, &cc2_chip_info,
@@ -777,6 +758,26 @@ static int cc2_probe(struct i2c_client *client)return dev_err_probe (dev,PTR_ERR (data->hwmon),"Failed to register hwmon device\n" ); +if (data->irq_low >0 ) { + ret =devm_request_threaded_irq (dev, data->irq_low,NULL , + cc2_low_interrupt, +IRQF_ONESHOT | +IRQF_TRIGGER_RISING , +dev_name (dev), data); +if (ret) +return dev_err_probe (dev, ret,"Failed to request alarm irqs\n" ); + } + +if (data->irq_high >0 ) { + ret =devm_request_threaded_irq (dev, data->irq_high,NULL , + cc2_high_interrupt, +IRQF_ONESHOT | +IRQF_TRIGGER_RISING , +dev_name (dev), data); +if (ret) +return dev_err_probe (dev, ret,"Failed to request alarm irqs\n" ); + } +return 0 ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 hwmon: chipcap2: disable device after hwmon teardown
From: Javier Carrasco <[email protected]>
[ Upstream commit 4724ac5556ce63f01a3f5d61fc7fcc20f4ddef3f ]
cc2_remove() disables the device while the device-managed hwmon device is still registered. A concurrent sysfs callback can then enable the device after it has been disabled during removal.
Register a device-managed disable action before registering the hwmon device, so devres unregisters the hwmon device before disabling the physical device.
--- drivers/hwmon/chipcap2.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/hwmon/chipcap2.c +9 -8
@@ -166,6 +166,11 @@ static void cc2_disable(struct cc2_data *data) data->regulator_enabled = false; } +static void cc2_disable_action (void *data) +{ +cc2_disable (data); +} +static int cc2_cmd_response_diagnostic (struct device *dev,u8 status) {int resp;
@@ -747,6 +752,10 @@ static int cc2_probe(struct i2c_client *client)if (ret)return dev_err_probe (dev, ret,"Failed to get IRQs\n" ); + ret =devm_add_action_or_reset (dev, cc2_disable_action, data); +if (ret) +return ret; + ret =cc2_request_data_ready (data, dev);if (ret)return dev_err_probe (dev, ret,"Failed to request ready irq\n" );
@@ -781,13 +790,6 @@ static int cc2_probe(struct i2c_client *client)return 0 ; } -static void cc2_remove (struct i2c_client *client) -{ -struct cc2_data *data =i2c_get_clientdata (client); - -cc2_disable (data); -} -static const struct i2c_device_id cc2_id[] = { {"cc2d23" }, {"cc2d23s" },
@@ -820,7 +822,6 @@ static struct i2c_driver cc2_driver = { .of_match_table = cc2_of_match, }, .probe = cc2_probe, - .remove = cc2_remove, .id_table = cc2_id, };module_i2c_driver (cc2_driver);
Signature · 1 line
2.53.0