linux/drivers/acpi/battery.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  battery.c - ACPI Battery Driver (Revision: 2.0)
 *
 *  Copyright (C) 2007 Alexey Starikovskiy <[email protected]>
 *  Copyright (C) 2004-2007 Vladimir Lebedev <[email protected]>
 *  Copyright (C) 2001, 2002 Andy Grover <[email protected]>
 *  Copyright (C) 2001, 2002 Paul Diefenbaugh <[email protected]>
 */

#define pr_fmt(fmt)

#include <linux/delay.h>
#include <linux/dmi.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/suspend.h>
#include <linux/types.h>

#include <linux/unaligned.h>

#include <linux/acpi.h>
#include <linux/power_supply.h>

#include <acpi/battery.h>

#define ACPI_BATTERY_VALUE_UNKNOWN
#define ACPI_BATTERY_CAPACITY_VALID(capacity)

#define ACPI_BATTERY_DEVICE_NAME

/* Battery power unit: 0 means mW, 1 means mA */
#define ACPI_BATTERY_POWER_UNIT_MA

#define ACPI_BATTERY_STATE_DISCHARGING
#define ACPI_BATTERY_STATE_CHARGING
#define ACPI_BATTERY_STATE_CRITICAL
#define ACPI_BATTERY_STATE_CHARGE_LIMITING

#define MAX_STRING_LENGTH

MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

static int battery_bix_broken_package;
static int battery_notification_delay_ms;
static int battery_ac_is_broken;
static unsigned int cache_time =;
module_param(cache_time, uint, 0644);
MODULE_PARM_DESC();

static const struct acpi_device_id battery_device_ids[] =;

MODULE_DEVICE_TABLE(acpi, battery_device_ids);

enum {};

struct acpi_battery {};

#define to_acpi_battery(x)

static inline int acpi_battery_present(struct acpi_battery *battery)
{}

static int acpi_battery_technology(struct acpi_battery *battery)
{}

static int acpi_battery_get_state(struct acpi_battery *battery);

static int acpi_battery_is_charged(struct acpi_battery *battery)
{}

static bool acpi_battery_is_degraded(struct acpi_battery *battery)
{}

static int acpi_battery_handle_discharging(struct acpi_battery *battery)
{}

static int acpi_battery_get_property(struct power_supply *psy,
				     enum power_supply_property psp,
				     union power_supply_propval *val)
{}

static const enum power_supply_property charge_battery_props[] =;

static const enum power_supply_property charge_battery_full_cap_broken_props[] =;

static const enum power_supply_property energy_battery_props[] =;

static const enum power_supply_property energy_battery_full_cap_broken_props[] =;

/* Battery Management */
struct acpi_offsets {};

static const struct acpi_offsets state_offsets[] =;

static const struct acpi_offsets info_offsets[] =;

static const struct acpi_offsets extended_info_offsets[] =;

static int extract_package(struct acpi_battery *battery,
			   union acpi_object *package,
			   const struct acpi_offsets *offsets, int num)
{}

static int acpi_battery_get_status(struct acpi_battery *battery)
{}


static int extract_battery_info(const int use_bix,
			 struct acpi_battery *battery,
			 const struct acpi_buffer *buffer)
{}

static int acpi_battery_get_info(struct acpi_battery *battery)
{}

static int acpi_battery_get_state(struct acpi_battery *battery)
{}

static int acpi_battery_set_alarm(struct acpi_battery *battery)
{}

static int acpi_battery_init_alarm(struct acpi_battery *battery)
{}

static ssize_t acpi_battery_alarm_show(struct device *dev,
					struct device_attribute *attr,
					char *buf)
{}

static ssize_t acpi_battery_alarm_store(struct device *dev,
					struct device_attribute *attr,
					const char *buf, size_t count)
{}

static struct device_attribute alarm_attr =;

static struct attribute *acpi_battery_attrs[] =;
ATTRIBUTE_GROUPS();

/*
 * The Battery Hooking API
 *
 * This API is used inside other drivers that need to expose
 * platform-specific behaviour within the generic driver in a
 * generic way.
 *
 */

static LIST_HEAD(acpi_battery_list);
static LIST_HEAD(battery_hook_list);
static DEFINE_MUTEX(hook_mutex);

static void battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
{}

void battery_hook_unregister(struct acpi_battery_hook *hook)
{}
EXPORT_SYMBOL_GPL();

void battery_hook_register(struct acpi_battery_hook *hook)
{}
EXPORT_SYMBOL_GPL();

static void devm_battery_hook_unregister(void *data)
{}

int devm_battery_hook_register(struct device *dev, struct acpi_battery_hook *hook)
{}
EXPORT_SYMBOL_GPL();

/*
 * This function gets called right after the battery sysfs
 * attributes have been added, so that the drivers that
 * define custom sysfs attributes can add their own.
 */
static void battery_hook_add_battery(struct acpi_battery *battery)
{}

static void battery_hook_remove_battery(struct acpi_battery *battery)
{}

static void __exit battery_hook_exit(void)
{}

static int sysfs_add_battery(struct acpi_battery *battery)
{}

static void sysfs_remove_battery(struct acpi_battery *battery)
{}

static void find_battery(const struct dmi_header *dm, void *private)
{}

/*
 * According to the ACPI spec, some kinds of primary batteries can
 * report percentage battery remaining capacity directly to OS.
 * In this case, it reports the Last Full Charged Capacity == 100
 * and BatteryPresentRate == 0xFFFFFFFF.
 *
 * Now we found some battery reports percentage remaining capacity
 * even if it's rechargeable.
 * https://bugzilla.kernel.org/show_bug.cgi?id=15979
 *
 * Handle this correctly so that they won't break userspace.
 */
static void acpi_battery_quirks(struct acpi_battery *battery)
{}

static int acpi_battery_update(struct acpi_battery *battery, bool resume)
{}

static void acpi_battery_refresh(struct acpi_battery *battery)
{}

/* Driver Interface */
static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
{}

static int battery_notify(struct notifier_block *nb,
			       unsigned long mode, void *_unused)
{}

static int __init
battery_bix_broken_package_quirk(const struct dmi_system_id *d)
{}

static int __init
battery_notification_delay_quirk(const struct dmi_system_id *d)
{}

static int __init
battery_ac_is_broken_quirk(const struct dmi_system_id *d)
{}

static const struct dmi_system_id bat_dmi_table[] __initconst =;

/*
 * Some machines'(E,G Lenovo Z480) ECs are not stable
 * during boot up and this causes battery driver fails to be
 * probed due to failure of getting battery information
 * from EC sometimes. After several retries, the operation
 * may work. So add retry code here and 20ms sleep between
 * every retries.
 */
static int acpi_battery_update_retry(struct acpi_battery *battery)
{}

static int acpi_battery_add(struct acpi_device *device)
{}

static void acpi_battery_remove(struct acpi_device *device)
{}

#ifdef CONFIG_PM_SLEEP
/* this is needed to learn about changes made in suspended state */
static int acpi_battery_resume(struct device *dev)
{}
#else
#define acpi_battery_resume
#endif

static SIMPLE_DEV_PM_OPS(acpi_battery_pm, NULL, acpi_battery_resume);

static struct acpi_driver acpi_battery_driver =;

static int __init acpi_battery_init(void)
{}

static void __exit acpi_battery_exit(void)
{}

module_init();
module_exit(acpi_battery_exit);