blob: 83c42ea88f2b252b0c77a65cfe1bab12135e9dca [file] [log] [blame]
Anton Vorontsova1e50fd2010-05-17 23:46:45 +04001/*
2 * Power supply driver for testing.
3 *
4 * Copyright 2010 Anton Vorontsov <cbouatmailru@gmail.com>
5 *
John Stultzf17ef9b2011-04-25 20:25:24 -07006 * Dynamic module parameter code from the Virtual Battery Driver
7 * Copyright (C) 2008 Pylone, Inc.
8 * By: Masashi YOKOTA <yokota@pylone.jp>
9 * Originally found here:
10 * http://downloads.pylone.jp/src/virtual_battery/virtual_battery-0.0.1.tar.bz2
11 *
Anton Vorontsova1e50fd2010-05-17 23:46:45 +040012 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/power_supply.h>
20#include <linux/errno.h>
21#include <linux/delay.h>
22#include <linux/vermagic.h>
23
Krzysztof Kozlowskia30067b2015-01-23 11:38:00 +010024enum test_power_id {
25 TEST_AC,
26 TEST_BATTERY,
27 TEST_USB,
28 TEST_POWER_NUM,
29};
30
John Stultzf17ef9b2011-04-25 20:25:24 -070031static int ac_online = 1;
Dmitry Eremin-Solenikov73847372012-05-29 13:37:43 +040032static int usb_online = 1;
John Stultzf17ef9b2011-04-25 20:25:24 -070033static int battery_status = POWER_SUPPLY_STATUS_DISCHARGING;
34static int battery_health = POWER_SUPPLY_HEALTH_GOOD;
35static int battery_present = 1; /* true */
36static int battery_technology = POWER_SUPPLY_TECHNOLOGY_LION;
37static int battery_capacity = 50;
Dmitry Eremin-Solenikov85a392d2012-05-29 13:37:44 +040038static int battery_voltage = 3300;
Anton Vorontsova1e50fd2010-05-17 23:46:45 +040039
Andrey Gelman9239ebc2013-01-27 22:16:33 +020040static bool module_initialized;
41
Anton Vorontsova1e50fd2010-05-17 23:46:45 +040042static int test_power_get_ac_property(struct power_supply *psy,
43 enum power_supply_property psp,
44 union power_supply_propval *val)
45{
46 switch (psp) {
47 case POWER_SUPPLY_PROP_ONLINE:
John Stultzf17ef9b2011-04-25 20:25:24 -070048 val->intval = ac_online;
Anton Vorontsova1e50fd2010-05-17 23:46:45 +040049 break;
50 default:
51 return -EINVAL;
52 }
53 return 0;
54}
55
Dmitry Eremin-Solenikov73847372012-05-29 13:37:43 +040056static int test_power_get_usb_property(struct power_supply *psy,
57 enum power_supply_property psp,
58 union power_supply_propval *val)
59{
60 switch (psp) {
61 case POWER_SUPPLY_PROP_ONLINE:
62 val->intval = usb_online;
63 break;
64 default:
65 return -EINVAL;
66 }
67 return 0;
68}
69
Anton Vorontsova1e50fd2010-05-17 23:46:45 +040070static int test_power_get_battery_property(struct power_supply *psy,
71 enum power_supply_property psp,
72 union power_supply_propval *val)
73{
74 switch (psp) {
75 case POWER_SUPPLY_PROP_MODEL_NAME:
76 val->strval = "Test battery";
77 break;
78 case POWER_SUPPLY_PROP_MANUFACTURER:
79 val->strval = "Linux";
80 break;
81 case POWER_SUPPLY_PROP_SERIAL_NUMBER:
82 val->strval = UTS_RELEASE;
83 break;
84 case POWER_SUPPLY_PROP_STATUS:
John Stultzf17ef9b2011-04-25 20:25:24 -070085 val->intval = battery_status;
Anton Vorontsova1e50fd2010-05-17 23:46:45 +040086 break;
87 case POWER_SUPPLY_PROP_CHARGE_TYPE:
88 val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST;
89 break;
90 case POWER_SUPPLY_PROP_HEALTH:
John Stultzf17ef9b2011-04-25 20:25:24 -070091 val->intval = battery_health;
92 break;
93 case POWER_SUPPLY_PROP_PRESENT:
94 val->intval = battery_present;
Anton Vorontsova1e50fd2010-05-17 23:46:45 +040095 break;
96 case POWER_SUPPLY_PROP_TECHNOLOGY:
John Stultzf17ef9b2011-04-25 20:25:24 -070097 val->intval = battery_technology;
Anton Vorontsova1e50fd2010-05-17 23:46:45 +040098 break;
99 case POWER_SUPPLY_PROP_CAPACITY_LEVEL:
100 val->intval = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
101 break;
102 case POWER_SUPPLY_PROP_CAPACITY:
John Stultzf17ef9b2011-04-25 20:25:24 -0700103 case POWER_SUPPLY_PROP_CHARGE_NOW:
104 val->intval = battery_capacity;
105 break;
106 case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
107 case POWER_SUPPLY_PROP_CHARGE_FULL:
108 val->intval = 100;
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400109 break;
110 case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
111 case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW:
112 val->intval = 3600;
113 break;
Dmitry Eremin-Solenikov85a392d2012-05-29 13:37:44 +0400114 case POWER_SUPPLY_PROP_TEMP:
115 val->intval = 26;
116 break;
117 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
118 val->intval = battery_voltage;
119 break;
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400120 default:
121 pr_info("%s: some properties deliberately report errors.\n",
122 __func__);
123 return -EINVAL;
124 }
125 return 0;
126}
127
128static enum power_supply_property test_power_ac_props[] = {
129 POWER_SUPPLY_PROP_ONLINE,
130};
131
132static enum power_supply_property test_power_battery_props[] = {
133 POWER_SUPPLY_PROP_STATUS,
134 POWER_SUPPLY_PROP_CHARGE_TYPE,
135 POWER_SUPPLY_PROP_HEALTH,
John Stultzf17ef9b2011-04-25 20:25:24 -0700136 POWER_SUPPLY_PROP_PRESENT,
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400137 POWER_SUPPLY_PROP_TECHNOLOGY,
John Stultzf17ef9b2011-04-25 20:25:24 -0700138 POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400139 POWER_SUPPLY_PROP_CHARGE_FULL,
John Stultzf17ef9b2011-04-25 20:25:24 -0700140 POWER_SUPPLY_PROP_CHARGE_NOW,
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400141 POWER_SUPPLY_PROP_CAPACITY,
142 POWER_SUPPLY_PROP_CAPACITY_LEVEL,
143 POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
144 POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
145 POWER_SUPPLY_PROP_MODEL_NAME,
146 POWER_SUPPLY_PROP_MANUFACTURER,
147 POWER_SUPPLY_PROP_SERIAL_NUMBER,
Dmitry Eremin-Solenikov85a392d2012-05-29 13:37:44 +0400148 POWER_SUPPLY_PROP_TEMP,
149 POWER_SUPPLY_PROP_VOLTAGE_NOW,
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400150};
151
152static char *test_power_ac_supplied_to[] = {
153 "test_battery",
154};
155
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100156static struct power_supply *test_power_supplies[TEST_POWER_NUM];
157
158static const struct power_supply_desc test_power_desc[] = {
Krzysztof Kozlowskia30067b2015-01-23 11:38:00 +0100159 [TEST_AC] = {
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400160 .name = "test_ac",
161 .type = POWER_SUPPLY_TYPE_MAINS,
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400162 .properties = test_power_ac_props,
163 .num_properties = ARRAY_SIZE(test_power_ac_props),
164 .get_property = test_power_get_ac_property,
Krzysztof Kozlowskia30067b2015-01-23 11:38:00 +0100165 },
166 [TEST_BATTERY] = {
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400167 .name = "test_battery",
168 .type = POWER_SUPPLY_TYPE_BATTERY,
169 .properties = test_power_battery_props,
170 .num_properties = ARRAY_SIZE(test_power_battery_props),
171 .get_property = test_power_get_battery_property,
Krzysztof Kozlowskia30067b2015-01-23 11:38:00 +0100172 },
173 [TEST_USB] = {
Dmitry Eremin-Solenikov73847372012-05-29 13:37:43 +0400174 .name = "test_usb",
175 .type = POWER_SUPPLY_TYPE_USB,
Dmitry Eremin-Solenikov73847372012-05-29 13:37:43 +0400176 .properties = test_power_ac_props,
177 .num_properties = ARRAY_SIZE(test_power_ac_props),
178 .get_property = test_power_get_usb_property,
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400179 },
180};
181
Krzysztof Kozlowski2dc92152015-03-12 08:44:02 +0100182static const struct power_supply_config test_power_configs[] = {
183 {
184 /* test_ac */
185 .supplied_to = test_power_ac_supplied_to,
186 .num_supplicants = ARRAY_SIZE(test_power_ac_supplied_to),
187 }, {
188 /* test_battery */
189 }, {
190 /* test_usb */
191 .supplied_to = test_power_ac_supplied_to,
192 .num_supplicants = ARRAY_SIZE(test_power_ac_supplied_to),
193 },
194};
John Stultzf17ef9b2011-04-25 20:25:24 -0700195
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400196static int __init test_power_init(void)
197{
198 int i;
199 int ret;
200
Krzysztof Kozlowskia30067b2015-01-23 11:38:00 +0100201 BUILD_BUG_ON(TEST_POWER_NUM != ARRAY_SIZE(test_power_supplies));
Krzysztof Kozlowski2dc92152015-03-12 08:44:02 +0100202 BUILD_BUG_ON(TEST_POWER_NUM != ARRAY_SIZE(test_power_configs));
Krzysztof Kozlowskia30067b2015-01-23 11:38:00 +0100203
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400204 for (i = 0; i < ARRAY_SIZE(test_power_supplies); i++) {
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100205 test_power_supplies[i] = power_supply_register(NULL,
206 &test_power_desc[i],
Krzysztof Kozlowski2dc92152015-03-12 08:44:02 +0100207 &test_power_configs[i]);
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100208 if (IS_ERR(test_power_supplies[i])) {
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400209 pr_err("%s: failed to register %s\n", __func__,
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100210 test_power_desc[i].name);
211 ret = PTR_ERR(test_power_supplies[i]);
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400212 goto failed;
213 }
214 }
215
Andrey Gelman9239ebc2013-01-27 22:16:33 +0200216 module_initialized = true;
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400217 return 0;
218failed:
219 while (--i >= 0)
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100220 power_supply_unregister(test_power_supplies[i]);
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400221 return ret;
222}
223module_init(test_power_init);
224
225static void __exit test_power_exit(void)
226{
227 int i;
228
229 /* Let's see how we handle changes... */
John Stultzf17ef9b2011-04-25 20:25:24 -0700230 ac_online = 0;
Dmitry Eremin-Solenikov73847372012-05-29 13:37:43 +0400231 usb_online = 0;
John Stultzf17ef9b2011-04-25 20:25:24 -0700232 battery_status = POWER_SUPPLY_STATUS_DISCHARGING;
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400233 for (i = 0; i < ARRAY_SIZE(test_power_supplies); i++)
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100234 power_supply_changed(test_power_supplies[i]);
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400235 pr_info("%s: 'changed' event sent, sleeping for 10 seconds...\n",
236 __func__);
237 ssleep(10);
238
239 for (i = 0; i < ARRAY_SIZE(test_power_supplies); i++)
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100240 power_supply_unregister(test_power_supplies[i]);
Andrey Gelman9239ebc2013-01-27 22:16:33 +0200241
242 module_initialized = false;
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400243}
244module_exit(test_power_exit);
245
John Stultzf17ef9b2011-04-25 20:25:24 -0700246
247
248#define MAX_KEYLENGTH 256
249struct battery_property_map {
250 int value;
251 char const *key;
252};
253
254static struct battery_property_map map_ac_online[] = {
Andrey Gelman9239ebc2013-01-27 22:16:33 +0200255 { 0, "off" },
256 { 1, "on" },
John Stultzf17ef9b2011-04-25 20:25:24 -0700257 { -1, NULL },
258};
259
260static struct battery_property_map map_status[] = {
261 { POWER_SUPPLY_STATUS_CHARGING, "charging" },
262 { POWER_SUPPLY_STATUS_DISCHARGING, "discharging" },
263 { POWER_SUPPLY_STATUS_NOT_CHARGING, "not-charging" },
264 { POWER_SUPPLY_STATUS_FULL, "full" },
265 { -1, NULL },
266};
267
268static struct battery_property_map map_health[] = {
269 { POWER_SUPPLY_HEALTH_GOOD, "good" },
270 { POWER_SUPPLY_HEALTH_OVERHEAT, "overheat" },
271 { POWER_SUPPLY_HEALTH_DEAD, "dead" },
272 { POWER_SUPPLY_HEALTH_OVERVOLTAGE, "overvoltage" },
273 { POWER_SUPPLY_HEALTH_UNSPEC_FAILURE, "failure" },
274 { -1, NULL },
275};
276
277static struct battery_property_map map_present[] = {
278 { 0, "false" },
279 { 1, "true" },
280 { -1, NULL },
281};
282
283static struct battery_property_map map_technology[] = {
284 { POWER_SUPPLY_TECHNOLOGY_NiMH, "NiMH" },
285 { POWER_SUPPLY_TECHNOLOGY_LION, "LION" },
286 { POWER_SUPPLY_TECHNOLOGY_LIPO, "LIPO" },
287 { POWER_SUPPLY_TECHNOLOGY_LiFe, "LiFe" },
288 { POWER_SUPPLY_TECHNOLOGY_NiCd, "NiCd" },
289 { POWER_SUPPLY_TECHNOLOGY_LiMn, "LiMn" },
290 { -1, NULL },
291};
292
293
294static int map_get_value(struct battery_property_map *map, const char *key,
295 int def_val)
296{
297 char buf[MAX_KEYLENGTH];
298 int cr;
299
300 strncpy(buf, key, MAX_KEYLENGTH);
301 buf[MAX_KEYLENGTH-1] = '\0';
302
303 cr = strnlen(buf, MAX_KEYLENGTH) - 1;
304 if (buf[cr] == '\n')
305 buf[cr] = '\0';
306
307 while (map->key) {
308 if (strncasecmp(map->key, buf, MAX_KEYLENGTH) == 0)
309 return map->value;
310 map++;
311 }
312
313 return def_val;
314}
315
316
317static const char *map_get_key(struct battery_property_map *map, int value,
318 const char *def_key)
319{
320 while (map->key) {
321 if (map->value == value)
322 return map->key;
323 map++;
324 }
325
326 return def_key;
327}
328
Andrey Gelman9239ebc2013-01-27 22:16:33 +0200329static inline void signal_power_supply_changed(struct power_supply *psy)
330{
331 if (module_initialized)
332 power_supply_changed(psy);
333}
334
John Stultzf17ef9b2011-04-25 20:25:24 -0700335static int param_set_ac_online(const char *key, const struct kernel_param *kp)
336{
337 ac_online = map_get_value(map_ac_online, key, ac_online);
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100338 signal_power_supply_changed(test_power_supplies[TEST_AC]);
John Stultzf17ef9b2011-04-25 20:25:24 -0700339 return 0;
340}
341
342static int param_get_ac_online(char *buffer, const struct kernel_param *kp)
343{
344 strcpy(buffer, map_get_key(map_ac_online, ac_online, "unknown"));
345 return strlen(buffer);
346}
347
Dmitry Eremin-Solenikov73847372012-05-29 13:37:43 +0400348static int param_set_usb_online(const char *key, const struct kernel_param *kp)
349{
350 usb_online = map_get_value(map_ac_online, key, usb_online);
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100351 signal_power_supply_changed(test_power_supplies[TEST_USB]);
Dmitry Eremin-Solenikov73847372012-05-29 13:37:43 +0400352 return 0;
353}
354
355static int param_get_usb_online(char *buffer, const struct kernel_param *kp)
356{
357 strcpy(buffer, map_get_key(map_ac_online, usb_online, "unknown"));
358 return strlen(buffer);
359}
360
John Stultzf17ef9b2011-04-25 20:25:24 -0700361static int param_set_battery_status(const char *key,
362 const struct kernel_param *kp)
363{
364 battery_status = map_get_value(map_status, key, battery_status);
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100365 signal_power_supply_changed(test_power_supplies[TEST_BATTERY]);
John Stultzf17ef9b2011-04-25 20:25:24 -0700366 return 0;
367}
368
369static int param_get_battery_status(char *buffer, const struct kernel_param *kp)
370{
371 strcpy(buffer, map_get_key(map_status, battery_status, "unknown"));
372 return strlen(buffer);
373}
374
375static int param_set_battery_health(const char *key,
376 const struct kernel_param *kp)
377{
378 battery_health = map_get_value(map_health, key, battery_health);
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100379 signal_power_supply_changed(test_power_supplies[TEST_BATTERY]);
John Stultzf17ef9b2011-04-25 20:25:24 -0700380 return 0;
381}
382
383static int param_get_battery_health(char *buffer, const struct kernel_param *kp)
384{
385 strcpy(buffer, map_get_key(map_health, battery_health, "unknown"));
386 return strlen(buffer);
387}
388
389static int param_set_battery_present(const char *key,
390 const struct kernel_param *kp)
391{
392 battery_present = map_get_value(map_present, key, battery_present);
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100393 signal_power_supply_changed(test_power_supplies[TEST_AC]);
John Stultzf17ef9b2011-04-25 20:25:24 -0700394 return 0;
395}
396
397static int param_get_battery_present(char *buffer,
398 const struct kernel_param *kp)
399{
400 strcpy(buffer, map_get_key(map_present, battery_present, "unknown"));
401 return strlen(buffer);
402}
403
404static int param_set_battery_technology(const char *key,
405 const struct kernel_param *kp)
406{
407 battery_technology = map_get_value(map_technology, key,
408 battery_technology);
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100409 signal_power_supply_changed(test_power_supplies[TEST_BATTERY]);
John Stultzf17ef9b2011-04-25 20:25:24 -0700410 return 0;
411}
412
413static int param_get_battery_technology(char *buffer,
414 const struct kernel_param *kp)
415{
416 strcpy(buffer,
417 map_get_key(map_technology, battery_technology, "unknown"));
418 return strlen(buffer);
419}
420
421static int param_set_battery_capacity(const char *key,
422 const struct kernel_param *kp)
423{
424 int tmp;
425
426 if (1 != sscanf(key, "%d", &tmp))
427 return -EINVAL;
428
429 battery_capacity = tmp;
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100430 signal_power_supply_changed(test_power_supplies[TEST_BATTERY]);
John Stultzf17ef9b2011-04-25 20:25:24 -0700431 return 0;
432}
433
434#define param_get_battery_capacity param_get_int
435
Dmitry Eremin-Solenikov85a392d2012-05-29 13:37:44 +0400436static int param_set_battery_voltage(const char *key,
437 const struct kernel_param *kp)
438{
439 int tmp;
440
441 if (1 != sscanf(key, "%d", &tmp))
442 return -EINVAL;
443
444 battery_voltage = tmp;
Krzysztof Kozlowski297d7162015-03-12 08:44:11 +0100445 signal_power_supply_changed(test_power_supplies[TEST_BATTERY]);
Dmitry Eremin-Solenikov85a392d2012-05-29 13:37:44 +0400446 return 0;
447}
448
449#define param_get_battery_voltage param_get_int
450
Luis R. Rodriguez9c278472015-05-27 11:09:38 +0930451static const struct kernel_param_ops param_ops_ac_online = {
John Stultzf17ef9b2011-04-25 20:25:24 -0700452 .set = param_set_ac_online,
453 .get = param_get_ac_online,
454};
455
Luis R. Rodriguez9c278472015-05-27 11:09:38 +0930456static const struct kernel_param_ops param_ops_usb_online = {
Dmitry Eremin-Solenikov73847372012-05-29 13:37:43 +0400457 .set = param_set_usb_online,
458 .get = param_get_usb_online,
459};
460
Luis R. Rodriguez9c278472015-05-27 11:09:38 +0930461static const struct kernel_param_ops param_ops_battery_status = {
John Stultzf17ef9b2011-04-25 20:25:24 -0700462 .set = param_set_battery_status,
463 .get = param_get_battery_status,
464};
465
Luis R. Rodriguez9c278472015-05-27 11:09:38 +0930466static const struct kernel_param_ops param_ops_battery_present = {
John Stultzf17ef9b2011-04-25 20:25:24 -0700467 .set = param_set_battery_present,
468 .get = param_get_battery_present,
469};
470
Luis R. Rodriguez9c278472015-05-27 11:09:38 +0930471static const struct kernel_param_ops param_ops_battery_technology = {
John Stultzf17ef9b2011-04-25 20:25:24 -0700472 .set = param_set_battery_technology,
473 .get = param_get_battery_technology,
474};
475
Luis R. Rodriguez9c278472015-05-27 11:09:38 +0930476static const struct kernel_param_ops param_ops_battery_health = {
John Stultzf17ef9b2011-04-25 20:25:24 -0700477 .set = param_set_battery_health,
478 .get = param_get_battery_health,
479};
480
Luis R. Rodriguez9c278472015-05-27 11:09:38 +0930481static const struct kernel_param_ops param_ops_battery_capacity = {
John Stultzf17ef9b2011-04-25 20:25:24 -0700482 .set = param_set_battery_capacity,
483 .get = param_get_battery_capacity,
484};
485
Luis R. Rodriguez9c278472015-05-27 11:09:38 +0930486static const struct kernel_param_ops param_ops_battery_voltage = {
Dmitry Eremin-Solenikov85a392d2012-05-29 13:37:44 +0400487 .set = param_set_battery_voltage,
488 .get = param_get_battery_voltage,
489};
John Stultzf17ef9b2011-04-25 20:25:24 -0700490
491#define param_check_ac_online(name, p) __param_check(name, p, void);
Dmitry Eremin-Solenikov73847372012-05-29 13:37:43 +0400492#define param_check_usb_online(name, p) __param_check(name, p, void);
John Stultzf17ef9b2011-04-25 20:25:24 -0700493#define param_check_battery_status(name, p) __param_check(name, p, void);
494#define param_check_battery_present(name, p) __param_check(name, p, void);
495#define param_check_battery_technology(name, p) __param_check(name, p, void);
496#define param_check_battery_health(name, p) __param_check(name, p, void);
497#define param_check_battery_capacity(name, p) __param_check(name, p, void);
Dmitry Eremin-Solenikov85a392d2012-05-29 13:37:44 +0400498#define param_check_battery_voltage(name, p) __param_check(name, p, void);
John Stultzf17ef9b2011-04-25 20:25:24 -0700499
500
501module_param(ac_online, ac_online, 0644);
502MODULE_PARM_DESC(ac_online, "AC charging state <on|off>");
503
Dmitry Eremin-Solenikov73847372012-05-29 13:37:43 +0400504module_param(usb_online, usb_online, 0644);
505MODULE_PARM_DESC(usb_online, "USB charging state <on|off>");
506
John Stultzf17ef9b2011-04-25 20:25:24 -0700507module_param(battery_status, battery_status, 0644);
508MODULE_PARM_DESC(battery_status,
509 "battery status <charging|discharging|not-charging|full>");
510
511module_param(battery_present, battery_present, 0644);
512MODULE_PARM_DESC(battery_present,
513 "battery presence state <good|overheat|dead|overvoltage|failure>");
514
515module_param(battery_technology, battery_technology, 0644);
516MODULE_PARM_DESC(battery_technology,
517 "battery technology <NiMH|LION|LIPO|LiFe|NiCd|LiMn>");
518
519module_param(battery_health, battery_health, 0644);
520MODULE_PARM_DESC(battery_health,
521 "battery health state <good|overheat|dead|overvoltage|failure>");
522
523module_param(battery_capacity, battery_capacity, 0644);
524MODULE_PARM_DESC(battery_capacity, "battery capacity (percentage)");
525
Dmitry Eremin-Solenikov85a392d2012-05-29 13:37:44 +0400526module_param(battery_voltage, battery_voltage, 0644);
527MODULE_PARM_DESC(battery_voltage, "battery voltage (millivolts)");
John Stultzf17ef9b2011-04-25 20:25:24 -0700528
Anton Vorontsova1e50fd2010-05-17 23:46:45 +0400529MODULE_DESCRIPTION("Power supply driver for testing");
530MODULE_AUTHOR("Anton Vorontsov <cbouatmailru@gmail.com>");
531MODULE_LICENSE("GPL");