From: Hans de Goede <hansg@kernel.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>,
Sebastian Reichel <sre@kernel.org>,
Chen-Yu Tsai <wens@kernel.org>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] power: supply: bq24190: Avoid rescheduling after cancelling work
Date: Sat, 21 Feb 2026 16:19:30 +0100 [thread overview]
Message-ID: <39fa92d6-edf6-4c88-9590-5b2dec62aa0d@kernel.org> (raw)
In-Reply-To: <20260220174938.672883-7-krzysztof.kozlowski@oss.qualcomm.com>
Hi,
On 20-Feb-26 18:49, Krzysztof Kozlowski wrote:
> Driver initializes delayed work and then registers interrupt handler
> with devm interface. This means that device removal will not use a
> reversed order, but first cancel pending work items and then, via devm
> release handlers, free the interrupt.
>
> The interrupt handler does not directly use/schedule work
> items on the workqueue, however it updates the status of the battery
> charger which might lead to calling power_supply_changed() and trigger
> chain of calls leading to scheduling the work items. If this happens
> during short time window after cancel_delayed_work_sync() in remove()
> callback, the work would be rescheduled.
>
> Avoid this by using devm interface to initialize and cancel work item,
> thus having exactly reverse order during remove() in respect to rest of
> the probe/cleanup paths. This is also more logical and readable code.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Regards,
Hans
> ---
> drivers/power/supply/bq24190_charger.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
> index ed0ceae8d90b..55da91bacc3e 100644
> --- a/drivers/power/supply/bq24190_charger.c
> +++ b/drivers/power/supply/bq24190_charger.c
> @@ -9,6 +9,7 @@
> #include <linux/module.h>
> #include <linux/interrupt.h>
> #include <linux/delay.h>
> +#include <linux/devm-helpers.h>
> #include <linux/pm_runtime.h>
> #include <linux/power_supply.h>
> #include <linux/power/bq24190_charger.h>
> @@ -2087,8 +2088,11 @@ static int bq24190_probe(struct i2c_client *client)
> bdi->charge_type = POWER_SUPPLY_CHARGE_TYPE_FAST;
> bdi->f_reg = 0;
> bdi->ss_reg = BQ24190_REG_SS_VBUS_STAT_MASK; /* impossible state */
> - INIT_DELAYED_WORK(&bdi->input_current_limit_work,
> - bq24190_input_current_limit_work);
> +
> + ret = devm_delayed_work_autocancel(dev, &bdi->input_current_limit_work,
> + bq24190_input_current_limit_work);
> + if (ret)
> + return ret;
>
> i2c_set_clientdata(client, bdi);
>
> @@ -2198,7 +2202,6 @@ static void bq24190_remove(struct i2c_client *client)
> struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
> int error;
>
> - cancel_delayed_work_sync(&bdi->input_current_limit_work);
> error = pm_runtime_resume_and_get(bdi->dev);
> if (error < 0)
> dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
next prev parent reply other threads:[~2026-02-21 15:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-20 17:49 [PATCH 1/4] power: supply: axp288_charger: Do not cancel work before initializing it Krzysztof Kozlowski
2026-02-20 17:49 ` [PATCH 2/4] power: supply: axp288_charger: Simplify returns of dev_err_probe() Krzysztof Kozlowski
2026-02-21 5:05 ` Chen-Yu Tsai
2026-02-21 15:19 ` Hans de Goede
2026-02-20 17:49 ` [PATCH 3/4] power: supply: bq24190: Avoid rescheduling after cancelling work Krzysztof Kozlowski
2026-02-21 15:19 ` Hans de Goede [this message]
2026-02-20 17:49 ` [PATCH 4/4] power: supply: twl4030_madc: Drop unused header includes Krzysztof Kozlowski
2026-02-21 15:19 ` Hans de Goede
2026-02-21 5:08 ` [PATCH 1/4] power: supply: axp288_charger: Do not cancel work before initializing it Chen-Yu Tsai
2026-02-21 15:17 ` Hans de Goede
2026-03-03 0:01 ` Sebastian Reichel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=39fa92d6-edf6-4c88-9590-5b2dec62aa0d@kernel.org \
--to=hansg@kernel.org \
--cc=krzysztof.kozlowski@oss.qualcomm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=sre@kernel.org \
--cc=wens@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox