From patchwork Fri Jan 15 21:59:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Len Brown X-Patchwork-Id: 73241 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0FLxLZQ001370 for ; Fri, 15 Jan 2010 21:59:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752025Ab0AOV7T (ORCPT ); Fri, 15 Jan 2010 16:59:19 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753319Ab0AOV7T (ORCPT ); Fri, 15 Jan 2010 16:59:19 -0500 Received: from vms173001pub.verizon.net ([206.46.173.1]:48030 "EHLO vms173001pub.verizon.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752025Ab0AOV7S (ORCPT ); Fri, 15 Jan 2010 16:59:18 -0500 Received: from localhost.localdomain ([unknown] [74.104.151.18]) by vms173001.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0KWB00FN36EF4I13@vms173001.mailsrvcs.net> for Linux-acpi@vger.kernel.org; Fri, 15 Jan 2010 15:59:15 -0600 (CST) Received: from localhost.localdomain (d975xbx2 [127.0.0.1]) by localhost.localdomain (8.14.2/8.14.2) with ESMTP id o0FLx2bS010527; Fri, 15 Jan 2010 16:59:02 -0500 Received: from localhost (lenb@localhost) by localhost.localdomain (8.14.2/8.14.2/Submit) with ESMTP id o0FLx1wk010523; Fri, 15 Jan 2010 16:59:02 -0500 X-Authentication-warning: localhost.localdomain: lenb owned process doing -bs Date: Fri, 15 Jan 2010 16:59:01 -0500 (EST) From: Len Brown X-X-Sender: lenb@localhost.localdomain To: Alexey Starikovskiy Cc: Linux-acpi@vger.kernel.org Subject: Re: [PATCH 1/4] ACPI: Battery: Add bit flags In-reply-to: <20091015103122.3853.34760.stgit@thinkpad> Message-id: References: <20091015103122.3853.34760.stgit@thinkpad> User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) MIME-version: 1.0 Content-type: TEXT/PLAIN; charset=US-ASCII Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index cada73f..b2b48f8 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -88,10 +88,13 @@ static const struct acpi_device_id battery_device_ids[] = { MODULE_DEVICE_TABLE(acpi, battery_device_ids); -/* For buggy DSDTs that report negative 16-bit values for either charging - * or discharging current and/or report 0 as 65536 due to bad math. - */ -#define QUIRK_SIGNED16_CURRENT 0x0001 +enum { + ACPI_BATTERY_ALARM_PRESENT, + /* For buggy DSDTs that report negative 16-bit values for either charging + * or discharging current and/or report 0 as 65536 due to bad math. + */ + ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, +}; struct acpi_battery { struct mutex lock; @@ -118,8 +121,7 @@ struct acpi_battery { char oem_info[32]; int state; int power_unit; - u8 alarm_present; - long quirks; + unsigned long flags; }; #define to_acpi_battery(x) container_of(x, struct acpi_battery, bat); @@ -399,7 +401,7 @@ static int acpi_battery_get_state(struct acpi_battery *battery) battery->update_time = jiffies; kfree(buffer.pointer); - if ((battery->quirks & QUIRK_SIGNED16_CURRENT) && + if (test_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags) && battery->rate_now != -1) battery->rate_now = abs((s16)battery->rate_now); @@ -412,7 +414,8 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery) union acpi_object arg0 = { .type = ACPI_TYPE_INTEGER }; struct acpi_object_list arg_list = { 1, &arg0 }; - if (!acpi_battery_present(battery)|| !battery->alarm_present) + if (!acpi_battery_present(battery)|| + !test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags)) return -ENODEV; arg0.integer.value = battery->alarm; @@ -437,10 +440,10 @@ static int acpi_battery_init_alarm(struct acpi_battery *battery) /* See if alarms are supported, and if so, set default */ status = acpi_get_handle(battery->device->handle, "_BTP", &handle); if (ACPI_FAILURE(status)) { - battery->alarm_present = 0; + clear_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags); return 0; } - battery->alarm_present = 1; + set_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags); if (!battery->alarm) battery->alarm = battery->design_capacity_warning; return acpi_battery_set_alarm(battery); @@ -510,9 +513,8 @@ static void sysfs_remove_battery(struct acpi_battery *battery) static void acpi_battery_quirks(struct acpi_battery *battery) { - battery->quirks = 0; if (dmi_name_in_vendors("Acer") && battery->power_unit) { - battery->quirks |= QUIRK_SIGNED16_CURRENT; + set_bit(ACPI_BATTERY_QUIRK_SIGNED16_CURRENT, &battery->flags); } }