Subject: [PATCH] [acpi battery] Add new school battery driver - Create drivers/acpi/drivers/battery/ - Add basic driver definition - Add NULL sysfs, proc, and event interfaces - Update Kconfig and Makefile in drivers/acpi/drivers/ Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/Kconfig | 1 + drivers/acpi/drivers/Makefile | 1 + drivers/acpi/drivers/battery/Kconfig | 9 +++++ drivers/acpi/drivers/battery/Makefile | 6 +++ drivers/acpi/drivers/battery/battery.h | 25 +++++++++++++++ drivers/acpi/drivers/battery/device.c | 16 +++++++++ drivers/acpi/drivers/battery/driver.c | 55 ++++++++++++++++++++++++++++++++ drivers/acpi/drivers/battery/event.c | 12 +++++++ drivers/acpi/drivers/battery/proc.c | 12 +++++++ drivers/acpi/drivers/battery/sysfs.c | 12 +++++++ 10 files changed, 149 insertions(+), 0 deletions(-) create mode 100644 drivers/acpi/drivers/battery/Kconfig create mode 100644 drivers/acpi/drivers/battery/Makefile create mode 100644 drivers/acpi/drivers/battery/battery.h create mode 100644 drivers/acpi/drivers/battery/device.c create mode 100644 drivers/acpi/drivers/battery/driver.c create mode 100644 drivers/acpi/drivers/battery/event.c create mode 100644 drivers/acpi/drivers/battery/proc.c create mode 100644 drivers/acpi/drivers/battery/sysfs.c applies-to: 2e04bdf6f13a075af7c6826f0c9ce9dda3e67ff8 200692c1b8bd4afbb70ccede0bbec71e9cbc4a27 diff --git a/drivers/acpi/drivers/Kconfig b/drivers/acpi/drivers/Kconfig index 85da7b4..cb4b5ec 100644 --- a/drivers/acpi/drivers/Kconfig +++ b/drivers/acpi/drivers/Kconfig @@ -95,6 +95,7 @@ if ACPI_DM comment "ACPI Drivers (New Style)" source drivers/acpi/drivers/ac/Kconfig +source drivers/acpi/drivers/battery/Kconfig endif # ACPI_DM diff --git a/drivers/acpi/drivers/Makefile b/drivers/acpi/drivers/Makefile index 6430eae..61db840 100644 --- a/drivers/acpi/drivers/Makefile +++ b/drivers/acpi/drivers/Makefile @@ -2,6 +2,7 @@ obj-$(CONFIG_ACPI_DM) := core/ obj-$(CONFIG_ACPI_AC) := ac/ +obj-$(CONFIG_ACPI_BATTERY) := battery/ obj-y += legacy/ diff --git a/drivers/acpi/drivers/battery/Kconfig b/drivers/acpi/drivers/battery/Kconfig new file mode 100644 index 0000000..70e6853 --- /dev/null +++ b/drivers/acpi/drivers/battery/Kconfig @@ -0,0 +1,9 @@ + +config ACPI_BATTERY + tristate "Battery" + depends on ACPI_DM && X86 + default y + help + This driver adds support for battery information through + /proc/acpi/battery. If you have a mobile system with a battery, + say Y. diff --git a/drivers/acpi/drivers/battery/Makefile b/drivers/acpi/drivers/battery/Makefile new file mode 100644 index 0000000..9ffdbbd --- /dev/null +++ b/drivers/acpi/drivers/battery/Makefile @@ -0,0 +1,6 @@ +obj-$(CONFIG_ACPI_BATTERY) += battery.o + +battery-objs := driver.o device.o event.o + +battery-$(CONFIG_ACPI_DM_PROC) += proc.o +battery-$(CONFIG_ACPI_DM_SYSFS) += sysfs.o diff --git a/drivers/acpi/drivers/battery/battery.h b/drivers/acpi/drivers/battery/battery.h new file mode 100644 index 0000000..407a566 --- /dev/null +++ b/drivers/acpi/drivers/battery/battery.h @@ -0,0 +1,25 @@ + +#ifdef DEBUG +#define dbg(fmt, ...) printk(PREFIX "battery: " fmt "\n", ## __VA_ARGS__) +#else +#define dbg(fmt, ...) +#endif + +#define _COMPONENT ACPI_BATTERY_COMPONENT +ACPI_MODULE_NAME("acpi_battery"); + +#define ACPI_BATTERY_FORMAT_BIF "NNNNNNNNNSSSS" +#define ACPI_BATTERY_FORMAT_BST "NNNN" +#define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF + +#define ACPI_BATTERY_NOTIFY_STATUS 0x80 +#define ACPI_BATTERY_NOTIFY_INFO 0x81 + +#define ACPI_BATTERY_HID "PNP0C0A" + +struct acpi_battery { + struct acpi_dev * b_ad; + unsigned int b_present; + unsigned int b_have_alarm; + unsigned int b_alarm; +}; diff --git a/drivers/acpi/drivers/battery/device.c b/drivers/acpi/drivers/battery/device.c new file mode 100644 index 0000000..9036102 --- /dev/null +++ b/drivers/acpi/drivers/battery/device.c @@ -0,0 +1,16 @@ +/* + * drivers/acpi/drivers/battery/device.c - Low-level battery access + * + * Copyright (C) 2005 Patrick Mochel + * + * Based on drivers/acpi/battery.c which was: + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * + * This file is released under the GPLv2. + */ + +#include +#include "battery.h" diff --git a/drivers/acpi/drivers/battery/driver.c b/drivers/acpi/drivers/battery/driver.c new file mode 100644 index 0000000..06ebe2f --- /dev/null +++ b/drivers/acpi/drivers/battery/driver.c @@ -0,0 +1,55 @@ +/* + * drivers/acpi/drivers/battery.c - New-style ACPI battery driver + * + * Copyright (C) 2005 Patrick Mochel + * + * Based on drivers/acpi/battery.c which was: + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * + * This file is released under the GPLv2. + */ + +#include +#include "battery.h" + + +static int battery_add(struct acpi_dev * ad) +{ + struct acpi_battery * ab; + + ab = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); + if (!ab) + return -ENOMEM; + + ab->b_ad = ad; + + dev_set_drvdata(&ad->dev, ab); + + printk(KERN_INFO PREFIX "Battery Slot [%s] (battery %s)\n", + acpi_dev_bid(ad), ab->b_present ? "present" : "absent"); + return 0; +} + +static int battery_remove(struct acpi_dev * ad) +{ + struct acpi_battery * ab = dev_get_drvdata(&ad->dev); + + dev_set_drvdata(&ad->dev, NULL); + kfree(ab); + return 0; +} + +acpi_no_start(battery); +acpi_no_stop(battery); +acpi_no_shutdown(battery); +acpi_no_suspend(battery); +acpi_no_resume(battery); + +declare_acpi_driver(battery, ACPI_BATTERY_HID); + +MODULE_AUTHOR("Patrick Mochel"); +MODULE_DESCRIPTION("ACPI Battery Driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/acpi/drivers/battery/event.c b/drivers/acpi/drivers/battery/event.c new file mode 100644 index 0000000..c9fd26e --- /dev/null +++ b/drivers/acpi/drivers/battery/event.c @@ -0,0 +1,12 @@ +/** + * drivers/acpi/drivers/battery/event.c - event interface for battery devices + * + * Copyright (C) 2005 Patrick Mochel + * + * This file is released under the GPLv2 + */ + +#include +#include "battery.h" + +acpi_device_event_none(battery); diff --git a/drivers/acpi/drivers/battery/proc.c b/drivers/acpi/drivers/battery/proc.c new file mode 100644 index 0000000..e92565e --- /dev/null +++ b/drivers/acpi/drivers/battery/proc.c @@ -0,0 +1,12 @@ +/** + * drivers/acpi/drivers/battery/proc.c - proc interface for battery devices + * + * Copyright (C) 2005 Patrick Mochel + * + * This file is released under the GPLv2 + */ + +#include +#include "battery.h" + +acpi_driver_proc_none(battery); diff --git a/drivers/acpi/drivers/battery/sysfs.c b/drivers/acpi/drivers/battery/sysfs.c new file mode 100644 index 0000000..494e297 --- /dev/null +++ b/drivers/acpi/drivers/battery/sysfs.c @@ -0,0 +1,12 @@ +/** + * drivers/acpi/drivers/battery/sysfs.c - sysfs interface for battery devices + * + * Copyright (C) 2005 Patrick Mochel + * + * This file is released under the GPLv2 + */ + +#include +#include "battery.h" + +acpi_driver_sysfs_none(battery); --- 0.99.9.GIT