Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply

Pull power supply and reset updates from Sebastian Reichel:

- new driver for Intel PIIX4

- lots of module autoload fixes

- misc fixes

* tag 'for-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply:
power_supply: wm97xx_battery: use power_supply_get_drvdata
wm8350_power: use permission-specific DEVICE_ATTR variants
power: ipaq_micro_battery: fix alias
power: supply: bq27xxx_battery: Fix register map for BQ27510 and BQ27520
bq24190_charger: Fix PM runtime use for bq24190_battery_set_property
power: supply: lp8788: remove an unneeded NULL check
power: reset: zx-reboot: Fix module autoload
power: reset: syscon-reboot-mode: Fix module autoload
power: reset: at91-poweroff: Fix module autoload
power: reset: at91-reset: Fix module autoload
power: supply: axp288_fuel_gauge: Fix module autoload
power: supply: max8997_charger: Fix module autoload
power: supply: max17040: Change register transaction length from 8 bits to 16 bits
power: supply: bq27xxx_battery: don't update poll_interval param if same
power: supply: improve function-level documentation
power: reset: Add Intel PIIX4 poweroff driver

+217 -65
+1 -1
drivers/input/touchscreen/wm97xx-core.c
··· 682 682 } 683 683 platform_set_drvdata(wm->battery_dev, wm); 684 684 wm->battery_dev->dev.parent = dev; 685 - wm->battery_dev->dev.platform_data = pdata; 685 + wm->battery_dev->dev.platform_data = pdata->batt_pdata; 686 686 ret = platform_device_add(wm->battery_dev); 687 687 if (ret < 0) 688 688 goto batt_reg_err;
+10
drivers/power/reset/Kconfig
··· 104 104 help 105 105 Power off and restart support for Qualcomm boards. 106 106 107 + config POWER_RESET_PIIX4_POWEROFF 108 + tristate "Intel PIIX4 power-off driver" 109 + depends on PCI 110 + depends on MIPS || COMPILE_TEST 111 + help 112 + This driver supports powering off a system using the Intel PIIX4 113 + southbridge, for example the MIPS Malta development board. The 114 + southbridge SOff state is entered in response to a request to 115 + power off the system. 116 + 107 117 config POWER_RESET_LTC2952 108 118 bool "LTC2952 PowerPath power-off driver" 109 119 depends on OF_GPIO
+1
drivers/power/reset/Makefile
··· 10 10 obj-$(CONFIG_POWER_RESET_HISI) += hisi-reboot.o 11 11 obj-$(CONFIG_POWER_RESET_IMX) += imx-snvs-poweroff.o 12 12 obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o 13 + obj-$(CONFIG_POWER_RESET_PIIX4_POWEROFF) += piix4-poweroff.o 13 14 obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o 14 15 obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o 15 16 obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
+1
drivers/power/reset/at91-poweroff.c
··· 169 169 { .compatible = "atmel,at91sam9x5-shdwc", }, 170 170 { /*sentinel*/ } 171 171 }; 172 + MODULE_DEVICE_TABLE(of, at91_poweroff_of_match); 172 173 173 174 static struct platform_driver at91_poweroff_driver = { 174 175 .remove = __exit_p(at91_poweroff_remove),
+2
drivers/power/reset/at91-reset.c
··· 175 175 { .compatible = "atmel,sama5d3-rstc", .data = sama5d3_restart }, 176 176 { /* sentinel */ } 177 177 }; 178 + MODULE_DEVICE_TABLE(of, at91_reset_of_match); 178 179 179 180 static struct notifier_block at91_restart_nb = { 180 181 .priority = 192, ··· 243 242 { "at91-sam9g45-reset", (unsigned long)at91sam9g45_restart }, 244 243 { /* sentinel */ } 245 244 }; 245 + MODULE_DEVICE_TABLE(platform, at91_reset_plat_match); 246 246 247 247 static struct platform_driver at91_reset_driver = { 248 248 .remove = __exit_p(at91_reset_remove),
+113
drivers/power/reset/piix4-poweroff.c
··· 1 + /* 2 + * Copyright (C) 2016 Imagination Technologies 3 + * Author: Paul Burton <paul.burton@imgtec.com> 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms of the GNU General Public License as published by the 7 + * Free Software Foundation; either version 2 of the License, or (at your 8 + * option) any later version. 9 + */ 10 + 11 + #include <linux/delay.h> 12 + #include <linux/io.h> 13 + #include <linux/module.h> 14 + #include <linux/pci.h> 15 + #include <linux/pm.h> 16 + 17 + static struct pci_dev *pm_dev; 18 + static resource_size_t io_offset; 19 + 20 + enum piix4_pm_io_reg { 21 + PIIX4_FUNC3IO_PMSTS = 0x00, 22 + #define PIIX4_FUNC3IO_PMSTS_PWRBTN_STS BIT(8) 23 + PIIX4_FUNC3IO_PMCNTRL = 0x04, 24 + #define PIIX4_FUNC3IO_PMCNTRL_SUS_EN BIT(13) 25 + #define PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF (0x0 << 10) 26 + }; 27 + 28 + #define PIIX4_SUSPEND_MAGIC 0x00120002 29 + 30 + static const int piix4_pm_io_region = PCI_BRIDGE_RESOURCES; 31 + 32 + static void piix4_poweroff(void) 33 + { 34 + int spec_devid; 35 + u16 sts; 36 + 37 + /* Ensure the power button status is clear */ 38 + while (1) { 39 + sts = inw(io_offset + PIIX4_FUNC3IO_PMSTS); 40 + if (!(sts & PIIX4_FUNC3IO_PMSTS_PWRBTN_STS)) 41 + break; 42 + outw(sts, io_offset + PIIX4_FUNC3IO_PMSTS); 43 + } 44 + 45 + /* Enable entry to suspend */ 46 + outw(PIIX4_FUNC3IO_PMCNTRL_SUS_TYP_SOFF | PIIX4_FUNC3IO_PMCNTRL_SUS_EN, 47 + io_offset + PIIX4_FUNC3IO_PMCNTRL); 48 + 49 + /* If the special cycle occurs too soon this doesn't work... */ 50 + mdelay(10); 51 + 52 + /* 53 + * The PIIX4 will enter the suspend state only after seeing a special 54 + * cycle with the correct magic data on the PCI bus. Generate that 55 + * cycle now. 56 + */ 57 + spec_devid = PCI_DEVID(0, PCI_DEVFN(0x1f, 0x7)); 58 + pci_bus_write_config_dword(pm_dev->bus, spec_devid, 0, 59 + PIIX4_SUSPEND_MAGIC); 60 + 61 + /* Give the system some time to power down, then error */ 62 + mdelay(1000); 63 + pr_emerg("Unable to poweroff system\n"); 64 + } 65 + 66 + static int piix4_poweroff_probe(struct pci_dev *dev, 67 + const struct pci_device_id *id) 68 + { 69 + int res; 70 + 71 + if (pm_dev) 72 + return -EINVAL; 73 + 74 + /* Request access to the PIIX4 PM IO registers */ 75 + res = pci_request_region(dev, piix4_pm_io_region, 76 + "PIIX4 PM IO registers"); 77 + if (res) { 78 + dev_err(&dev->dev, "failed to request PM IO registers: %d\n", 79 + res); 80 + return res; 81 + } 82 + 83 + pm_dev = dev; 84 + io_offset = pci_resource_start(dev, piix4_pm_io_region); 85 + pm_power_off = piix4_poweroff; 86 + 87 + return 0; 88 + } 89 + 90 + static void piix4_poweroff_remove(struct pci_dev *dev) 91 + { 92 + if (pm_power_off == piix4_poweroff) 93 + pm_power_off = NULL; 94 + 95 + pci_release_region(dev, piix4_pm_io_region); 96 + pm_dev = NULL; 97 + } 98 + 99 + static const struct pci_device_id piix4_poweroff_ids[] = { 100 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3) }, 101 + { 0 }, 102 + }; 103 + 104 + static struct pci_driver piix4_poweroff_driver = { 105 + .name = "piix4-poweroff", 106 + .id_table = piix4_poweroff_ids, 107 + .probe = piix4_poweroff_probe, 108 + .remove = piix4_poweroff_remove, 109 + }; 110 + 111 + module_pci_driver(piix4_poweroff_driver); 112 + MODULE_AUTHOR("Paul Burton <paul.burton@imgtec.com>"); 113 + MODULE_LICENSE("GPL");
+1
drivers/power/reset/syscon-reboot-mode.c
··· 74 74 { .compatible = "syscon-reboot-mode" }, 75 75 {} 76 76 }; 77 + MODULE_DEVICE_TABLE(of, syscon_reboot_mode_of_match); 77 78 78 79 static struct platform_driver syscon_reboot_mode_driver = { 79 80 .probe = syscon_reboot_mode_probe,
+1
drivers/power/reset/zx-reboot.c
··· 72 72 { .compatible = "zte,sysctrl" }, 73 73 {} 74 74 }; 75 + MODULE_DEVICE_TABLE(of, zx_reboot_of_match); 75 76 76 77 static struct platform_driver zx_reboot_driver = { 77 78 .probe = zx_reboot_probe,
+4 -4
drivers/power/supply/ab8500_fg.c
··· 1900 1900 * ab8500_fg_battok_calc - calculate the bit pattern corresponding 1901 1901 * to the target voltage. 1902 1902 * @di: pointer to the ab8500_fg structure 1903 - * @target target voltage 1903 + * @target: target voltage 1904 1904 * 1905 1905 * Returns bit pattern closest to the target voltage 1906 1906 * valid return values are 0-14. (0-BATT_OK_MAX_NR_INCREMENTS) ··· 2391 2391 } 2392 2392 2393 2393 /** 2394 - * abab8500_fg_reinit_work() - work to reset the FG algorithm 2394 + * ab8500_fg_reinit_work() - work to reset the FG algorithm 2395 2395 * @work: pointer to the work_struct structure 2396 2396 * 2397 2397 * Used to reset the current battery capacity to be able to ··· 2528 2528 }; 2529 2529 2530 2530 /** 2531 - * ab8500_chargalg_sysfs_exit() - de-init of sysfs entry 2531 + * ab8500_fg_sysfs_exit() - de-init of sysfs entry 2532 2532 * @di: pointer to the struct ab8500_chargalg 2533 2533 * 2534 2534 * This function removes the entry in sysfs. ··· 2539 2539 } 2540 2540 2541 2541 /** 2542 - * ab8500_chargalg_sysfs_init() - init of sysfs entry 2542 + * ab8500_fg_sysfs_init() - init of sysfs entry 2543 2543 * @di: pointer to the struct ab8500_chargalg 2544 2544 * 2545 2545 * This function adds an entry in sysfs.
+1
drivers/power/supply/axp288_fuel_gauge.c
··· 1120 1120 { .name = DEV_NAME }, 1121 1121 {}, 1122 1122 }; 1123 + MODULE_DEVICE_TABLE(platform, axp288_fg_id_table); 1123 1124 1124 1125 static int axp288_fuel_gauge_remove(struct platform_device *pdev) 1125 1126 {
+1 -1
drivers/power/supply/bq24190_charger.c
··· 1141 1141 1142 1142 dev_dbg(bdi->dev, "prop: %d\n", psp); 1143 1143 1144 - pm_runtime_put_sync(bdi->dev); 1144 + pm_runtime_get_sync(bdi->dev); 1145 1145 1146 1146 switch (psp) { 1147 1147 case POWER_SUPPLY_PROP_ONLINE:
+42 -2
drivers/power/supply/bq27xxx_battery.c
··· 164 164 [BQ27XXX_REG_DCAP] = 0x3c, 165 165 [BQ27XXX_REG_AP] = INVALID_REG_ADDR, 166 166 }, 167 + [BQ27510] = { 168 + [BQ27XXX_REG_CTRL] = 0x00, 169 + [BQ27XXX_REG_TEMP] = 0x06, 170 + [BQ27XXX_REG_INT_TEMP] = 0x28, 171 + [BQ27XXX_REG_VOLT] = 0x08, 172 + [BQ27XXX_REG_AI] = 0x14, 173 + [BQ27XXX_REG_FLAGS] = 0x0a, 174 + [BQ27XXX_REG_TTE] = 0x16, 175 + [BQ27XXX_REG_TTF] = INVALID_REG_ADDR, 176 + [BQ27XXX_REG_TTES] = 0x1a, 177 + [BQ27XXX_REG_TTECP] = INVALID_REG_ADDR, 178 + [BQ27XXX_REG_NAC] = 0x0c, 179 + [BQ27XXX_REG_FCC] = 0x12, 180 + [BQ27XXX_REG_CYCT] = 0x1e, 181 + [BQ27XXX_REG_AE] = INVALID_REG_ADDR, 182 + [BQ27XXX_REG_SOC] = 0x20, 183 + [BQ27XXX_REG_DCAP] = 0x2e, 184 + [BQ27XXX_REG_AP] = INVALID_REG_ADDR, 185 + }, 167 186 [BQ27530] = { 168 187 [BQ27XXX_REG_CTRL] = 0x00, 169 188 [BQ27XXX_REG_TEMP] = 0x06, ··· 321 302 POWER_SUPPLY_PROP_MANUFACTURER, 322 303 }; 323 304 305 + static enum power_supply_property bq27510_battery_props[] = { 306 + POWER_SUPPLY_PROP_STATUS, 307 + POWER_SUPPLY_PROP_PRESENT, 308 + POWER_SUPPLY_PROP_VOLTAGE_NOW, 309 + POWER_SUPPLY_PROP_CURRENT_NOW, 310 + POWER_SUPPLY_PROP_CAPACITY, 311 + POWER_SUPPLY_PROP_CAPACITY_LEVEL, 312 + POWER_SUPPLY_PROP_TEMP, 313 + POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW, 314 + POWER_SUPPLY_PROP_TECHNOLOGY, 315 + POWER_SUPPLY_PROP_CHARGE_FULL, 316 + POWER_SUPPLY_PROP_CHARGE_NOW, 317 + POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, 318 + POWER_SUPPLY_PROP_CYCLE_COUNT, 319 + POWER_SUPPLY_PROP_HEALTH, 320 + POWER_SUPPLY_PROP_MANUFACTURER, 321 + }; 322 + 324 323 static enum power_supply_property bq27530_battery_props[] = { 325 324 POWER_SUPPLY_PROP_STATUS, 326 325 POWER_SUPPLY_PROP_PRESENT, ··· 422 385 BQ27XXX_PROP(BQ27000, bq27000_battery_props), 423 386 BQ27XXX_PROP(BQ27010, bq27010_battery_props), 424 387 BQ27XXX_PROP(BQ27500, bq27500_battery_props), 388 + BQ27XXX_PROP(BQ27510, bq27510_battery_props), 425 389 BQ27XXX_PROP(BQ27530, bq27530_battery_props), 426 390 BQ27XXX_PROP(BQ27541, bq27541_battery_props), 427 391 BQ27XXX_PROP(BQ27545, bq27545_battery_props), ··· 435 397 static int poll_interval_param_set(const char *val, const struct kernel_param *kp) 436 398 { 437 399 struct bq27xxx_device_info *di; 400 + unsigned int prev_val = *(unsigned int *) kp->arg; 438 401 int ret; 439 402 440 403 ret = param_set_uint(val, kp); 441 - if (ret < 0) 404 + if (ret < 0 || prev_val == *(unsigned int *) kp->arg) 442 405 return ret; 443 406 444 407 mutex_lock(&bq27xxx_list_lock); ··· 674 635 */ 675 636 static bool bq27xxx_battery_overtemp(struct bq27xxx_device_info *di, u16 flags) 676 637 { 677 - if (di->chip == BQ27500 || di->chip == BQ27541 || di->chip == BQ27545) 638 + if (di->chip == BQ27500 || di->chip == BQ27510 || 639 + di->chip == BQ27541 || di->chip == BQ27545) 678 640 return flags & (BQ27XXX_FLAG_OTC | BQ27XXX_FLAG_OTD); 679 641 if (di->chip == BQ27530 || di->chip == BQ27421) 680 642 return flags & BQ27XXX_FLAG_OT;
+2 -2
drivers/power/supply/bq27xxx_battery_i2c.c
··· 149 149 { "bq27200", BQ27000 }, 150 150 { "bq27210", BQ27010 }, 151 151 { "bq27500", BQ27500 }, 152 - { "bq27510", BQ27500 }, 153 - { "bq27520", BQ27500 }, 152 + { "bq27510", BQ27510 }, 153 + { "bq27520", BQ27510 }, 154 154 { "bq27530", BQ27530 }, 155 155 { "bq27531", BQ27530 }, 156 156 { "bq27541", BQ27541 },
+1 -1
drivers/power/supply/ipaq_micro_battery.c
··· 313 313 314 314 MODULE_LICENSE("GPL"); 315 315 MODULE_DESCRIPTION("driver for iPAQ Atmel micro battery"); 316 - MODULE_ALIAS("platform:battery-ipaq-micro"); 316 + MODULE_ALIAS("platform:ipaq-micro-battery");
-3
drivers/power/supply/lp8788-charger.c
··· 384 384 for (i = 0; i < pdata->num_chg_params; i++) { 385 385 param = pdata->chg_params + i; 386 386 387 - if (!param) 388 - continue; 389 - 390 387 if (lp8788_is_valid_charger_register(param->addr)) { 391 388 ret = lp8788_write_byte(lp, param->addr, param->val); 392 389 if (ret)
+20 -32
drivers/power/supply/max17040_battery.c
··· 21 21 #include <linux/max17040_battery.h> 22 22 #include <linux/slab.h> 23 23 24 - #define MAX17040_VCELL_MSB 0x02 25 - #define MAX17040_VCELL_LSB 0x03 26 - #define MAX17040_SOC_MSB 0x04 27 - #define MAX17040_SOC_LSB 0x05 28 - #define MAX17040_MODE_MSB 0x06 29 - #define MAX17040_MODE_LSB 0x07 30 - #define MAX17040_VER_MSB 0x08 31 - #define MAX17040_VER_LSB 0x09 32 - #define MAX17040_RCOMP_MSB 0x0C 33 - #define MAX17040_RCOMP_LSB 0x0D 34 - #define MAX17040_CMD_MSB 0xFE 35 - #define MAX17040_CMD_LSB 0xFF 24 + #define MAX17040_VCELL 0x02 25 + #define MAX17040_SOC 0x04 26 + #define MAX17040_MODE 0x06 27 + #define MAX17040_VER 0x08 28 + #define MAX17040_RCOMP 0x0C 29 + #define MAX17040_CMD 0xFE 30 + 36 31 37 32 #define MAX17040_DELAY 1000 38 33 #define MAX17040_BATTERY_FULL 95 ··· 73 78 return 0; 74 79 } 75 80 76 - static int max17040_write_reg(struct i2c_client *client, int reg, u8 value) 81 + static int max17040_write_reg(struct i2c_client *client, int reg, u16 value) 77 82 { 78 83 int ret; 79 84 80 - ret = i2c_smbus_write_byte_data(client, reg, value); 85 + ret = i2c_smbus_write_word_swapped(client, reg, value); 81 86 82 87 if (ret < 0) 83 88 dev_err(&client->dev, "%s: err %d\n", __func__, ret); ··· 89 94 { 90 95 int ret; 91 96 92 - ret = i2c_smbus_read_byte_data(client, reg); 97 + ret = i2c_smbus_read_word_swapped(client, reg); 93 98 94 99 if (ret < 0) 95 100 dev_err(&client->dev, "%s: err %d\n", __func__, ret); ··· 99 104 100 105 static void max17040_reset(struct i2c_client *client) 101 106 { 102 - max17040_write_reg(client, MAX17040_CMD_MSB, 0x54); 103 - max17040_write_reg(client, MAX17040_CMD_LSB, 0x00); 107 + max17040_write_reg(client, MAX17040_CMD, 0x0054); 104 108 } 105 109 106 110 static void max17040_get_vcell(struct i2c_client *client) 107 111 { 108 112 struct max17040_chip *chip = i2c_get_clientdata(client); 109 - u8 msb; 110 - u8 lsb; 113 + u16 vcell; 111 114 112 - msb = max17040_read_reg(client, MAX17040_VCELL_MSB); 113 - lsb = max17040_read_reg(client, MAX17040_VCELL_LSB); 115 + vcell = max17040_read_reg(client, MAX17040_VCELL); 114 116 115 - chip->vcell = (msb << 4) + (lsb >> 4); 117 + chip->vcell = vcell; 116 118 } 117 119 118 120 static void max17040_get_soc(struct i2c_client *client) 119 121 { 120 122 struct max17040_chip *chip = i2c_get_clientdata(client); 121 - u8 msb; 122 - u8 lsb; 123 + u16 soc; 123 124 124 - msb = max17040_read_reg(client, MAX17040_SOC_MSB); 125 - lsb = max17040_read_reg(client, MAX17040_SOC_LSB); 125 + soc = max17040_read_reg(client, MAX17040_SOC); 126 126 127 - chip->soc = msb; 127 + chip->soc = (soc >> 8); 128 128 } 129 129 130 130 static void max17040_get_version(struct i2c_client *client) 131 131 { 132 - u8 msb; 133 - u8 lsb; 132 + u16 version; 134 133 135 - msb = max17040_read_reg(client, MAX17040_VER_MSB); 136 - lsb = max17040_read_reg(client, MAX17040_VER_LSB); 134 + version = max17040_read_reg(client, MAX17040_VER); 137 135 138 - dev_info(&client->dev, "MAX17040 Fuel-Gauge Ver %d%d\n", msb, lsb); 136 + dev_info(&client->dev, "MAX17040 Fuel-Gauge Ver 0x%x\n", version); 139 137 } 140 138 141 139 static void max17040_get_online(struct i2c_client *client)
+1
drivers/power/supply/max8997_charger.c
··· 184 184 { "max8997-battery", 0 }, 185 185 { } 186 186 }; 187 + MODULE_DEVICE_TABLE(platform, max8997_battery_id); 187 188 188 189 static struct platform_driver max8997_battery_driver = { 189 190 .driver = {
+2 -2
drivers/power/supply/power_supply_core.c
··· 413 413 /** 414 414 * power_supply_get_by_phandle() - Search for a power supply and returns its ref 415 415 * @np: Pointer to device node holding phandle property 416 - * @phandle_name: Name of property holding a power supply name 416 + * @property: Name of property holding a power supply name 417 417 * 418 418 * If power supply was found, it increases reference count for the 419 419 * internal power supply's device. The user should power_supply_put() ··· 458 458 * devm_power_supply_get_by_phandle() - Resource managed version of 459 459 * power_supply_get_by_phandle() 460 460 * @dev: Pointer to device holding phandle property 461 - * @phandle_name: Name of property holding a power supply phandle 461 + * @property: Name of property holding a power supply phandle 462 462 * 463 463 * Return: On success returns a reference to a power supply with 464 464 * matching name equals to value under @property, NULL or ERR_PTR otherwise.
+1 -1
drivers/power/supply/wm8350_power.c
··· 182 182 return sprintf(buf, "%s\n", charge); 183 183 } 184 184 185 - static DEVICE_ATTR(charger_state, 0444, charger_state_show, NULL); 185 + static DEVICE_ATTR_RO(charger_state); 186 186 187 187 static irqreturn_t wm8350_charger_handler(int irq, void *data) 188 188 {
+10 -15
drivers/power/supply/wm97xx_battery.c
··· 30 30 31 31 static unsigned long wm97xx_read_bat(struct power_supply *bat_ps) 32 32 { 33 - struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data; 34 - struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata; 33 + struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps); 35 34 36 35 return wm97xx_read_aux_adc(dev_get_drvdata(bat_ps->dev.parent), 37 36 pdata->batt_aux) * pdata->batt_mult / ··· 39 40 40 41 static unsigned long wm97xx_read_temp(struct power_supply *bat_ps) 41 42 { 42 - struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data; 43 - struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata; 43 + struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps); 44 44 45 45 return wm97xx_read_aux_adc(dev_get_drvdata(bat_ps->dev.parent), 46 46 pdata->temp_aux) * pdata->temp_mult / ··· 50 52 enum power_supply_property psp, 51 53 union power_supply_propval *val) 52 54 { 53 - struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data; 54 - struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata; 55 + struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps); 55 56 56 57 switch (psp) { 57 58 case POWER_SUPPLY_PROP_STATUS: ··· 100 103 static void wm97xx_bat_update(struct power_supply *bat_ps) 101 104 { 102 105 int old_status = bat_status; 103 - struct wm97xx_pdata *wmdata = bat_ps->dev.parent->platform_data; 104 - struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata; 106 + struct wm97xx_batt_pdata *pdata = power_supply_get_drvdata(bat_ps); 105 107 106 108 mutex_lock(&work_lock); 107 109 ··· 162 166 int ret = 0; 163 167 int props = 1; /* POWER_SUPPLY_PROP_PRESENT */ 164 168 int i = 0; 165 - struct wm97xx_pdata *wmdata = dev->dev.platform_data; 166 - struct wm97xx_batt_pdata *pdata; 169 + struct wm97xx_batt_pdata *pdata = dev->dev.platform_data; 170 + struct power_supply_config cfg = {}; 167 171 168 - if (!wmdata) { 172 + if (!pdata) { 169 173 dev_err(&dev->dev, "No platform data supplied\n"); 170 174 return -EINVAL; 171 175 } 172 176 173 - pdata = wmdata->batt_pdata; 177 + cfg.drv_data = pdata; 174 178 175 179 if (dev->id != -1) 176 180 return -EINVAL; ··· 239 243 bat_psy_desc.properties = prop; 240 244 bat_psy_desc.num_properties = props; 241 245 242 - bat_psy = power_supply_register(&dev->dev, &bat_psy_desc, NULL); 246 + bat_psy = power_supply_register(&dev->dev, &bat_psy_desc, &cfg); 243 247 if (!IS_ERR(bat_psy)) { 244 248 schedule_work(&bat_work); 245 249 } else { ··· 262 266 263 267 static int wm97xx_bat_remove(struct platform_device *dev) 264 268 { 265 - struct wm97xx_pdata *wmdata = dev->dev.platform_data; 266 - struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata; 269 + struct wm97xx_batt_pdata *pdata = dev->dev.platform_data; 267 270 268 271 if (pdata && gpio_is_valid(pdata->charge_gpio)) { 269 272 free_irq(gpio_to_irq(pdata->charge_gpio), dev);
+2 -1
include/linux/power/bq27xxx_battery.h
··· 4 4 enum bq27xxx_chip { 5 5 BQ27000 = 1, /* bq27000, bq27200 */ 6 6 BQ27010, /* bq27010, bq27210 */ 7 - BQ27500, /* bq27500, bq27510, bq27520 */ 7 + BQ27500, /* bq27500 */ 8 + BQ27510, /* bq27510, bq27520 */ 8 9 BQ27530, /* bq27530, bq27531 */ 9 10 BQ27541, /* bq27541, bq27542, bq27546, bq27742 */ 10 11 BQ27545, /* bq27545 */