From: Alex Hung <alex.hung@canonical.com>
To: Alex Hung <alex.hung@canonical.com>
Cc: lenb@kernel.org, linux-acpi@vger.kernel.org
Subject: Re: [PATCH] ACPI: battery: fix battery->alarm is updated when it is not supported
Date: Thu, 19 Jul 2012 00:16:46 +0800 [thread overview]
Message-ID: <5006E16E.9070202@canonical.com> (raw)
In-Reply-To: <1337515556-5232-1-git-send-email-alex.hung@canonical.com>
Hi,
I haven't received any feedback for the patch. I am wondering whether I
can improve the patch or the extra check is not needed.
Any suggestion is the most appreciated.
Best Regards,
Alex Hung
On 05/20/2012 08:05 PM, Alex Hung wrote:
> battery alarm is checked whether BIOS supports it before past to BIOS;
> however, the value is updatd without being checked. This causes alarm return
> an incorrect value that never represents an actual state BIOS is in.
>
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
> drivers/acpi/battery.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 86933ca..14548e8 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -535,7 +535,8 @@ static ssize_t acpi_battery_alarm_store(struct device *dev,
> {
> unsigned long x;
> struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev));
> - if (sscanf(buf, "%ld\n", &x) == 1)
> + if (sscanf(buf, "%ld\n", &x) == 1 &&
> + test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags))
> battery->alarm = x/1000;
> if (acpi_battery_present(battery))
> acpi_battery_set_alarm(battery);
> @@ -805,7 +806,8 @@ static ssize_t acpi_battery_write_alarm(struct file *file,
> goto end;
> }
> alarm_string[count] = '\0';
> - battery->alarm = simple_strtol(alarm_string, NULL, 0);
> + if (test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags))
> + battery->alarm = simple_strtol(alarm_string, NULL, 0);
> result = acpi_battery_set_alarm(battery);
> end:
> if (!result)
>
prev parent reply other threads:[~2012-07-18 16:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-20 12:05 [PATCH] ACPI: battery: fix battery->alarm is updated when it is not supported Alex Hung
2012-07-18 16:16 ` Alex Hung [this message]
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=5006E16E.9070202@canonical.com \
--to=alex.hung@canonical.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.