mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
ACPI: battery: Use kstrtoul() over sscanf("%lu\n")
It is more preferred to use kstrto*() to parse a single number. The function family properly returns an errno on error and is the correct mechanism to parse data from sysfs. The number base is set to 10 in order not to break the ABI. Tested-by: Avraham Hollander <anhollander516@gmail.com> Signed-off-by: Rong Zhang <i@rong.moe> Link: https://patch.msgid.link/20260718-b4-acpi-battery-notification-v4-2-599c8ed1072f@rong.moe Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
69e81ddfee
commit
57346c4d78
|
|
@ -689,9 +689,13 @@ static ssize_t acpi_battery_alarm_store(struct device *dev,
|
|||
{
|
||||
unsigned long x;
|
||||
struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev));
|
||||
int err;
|
||||
|
||||
if (sscanf(buf, "%lu\n", &x) == 1)
|
||||
battery->alarm = x/1000;
|
||||
err = kstrtoul(buf, 10, &x);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
battery->alarm = x / 1000;
|
||||
if (acpi_battery_present(battery))
|
||||
acpi_battery_set_alarm(battery);
|
||||
return count;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user