diff mbox series

ACPI: AC: Properly notify powermanagement core about changes

Message ID 20240526-acpi-ac-changed-v1-1-f4b5997753bb@weissschuh.net
State Accepted
Commit ac62f52138f752d6c74adc6321e4996d84caf5bb
Headers show
Series ACPI: AC: Properly notify powermanagement core about changes | expand

Commit Message

Thomas Weißschuh May 26, 2024, 9:40 p.m. UTC
The powermanagement core does various actions when a powersupply changes.
It calls into notifiers, LED triggers, other power supplies and emits an uevent.

To make sure that all these actions happen properly call power_supply_changed().

Reported-by: Rajas Paranjpe <paranjperajas@gmail.com>
Closes: https://github.com/MrChromebox/firmware/issues/420#issuecomment-2132251318
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 drivers/acpi/ac.c  | 4 ++--
 drivers/acpi/sbs.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)


---
base-commit: 6fbf71854e2ddea7c99397772fbbb3783bfe15b5
change-id: 20240526-acpi-ac-changed-a08c6941ae51

Best regards,

Comments

Sebastian Reichel May 27, 2024, 9:43 p.m. UTC | #1
Hi,

On Sun, May 26, 2024 at 11:40:01PM +0200, Thomas Weißschuh wrote:
> The powermanagement core does various actions when a power-supply changes.
> It calls into notifiers, LED triggers, other power supplies and emits an uevent.
> 
> To make sure that all these actions happen properly call power_supply_changed().
> 
> Reported-by: Rajas Paranjpe <paranjperajas@gmail.com>
> Closes: https://github.com/MrChromebox/firmware/issues/420#issuecomment-2132251318
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/acpi/ac.c  | 4 ++--
>  drivers/acpi/sbs.c | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
> index 2d4a35e6dd18..09a87fa222c7 100644
> --- a/drivers/acpi/ac.c
> +++ b/drivers/acpi/ac.c
> @@ -145,7 +145,7 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
>  						  dev_name(&adev->dev), event,
>  						  (u32) ac->state);
>  		acpi_notifier_call_chain(adev, event, (u32) ac->state);
> -		kobject_uevent(&ac->charger->dev.kobj, KOBJ_CHANGE);
> +		power_supply_changed(ac->charger);
>  	}
>  }
>  
> @@ -268,7 +268,7 @@ static int acpi_ac_resume(struct device *dev)
>  	if (acpi_ac_get_state(ac))
>  		return 0;
>  	if (old_state != ac->state)
> -		kobject_uevent(&ac->charger->dev.kobj, KOBJ_CHANGE);
> +		power_supply_changed(ac->charger);
>  
>  	return 0;
>  }
> diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
> index 94e3c000df2e..dc8164b182dc 100644
> --- a/drivers/acpi/sbs.c
> +++ b/drivers/acpi/sbs.c
> @@ -610,7 +610,7 @@ static void acpi_sbs_callback(void *context)
>  	if (sbs->charger_exists) {
>  		acpi_ac_get_present(sbs);
>  		if (sbs->charger_present != saved_charger_state)
> -			kobject_uevent(&sbs->charger->dev.kobj, KOBJ_CHANGE);
> +			power_supply_changed(sbs->charger);
>  	}
>  
>  	if (sbs->manager_present) {
> @@ -622,7 +622,7 @@ static void acpi_sbs_callback(void *context)
>  			acpi_battery_read(bat);
>  			if (saved_battery_state == bat->present)
>  				continue;
> -			kobject_uevent(&bat->bat->dev.kobj, KOBJ_CHANGE);
> +			power_supply_changed(bat->bat);
>  		}
>  	}
>  }
> 
> ---
> base-commit: 6fbf71854e2ddea7c99397772fbbb3783bfe15b5
> change-id: 20240526-acpi-ac-changed-a08c6941ae51
> 
> Best regards,
> -- 
> Thomas Weißschuh <linux@weissschuh.net>
>
Rafael J. Wysocki May 28, 2024, 7:57 p.m. UTC | #2
On Mon, May 27, 2024 at 11:43 PM Sebastian Reichel
<sebastian.reichel@collabora.com> wrote:
>
> Hi,
>
> On Sun, May 26, 2024 at 11:40:01PM +0200, Thomas Weißschuh wrote:
> > The powermanagement core does various actions when a power-supply changes.
> > It calls into notifiers, LED triggers, other power supplies and emits an uevent.
> >
> > To make sure that all these actions happen properly call power_supply_changed().
> >
> > Reported-by: Rajas Paranjpe <paranjperajas@gmail.com>
> > Closes: https://github.com/MrChromebox/firmware/issues/420#issuecomment-2132251318
> > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> > ---
>
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
>
> -- Sebastian
>
> >  drivers/acpi/ac.c  | 4 ++--
> >  drivers/acpi/sbs.c | 4 ++--
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
> > index 2d4a35e6dd18..09a87fa222c7 100644
> > --- a/drivers/acpi/ac.c
> > +++ b/drivers/acpi/ac.c
> > @@ -145,7 +145,7 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
> >                                                 dev_name(&adev->dev), event,
> >                                                 (u32) ac->state);
> >               acpi_notifier_call_chain(adev, event, (u32) ac->state);
> > -             kobject_uevent(&ac->charger->dev.kobj, KOBJ_CHANGE);
> > +             power_supply_changed(ac->charger);
> >       }
> >  }
> >
> > @@ -268,7 +268,7 @@ static int acpi_ac_resume(struct device *dev)
> >       if (acpi_ac_get_state(ac))
> >               return 0;
> >       if (old_state != ac->state)
> > -             kobject_uevent(&ac->charger->dev.kobj, KOBJ_CHANGE);
> > +             power_supply_changed(ac->charger);
> >
> >       return 0;
> >  }
> > diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
> > index 94e3c000df2e..dc8164b182dc 100644
> > --- a/drivers/acpi/sbs.c
> > +++ b/drivers/acpi/sbs.c
> > @@ -610,7 +610,7 @@ static void acpi_sbs_callback(void *context)
> >       if (sbs->charger_exists) {
> >               acpi_ac_get_present(sbs);
> >               if (sbs->charger_present != saved_charger_state)
> > -                     kobject_uevent(&sbs->charger->dev.kobj, KOBJ_CHANGE);
> > +                     power_supply_changed(sbs->charger);
> >       }
> >
> >       if (sbs->manager_present) {
> > @@ -622,7 +622,7 @@ static void acpi_sbs_callback(void *context)
> >                       acpi_battery_read(bat);
> >                       if (saved_battery_state == bat->present)
> >                               continue;
> > -                     kobject_uevent(&bat->bat->dev.kobj, KOBJ_CHANGE);
> > +                     power_supply_changed(bat->bat);
> >               }
> >       }
> >  }
> >
> > ---

Applied as 6.10-rc material, thanks!
diff mbox series

Patch

diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 2d4a35e6dd18..09a87fa222c7 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -145,7 +145,7 @@  static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
 						  dev_name(&adev->dev), event,
 						  (u32) ac->state);
 		acpi_notifier_call_chain(adev, event, (u32) ac->state);
-		kobject_uevent(&ac->charger->dev.kobj, KOBJ_CHANGE);
+		power_supply_changed(ac->charger);
 	}
 }
 
@@ -268,7 +268,7 @@  static int acpi_ac_resume(struct device *dev)
 	if (acpi_ac_get_state(ac))
 		return 0;
 	if (old_state != ac->state)
-		kobject_uevent(&ac->charger->dev.kobj, KOBJ_CHANGE);
+		power_supply_changed(ac->charger);
 
 	return 0;
 }
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 94e3c000df2e..dc8164b182dc 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -610,7 +610,7 @@  static void acpi_sbs_callback(void *context)
 	if (sbs->charger_exists) {
 		acpi_ac_get_present(sbs);
 		if (sbs->charger_present != saved_charger_state)
-			kobject_uevent(&sbs->charger->dev.kobj, KOBJ_CHANGE);
+			power_supply_changed(sbs->charger);
 	}
 
 	if (sbs->manager_present) {
@@ -622,7 +622,7 @@  static void acpi_sbs_callback(void *context)
 			acpi_battery_read(bat);
 			if (saved_battery_state == bat->present)
 				continue;
-			kobject_uevent(&bat->bat->dev.kobj, KOBJ_CHANGE);
+			power_supply_changed(bat->bat);
 		}
 	}
 }