1a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov/*
2a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov * Power supply driver for testing.
3a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov *
4a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov * Copyright 2010  Anton Vorontsov <cbouatmailru@gmail.com>
5a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov *
6f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz * Dynamic module parameter code from the Virtual Battery Driver
7f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz * Copyright (C) 2008 Pylone, Inc.
8f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz * By: Masashi YOKOTA <yokota@pylone.jp>
9f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz * Originally found here:
10f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz * http://downloads.pylone.jp/src/virtual_battery/virtual_battery-0.0.1.tar.bz2
11f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz *
12a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov * This program is free software; you can redistribute it and/or modify
13a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov * it under the terms of the GNU General Public License version 2 as
14a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov * published by the Free Software Foundation.
15a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov */
16a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov
17a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov#include <linux/kernel.h>
18a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov#include <linux/module.h>
19a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov#include <linux/power_supply.h>
20a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov#include <linux/errno.h>
21a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov#include <linux/delay.h>
22a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov#include <linux/vermagic.h>
23a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov
24f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int ac_online			= 1;
25f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int battery_status		= POWER_SUPPLY_STATUS_DISCHARGING;
26f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int battery_health		= POWER_SUPPLY_HEALTH_GOOD;
27f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int battery_present		= 1; /* true */
28f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int battery_technology		= POWER_SUPPLY_TECHNOLOGY_LION;
29f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int battery_capacity		= 50;
30a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov
31a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsovstatic int test_power_get_ac_property(struct power_supply *psy,
32a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov				      enum power_supply_property psp,
33a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov				      union power_supply_propval *val)
34a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov{
35a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	switch (psp) {
36a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	case POWER_SUPPLY_PROP_ONLINE:
37f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		val->intval = ac_online;
38a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		break;
39a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	default:
40a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		return -EINVAL;
41a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	}
42a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	return 0;
43a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov}
44a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov
45a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsovstatic int test_power_get_battery_property(struct power_supply *psy,
46a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov					   enum power_supply_property psp,
47a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov					   union power_supply_propval *val)
48a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov{
49a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	switch (psp) {
50a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	case POWER_SUPPLY_PROP_MODEL_NAME:
51a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		val->strval = "Test battery";
52a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		break;
53a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	case POWER_SUPPLY_PROP_MANUFACTURER:
54a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		val->strval = "Linux";
55a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		break;
56a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	case POWER_SUPPLY_PROP_SERIAL_NUMBER:
57a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		val->strval = UTS_RELEASE;
58a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		break;
59a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	case POWER_SUPPLY_PROP_STATUS:
60f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		val->intval = battery_status;
61a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		break;
62a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	case POWER_SUPPLY_PROP_CHARGE_TYPE:
63a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST;
64a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		break;
65a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	case POWER_SUPPLY_PROP_HEALTH:
66f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		val->intval = battery_health;
67f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		break;
68f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	case POWER_SUPPLY_PROP_PRESENT:
69f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		val->intval = battery_present;
70a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		break;
71a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	case POWER_SUPPLY_PROP_TECHNOLOGY:
72f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		val->intval = battery_technology;
73a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		break;
74a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	case POWER_SUPPLY_PROP_CAPACITY_LEVEL:
75a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		val->intval = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
76a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		break;
77a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	case POWER_SUPPLY_PROP_CAPACITY:
78f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	case POWER_SUPPLY_PROP_CHARGE_NOW:
79f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		val->intval = battery_capacity;
80f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		break;
81f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
82f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	case POWER_SUPPLY_PROP_CHARGE_FULL:
83f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		val->intval = 100;
84a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		break;
85a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
86a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW:
87a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		val->intval = 3600;
88a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		break;
89a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	default:
90a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		pr_info("%s: some properties deliberately report errors.\n",
91a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov			__func__);
92a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		return -EINVAL;
93a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	}
94a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	return 0;
95a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov}
96a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov
97a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsovstatic enum power_supply_property test_power_ac_props[] = {
98a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	POWER_SUPPLY_PROP_ONLINE,
99a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov};
100a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov
101a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsovstatic enum power_supply_property test_power_battery_props[] = {
102a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	POWER_SUPPLY_PROP_STATUS,
103a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	POWER_SUPPLY_PROP_CHARGE_TYPE,
104a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	POWER_SUPPLY_PROP_HEALTH,
105f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	POWER_SUPPLY_PROP_PRESENT,
106a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	POWER_SUPPLY_PROP_TECHNOLOGY,
107f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
108a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	POWER_SUPPLY_PROP_CHARGE_FULL,
109f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	POWER_SUPPLY_PROP_CHARGE_NOW,
110a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	POWER_SUPPLY_PROP_CAPACITY,
111a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	POWER_SUPPLY_PROP_CAPACITY_LEVEL,
112a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
113a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
114a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	POWER_SUPPLY_PROP_MODEL_NAME,
115a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	POWER_SUPPLY_PROP_MANUFACTURER,
116a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	POWER_SUPPLY_PROP_SERIAL_NUMBER,
117a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov};
118a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov
119a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsovstatic char *test_power_ac_supplied_to[] = {
120a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	"test_battery",
121a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov};
122a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov
123a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsovstatic struct power_supply test_power_supplies[] = {
124a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	{
125a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		.name = "test_ac",
126a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		.type = POWER_SUPPLY_TYPE_MAINS,
127a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		.supplied_to = test_power_ac_supplied_to,
128a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		.num_supplicants = ARRAY_SIZE(test_power_ac_supplied_to),
129a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		.properties = test_power_ac_props,
130a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		.num_properties = ARRAY_SIZE(test_power_ac_props),
131a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		.get_property = test_power_get_ac_property,
132a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	}, {
133a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		.name = "test_battery",
134a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		.type = POWER_SUPPLY_TYPE_BATTERY,
135a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		.properties = test_power_battery_props,
136a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		.num_properties = ARRAY_SIZE(test_power_battery_props),
137a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		.get_property = test_power_get_battery_property,
138a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	},
139a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov};
140a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov
141f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
142a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsovstatic int __init test_power_init(void)
143a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov{
144a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	int i;
145a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	int ret;
146a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov
147a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	for (i = 0; i < ARRAY_SIZE(test_power_supplies); i++) {
148a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		ret = power_supply_register(NULL, &test_power_supplies[i]);
149a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		if (ret) {
150a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov			pr_err("%s: failed to register %s\n", __func__,
151a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov				test_power_supplies[i].name);
152a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov			goto failed;
153a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		}
154a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	}
155a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov
156a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	return 0;
157a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsovfailed:
158a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	while (--i >= 0)
159a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		power_supply_unregister(&test_power_supplies[i]);
160a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	return ret;
161a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov}
162a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsovmodule_init(test_power_init);
163a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov
164a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsovstatic void __exit test_power_exit(void)
165a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov{
166a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	int i;
167a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov
168a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	/* Let's see how we handle changes... */
169f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	ac_online = 0;
170f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	battery_status = POWER_SUPPLY_STATUS_DISCHARGING;
171a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	for (i = 0; i < ARRAY_SIZE(test_power_supplies); i++)
172a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		power_supply_changed(&test_power_supplies[i]);
173a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	pr_info("%s: 'changed' event sent, sleeping for 10 seconds...\n",
174a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		__func__);
175a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	ssleep(10);
176a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov
177a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov	for (i = 0; i < ARRAY_SIZE(test_power_supplies); i++)
178a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov		power_supply_unregister(&test_power_supplies[i]);
179a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov}
180a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsovmodule_exit(test_power_exit);
181a1e50fd4452b2ed57376ece465a17276b59fad9cAnton Vorontsov
182f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
183f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
184f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz#define MAX_KEYLENGTH 256
185f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstruct battery_property_map {
186f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	int value;
187f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	char const *key;
188f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz};
189f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
190f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic struct battery_property_map map_ac_online[] = {
191f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ 0,  "on"  },
192f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ 1,  "off" },
193f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ -1, NULL  },
194f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz};
195f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
196f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic struct battery_property_map map_status[] = {
197f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ POWER_SUPPLY_STATUS_CHARGING,     "charging"     },
198f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ POWER_SUPPLY_STATUS_DISCHARGING,  "discharging"  },
199f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ POWER_SUPPLY_STATUS_NOT_CHARGING, "not-charging" },
200f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ POWER_SUPPLY_STATUS_FULL,         "full"         },
201f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ -1,                               NULL           },
202f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz};
203f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
204f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic struct battery_property_map map_health[] = {
205f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ POWER_SUPPLY_HEALTH_GOOD,           "good"        },
206f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ POWER_SUPPLY_HEALTH_OVERHEAT,       "overheat"    },
207f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ POWER_SUPPLY_HEALTH_DEAD,           "dead"        },
208f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ POWER_SUPPLY_HEALTH_OVERVOLTAGE,    "overvoltage" },
209f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ POWER_SUPPLY_HEALTH_UNSPEC_FAILURE, "failure"     },
210f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ -1,                                 NULL          },
211f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz};
212f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
213f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic struct battery_property_map map_present[] = {
214f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ 0,  "false" },
215f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ 1,  "true"  },
216f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ -1, NULL    },
217f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz};
218f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
219f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic struct battery_property_map map_technology[] = {
220f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ POWER_SUPPLY_TECHNOLOGY_NiMH, "NiMH" },
221f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ POWER_SUPPLY_TECHNOLOGY_LION, "LION" },
222f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ POWER_SUPPLY_TECHNOLOGY_LIPO, "LIPO" },
223f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ POWER_SUPPLY_TECHNOLOGY_LiFe, "LiFe" },
224f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ POWER_SUPPLY_TECHNOLOGY_NiCd, "NiCd" },
225f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ POWER_SUPPLY_TECHNOLOGY_LiMn, "LiMn" },
226f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	{ -1,				NULL   },
227f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz};
228f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
229f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
230f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int map_get_value(struct battery_property_map *map, const char *key,
231f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz				int def_val)
232f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz{
233f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	char buf[MAX_KEYLENGTH];
234f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	int cr;
235f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
236f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	strncpy(buf, key, MAX_KEYLENGTH);
237f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	buf[MAX_KEYLENGTH-1] = '\0';
238f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
239f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	cr = strnlen(buf, MAX_KEYLENGTH) - 1;
240f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	if (buf[cr] == '\n')
241f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		buf[cr] = '\0';
242f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
243f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	while (map->key) {
244f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		if (strncasecmp(map->key, buf, MAX_KEYLENGTH) == 0)
245f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz			return map->value;
246f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		map++;
247f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	}
248f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
249f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	return def_val;
250f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz}
251f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
252f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
253f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic const char *map_get_key(struct battery_property_map *map, int value,
254f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz				const char *def_key)
255f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz{
256f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	while (map->key) {
257f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		if (map->value == value)
258f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz			return map->key;
259f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		map++;
260f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	}
261f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
262f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	return def_key;
263f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz}
264f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
265f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int param_set_ac_online(const char *key, const struct kernel_param *kp)
266f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz{
267f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	ac_online = map_get_value(map_ac_online, key, ac_online);
268f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	power_supply_changed(&test_power_supplies[0]);
269f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	return 0;
270f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz}
271f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
272f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int param_get_ac_online(char *buffer, const struct kernel_param *kp)
273f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz{
274f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	strcpy(buffer, map_get_key(map_ac_online, ac_online, "unknown"));
275f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	return strlen(buffer);
276f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz}
277f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
278f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int param_set_battery_status(const char *key,
279f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz					const struct kernel_param *kp)
280f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz{
281f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	battery_status = map_get_value(map_status, key, battery_status);
282f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	power_supply_changed(&test_power_supplies[1]);
283f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	return 0;
284f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz}
285f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
286f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int param_get_battery_status(char *buffer, const struct kernel_param *kp)
287f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz{
288f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	strcpy(buffer, map_get_key(map_status, battery_status, "unknown"));
289f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	return strlen(buffer);
290f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz}
291f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
292f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int param_set_battery_health(const char *key,
293f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz					const struct kernel_param *kp)
294f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz{
295f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	battery_health = map_get_value(map_health, key, battery_health);
296f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	power_supply_changed(&test_power_supplies[1]);
297f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	return 0;
298f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz}
299f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
300f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int param_get_battery_health(char *buffer, const struct kernel_param *kp)
301f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz{
302f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	strcpy(buffer, map_get_key(map_health, battery_health, "unknown"));
303f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	return strlen(buffer);
304f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz}
305f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
306f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int param_set_battery_present(const char *key,
307f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz					const struct kernel_param *kp)
308f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz{
309f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	battery_present = map_get_value(map_present, key, battery_present);
310f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	power_supply_changed(&test_power_supplies[0]);
311f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	return 0;
312f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz}
313f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
314f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int param_get_battery_present(char *buffer,
315f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz					const struct kernel_param *kp)
316f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz{
317f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	strcpy(buffer, map_get_key(map_present, battery_present, "unknown"));
318f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	return strlen(buffer);
319f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz}
320f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
321f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int param_set_battery_technology(const char *key,
322f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz					const struct kernel_param *kp)
323f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz{
324f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	battery_technology = map_get_value(map_technology, key,
325f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz						battery_technology);
326f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	power_supply_changed(&test_power_supplies[1]);
327f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	return 0;
328f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz}
329f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
330f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int param_get_battery_technology(char *buffer,
331f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz					const struct kernel_param *kp)
332f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz{
333f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	strcpy(buffer,
334f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		map_get_key(map_technology, battery_technology, "unknown"));
335f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	return strlen(buffer);
336f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz}
337f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
338f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic int param_set_battery_capacity(const char *key,
339f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz					const struct kernel_param *kp)
340f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz{
341f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	int tmp;
342f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
343f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	if (1 != sscanf(key, "%d", &tmp))
344f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz		return -EINVAL;
345f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
346f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	battery_capacity = tmp;
347f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	power_supply_changed(&test_power_supplies[1]);
348f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	return 0;
349f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz}
350f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
351f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz#define param_get_battery_capacity param_get_int
352f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
353f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
354f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
355f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic struct kernel_param_ops param_ops_ac_online = {
356f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	.set = param_set_ac_online,
357f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	.get = param_get_ac_online,
358f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz};
359f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
360f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic struct kernel_param_ops param_ops_battery_status = {
361f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	.set = param_set_battery_status,
362f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	.get = param_get_battery_status,
363f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz};
364f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
365f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic struct kernel_param_ops param_ops_battery_present = {
366f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	.set = param_set_battery_present,
367f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	.get = param_get_battery_present,
368f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz};
369f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
370f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic struct kernel_param_ops param_ops_battery_technology = {
371f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	.set = param_set_battery_technology,
372f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	.get = param_get_battery_technology,
373f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz};
374f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
375f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic struct kernel_param_ops param_ops_battery_health = {
376f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	.set = param_set_battery_health,
377f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	.get = param_get_battery_health,
378f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz};
379f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
380f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzstatic struct kernel_param_ops param_ops_battery_capacity = {
381f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	.set = param_set_battery_capacity,
382f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	.get = param_get_battery_capacity,
383f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz};
384f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
385f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
386f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz#define param_check_ac_online(name, p) __param_check(name, p, void);
387f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz#define param_check_battery_status(name, p) __param_check(name, p, void);
388f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz#define param_check_battery_present(name, p) __param_check(name, p, void);
389f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz#define param_check_battery_technology(name, p) __param_check(name, p, void);
390f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz#define param_check_battery_health(name, p) __param_check(name, p, void);
391f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz#define param_check_battery_capacity(name, p) __param_check(name, p, void);
392f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
393f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
394f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzmodule_param(ac_online, ac_online, 0644);
395f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn StultzMODULE_PARM_DESC(ac_online, "AC charging state <on|off>");
396f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
397f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzmodule_param(battery_status, battery_status, 0644);
398f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn StultzMODULE_PARM_DESC(battery_status,
399f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	"battery status <charging|discharging|not-charging|full>");
400f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
401f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzmodule_param(battery_present, battery_present, 0644);
402f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn StultzMODULE_PARM_DESC(battery_present,
403f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	"battery presence state <good|overheat|dead|overvoltage|failure>");
404f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
405f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzmodule_param(battery_technology, battery_technology, 0644);
406f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn StultzMODULE_PARM_DESC(battery_technology,
407f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	"battery technology <NiMH|LION|LIPO|LiFe|NiCd|LiMn>");
408f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
409f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzmodule_param(battery_health, battery_health, 0644);
410f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn StultzMODULE_PARM_DESC(battery_health,
411f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz	"battery health state <good|overheat|dead|overvoltage|failure>");
412f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
413f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultzmodule_param(battery_capacity, battery_capacity, 0644);
414f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn StultzMODULE_PARM_DESC(battery_capacity, "battery capacity (percentage)");
415f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
416f17ef9b2dade4d7afb605465ef1a926fdfc1a4ccJohn Stultz
417a1e50fd4452b2ed57376ece465a17276b59fad9cAnton VorontsovMODULE_DESCRIPTION("Power supply driver for testing");
418a1e50fd4452b2ed57376ece465a17276b59fad9cAnton VorontsovMODULE_AUTHOR("Anton Vorontsov <cbouatmailru@gmail.com>");
419a1e50fd4452b2ed57376ece465a17276b59fad9cAnton VorontsovMODULE_LICENSE("GPL");
420