Subject: [PATCH] [acpi driver model] Add proc interface to AC driver - Create drivers/acpi/drivers/ac/proc.c - Build it (when the ACPI proc interface is enabled) This driver should now be 100% compatible with the legacy driver. Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/ac/Makefile | 2 ++ drivers/acpi/drivers/ac/proc.c | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 0 deletions(-) create mode 100644 drivers/acpi/drivers/ac/proc.c applies-to: d7acaacff22f154dede0aa2c836c5217a7588ea3 663a5f027c0921d20fd7ba7419d37dbb9ed7d6a2 diff --git a/drivers/acpi/drivers/ac/Makefile b/drivers/acpi/drivers/ac/Makefile index a5b6bb2..91f0082 100644 --- a/drivers/acpi/drivers/ac/Makefile +++ b/drivers/acpi/drivers/ac/Makefile @@ -2,3 +2,5 @@ obj-$(CONFIG_ACPI_AC) += ac.o ac-y := driver.o device.o event.o +ac-$(CONFIG_ACPI_DM_PROC) += proc.o + diff --git a/drivers/acpi/drivers/ac/proc.c b/drivers/acpi/drivers/ac/proc.c new file mode 100644 index 0000000..a83276c --- /dev/null +++ b/drivers/acpi/drivers/ac/proc.c @@ -0,0 +1,46 @@ +/** + * drivers/acpi/drivers/ac/proc.c - procfs interface for ac driver + * + * Copyright (C) 2005 Patrick Mochel + * + * Based on old-school driver drivers/acpi/ac.c. + * + * This file is released under the GPLv2. + */ + +#include +#include "ac.h" + +static int read_state(struct seq_file * seq, void * offset) +{ + struct acpi_dev * ad = seq->private; + struct acpi_ac * ac = dev_get_drvdata(&ad->dev); + const char * state; + + if (ac_get_state(ac)) { + seq_puts(seq, "ERROR: Unable to read AC Adapter state\n"); + return 0; + } + + if (ac->a_state == AC_STATE_ONLINE) + state = "on-line"; + else if (ac->a_state == AC_STATE_OFFLINE) + state = "off-line"; + else + state = "unknown"; + + seq_printf(seq, "state: %s\n", state); + return 0; +} + +static int open_state(struct inode * inode, struct file * file) +{ + return single_open(file, read_state, PDE(inode)->data); +} + +static struct acpi_proc_file ac_files[] = { + proc_file_ro(state), +}; + +acpi_driver_proc(ac); + --- 0.99.9.GIT