From: Len Brown <lenb@kernel.org>
To: Alexey Starikovskiy <astarikovskiy@suse.de>,
Frans Pop <elendil@planet.nl>,
Andrey Borzenkov <arvidjaar@mail.ru>
Cc: Linux-acpi@vger.kernel.org
Subject: Re: [PATCH] ACPI: Battery: Allow extract string from integer
Date: Mon, 29 Oct 2007 16:57:12 -0400 [thread overview]
Message-ID: <200710291657.12962.lenb@kernel.org> (raw)
In-Reply-To: <20071029202938.16515.24421.stgit@samsung>
Applied.
Andrey, Frans,
thanks for helping with Alexey's patch this weekend.
-Len
On Monday 29 October 2007 16:29, Alexey Starikovskiy wrote:
> Some machines return integer instead of expected string.
>
> Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
> ---
>
> drivers/acpi/battery.c | 25 +++++++++++++++----------
> 1 files changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 02a396d..6c06879 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -260,7 +260,7 @@ static int extract_package(struct acpi_battery *battery,
> union acpi_object *package,
> struct acpi_offsets *offsets, int num)
> {
> - int i, *x;
> + int i;
> union acpi_object *element;
> if (package->type != ACPI_TYPE_PACKAGE)
> return -EFAULT;
> @@ -269,16 +269,21 @@ static int extract_package(struct acpi_battery *battery,
> return -EFAULT;
> element = &package->package.elements[i];
> if (offsets[i].mode) {
> - if (element->type != ACPI_TYPE_STRING &&
> - element->type != ACPI_TYPE_BUFFER)
> - return -EFAULT;
> - strncpy((u8 *)battery + offsets[i].offset,
> - element->string.pointer, 32);
> + u8 *ptr = (u8 *)battery + offsets[i].offset;
> + if (element->type == ACPI_TYPE_STRING ||
> + element->type == ACPI_TYPE_BUFFER)
> + strncpy(ptr, element->string.pointer, 32);
> + else if (element->type == ACPI_TYPE_INTEGER) {
> + strncpy(ptr, (u8 *)&element->integer.value,
> + sizeof(acpi_integer));
> + ptr[sizeof(acpi_integer)] = 0;
> + } else return -EFAULT;
> } else {
> - if (element->type != ACPI_TYPE_INTEGER)
> - return -EFAULT;
> - x = (int *)((u8 *)battery + offsets[i].offset);
> - *x = element->integer.value;
> + if (element->type == ACPI_TYPE_INTEGER) {
> + int *x = (int *)((u8 *)battery +
> + offsets[i].offset);
> + *x = element->integer.value;
> + } else return -EFAULT;
> }
> }
> return 0;
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2007-10-29 20:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-29 20:29 [PATCH] ACPI: Battery: Allow extract string from integer Alexey Starikovskiy
2007-10-29 20:57 ` Len Brown [this message]
2007-10-29 22:37 ` Rafael J. Wysocki
2007-10-30 15:12 ` Len Brown
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=200710291657.12962.lenb@kernel.org \
--to=lenb@kernel.org \
--cc=Linux-acpi@vger.kernel.org \
--cc=arvidjaar@mail.ru \
--cc=astarikovskiy@suse.de \
--cc=elendil@planet.nl \
/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.