aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/test_power.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/power/test_power.c b/drivers/power/test_power.c
index 99aec3b38b2..b99a452a4fd 100644
--- a/drivers/power/test_power.c
+++ b/drivers/power/test_power.c
@@ -28,6 +28,7 @@ static int battery_health = POWER_SUPPLY_HEALTH_GOOD;
28static int battery_present = 1; /* true */ 28static int battery_present = 1; /* true */
29static int battery_technology = POWER_SUPPLY_TECHNOLOGY_LION; 29static int battery_technology = POWER_SUPPLY_TECHNOLOGY_LION;
30static int battery_capacity = 50; 30static int battery_capacity = 50;
31static int battery_voltage = 3300;
31 32
32static int test_power_get_ac_property(struct power_supply *psy, 33static int test_power_get_ac_property(struct power_supply *psy,
33 enum power_supply_property psp, 34 enum power_supply_property psp,
@@ -101,6 +102,12 @@ static int test_power_get_battery_property(struct power_supply *psy,
101 case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW: 102 case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW:
102 val->intval = 3600; 103 val->intval = 3600;
103 break; 104 break;
105 case POWER_SUPPLY_PROP_TEMP:
106 val->intval = 26;
107 break;
108 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
109 val->intval = battery_voltage;
110 break;
104 default: 111 default:
105 pr_info("%s: some properties deliberately report errors.\n", 112 pr_info("%s: some properties deliberately report errors.\n",
106 __func__); 113 __func__);
@@ -129,6 +136,8 @@ static enum power_supply_property test_power_battery_props[] = {
129 POWER_SUPPLY_PROP_MODEL_NAME, 136 POWER_SUPPLY_PROP_MODEL_NAME,
130 POWER_SUPPLY_PROP_MANUFACTURER, 137 POWER_SUPPLY_PROP_MANUFACTURER,
131 POWER_SUPPLY_PROP_SERIAL_NUMBER, 138 POWER_SUPPLY_PROP_SERIAL_NUMBER,
139 POWER_SUPPLY_PROP_TEMP,
140 POWER_SUPPLY_PROP_VOLTAGE_NOW,
132}; 141};
133 142
134static char *test_power_ac_supplied_to[] = { 143static char *test_power_ac_supplied_to[] = {
@@ -387,6 +396,21 @@ static int param_set_battery_capacity(const char *key,
387 396
388#define param_get_battery_capacity param_get_int 397#define param_get_battery_capacity param_get_int
389 398
399static int param_set_battery_voltage(const char *key,
400 const struct kernel_param *kp)
401{
402 int tmp;
403
404 if (1 != sscanf(key, "%d", &tmp))
405 return -EINVAL;
406
407 battery_voltage = tmp;
408 power_supply_changed(&test_power_supplies[1]);
409 return 0;
410}
411
412#define param_get_battery_voltage param_get_int
413
390static struct kernel_param_ops param_ops_ac_online = { 414static struct kernel_param_ops param_ops_ac_online = {
391 .set = param_set_ac_online, 415 .set = param_set_ac_online,
392 .get = param_get_ac_online, 416 .get = param_get_ac_online,
@@ -422,6 +446,10 @@ static struct kernel_param_ops param_ops_battery_capacity = {
422 .get = param_get_battery_capacity, 446 .get = param_get_battery_capacity,
423}; 447};
424 448
449static struct kernel_param_ops param_ops_battery_voltage = {
450 .set = param_set_battery_voltage,
451 .get = param_get_battery_voltage,
452};
425 453
426#define param_check_ac_online(name, p) __param_check(name, p, void); 454#define param_check_ac_online(name, p) __param_check(name, p, void);
427#define param_check_usb_online(name, p) __param_check(name, p, void); 455#define param_check_usb_online(name, p) __param_check(name, p, void);
@@ -430,6 +458,7 @@ static struct kernel_param_ops param_ops_battery_capacity = {
430#define param_check_battery_technology(name, p) __param_check(name, p, void); 458#define param_check_battery_technology(name, p) __param_check(name, p, void);
431#define param_check_battery_health(name, p) __param_check(name, p, void); 459#define param_check_battery_health(name, p) __param_check(name, p, void);
432#define param_check_battery_capacity(name, p) __param_check(name, p, void); 460#define param_check_battery_capacity(name, p) __param_check(name, p, void);
461#define param_check_battery_voltage(name, p) __param_check(name, p, void);
433 462
434 463
435module_param(ac_online, ac_online, 0644); 464module_param(ac_online, ac_online, 0644);
@@ -457,6 +486,8 @@ MODULE_PARM_DESC(battery_health,
457module_param(battery_capacity, battery_capacity, 0644); 486module_param(battery_capacity, battery_capacity, 0644);
458MODULE_PARM_DESC(battery_capacity, "battery capacity (percentage)"); 487MODULE_PARM_DESC(battery_capacity, "battery capacity (percentage)");
459 488
489module_param(battery_voltage, battery_voltage, 0644);
490MODULE_PARM_DESC(battery_voltage, "battery voltage (millivolts)");
460 491
461MODULE_DESCRIPTION("Power supply driver for testing"); 492MODULE_DESCRIPTION("Power supply driver for testing");
462MODULE_AUTHOR("Anton Vorontsov <cbouatmailru@gmail.com>"); 493MODULE_AUTHOR("Anton Vorontsov <cbouatmailru@gmail.com>");