-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
battery: Add the battery hooking API
This is a patch that implements a generic hooking API for the generic ACPI battery driver. With this new generic API, drivers can expose platform specific behaviour via sysfs attributes in /sys/class/power_supply/BATn/ in a generic way. A perfect example of the need for this API are Lenovo ThinkPads. Lenovo ThinkPads have a ACPI extension that allows the setting of start and stop charge thresholds in the EC and battery firmware via ACPI. The thinkpad_acpi module can use this API to expose sysfs attributes that it controls inside the ACPI battery driver sysfs tree, under /sys/class/power_supply/BATN/. The file drivers/acpi/battery.h has been moved to include/acpi/battery.h and the includes inside ac.c, sbs.c, and battery.c have been adjusted to reflect that. When drivers hooks into the API, the API calls add_battery() for each battery in the system that passes it a acpi_battery struct. Then, the drivers can use device_create_file() to create new sysfs attributes with that struct and identify the batteries for per-battery attributes. Signed-off-by: Ognjen Galic <smclt30p@gmail.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
- Loading branch information
Ognjen Galic
authored and
Rafael J. Wysocki
committed
Feb 21, 2018
1 parent
91ab883
commit fa93854
Showing
5 changed files
with
167 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef __ACPI_BATTERY_H | ||
#define __ACPI_BATTERY_H | ||
|
||
#define ACPI_BATTERY_CLASS "battery" | ||
|
||
#define ACPI_BATTERY_NOTIFY_STATUS 0x80 | ||
#define ACPI_BATTERY_NOTIFY_INFO 0x81 | ||
#define ACPI_BATTERY_NOTIFY_THRESHOLD 0x82 | ||
|
||
struct acpi_battery_hook { | ||
const char *name; | ||
int (*add_battery)(struct power_supply *battery); | ||
int (*remove_battery)(struct power_supply *battery); | ||
struct list_head list; | ||
}; | ||
|
||
void battery_hook_register(struct acpi_battery_hook *hook); | ||
void battery_hook_unregister(struct acpi_battery_hook *hook); | ||
|
||
#endif |