lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJZ5v0im2ThDaMyV3bEtYsQYWJH0Y9sYVjpJJ0Zb-wBk_wZr0Q@mail.gmail.com>
Date: Thu, 13 Jun 2024 21:31:23 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Thomas Weißschuh <linux@...ssschuh.net>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>, Len Brown <lenb@...nel.org>, linux-acpi@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ACPI: SBS: manage alarm sysfs attribute through psy core

On Sun, Jun 9, 2024 at 1:13 PM Thomas Weißschuh <linux@...ssschuh.net> wrote:
>
> Let the power supply core register the attribute.
> This ensures that the attribute is created before the device is
> announced to userspace, avoiding a race condition.
>
> Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
> ---
> Only compile-tested.
>
> This is the SBS equivalent of
> "ACPI: battery: create alarm sysfs attribute atomically" [0]
>
> [0] https://lore.kernel.org/lkml/20240609-acpi-battery-cleanup-v1-5-344517bdca73@weisss
> ---
>  drivers/acpi/sbs.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
> index dc8164b182dc..442c5905d43b 100644
> --- a/drivers/acpi/sbs.c
> +++ b/drivers/acpi/sbs.c
> @@ -77,7 +77,6 @@ struct acpi_battery {
>         u16 spec;
>         u8 id;
>         u8 present:1;
> -       u8 have_sysfs_alarm:1;
>  };
>
>  #define to_acpi_battery(x) power_supply_get_drvdata(x)
> @@ -462,12 +461,18 @@ static ssize_t acpi_battery_alarm_store(struct device *dev,
>         return count;
>  }
>
> -static const struct device_attribute alarm_attr = {
> +static struct device_attribute alarm_attr = {
>         .attr = {.name = "alarm", .mode = 0644},
>         .show = acpi_battery_alarm_show,
>         .store = acpi_battery_alarm_store,
>  };
>
> +static struct attribute *acpi_battery_attrs[] = {
> +       &alarm_attr.attr,
> +       NULL
> +};
> +ATTRIBUTE_GROUPS(acpi_battery);
> +
>  /* --------------------------------------------------------------------------
>                                   Driver Interface
>     -------------------------------------------------------------------------- */
> @@ -518,7 +523,10 @@ static int acpi_battery_read(struct acpi_battery *battery)
>  static int acpi_battery_add(struct acpi_sbs *sbs, int id)
>  {
>         struct acpi_battery *battery = &sbs->battery[id];
> -       struct power_supply_config psy_cfg = { .drv_data = battery, };
> +       struct power_supply_config psy_cfg = {
> +               .drv_data = battery,
> +               .attr_grp = acpi_battery_groups,
> +       };
>         int result;
>
>         battery->id = id;
> @@ -548,10 +556,6 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
>                 goto end;
>         }
>
> -       result = device_create_file(&battery->bat->dev, &alarm_attr);
> -       if (result)
> -               goto end;
> -       battery->have_sysfs_alarm = 1;
>        end:
>         pr_info("%s [%s]: Battery Slot [%s] (battery %s)\n",
>                ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device),
> @@ -563,11 +567,8 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
>  {
>         struct acpi_battery *battery = &sbs->battery[id];
>
> -       if (battery->bat) {
> -               if (battery->have_sysfs_alarm)
> -                       device_remove_file(&battery->bat->dev, &alarm_attr);
> +       if (battery->bat)
>                 power_supply_unregister(battery->bat);
> -       }
>  }
>
>  static int acpi_charger_add(struct acpi_sbs *sbs)
>
> ---

Applied as 6.11 material, thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ