1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Power supply driver for testing. 4 * 5 * Copyright 2010 Anton Vorontsov <cbouatmailru@gmail.com> 6 * 7 * Dynamic module parameter code from the Virtual Battery Driver 8 * Copyright (C) 2008 Pylone, Inc. 9 * By: Masashi YOKOTA <yokota@pylone.jp> 10 * Originally found here: 11 * http://downloads.pylone.jp/src/virtual_battery/virtual_battery-0.0.1.tar.bz2 12 */ 13 14 #include <linux/kernel.h> 15 #include <linux/module.h> 16 #include <linux/power_supply.h> 17 #include <linux/errno.h> 18 #include <linux/delay.h> 19 #include <generated/utsrelease.h> 20 21 enum test_power_id { 22 TEST_AC, 23 TEST_BATTERY, 24 TEST_USB, 25 TEST_POWER_NUM, 26 }; 27 28 static int ac_online = 1; 29 static int usb_online = 1; 30 static int battery_status = POWER_SUPPLY_STATUS_DISCHARGING; 31 static int battery_health = POWER_SUPPLY_HEALTH_GOOD; 32 static int battery_present = 1; /* true */ 33 static int battery_technology = POWER_SUPPLY_TECHNOLOGY_LION; 34 static int battery_capacity = 50; 35 static int battery_voltage = 3300; 36 static int battery_charge_counter = -1000; 37 static int battery_current = -1600; 38 static enum power_supply_charge_behaviour battery_charge_behaviour = 39 POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO; 40 static bool battery_extension; 41 42 static bool module_initialized; 43 44 static int test_power_get_ac_property(struct power_supply *psy, 45 enum power_supply_property psp, 46 union power_supply_propval *val) 47 { 48 switch (psp) { 49 case POWER_SUPPLY_PROP_ONLINE: 50 val->intval = ac_online; 51 break; 52 default: 53 return -EINVAL; 54 } 55 return 0; 56 } 57 58 static int test_power_get_usb_property(struct power_supply *psy, 59 enum power_supply_property psp, 60 union power_supply_propval *val) 61 { 62 switch (psp) { 63 case POWER_SUPPLY_PROP_ONLINE: 64 val->intval = usb_online; 65 break; 66 default: 67 return -EINVAL; 68 } 69 return 0; 70 } 71 72 static int test_power_get_battery_property(struct power_supply *psy, 73 enum power_supply_property psp, 74 union power_supply_propval *val) 75 { 76 switch (psp) { 77 case POWER_SUPPLY_PROP_MODEL_NAME: 78 val->strval = "Test battery"; 79 break; 80 case POWER_SUPPLY_PROP_MANUFACTURER: 81 val->strval = "Linux"; 82 break; 83 case POWER_SUPPLY_PROP_SERIAL_NUMBER: 84 val->strval = UTS_RELEASE; 85 break; 86 case POWER_SUPPLY_PROP_STATUS: 87 val->intval = battery_status; 88 break; 89 case POWER_SUPPLY_PROP_CHARGE_TYPE: 90 val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST; 91 break; 92 case POWER_SUPPLY_PROP_HEALTH: 93 val->intval = battery_health; 94 break; 95 case POWER_SUPPLY_PROP_PRESENT: 96 val->intval = battery_present; 97 break; 98 case POWER_SUPPLY_PROP_TECHNOLOGY: 99 val->intval = battery_technology; 100 break; 101 case POWER_SUPPLY_PROP_CAPACITY_LEVEL: 102 val->intval = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; 103 break; 104 case POWER_SUPPLY_PROP_CAPACITY: 105 case POWER_SUPPLY_PROP_CHARGE_NOW: 106 val->intval = battery_capacity; 107 break; 108 case POWER_SUPPLY_PROP_CHARGE_COUNTER: 109 val->intval = battery_charge_counter; 110 break; 111 case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: 112 case POWER_SUPPLY_PROP_CHARGE_FULL: 113 val->intval = 100; 114 break; 115 case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG: 116 case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW: 117 val->intval = 3600; 118 break; 119 case POWER_SUPPLY_PROP_TEMP: 120 val->intval = 26; 121 break; 122 case POWER_SUPPLY_PROP_VOLTAGE_NOW: 123 val->intval = battery_voltage; 124 break; 125 case POWER_SUPPLY_PROP_CURRENT_AVG: 126 case POWER_SUPPLY_PROP_CURRENT_NOW: 127 val->intval = battery_current; 128 break; 129 case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR: 130 val->intval = battery_charge_behaviour; 131 break; 132 default: 133 pr_info("%s: some properties deliberately report errors.\n", 134 __func__); 135 return -EINVAL; 136 } 137 return 0; 138 } 139 140 static int test_power_battery_property_is_writeable(struct power_supply *psy, 141 enum power_supply_property psp) 142 { 143 return psp == POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR; 144 } 145 146 static int test_power_set_battery_property(struct power_supply *psy, 147 enum power_supply_property psp, 148 const union power_supply_propval *val) 149 { 150 switch (psp) { 151 case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR: 152 if (val->intval < 0 || 153 val->intval >= BITS_PER_TYPE(typeof(psy->desc->charge_behaviours)) || 154 !(BIT(val->intval) & psy->desc->charge_behaviours)) { 155 return -EINVAL; 156 } 157 battery_charge_behaviour = val->intval; 158 break; 159 default: 160 return -EINVAL; 161 } 162 return 0; 163 } 164 165 static enum power_supply_property test_power_ac_props[] = { 166 POWER_SUPPLY_PROP_ONLINE, 167 }; 168 169 static enum power_supply_property test_power_battery_props[] = { 170 POWER_SUPPLY_PROP_STATUS, 171 POWER_SUPPLY_PROP_CHARGE_TYPE, 172 POWER_SUPPLY_PROP_HEALTH, 173 POWER_SUPPLY_PROP_PRESENT, 174 POWER_SUPPLY_PROP_TECHNOLOGY, 175 POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, 176 POWER_SUPPLY_PROP_CHARGE_FULL, 177 POWER_SUPPLY_PROP_CHARGE_NOW, 178 POWER_SUPPLY_PROP_CHARGE_COUNTER, 179 POWER_SUPPLY_PROP_CAPACITY, 180 POWER_SUPPLY_PROP_CAPACITY_LEVEL, 181 POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG, 182 POWER_SUPPLY_PROP_TIME_TO_FULL_NOW, 183 POWER_SUPPLY_PROP_MODEL_NAME, 184 POWER_SUPPLY_PROP_MANUFACTURER, 185 POWER_SUPPLY_PROP_SERIAL_NUMBER, 186 POWER_SUPPLY_PROP_TEMP, 187 POWER_SUPPLY_PROP_VOLTAGE_NOW, 188 POWER_SUPPLY_PROP_CURRENT_AVG, 189 POWER_SUPPLY_PROP_CURRENT_NOW, 190 POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR, 191 }; 192 193 static char *test_power_ac_supplied_to[] = { 194 "test_battery", 195 }; 196 197 static struct power_supply *test_power_supplies[TEST_POWER_NUM]; 198 199 static const struct power_supply_desc test_power_desc[] = { 200 [TEST_AC] = { 201 .name = "test_ac", 202 .type = POWER_SUPPLY_TYPE_MAINS, 203 .properties = test_power_ac_props, 204 .num_properties = ARRAY_SIZE(test_power_ac_props), 205 .get_property = test_power_get_ac_property, 206 }, 207 [TEST_BATTERY] = { 208 .name = "test_battery", 209 .type = POWER_SUPPLY_TYPE_BATTERY, 210 .properties = test_power_battery_props, 211 .num_properties = ARRAY_SIZE(test_power_battery_props), 212 .get_property = test_power_get_battery_property, 213 .set_property = test_power_set_battery_property, 214 .property_is_writeable = test_power_battery_property_is_writeable, 215 .charge_behaviours = BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO) 216 | BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE) 217 | BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE_AWAKE) 218 | BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_FORCE_DISCHARGE), 219 }, 220 [TEST_USB] = { 221 .name = "test_usb", 222 .type = POWER_SUPPLY_TYPE_USB, 223 .properties = test_power_ac_props, 224 .num_properties = ARRAY_SIZE(test_power_ac_props), 225 .get_property = test_power_get_usb_property, 226 }, 227 }; 228 229 static const struct power_supply_config test_power_configs[] = { 230 { 231 /* test_ac */ 232 .supplied_to = test_power_ac_supplied_to, 233 .num_supplicants = ARRAY_SIZE(test_power_ac_supplied_to), 234 }, { 235 /* test_battery */ 236 }, { 237 /* test_usb */ 238 .supplied_to = test_power_ac_supplied_to, 239 .num_supplicants = ARRAY_SIZE(test_power_ac_supplied_to), 240 }, 241 }; 242 243 static int test_power_battery_extmanufacture_year = 1234; 244 static int test_power_battery_exttemp_max = 1000; 245 static const enum power_supply_property test_power_battery_extprops[] = { 246 POWER_SUPPLY_PROP_MANUFACTURE_YEAR, 247 POWER_SUPPLY_PROP_TEMP_MAX, 248 }; 249 250 static int test_power_battery_extget_property(struct power_supply *psy, 251 const struct power_supply_ext *ext, 252 void *ext_data, 253 enum power_supply_property psp, 254 union power_supply_propval *val) 255 { 256 switch (psp) { 257 case POWER_SUPPLY_PROP_MANUFACTURE_YEAR: 258 val->intval = test_power_battery_extmanufacture_year; 259 break; 260 case POWER_SUPPLY_PROP_TEMP_MAX: 261 val->intval = test_power_battery_exttemp_max; 262 break; 263 default: 264 return -EINVAL; 265 } 266 return 0; 267 } 268 269 static int test_power_battery_extset_property(struct power_supply *psy, 270 const struct power_supply_ext *ext, 271 void *ext_data, 272 enum power_supply_property psp, 273 const union power_supply_propval *val) 274 { 275 switch (psp) { 276 case POWER_SUPPLY_PROP_MANUFACTURE_YEAR: 277 test_power_battery_extmanufacture_year = val->intval; 278 break; 279 case POWER_SUPPLY_PROP_TEMP_MAX: 280 test_power_battery_exttemp_max = val->intval; 281 break; 282 default: 283 return -EINVAL; 284 } 285 return 0; 286 } 287 288 static int test_power_battery_extproperty_is_writeable(struct power_supply *psy, 289 const struct power_supply_ext *ext, 290 void *ext_data, 291 enum power_supply_property psp) 292 { 293 return true; 294 } 295 296 static const struct power_supply_ext test_power_battery_ext = { 297 .name = "test_power", 298 .properties = test_power_battery_extprops, 299 .num_properties = ARRAY_SIZE(test_power_battery_extprops), 300 .get_property = test_power_battery_extget_property, 301 .set_property = test_power_battery_extset_property, 302 .property_is_writeable = test_power_battery_extproperty_is_writeable, 303 }; 304 305 static void test_power_configure_battery_extension(bool enable) 306 { 307 struct power_supply *psy; 308 309 psy = test_power_supplies[TEST_BATTERY]; 310 311 if (enable) { 312 if (power_supply_register_extension(psy, &test_power_battery_ext, &psy->dev, 313 NULL)) { 314 pr_err("registering battery extension failed\n"); 315 return; 316 } 317 } else { 318 power_supply_unregister_extension(psy, &test_power_battery_ext); 319 } 320 321 battery_extension = enable; 322 } 323 324 static int __init test_power_init(void) 325 { 326 int i; 327 int ret; 328 329 BUILD_BUG_ON(TEST_POWER_NUM != ARRAY_SIZE(test_power_supplies)); 330 BUILD_BUG_ON(TEST_POWER_NUM != ARRAY_SIZE(test_power_configs)); 331 332 for (i = 0; i < ARRAY_SIZE(test_power_supplies); i++) { 333 test_power_supplies[i] = power_supply_register(NULL, 334 &test_power_desc[i], 335 &test_power_configs[i]); 336 if (IS_ERR(test_power_supplies[i])) { 337 pr_err("%s: failed to register %s\n", __func__, 338 test_power_desc[i].name); 339 ret = PTR_ERR(test_power_supplies[i]); 340 goto failed; 341 } 342 } 343 344 test_power_configure_battery_extension(true); 345 346 module_initialized = true; 347 return 0; 348 failed: 349 while (--i >= 0) 350 power_supply_unregister(test_power_supplies[i]); 351 return ret; 352 } 353 module_init(test_power_init); 354 355 static void __exit test_power_exit(void) 356 { 357 int i; 358 359 /* Let's see how we handle changes... */ 360 ac_online = 0; 361 usb_online = 0; 362 battery_status = POWER_SUPPLY_STATUS_DISCHARGING; 363 for (i = 0; i < ARRAY_SIZE(test_power_supplies); i++) 364 power_supply_changed(test_power_supplies[i]); 365 pr_info("%s: 'changed' event sent, sleeping for 10 seconds...\n", 366 __func__); 367 ssleep(10); 368 369 for (i = 0; i < ARRAY_SIZE(test_power_supplies); i++) 370 power_supply_unregister(test_power_supplies[i]); 371 372 module_initialized = false; 373 } 374 module_exit(test_power_exit); 375 376 377 378 #define MAX_KEYLENGTH 256 379 struct battery_property_map { 380 int value; 381 char const *key; 382 }; 383 384 static struct battery_property_map map_ac_online[] = { 385 { 0, "off" }, 386 { 1, "on" }, 387 { -1, NULL }, 388 }; 389 390 static struct battery_property_map map_status[] = { 391 { POWER_SUPPLY_STATUS_CHARGING, "charging" }, 392 { POWER_SUPPLY_STATUS_DISCHARGING, "discharging" }, 393 { POWER_SUPPLY_STATUS_NOT_CHARGING, "not-charging" }, 394 { POWER_SUPPLY_STATUS_FULL, "full" }, 395 { -1, NULL }, 396 }; 397 398 static struct battery_property_map map_health[] = { 399 { POWER_SUPPLY_HEALTH_GOOD, "good" }, 400 { POWER_SUPPLY_HEALTH_OVERHEAT, "overheat" }, 401 { POWER_SUPPLY_HEALTH_DEAD, "dead" }, 402 { POWER_SUPPLY_HEALTH_OVERVOLTAGE, "overvoltage" }, 403 { POWER_SUPPLY_HEALTH_UNSPEC_FAILURE, "failure" }, 404 { -1, NULL }, 405 }; 406 407 static struct battery_property_map map_present[] = { 408 { 0, "false" }, 409 { 1, "true" }, 410 { -1, NULL }, 411 }; 412 413 static struct battery_property_map map_technology[] = { 414 { POWER_SUPPLY_TECHNOLOGY_NiMH, "NiMH" }, 415 { POWER_SUPPLY_TECHNOLOGY_LION, "LION" }, 416 { POWER_SUPPLY_TECHNOLOGY_LIPO, "LIPO" }, 417 { POWER_SUPPLY_TECHNOLOGY_LiFe, "LiFe" }, 418 { POWER_SUPPLY_TECHNOLOGY_NiCd, "NiCd" }, 419 { POWER_SUPPLY_TECHNOLOGY_LiMn, "LiMn" }, 420 { -1, NULL }, 421 }; 422 423 424 static int map_get_value(struct battery_property_map *map, const char *key, 425 int def_val) 426 { 427 char buf[MAX_KEYLENGTH]; 428 int cr; 429 430 strscpy(buf, key, MAX_KEYLENGTH); 431 432 cr = strnlen(buf, MAX_KEYLENGTH) - 1; 433 if (cr < 0) 434 return def_val; 435 if (buf[cr] == '\n') 436 buf[cr] = '\0'; 437 438 while (map->key) { 439 if (strncasecmp(map->key, buf, MAX_KEYLENGTH) == 0) 440 return map->value; 441 map++; 442 } 443 444 return def_val; 445 } 446 447 448 static const char *map_get_key(struct battery_property_map *map, int value, 449 const char *def_key) 450 { 451 while (map->key) { 452 if (map->value == value) 453 return map->key; 454 map++; 455 } 456 457 return def_key; 458 } 459 460 static inline void signal_power_supply_changed(struct power_supply *psy) 461 { 462 if (module_initialized) 463 power_supply_changed(psy); 464 } 465 466 static int param_set_ac_online(const char *key, const struct kernel_param *kp) 467 { 468 ac_online = map_get_value(map_ac_online, key, ac_online); 469 signal_power_supply_changed(test_power_supplies[TEST_AC]); 470 return 0; 471 } 472 473 static int param_get_ac_online(char *buffer, const struct kernel_param *kp) 474 { 475 return sprintf(buffer, "%s\n", 476 map_get_key(map_ac_online, ac_online, "unknown")); 477 } 478 479 static int param_set_usb_online(const char *key, const struct kernel_param *kp) 480 { 481 usb_online = map_get_value(map_ac_online, key, usb_online); 482 signal_power_supply_changed(test_power_supplies[TEST_USB]); 483 return 0; 484 } 485 486 static int param_get_usb_online(char *buffer, const struct kernel_param *kp) 487 { 488 return sprintf(buffer, "%s\n", 489 map_get_key(map_ac_online, usb_online, "unknown")); 490 } 491 492 static int param_set_battery_status(const char *key, 493 const struct kernel_param *kp) 494 { 495 battery_status = map_get_value(map_status, key, battery_status); 496 signal_power_supply_changed(test_power_supplies[TEST_BATTERY]); 497 return 0; 498 } 499 500 static int param_get_battery_status(char *buffer, const struct kernel_param *kp) 501 { 502 return sprintf(buffer, "%s\n", 503 map_get_key(map_ac_online, battery_status, "unknown")); 504 } 505 506 static int param_set_battery_health(const char *key, 507 const struct kernel_param *kp) 508 { 509 battery_health = map_get_value(map_health, key, battery_health); 510 signal_power_supply_changed(test_power_supplies[TEST_BATTERY]); 511 return 0; 512 } 513 514 static int param_get_battery_health(char *buffer, const struct kernel_param *kp) 515 { 516 return sprintf(buffer, "%s\n", 517 map_get_key(map_ac_online, battery_health, "unknown")); 518 } 519 520 static int param_set_battery_present(const char *key, 521 const struct kernel_param *kp) 522 { 523 battery_present = map_get_value(map_present, key, battery_present); 524 signal_power_supply_changed(test_power_supplies[TEST_AC]); 525 return 0; 526 } 527 528 static int param_get_battery_present(char *buffer, 529 const struct kernel_param *kp) 530 { 531 return sprintf(buffer, "%s\n", 532 map_get_key(map_ac_online, battery_present, "unknown")); 533 } 534 535 static int param_set_battery_technology(const char *key, 536 const struct kernel_param *kp) 537 { 538 battery_technology = map_get_value(map_technology, key, 539 battery_technology); 540 signal_power_supply_changed(test_power_supplies[TEST_BATTERY]); 541 return 0; 542 } 543 544 static int param_get_battery_technology(char *buffer, 545 const struct kernel_param *kp) 546 { 547 return sprintf(buffer, "%s\n", 548 map_get_key(map_ac_online, battery_technology, 549 "unknown")); 550 } 551 552 static int param_set_battery_capacity(const char *key, 553 const struct kernel_param *kp) 554 { 555 int tmp; 556 557 if (1 != sscanf(key, "%d", &tmp)) 558 return -EINVAL; 559 560 battery_capacity = tmp; 561 signal_power_supply_changed(test_power_supplies[TEST_BATTERY]); 562 return 0; 563 } 564 565 #define param_get_battery_capacity param_get_int 566 567 static int param_set_battery_voltage(const char *key, 568 const struct kernel_param *kp) 569 { 570 int tmp; 571 572 if (1 != sscanf(key, "%d", &tmp)) 573 return -EINVAL; 574 575 battery_voltage = tmp; 576 signal_power_supply_changed(test_power_supplies[TEST_BATTERY]); 577 return 0; 578 } 579 580 #define param_get_battery_voltage param_get_int 581 582 static int param_set_battery_charge_counter(const char *key, 583 const struct kernel_param *kp) 584 { 585 int tmp; 586 587 if (1 != sscanf(key, "%d", &tmp)) 588 return -EINVAL; 589 590 battery_charge_counter = tmp; 591 signal_power_supply_changed(test_power_supplies[TEST_BATTERY]); 592 return 0; 593 } 594 595 #define param_get_battery_charge_counter param_get_int 596 597 static int param_set_battery_current(const char *key, 598 const struct kernel_param *kp) 599 { 600 int tmp; 601 602 if (1 != sscanf(key, "%d", &tmp)) 603 return -EINVAL; 604 605 battery_current = tmp; 606 signal_power_supply_changed(test_power_supplies[TEST_BATTERY]); 607 return 0; 608 } 609 610 #define param_get_battery_current param_get_int 611 612 static int param_set_battery_extension(const char *key, 613 const struct kernel_param *kp) 614 { 615 bool prev_battery_extension; 616 int ret; 617 618 prev_battery_extension = battery_extension; 619 620 ret = param_set_bool(key, kp); 621 if (ret) 622 return ret; 623 624 if (prev_battery_extension != battery_extension) 625 test_power_configure_battery_extension(battery_extension); 626 627 return 0; 628 } 629 630 #define param_get_battery_extension param_get_bool 631 632 static const struct kernel_param_ops param_ops_ac_online = { 633 .set = param_set_ac_online, 634 .get = param_get_ac_online, 635 }; 636 637 static const struct kernel_param_ops param_ops_usb_online = { 638 .set = param_set_usb_online, 639 .get = param_get_usb_online, 640 }; 641 642 static const struct kernel_param_ops param_ops_battery_status = { 643 .set = param_set_battery_status, 644 .get = param_get_battery_status, 645 }; 646 647 static const struct kernel_param_ops param_ops_battery_present = { 648 .set = param_set_battery_present, 649 .get = param_get_battery_present, 650 }; 651 652 static const struct kernel_param_ops param_ops_battery_technology = { 653 .set = param_set_battery_technology, 654 .get = param_get_battery_technology, 655 }; 656 657 static const struct kernel_param_ops param_ops_battery_health = { 658 .set = param_set_battery_health, 659 .get = param_get_battery_health, 660 }; 661 662 static const struct kernel_param_ops param_ops_battery_capacity = { 663 .set = param_set_battery_capacity, 664 .get = param_get_battery_capacity, 665 }; 666 667 static const struct kernel_param_ops param_ops_battery_voltage = { 668 .set = param_set_battery_voltage, 669 .get = param_get_battery_voltage, 670 }; 671 672 static const struct kernel_param_ops param_ops_battery_charge_counter = { 673 .set = param_set_battery_charge_counter, 674 .get = param_get_battery_charge_counter, 675 }; 676 677 static const struct kernel_param_ops param_ops_battery_current = { 678 .set = param_set_battery_current, 679 .get = param_get_battery_current, 680 }; 681 682 static const struct kernel_param_ops param_ops_battery_extension = { 683 .set = param_set_battery_extension, 684 .get = param_get_battery_extension, 685 }; 686 687 #define param_check_ac_online(name, p) __param_check(name, p, void); 688 #define param_check_usb_online(name, p) __param_check(name, p, void); 689 #define param_check_battery_status(name, p) __param_check(name, p, void); 690 #define param_check_battery_present(name, p) __param_check(name, p, void); 691 #define param_check_battery_technology(name, p) __param_check(name, p, void); 692 #define param_check_battery_health(name, p) __param_check(name, p, void); 693 #define param_check_battery_capacity(name, p) __param_check(name, p, void); 694 #define param_check_battery_voltage(name, p) __param_check(name, p, void); 695 #define param_check_battery_charge_counter(name, p) __param_check(name, p, void); 696 #define param_check_battery_current(name, p) __param_check(name, p, void); 697 #define param_check_battery_extension(name, p) __param_check(name, p, void); 698 699 700 module_param(ac_online, ac_online, 0644); 701 MODULE_PARM_DESC(ac_online, "AC charging state <on|off>"); 702 703 module_param(usb_online, usb_online, 0644); 704 MODULE_PARM_DESC(usb_online, "USB charging state <on|off>"); 705 706 module_param(battery_status, battery_status, 0644); 707 MODULE_PARM_DESC(battery_status, 708 "battery status <charging|discharging|not-charging|full>"); 709 710 module_param(battery_present, battery_present, 0644); 711 MODULE_PARM_DESC(battery_present, 712 "battery presence state <good|overheat|dead|overvoltage|failure>"); 713 714 module_param(battery_technology, battery_technology, 0644); 715 MODULE_PARM_DESC(battery_technology, 716 "battery technology <NiMH|LION|LIPO|LiFe|NiCd|LiMn>"); 717 718 module_param(battery_health, battery_health, 0644); 719 MODULE_PARM_DESC(battery_health, 720 "battery health state <good|overheat|dead|overvoltage|failure>"); 721 722 module_param(battery_capacity, battery_capacity, 0644); 723 MODULE_PARM_DESC(battery_capacity, "battery capacity (percentage)"); 724 725 module_param(battery_voltage, battery_voltage, 0644); 726 MODULE_PARM_DESC(battery_voltage, "battery voltage (millivolts)"); 727 728 module_param(battery_charge_counter, battery_charge_counter, 0644); 729 MODULE_PARM_DESC(battery_charge_counter, 730 "battery charge counter (microampere-hours)"); 731 732 module_param(battery_current, battery_current, 0644); 733 MODULE_PARM_DESC(battery_current, "battery current (milliampere)"); 734 735 module_param(battery_extension, battery_extension, 0644); 736 MODULE_PARM_DESC(battery_extension, "battery extension"); 737 738 MODULE_DESCRIPTION("Power supply driver for testing"); 739 MODULE_AUTHOR("Anton Vorontsov <cbouatmailru@gmail.com>"); 740 MODULE_LICENSE("GPL"); 741