* [PATCH V2] power: supply: max17042_battery: Use devm_work_autocancel()
@ 2022-02-18 17:37 Christophe JAILLET
2022-02-18 18:13 ` Hans de Goede
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Christophe JAILLET @ 2022-02-18 17:37 UTC (permalink / raw)
To: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-pm
Use devm_work_autocancel() instead of hand-writing it.
This saves a few lines of code.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
V2: s/devm_delayed_work_autocancel/devm_work_autocancel/
drivers/power/supply/max17042_battery.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
index 87128cf0d577..ab031bbfbe78 100644
--- a/drivers/power/supply/max17042_battery.c
+++ b/drivers/power/supply/max17042_battery.c
@@ -9,6 +9,7 @@
// This driver is based on max17040_battery.c
#include <linux/acpi.h>
+#include <linux/devm-helpers.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
@@ -1030,13 +1031,6 @@ static const struct power_supply_desc max17042_no_current_sense_psy_desc = {
.num_properties = ARRAY_SIZE(max17042_battery_props) - 2,
};
-static void max17042_stop_work(void *data)
-{
- struct max17042_chip *chip = data;
-
- cancel_work_sync(&chip->work);
-}
-
static int max17042_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -1142,8 +1136,8 @@ static int max17042_probe(struct i2c_client *client,
regmap_read(chip->regmap, MAX17042_STATUS, &val);
if (val & STATUS_POR_BIT) {
- INIT_WORK(&chip->work, max17042_init_worker);
- ret = devm_add_action(&client->dev, max17042_stop_work, chip);
+ ret = devm_work_autocancel(&client->dev, &chip->work,
+ max17042_init_worker);
if (ret)
return ret;
schedule_work(&chip->work);
--
2.32.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] power: supply: max17042_battery: Use devm_work_autocancel()
2022-02-18 17:37 [PATCH V2] power: supply: max17042_battery: Use devm_work_autocancel() Christophe JAILLET
@ 2022-02-18 18:13 ` Hans de Goede
2022-02-18 19:20 ` Krzysztof Kozlowski
2022-02-24 11:03 ` Sebastian Reichel
2 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2022-02-18 18:13 UTC (permalink / raw)
To: Christophe JAILLET, Krzysztof Kozlowski, Marek Szyprowski,
Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel
Cc: linux-kernel, kernel-janitors, linux-pm
Hi,
On 2/18/22 18:37, Christophe JAILLET wrote:
> Use devm_work_autocancel() instead of hand-writing it.
> This saves a few lines of code.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> V2: s/devm_delayed_work_autocancel/devm_work_autocancel/
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
>
> drivers/power/supply/max17042_battery.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
> index 87128cf0d577..ab031bbfbe78 100644
> --- a/drivers/power/supply/max17042_battery.c
> +++ b/drivers/power/supply/max17042_battery.c
> @@ -9,6 +9,7 @@
> // This driver is based on max17040_battery.c
>
> #include <linux/acpi.h>
> +#include <linux/devm-helpers.h>
> #include <linux/init.h>
> #include <linux/module.h>
> #include <linux/slab.h>
> @@ -1030,13 +1031,6 @@ static const struct power_supply_desc max17042_no_current_sense_psy_desc = {
> .num_properties = ARRAY_SIZE(max17042_battery_props) - 2,
> };
>
> -static void max17042_stop_work(void *data)
> -{
> - struct max17042_chip *chip = data;
> -
> - cancel_work_sync(&chip->work);
> -}
> -
> static int max17042_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> @@ -1142,8 +1136,8 @@ static int max17042_probe(struct i2c_client *client,
>
> regmap_read(chip->regmap, MAX17042_STATUS, &val);
> if (val & STATUS_POR_BIT) {
> - INIT_WORK(&chip->work, max17042_init_worker);
> - ret = devm_add_action(&client->dev, max17042_stop_work, chip);
> + ret = devm_work_autocancel(&client->dev, &chip->work,
> + max17042_init_worker);
> if (ret)
> return ret;
> schedule_work(&chip->work);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] power: supply: max17042_battery: Use devm_work_autocancel()
2022-02-18 17:37 [PATCH V2] power: supply: max17042_battery: Use devm_work_autocancel() Christophe JAILLET
2022-02-18 18:13 ` Hans de Goede
@ 2022-02-18 19:20 ` Krzysztof Kozlowski
2022-02-24 11:03 ` Sebastian Reichel
2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2022-02-18 19:20 UTC (permalink / raw)
To: Christophe JAILLET, Hans de Goede, Marek Szyprowski,
Sebastian Krzyszkowiak, Purism Kernel Team, Sebastian Reichel
Cc: linux-kernel, kernel-janitors, linux-pm
On 18/02/2022 18:37, Christophe JAILLET wrote:
> Use devm_work_autocancel() instead of hand-writing it.
> This saves a few lines of code.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> V2: s/devm_delayed_work_autocancel/devm_work_autocancel/
>
> drivers/power/supply/max17042_battery.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] power: supply: max17042_battery: Use devm_work_autocancel()
2022-02-18 17:37 [PATCH V2] power: supply: max17042_battery: Use devm_work_autocancel() Christophe JAILLET
2022-02-18 18:13 ` Hans de Goede
2022-02-18 19:20 ` Krzysztof Kozlowski
@ 2022-02-24 11:03 ` Sebastian Reichel
2 siblings, 0 replies; 4+ messages in thread
From: Sebastian Reichel @ 2022-02-24 11:03 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Hans de Goede, Krzysztof Kozlowski, Marek Szyprowski,
Sebastian Krzyszkowiak, Purism Kernel Team, linux-kernel,
kernel-janitors, linux-pm
[-- Attachment #1: Type: text/plain, Size: 1832 bytes --]
Hi,
On Fri, Feb 18, 2022 at 06:37:37PM +0100, Christophe JAILLET wrote:
> Use devm_work_autocancel() instead of hand-writing it.
> This saves a few lines of code.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
Thanks, queued.
-- Sebastian
> V2: s/devm_delayed_work_autocancel/devm_work_autocancel/
>
> drivers/power/supply/max17042_battery.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
> index 87128cf0d577..ab031bbfbe78 100644
> --- a/drivers/power/supply/max17042_battery.c
> +++ b/drivers/power/supply/max17042_battery.c
> @@ -9,6 +9,7 @@
> // This driver is based on max17040_battery.c
>
> #include <linux/acpi.h>
> +#include <linux/devm-helpers.h>
> #include <linux/init.h>
> #include <linux/module.h>
> #include <linux/slab.h>
> @@ -1030,13 +1031,6 @@ static const struct power_supply_desc max17042_no_current_sense_psy_desc = {
> .num_properties = ARRAY_SIZE(max17042_battery_props) - 2,
> };
>
> -static void max17042_stop_work(void *data)
> -{
> - struct max17042_chip *chip = data;
> -
> - cancel_work_sync(&chip->work);
> -}
> -
> static int max17042_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> @@ -1142,8 +1136,8 @@ static int max17042_probe(struct i2c_client *client,
>
> regmap_read(chip->regmap, MAX17042_STATUS, &val);
> if (val & STATUS_POR_BIT) {
> - INIT_WORK(&chip->work, max17042_init_worker);
> - ret = devm_add_action(&client->dev, max17042_stop_work, chip);
> + ret = devm_work_autocancel(&client->dev, &chip->work,
> + max17042_init_worker);
> if (ret)
> return ret;
> schedule_work(&chip->work);
> --
> 2.32.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-02-24 11:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-18 17:37 [PATCH V2] power: supply: max17042_battery: Use devm_work_autocancel() Christophe JAILLET
2022-02-18 18:13 ` Hans de Goede
2022-02-18 19:20 ` Krzysztof Kozlowski
2022-02-24 11:03 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®