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

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull power supply and reset updates from Sebastian Reichel:

- bq25890: add charge voltage/current support

- bd99954: convert to linear range

- convert all i2c drivers to use probe_new

- misc fixes and cleanups

* tag 'for-v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (51 commits)
power: supply: fix null pointer dereferencing in power_supply_get_battery_info
power: supply: bq25890: Fix usb-notifier probe and remove races
power: supply: bq25890: Ensure pump_express_work is cancelled on remove
power: supply: Fix refcount leak in rk817_charger_probe
power: supply: bq25890: Only use pdata->regulator_init_data for vbus
power: supply: ab8500: Fix error handling in ab8500_charger_init()
power: supply: cw2015: Fix potential null-ptr-deref in cw_bat_probe()
power: supply: z2_battery: Fix possible memleak in z2_batt_probe()
power: supply: z2_battery: Convert to i2c's .probe_new()
power: supply: ucs1002: Convert to i2c's .probe_new()
power: supply: smb347: Convert to i2c's .probe_new()
power: supply: sbs-manager: Convert to i2c's .probe_new()
power: supply: sbs: Convert to i2c's .probe_new()
power: supply: rt9455: Convert to i2c's .probe_new()
power: supply: rt5033_battery: Convert to i2c's .probe_new()
power: supply: max17042_battery: Convert to i2c's .probe_new()
power: supply: max17040: Convert to i2c's .probe_new()
power: supply: max14656: Convert to i2c's .probe_new()
power: supply: ltc4162-l: Convert to i2c's .probe_new()
power: supply: ltc2941: Convert to i2c's .probe_new()
...

+372 -285
+3 -3
Documentation/devicetree/bindings/mfd/ene-kb930.yaml
··· 13 13 maintainers: 14 14 - Dmitry Osipenko <digetx@gmail.com> 15 15 16 + $ref: /schemas/power/supply/power-supply.yaml 17 + 16 18 properties: 17 19 compatible: 18 20 items: ··· 24 22 reg: 25 23 maxItems: 1 26 24 27 - monitored-battery: true 28 - power-supplies: true 29 25 system-power-controller: true 30 26 31 27 required: 32 28 - compatible 33 29 - reg 34 30 35 - additionalProperties: false 31 + unevaluatedProperties: false 36 32 37 33 examples: 38 34 - |
+2
Documentation/devicetree/bindings/mfd/rockchip,rk817.yaml
··· 124 124 The child node for the charger to hold additional properties. If a 125 125 battery is not in use, this node can be omitted. 126 126 type: object 127 + $ref: /schemas/power/supply/power-supply.yaml 128 + 127 129 properties: 128 130 monitored-battery: 129 131 description: |
+3 -10
Documentation/devicetree/bindings/power/reset/gpio-restart.yaml
··· 25 25 inactive-delay, the GPIO is driven active again. After a delay specified by wait-delay, the 26 26 restart handler completes allowing other restart handlers to be attempted. 27 27 28 + allOf: 29 + - $ref: restart-handler.yaml# 30 + 28 31 properties: 29 32 compatible: 30 33 const: gpio-restart ··· 44 41 in its inactive state. 45 42 46 43 priority: 47 - $ref: /schemas/types.yaml#/definitions/uint32 48 - description: | 49 - A priority ranging from 0 to 255 (default 129) according to the following guidelines: 50 - 51 - 0: Restart handler of last resort, with limited restart capabilities. 52 - 128: Default restart handler; use if no other restart handler is expected to be available, 53 - and/or if restart functionality is sufficient to restart the entire system. 54 - 255: Highest priority restart handler, will preempt all other restart handlers. 55 - minimum: 0 56 - maximum: 255 57 44 default: 129 58 45 59 46 active-delay:
+30
Documentation/devicetree/bindings/power/reset/restart-handler.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/power/reset/restart-handler.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Restart and shutdown handler generic binding 8 + 9 + maintainers: 10 + - Sebastian Reichel <sre@kernel.org> 11 + 12 + description: 13 + Restart and shutdown handler device is responsible for powering off the 14 + system, e.g. my cutting off the power. System might have several restart 15 + handlers, which usually are tried from most precise to last resort. 16 + 17 + properties: 18 + priority: 19 + $ref: /schemas/types.yaml#/definitions/uint32 20 + description: | 21 + A priority ranging from 0 to 255 according to the following guidelines:: 22 + 0:: Restart handler of last resort, with limited restart capabilities. 23 + 128:: Typical, default restart handler; use if no other restart handler 24 + is expected to be available, and/or if restart functionality is 25 + sufficient to restart the entire system. 26 + 255:: Highest priority restart handler, will preempt all other restart handlers. 27 + minimum: 0 28 + maximum: 255 29 + 30 + additionalProperties: true
+10 -6
Documentation/devicetree/bindings/power/supply/bq25890.yaml
··· 15 15 16 16 properties: 17 17 compatible: 18 - enum: 19 - - ti,bq25890 20 - - ti,bq25892 21 - - ti,bq25895 22 - - ti,bq25896 18 + oneOf: 19 + - enum: 20 + - ti,bq25890 21 + - items: 22 + - enum: 23 + - ti,bq25892 24 + - ti,bq25895 25 + - ti,bq25896 26 + - const: ti,bq25890 23 27 24 28 reg: 25 29 maxItems: 1 ··· 97 93 - ti,boost-voltage 98 94 - ti,boost-max-current 99 95 100 - additionalProperties: false 96 + unevaluatedProperties: false 101 97 102 98 examples: 103 99 - |
-2
Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
··· 60 60 61 61 monitored-battery: 62 62 description: | 63 - phandle of battery characteristics node. 64 63 The fuel gauge uses the following battery properties: 65 64 - energy-full-design-microwatt-hours 66 65 - charge-full-design-microamp-hours 67 66 - voltage-min-design-microvolt 68 67 Both or neither of the *-full-design-*-hours properties must be set. 69 - See Documentation/devicetree/bindings/power/supply/battery.yaml 70 68 71 69 power-supplies: true 72 70
+2 -2
Documentation/devicetree/bindings/power/supply/ingenic,battery.yaml
··· 10 10 maintainers: 11 11 - Artur Rojek <contact@artur-rojek.eu> 12 12 13 + $ref: power-supply.yaml# 14 + 13 15 properties: 14 16 compatible: 15 17 oneOf: ··· 30 28 31 29 monitored-battery: 32 30 description: > 33 - phandle to a "simple-battery" compatible node. 34 - 35 31 This property must be a phandle to a node using the format described 36 32 in battery.yaml, with the following properties being required: 37 33 - voltage-min-design-microvolt: drained battery voltage,
+2
Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
··· 59 59 Voltage threshold to report battery as over voltage (in mV). 60 60 Default is not to report over-voltage events. 61 61 62 + power-supplies: true 63 + 62 64 required: 63 65 - compatible 64 66 - reg
+6
Documentation/devicetree/bindings/power/supply/power-supply.yaml
··· 18 18 This property is added to a supply in order to list the devices which 19 19 supply it power, referenced by their phandles. 20 20 21 + monitored-battery: 22 + $ref: /schemas/types.yaml#/definitions/phandle 23 + description: 24 + The battery (with "simple-battery" compatible) being monitored by this 25 + power supply. 26 + 21 27 additionalProperties: true
+1
Documentation/devicetree/bindings/power/supply/rohm,bd99954.yaml
··· 18 18 provides a Dual-source Battery Charger, two port BC1.2 detection and a 19 19 Battery Monitor. 20 20 21 + $ref: power-supply.yaml# 21 22 22 23 properties: 23 24 compatible:
-1
Documentation/devicetree/bindings/power/supply/sc2731-charger.yaml
··· 28 28 The charger uses the following battery properties 29 29 - charge-term-current-microamp: current for charge termination phase. 30 30 - constant-charge-voltage-max-microvolt: maximum constant input voltage. 31 - See Documentation/devicetree/bindings/power/supply/battery.yaml 32 31 33 32 additionalProperties: false 34 33
+9 -29
drivers/power/supply/88pm860x_charger.c
··· 690 690 (chip->id == CHIP_PM8607) ? chip->companion : chip->client; 691 691 if (!info->i2c_8606) { 692 692 dev_err(&pdev->dev, "Missed I2C address of 88PM8606!\n"); 693 - ret = -EINVAL; 694 - goto out; 693 + return -EINVAL; 695 694 } 696 695 info->dev = &pdev->dev; 697 696 ··· 703 704 psy_cfg.drv_data = info; 704 705 psy_cfg.supplied_to = pm860x_supplied_to; 705 706 psy_cfg.num_supplicants = ARRAY_SIZE(pm860x_supplied_to); 706 - info->usb = power_supply_register(&pdev->dev, &pm860x_charger_desc, 707 - &psy_cfg); 707 + info->usb = devm_power_supply_register(&pdev->dev, &pm860x_charger_desc, 708 + &psy_cfg); 708 709 if (IS_ERR(info->usb)) { 709 - ret = PTR_ERR(info->usb); 710 - goto out; 710 + return PTR_ERR(info->usb); 711 711 } 712 712 713 713 pm860x_init_charger(info); 714 714 715 715 for (i = 0; i < ARRAY_SIZE(info->irq); i++) { 716 - ret = request_threaded_irq(info->irq[i], NULL, 717 - pm860x_irq_descs[i].handler, 718 - IRQF_ONESHOT, pm860x_irq_descs[i].name, info); 716 + ret = devm_request_threaded_irq(&pdev->dev, info->irq[i], NULL, 717 + pm860x_irq_descs[i].handler, 718 + IRQF_ONESHOT, 719 + pm860x_irq_descs[i].name, info); 719 720 if (ret < 0) { 720 721 dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", 721 722 info->irq[i], ret); 722 - goto out_irq; 723 + return ret; 723 724 } 724 725 } 725 - return 0; 726 - 727 - out_irq: 728 - power_supply_unregister(info->usb); 729 - while (--i >= 0) 730 - free_irq(info->irq[i], info); 731 - out: 732 - return ret; 733 - } 734 - 735 - static int pm860x_charger_remove(struct platform_device *pdev) 736 - { 737 - struct pm860x_charger_info *info = platform_get_drvdata(pdev); 738 - int i; 739 - 740 - power_supply_unregister(info->usb); 741 - for (i = 0; i < info->irq_nums; i++) 742 - free_irq(info->irq[i], info); 743 726 return 0; 744 727 } 745 728 ··· 730 749 .name = "88pm860x-charger", 731 750 }, 732 751 .probe = pm860x_charger_probe, 733 - .remove = pm860x_charger_remove, 734 752 }; 735 753 module_platform_driver(pm860x_charger_driver); 736 754
+9 -2
drivers/power/supply/ab8500_charger.c
··· 1940 1940 * 1941 1941 * Due to a asic bug it is necessary to lower the input current to the vbus 1942 1942 * charger when charging with at some specific levels. This issue is only valid 1943 - * for below a certain battery voltage. This function makes sure that the 1943 + * for below a certain battery voltage. This function makes sure that 1944 1944 * the allowed current limit isn't exceeded. 1945 1945 */ 1946 1946 static void ab8500_charger_check_vbat_work(struct work_struct *work) ··· 3719 3719 if (ret) 3720 3720 return ret; 3721 3721 3722 - return platform_driver_register(&ab8500_charger_driver); 3722 + ret = platform_driver_register(&ab8500_charger_driver); 3723 + if (ret) { 3724 + platform_unregister_drivers(ab8500_charger_component_drivers, 3725 + ARRAY_SIZE(ab8500_charger_component_drivers)); 3726 + return ret; 3727 + } 3728 + 3729 + return 0; 3723 3730 } 3724 3731 3725 3732 static void __exit ab8500_charger_exit(void)
+2 -3
drivers/power/supply/adp5061.c
··· 694 694 .num_properties = ARRAY_SIZE(adp5061_props), 695 695 }; 696 696 697 - static int adp5061_probe(struct i2c_client *client, 698 - const struct i2c_device_id *id) 697 + static int adp5061_probe(struct i2c_client *client) 699 698 { 700 699 struct power_supply_config psy_cfg = {}; 701 700 struct adp5061_state *st; ··· 736 737 .driver = { 737 738 .name = KBUILD_MODNAME, 738 739 }, 739 - .probe = adp5061_probe, 740 + .probe_new = adp5061_probe, 740 741 .id_table = adp5061_id, 741 742 }; 742 743 module_i2c_driver(adp5061_driver);
+13 -71
drivers/power/supply/bd99954-charger.c
··· 768 768 * Describe the setting in linear_range table. 769 769 */ 770 770 static const struct linear_range input_current_limit_ranges[] = { 771 - { 772 - .min = 0, 773 - .step = 32000, 774 - .min_sel = 0x0, 775 - .max_sel = 0x1ff, 776 - }, 771 + LINEAR_RANGE(0, 0x0, 0x1ff, 32000), 777 772 }; 778 773 779 774 /* Possible trickle, pre-charging and termination current values */ 780 775 static const struct linear_range charging_current_ranges[] = { 781 - { 782 - .min = 0, 783 - .step = 64000, 784 - .min_sel = 0x0, 785 - .max_sel = 0x10, 786 - }, { 787 - .min = 1024000, 788 - .step = 0, 789 - .min_sel = 0x11, 790 - .max_sel = 0x1f, 791 - }, 776 + LINEAR_RANGE(0, 0x0, 0x10, 64000), 777 + LINEAR_RANGE(1024000, 0x11, 0x1f, 0), 792 778 }; 793 779 794 780 /* ··· 782 796 * and battery over voltage protection have same possible values 783 797 */ 784 798 static const struct linear_range charge_voltage_regulation_ranges[] = { 785 - { 786 - .min = 2560000, 787 - .step = 0, 788 - .min_sel = 0, 789 - .max_sel = 0xA0, 790 - }, { 791 - .min = 2560000, 792 - .step = 16000, 793 - .min_sel = 0xA0, 794 - .max_sel = 0x4B0, 795 - }, { 796 - .min = 19200000, 797 - .step = 0, 798 - .min_sel = 0x4B0, 799 - .max_sel = 0x7FF, 800 - }, 799 + LINEAR_RANGE(2560000, 0, 0xA0, 0), 800 + LINEAR_RANGE(2560000, 0xA0, 0x4B0, 16000), 801 + LINEAR_RANGE(19200000, 0x4B0, 0x7FF, 0), 801 802 }; 802 803 803 804 /* Possible VSYS voltage regulation values */ 804 805 static const struct linear_range vsys_voltage_regulation_ranges[] = { 805 - { 806 - .min = 2560000, 807 - .step = 0, 808 - .min_sel = 0, 809 - .max_sel = 0x28, 810 - }, { 811 - .min = 2560000, 812 - .step = 64000, 813 - .min_sel = 0x28, 814 - .max_sel = 0x12C, 815 - }, { 816 - .min = 19200000, 817 - .step = 0, 818 - .min_sel = 0x12C, 819 - .max_sel = 0x1FF, 820 - }, 806 + LINEAR_RANGE(2560000, 0, 0x28, 0), 807 + LINEAR_RANGE(2560000, 0x28, 0x12C, 64000), 808 + LINEAR_RANGE(19200000, 0x12C, 0x1FF, 0), 821 809 }; 822 810 823 811 /* Possible settings for switching from trickle to pre-charging limits */ 824 812 static const struct linear_range trickle_to_pre_threshold_ranges[] = { 825 - { 826 - .min = 2048000, 827 - .step = 0, 828 - .min_sel = 0, 829 - .max_sel = 0x20, 830 - }, { 831 - .min = 2048000, 832 - .step = 64000, 833 - .min_sel = 0x20, 834 - .max_sel = 0x12C, 835 - }, { 836 - .min = 19200000, 837 - .step = 0, 838 - .min_sel = 0x12C, 839 - .max_sel = 0x1FF 840 - } 813 + LINEAR_RANGE(2048000, 0, 0x20, 0), 814 + LINEAR_RANGE(2048000, 0x20, 0x12C, 64000), 815 + LINEAR_RANGE(19200000, 0x12C, 0x1FF, 0), 841 816 }; 842 817 843 818 /* Possible current values for fast-charging constant current phase */ 844 819 static const struct linear_range fast_charge_current_ranges[] = { 845 - { 846 - .min = 0, 847 - .step = 64000, 848 - .min_sel = 0, 849 - .max_sel = 0xFF, 850 - } 820 + LINEAR_RANGE(0, 0, 0xFF, 64000), 851 821 }; 852 822 853 823 struct battery_init {
+3 -3
drivers/power/supply/bq2415x_charger.c
··· 1520 1520 } 1521 1521 1522 1522 /* main bq2415x probe function */ 1523 - static int bq2415x_probe(struct i2c_client *client, 1524 - const struct i2c_device_id *id) 1523 + static int bq2415x_probe(struct i2c_client *client) 1525 1524 { 1525 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1526 1526 int ret; 1527 1527 int num; 1528 1528 char *name = NULL; ··· 1780 1780 .of_match_table = of_match_ptr(bq2415x_of_match_table), 1781 1781 .acpi_match_table = ACPI_PTR(bq2415x_i2c_acpi_match), 1782 1782 }, 1783 - .probe = bq2415x_probe, 1783 + .probe_new = bq2415x_probe, 1784 1784 .remove = bq2415x_remove, 1785 1785 .id_table = bq2415x_i2c_id_table, 1786 1786 };
+3 -3
drivers/power/supply/bq24190_charger.c
··· 1767 1767 return 0; 1768 1768 } 1769 1769 1770 - static int bq24190_probe(struct i2c_client *client, 1771 - const struct i2c_device_id *id) 1770 + static int bq24190_probe(struct i2c_client *client) 1772 1771 { 1772 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1773 1773 struct i2c_adapter *adapter = client->adapter; 1774 1774 struct device *dev = &client->dev; 1775 1775 struct power_supply_config charger_cfg = {}, battery_cfg = {}; ··· 2032 2032 MODULE_DEVICE_TABLE(of, bq24190_of_match); 2033 2033 2034 2034 static struct i2c_driver bq24190_driver = { 2035 - .probe = bq24190_probe, 2035 + .probe_new = bq24190_probe, 2036 2036 .remove = bq24190_remove, 2037 2037 .shutdown = bq24190_shutdown, 2038 2038 .id_table = bq24190_i2c_ids,
+3 -3
drivers/power/supply/bq24257_charger.c
··· 947 947 return 0; 948 948 } 949 949 950 - static int bq24257_probe(struct i2c_client *client, 951 - const struct i2c_device_id *id) 950 + static int bq24257_probe(struct i2c_client *client) 952 951 { 952 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 953 953 struct i2c_adapter *adapter = client->adapter; 954 954 struct device *dev = &client->dev; 955 955 const struct acpi_device_id *acpi_id; ··· 1167 1167 .acpi_match_table = ACPI_PTR(bq24257_acpi_match), 1168 1168 .pm = &bq24257_pm, 1169 1169 }, 1170 - .probe = bq24257_probe, 1170 + .probe_new = bq24257_probe, 1171 1171 .remove = bq24257_remove, 1172 1172 .id_table = bq24257_i2c_ids, 1173 1173 };
+2 -3
drivers/power/supply/bq24735-charger.c
··· 352 352 return pdata; 353 353 } 354 354 355 - static int bq24735_charger_probe(struct i2c_client *client, 356 - const struct i2c_device_id *id) 355 + static int bq24735_charger_probe(struct i2c_client *client) 357 356 { 358 357 int ret; 359 358 struct bq24735 *charger; ··· 505 506 .name = "bq24735-charger", 506 507 .of_match_table = bq24735_match_ids, 507 508 }, 508 - .probe = bq24735_charger_probe, 509 + .probe_new = bq24735_charger_probe, 509 510 .id_table = bq24735_charger_id, 510 511 }; 511 512
+3 -3
drivers/power/supply/bq2515x_charger.c
··· 1078 1078 .volatile_reg = bq2515x_volatile_register, 1079 1079 }; 1080 1080 1081 - static int bq2515x_probe(struct i2c_client *client, 1082 - const struct i2c_device_id *id) 1081 + static int bq2515x_probe(struct i2c_client *client) 1083 1082 { 1083 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1084 1084 struct device *dev = &client->dev; 1085 1085 struct bq2515x_device *bq2515x; 1086 1086 struct power_supply_config charger_cfg = {}; ··· 1158 1158 .name = "bq2515x-charger", 1159 1159 .of_match_table = bq2515x_of_match, 1160 1160 }, 1161 - .probe = bq2515x_probe, 1161 + .probe_new = bq2515x_probe, 1162 1162 .id_table = bq2515x_i2c_ids, 1163 1163 }; 1164 1164 module_i2c_driver(bq2515x_driver);
+3 -3
drivers/power/supply/bq256xx_charger.c
··· 1619 1619 return 0; 1620 1620 } 1621 1621 1622 - static int bq256xx_probe(struct i2c_client *client, 1623 - const struct i2c_device_id *id) 1622 + static int bq256xx_probe(struct i2c_client *client) 1624 1623 { 1624 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1625 1625 struct device *dev = &client->dev; 1626 1626 struct bq256xx_device *bq; 1627 1627 struct power_supply_config psy_cfg = { }; ··· 1744 1744 .of_match_table = bq256xx_of_match, 1745 1745 .acpi_match_table = bq256xx_acpi_match, 1746 1746 }, 1747 - .probe = bq256xx_probe, 1747 + .probe_new = bq256xx_probe, 1748 1748 .id_table = bq256xx_i2c_ids, 1749 1749 }; 1750 1750 module_i2c_driver(bq256xx_driver);
+201 -76
drivers/power/supply/bq25890_charger.c
··· 529 529 val->intval = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; 530 530 break; 531 531 532 - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: 533 - val->intval = bq25890_find_val(bq->init_data.ichg, TBL_ICHG); 534 - 535 - /* When temperature is too low, charge current is decreased */ 536 - if (bq->state.ntc_fault == NTC_FAULT_COOL) { 537 - ret = bq25890_field_read(bq, F_JEITA_ISET); 538 - if (ret < 0) 539 - return ret; 540 - 541 - if (ret) 542 - val->intval /= 5; 543 - else 544 - val->intval /= 2; 545 - } 546 - break; 547 - 548 - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: 549 - if (!state.online) { 550 - val->intval = 0; 551 - break; 552 - } 553 - 554 - ret = bq25890_field_read(bq, F_BATV); /* read measured value */ 555 - if (ret < 0) 556 - return ret; 557 - 558 - /* converted_val = 2.304V + ADC_val * 20mV (table 10.3.15) */ 559 - val->intval = 2304000 + ret * 20000; 560 - break; 561 - 562 - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX: 563 - val->intval = bq25890_find_val(bq->init_data.vreg, TBL_VREG); 564 - break; 565 - 566 532 case POWER_SUPPLY_PROP_PRECHARGE_CURRENT: 567 533 val->intval = bq25890_find_val(bq->init_data.iprechg, TBL_ITERM); 568 534 break; ··· 545 579 val->intval = bq25890_find_val(ret, TBL_IINLIM); 546 580 break; 547 581 548 - case POWER_SUPPLY_PROP_VOLTAGE_NOW: 549 - ret = bq25890_field_read(bq, F_SYSV); /* read measured value */ 582 + case POWER_SUPPLY_PROP_CURRENT_NOW: /* I_BAT now */ 583 + /* 584 + * This is ADC-sampled immediate charge current supplied 585 + * from charger to battery. The property name is confusing, 586 + * for clarification refer to: 587 + * Documentation/ABI/testing/sysfs-class-power 588 + * /sys/class/power_supply/<supply_name>/current_now 589 + */ 590 + ret = bq25890_field_read(bq, F_ICHGR); /* read measured value */ 591 + if (ret < 0) 592 + return ret; 593 + 594 + /* converted_val = ADC_val * 50mA (table 10.3.19) */ 595 + val->intval = ret * -50000; 596 + break; 597 + 598 + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: /* I_BAT user limit */ 599 + /* 600 + * This is user-configured constant charge current supplied 601 + * from charger to battery in first phase of charging, when 602 + * battery voltage is below constant charge voltage. 603 + * 604 + * This value reflects the current hardware setting. 605 + * 606 + * The POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX is the 607 + * maximum value of this property. 608 + */ 609 + ret = bq25890_field_read(bq, F_ICHG); 610 + if (ret < 0) 611 + return ret; 612 + val->intval = bq25890_find_val(ret, TBL_ICHG); 613 + 614 + /* When temperature is too low, charge current is decreased */ 615 + if (bq->state.ntc_fault == NTC_FAULT_COOL) { 616 + ret = bq25890_field_read(bq, F_JEITA_ISET); 617 + if (ret < 0) 618 + return ret; 619 + 620 + if (ret) 621 + val->intval /= 5; 622 + else 623 + val->intval /= 2; 624 + } 625 + break; 626 + 627 + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: /* I_BAT max */ 628 + /* 629 + * This is maximum allowed constant charge current supplied 630 + * from charger to battery in first phase of charging, when 631 + * battery voltage is below constant charge voltage. 632 + * 633 + * This value is constant for each battery and set from DT. 634 + */ 635 + val->intval = bq25890_find_val(bq->init_data.ichg, TBL_ICHG); 636 + break; 637 + 638 + case POWER_SUPPLY_PROP_VOLTAGE_NOW: /* V_BAT now */ 639 + /* 640 + * This is ADC-sampled immediate charge voltage supplied 641 + * from charger to battery. The property name is confusing, 642 + * for clarification refer to: 643 + * Documentation/ABI/testing/sysfs-class-power 644 + * /sys/class/power_supply/<supply_name>/voltage_now 645 + */ 646 + ret = bq25890_field_read(bq, F_BATV); /* read measured value */ 550 647 if (ret < 0) 551 648 return ret; 552 649 ··· 617 588 val->intval = 2304000 + ret * 20000; 618 589 break; 619 590 620 - case POWER_SUPPLY_PROP_CURRENT_NOW: 621 - ret = bq25890_field_read(bq, F_ICHGR); /* read measured value */ 591 + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: /* V_BAT user limit */ 592 + /* 593 + * This is user-configured constant charge voltage supplied 594 + * from charger to battery in second phase of charging, when 595 + * battery voltage reached constant charge voltage. 596 + * 597 + * This value reflects the current hardware setting. 598 + * 599 + * The POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX is the 600 + * maximum value of this property. 601 + */ 602 + ret = bq25890_field_read(bq, F_VREG); 622 603 if (ret < 0) 623 604 return ret; 624 605 625 - /* converted_val = ADC_val * 50mA (table 10.3.19) */ 626 - val->intval = ret * -50000; 606 + val->intval = bq25890_find_val(ret, TBL_VREG); 607 + break; 608 + 609 + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX: /* V_BAT max */ 610 + /* 611 + * This is maximum allowed constant charge voltage supplied 612 + * from charger to battery in second phase of charging, when 613 + * battery voltage reached constant charge voltage. 614 + * 615 + * This value is constant for each battery and set from DT. 616 + */ 617 + val->intval = bq25890_find_val(bq->init_data.vreg, TBL_VREG); 627 618 break; 628 619 629 620 case POWER_SUPPLY_PROP_TEMP: ··· 667 618 const union power_supply_propval *val) 668 619 { 669 620 struct bq25890_device *bq = power_supply_get_drvdata(psy); 621 + int maxval; 670 622 u8 lval; 671 623 672 624 switch (psp) { 625 + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: 626 + maxval = bq25890_find_val(bq->init_data.ichg, TBL_ICHG); 627 + lval = bq25890_find_idx(min(val->intval, maxval), TBL_ICHG); 628 + return bq25890_field_write(bq, F_ICHG, lval); 629 + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: 630 + maxval = bq25890_find_val(bq->init_data.vreg, TBL_VREG); 631 + lval = bq25890_find_idx(min(val->intval, maxval), TBL_VREG); 632 + return bq25890_field_write(bq, F_VREG, lval); 673 633 case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: 674 634 lval = bq25890_find_idx(val->intval, TBL_IINLIM); 675 635 return bq25890_field_write(bq, F_IINLIM, lval); ··· 691 633 enum power_supply_property psp) 692 634 { 693 635 switch (psp) { 636 + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: 637 + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: 694 638 case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: 695 639 return true; 696 640 default: ··· 940 880 POWER_SUPPLY_PROP_CHARGE_TYPE, 941 881 POWER_SUPPLY_PROP_ONLINE, 942 882 POWER_SUPPLY_PROP_HEALTH, 883 + POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, 943 884 POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, 944 885 POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, 945 886 POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX, ··· 1095 1034 return bq25890_field_read(bq, F_OTG_CFG); 1096 1035 } 1097 1036 1037 + static int bq25890_vbus_get_voltage(struct regulator_dev *rdev) 1038 + { 1039 + struct bq25890_device *bq = rdev_get_drvdata(rdev); 1040 + 1041 + return bq25890_get_vbus_voltage(bq); 1042 + } 1043 + 1044 + static int bq25890_vsys_get_voltage(struct regulator_dev *rdev) 1045 + { 1046 + struct bq25890_device *bq = rdev_get_drvdata(rdev); 1047 + int ret; 1048 + 1049 + /* Should be some output voltage ? */ 1050 + ret = bq25890_field_read(bq, F_SYSV); /* read measured value */ 1051 + if (ret < 0) 1052 + return ret; 1053 + 1054 + /* converted_val = 2.304V + ADC_val * 20mV (table 10.3.15) */ 1055 + return 2304000 + ret * 20000; 1056 + } 1057 + 1098 1058 static const struct regulator_ops bq25890_vbus_ops = { 1099 1059 .enable = bq25890_vbus_enable, 1100 1060 .disable = bq25890_vbus_disable, 1101 1061 .is_enabled = bq25890_vbus_is_enabled, 1062 + .get_voltage = bq25890_vbus_get_voltage, 1102 1063 }; 1103 1064 1104 1065 static const struct regulator_desc bq25890_vbus_desc = { ··· 1129 1046 .type = REGULATOR_VOLTAGE, 1130 1047 .owner = THIS_MODULE, 1131 1048 .ops = &bq25890_vbus_ops, 1132 - .fixed_uV = 5000000, 1133 - .n_voltages = 1, 1134 1049 }; 1050 + 1051 + static const struct regulator_ops bq25890_vsys_ops = { 1052 + .get_voltage = bq25890_vsys_get_voltage, 1053 + }; 1054 + 1055 + static const struct regulator_desc bq25890_vsys_desc = { 1056 + .name = "vsys", 1057 + .of_match = "vsys", 1058 + .type = REGULATOR_VOLTAGE, 1059 + .owner = THIS_MODULE, 1060 + .ops = &bq25890_vsys_ops, 1061 + }; 1062 + 1063 + static int bq25890_register_regulator(struct bq25890_device *bq) 1064 + { 1065 + struct bq25890_platform_data *pdata = dev_get_platdata(bq->dev); 1066 + struct regulator_config cfg = { 1067 + .dev = bq->dev, 1068 + .driver_data = bq, 1069 + }; 1070 + struct regulator_dev *reg; 1071 + 1072 + if (pdata) 1073 + cfg.init_data = pdata->regulator_init_data; 1074 + 1075 + reg = devm_regulator_register(bq->dev, &bq25890_vbus_desc, &cfg); 1076 + if (IS_ERR(reg)) { 1077 + return dev_err_probe(bq->dev, PTR_ERR(reg), 1078 + "registering vbus regulator"); 1079 + } 1080 + 1081 + /* pdata->regulator_init_data is for vbus only */ 1082 + cfg.init_data = NULL; 1083 + reg = devm_regulator_register(bq->dev, &bq25890_vsys_desc, &cfg); 1084 + if (IS_ERR(reg)) { 1085 + return dev_err_probe(bq->dev, PTR_ERR(reg), 1086 + "registering vsys regulator"); 1087 + } 1088 + 1089 + return 0; 1090 + } 1091 + #else 1092 + static inline int 1093 + bq25890_register_regulator(struct bq25890_device *bq) 1094 + { 1095 + return 0; 1096 + } 1135 1097 #endif 1136 1098 1137 1099 static int bq25890_get_chip_version(struct bq25890_device *bq) ··· 1317 1189 return 0; 1318 1190 } 1319 1191 1320 - static int bq25890_probe(struct i2c_client *client, 1321 - const struct i2c_device_id *id) 1192 + static void bq25890_non_devm_cleanup(void *data) 1193 + { 1194 + struct bq25890_device *bq = data; 1195 + 1196 + cancel_delayed_work_sync(&bq->pump_express_work); 1197 + } 1198 + 1199 + static int bq25890_probe(struct i2c_client *client) 1322 1200 { 1323 1201 struct device *dev = &client->dev; 1324 1202 struct bq25890_device *bq; ··· 1378 1244 1379 1245 /* OTG reporting */ 1380 1246 bq->usb_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); 1381 - if (!IS_ERR_OR_NULL(bq->usb_phy)) { 1382 - INIT_WORK(&bq->usb_work, bq25890_usb_work); 1383 - bq->usb_nb.notifier_call = bq25890_usb_notifier; 1384 - usb_register_notifier(bq->usb_phy, &bq->usb_nb); 1385 - } 1386 - #ifdef CONFIG_REGULATOR 1387 - else { 1388 - struct bq25890_platform_data *pdata = dev_get_platdata(dev); 1389 - struct regulator_config cfg = { }; 1390 - struct regulator_dev *reg; 1391 1247 1392 - cfg.dev = dev; 1393 - cfg.driver_data = bq; 1394 - if (pdata) 1395 - cfg.init_data = pdata->regulator_init_data; 1248 + /* 1249 + * This must be before bq25890_power_supply_init(), so that it runs 1250 + * after devm unregisters the power_supply. 1251 + */ 1252 + ret = devm_add_action_or_reset(dev, bq25890_non_devm_cleanup, bq); 1253 + if (ret) 1254 + return ret; 1396 1255 1397 - reg = devm_regulator_register(dev, &bq25890_vbus_desc, &cfg); 1398 - if (IS_ERR(reg)) 1399 - return dev_err_probe(dev, PTR_ERR(reg), "registering regulator"); 1400 - } 1401 - #endif 1256 + ret = bq25890_register_regulator(bq); 1257 + if (ret) 1258 + return ret; 1402 1259 1403 1260 ret = bq25890_power_supply_init(bq); 1404 - if (ret < 0) { 1405 - dev_err(dev, "Failed to register power supply\n"); 1406 - goto err_unregister_usb_notifier; 1407 - } 1261 + if (ret < 0) 1262 + return dev_err_probe(dev, ret, "registering power supply\n"); 1408 1263 1409 1264 ret = devm_request_threaded_irq(dev, client->irq, NULL, 1410 1265 bq25890_irq_handler_thread, 1411 1266 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 1412 1267 BQ25890_IRQ_PIN, bq); 1413 1268 if (ret) 1414 - goto err_unregister_usb_notifier; 1269 + return ret; 1270 + 1271 + if (!IS_ERR_OR_NULL(bq->usb_phy)) { 1272 + INIT_WORK(&bq->usb_work, bq25890_usb_work); 1273 + bq->usb_nb.notifier_call = bq25890_usb_notifier; 1274 + usb_register_notifier(bq->usb_phy, &bq->usb_nb); 1275 + } 1415 1276 1416 1277 return 0; 1417 - 1418 - err_unregister_usb_notifier: 1419 - if (!IS_ERR_OR_NULL(bq->usb_phy)) 1420 - usb_unregister_notifier(bq->usb_phy, &bq->usb_nb); 1421 - 1422 - return ret; 1423 1278 } 1424 1279 1425 1280 static void bq25890_remove(struct i2c_client *client) 1426 1281 { 1427 1282 struct bq25890_device *bq = i2c_get_clientdata(client); 1428 1283 1429 - if (!IS_ERR_OR_NULL(bq->usb_phy)) 1284 + if (!IS_ERR_OR_NULL(bq->usb_phy)) { 1430 1285 usb_unregister_notifier(bq->usb_phy, &bq->usb_nb); 1286 + cancel_work_sync(&bq->usb_work); 1287 + } 1431 1288 1432 1289 if (!bq->skip_reset) { 1433 1290 /* reset all registers to default values */ ··· 1525 1400 .acpi_match_table = ACPI_PTR(bq25890_acpi_match), 1526 1401 .pm = &bq25890_pm, 1527 1402 }, 1528 - .probe = bq25890_probe, 1403 + .probe_new = bq25890_probe, 1529 1404 .remove = bq25890_remove, 1530 1405 .shutdown = bq25890_shutdown, 1531 1406 .id_table = bq25890_i2c_ids,
+3 -3
drivers/power/supply/bq25980_charger.c
··· 1207 1207 return 0; 1208 1208 } 1209 1209 1210 - static int bq25980_probe(struct i2c_client *client, 1211 - const struct i2c_device_id *id) 1210 + static int bq25980_probe(struct i2c_client *client) 1212 1211 { 1212 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1213 1213 struct device *dev = &client->dev; 1214 1214 struct bq25980_device *bq; 1215 1215 int ret; ··· 1287 1287 .name = "bq25980-charger", 1288 1288 .of_match_table = bq25980_of_match, 1289 1289 }, 1290 - .probe = bq25980_probe, 1290 + .probe_new = bq25980_probe, 1291 1291 .id_table = bq25980_i2c_ids, 1292 1292 }; 1293 1293 module_i2c_driver(bq25980_driver);
+3 -3
drivers/power/supply/bq27xxx_battery_i2c.c
··· 136 136 return 0; 137 137 } 138 138 139 - static int bq27xxx_battery_i2c_probe(struct i2c_client *client, 140 - const struct i2c_device_id *id) 139 + static int bq27xxx_battery_i2c_probe(struct i2c_client *client) 141 140 { 141 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 142 142 struct bq27xxx_device_info *di; 143 143 int ret; 144 144 char *name; ··· 295 295 .name = "bq27xxx-battery", 296 296 .of_match_table = of_match_ptr(bq27xxx_battery_i2c_of_match_table), 297 297 }, 298 - .probe = bq27xxx_battery_i2c_probe, 298 + .probe_new = bq27xxx_battery_i2c_probe, 299 299 .remove = bq27xxx_battery_i2c_remove, 300 300 .id_table = bq27xxx_i2c_id_table, 301 301 };
+3
drivers/power/supply/cw2015_battery.c
··· 699 699 } 700 700 701 701 cw_bat->battery_workqueue = create_singlethread_workqueue("rk_battery"); 702 + if (!cw_bat->battery_workqueue) 703 + return -ENOMEM; 704 + 702 705 devm_delayed_work_autocancel(&client->dev, 703 706 &cw_bat->battery_delay_work, cw_bat_work); 704 707 queue_delayed_work(cw_bat->battery_workqueue,
+3 -3
drivers/power/supply/ds2782_battery.c
··· 368 368 } 369 369 }; 370 370 371 - static int ds278x_battery_probe(struct i2c_client *client, 372 - const struct i2c_device_id *id) 371 + static int ds278x_battery_probe(struct i2c_client *client) 373 372 { 373 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 374 374 struct ds278x_platform_data *pdata = client->dev.platform_data; 375 375 struct power_supply_config psy_cfg = {}; 376 376 struct ds278x_info *info; ··· 458 458 .name = "ds2782-battery", 459 459 .pm = &ds278x_battery_pm_ops, 460 460 }, 461 - .probe = ds278x_battery_probe, 461 + .probe_new = ds278x_battery_probe, 462 462 .remove = ds278x_battery_remove, 463 463 .id_table = ds278x_id, 464 464 };
+2 -2
drivers/power/supply/lp8727_charger.c
··· 540 540 } 541 541 #endif 542 542 543 - static int lp8727_probe(struct i2c_client *cl, const struct i2c_device_id *id) 543 + static int lp8727_probe(struct i2c_client *cl) 544 544 { 545 545 struct lp8727_chg *pchg; 546 546 struct lp8727_platform_data *pdata; ··· 615 615 .name = "lp8727", 616 616 .of_match_table = of_match_ptr(lp8727_dt_ids), 617 617 }, 618 - .probe = lp8727_probe, 618 + .probe_new = lp8727_probe, 619 619 .remove = lp8727_remove, 620 620 .id_table = lp8727_ids, 621 621 };
+1 -1
drivers/power/supply/lp8788-charger.c
··· 520 520 static int lp8788_irq_register(struct platform_device *pdev, 521 521 struct lp8788_charger *pchg) 522 522 { 523 - const char *name[] = { 523 + static const char * const name[] = { 524 524 LP8788_CHG_IRQ, LP8788_PRSW_IRQ, LP8788_BATT_IRQ 525 525 }; 526 526 int i;
+2 -3
drivers/power/supply/ltc2941-battery-gauge.c
··· 439 439 POWER_SUPPLY_PROP_CURRENT_NOW, 440 440 }; 441 441 442 - static int ltc294x_i2c_probe(struct i2c_client *client, 443 - const struct i2c_device_id *id) 442 + static int ltc294x_i2c_probe(struct i2c_client *client) 444 443 { 445 444 struct power_supply_config psy_cfg = {}; 446 445 struct ltc294x_info *info; ··· 635 636 .of_match_table = ltc294x_i2c_of_match, 636 637 .pm = LTC294X_PM_OPS, 637 638 }, 638 - .probe = ltc294x_i2c_probe, 639 + .probe_new = ltc294x_i2c_probe, 639 640 .shutdown = ltc294x_i2c_shutdown, 640 641 .id_table = ltc294x_i2c_id, 641 642 };
+2 -3
drivers/power/supply/ltc4162-l-charger.c
··· 819 819 regmap_write(info->regmap, LTC4162L_CHARGE_STATUS_ALERTS_REG, 0); 820 820 } 821 821 822 - static int ltc4162l_probe(struct i2c_client *client, 823 - const struct i2c_device_id *id) 822 + static int ltc4162l_probe(struct i2c_client *client) 824 823 { 825 824 struct i2c_adapter *adapter = client->adapter; 826 825 struct device *dev = &client->dev; ··· 915 916 MODULE_DEVICE_TABLE(of, ltc4162l_of_match); 916 917 917 918 static struct i2c_driver ltc4162l_driver = { 918 - .probe = ltc4162l_probe, 919 + .probe_new = ltc4162l_probe, 919 920 .alert = ltc4162l_alert, 920 921 .id_table = ltc4162l_i2c_id_table, 921 922 .driver = {
+2 -3
drivers/power/supply/max14656_charger_detector.c
··· 234 234 POWER_SUPPLY_PROP_MANUFACTURER, 235 235 }; 236 236 237 - static int max14656_probe(struct i2c_client *client, 238 - const struct i2c_device_id *id) 237 + static int max14656_probe(struct i2c_client *client) 239 238 { 240 239 struct i2c_adapter *adapter = client->adapter; 241 240 struct device *dev = &client->dev; ··· 316 317 .name = "max14656", 317 318 .of_match_table = max14656_match_table, 318 319 }, 319 - .probe = max14656_probe, 320 + .probe_new = max14656_probe, 320 321 .id_table = max14656_id, 321 322 }; 322 323 module_i2c_driver(max14656_i2c_driver);
+3 -3
drivers/power/supply/max17040_battery.c
··· 430 430 .num_properties = ARRAY_SIZE(max17040_battery_props), 431 431 }; 432 432 433 - static int max17040_probe(struct i2c_client *client, 434 - const struct i2c_device_id *id) 433 + static int max17040_probe(struct i2c_client *client) 435 434 { 435 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 436 436 struct i2c_adapter *adapter = client->adapter; 437 437 struct power_supply_config psy_cfg = {}; 438 438 struct max17040_chip *chip; ··· 599 599 .of_match_table = max17040_of_match, 600 600 .pm = MAX17040_PM_OPS, 601 601 }, 602 - .probe = max17040_probe, 602 + .probe_new = max17040_probe, 603 603 .id_table = max17040_id, 604 604 }; 605 605 module_i2c_driver(max17040_i2c_driver);
+3 -3
drivers/power/supply/max17042_battery.c
··· 1031 1031 .num_properties = ARRAY_SIZE(max17042_battery_props) - 2, 1032 1032 }; 1033 1033 1034 - static int max17042_probe(struct i2c_client *client, 1035 - const struct i2c_device_id *id) 1034 + static int max17042_probe(struct i2c_client *client) 1036 1035 { 1036 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1037 1037 struct i2c_adapter *adapter = client->adapter; 1038 1038 const struct power_supply_desc *max17042_desc = &max17042_psy_desc; 1039 1039 struct power_supply_config psy_cfg = {}; ··· 1220 1220 .of_match_table = of_match_ptr(max17042_dt_match), 1221 1221 .pm = &max17042_pm_ops, 1222 1222 }, 1223 - .probe = max17042_probe, 1223 + .probe_new = max17042_probe, 1224 1224 .id_table = max17042_id, 1225 1225 }; 1226 1226 module_i2c_driver(max17042_i2c_driver);
+6 -9
drivers/power/supply/mt6360_charger.c
··· 113 113 MT6360_RANGE_MAX, 114 114 }; 115 115 116 - #define MT6360_LINEAR_RANGE(idx, _min, _min_sel, _max_sel, _step) \ 117 - [idx] = REGULATOR_LINEAR_RANGE(_min, _min_sel, _max_sel, _step) 118 - 119 116 static const struct linear_range mt6360_chg_range[MT6360_RANGE_MAX] = { 120 - MT6360_LINEAR_RANGE(MT6360_RANGE_VMIVR, 3900000, 0, 0x5F, 100000), 121 - MT6360_LINEAR_RANGE(MT6360_RANGE_ICHG, 100000, 0, 0x31, 100000), 122 - MT6360_LINEAR_RANGE(MT6360_RANGE_VOREG, 3900000, 0, 0x51, 10000), 123 - MT6360_LINEAR_RANGE(MT6360_RANGE_AICR, 100000, 0, 0x3F, 50000), 124 - MT6360_LINEAR_RANGE(MT6360_RANGE_IPREC, 100000, 0, 0x0F, 50000), 125 - MT6360_LINEAR_RANGE(MT6360_RANGE_IEOC, 100000, 0, 0x0F, 50000), 117 + LINEAR_RANGE_IDX(MT6360_RANGE_VMIVR, 3900000, 0, 0x5F, 100000), 118 + LINEAR_RANGE_IDX(MT6360_RANGE_ICHG, 100000, 0, 0x31, 100000), 119 + LINEAR_RANGE_IDX(MT6360_RANGE_VOREG, 3900000, 0, 0x51, 10000), 120 + LINEAR_RANGE_IDX(MT6360_RANGE_AICR, 100000, 0, 0x3F, 50000), 121 + LINEAR_RANGE_IDX(MT6360_RANGE_IPREC, 100000, 0, 0x0F, 50000), 122 + LINEAR_RANGE_IDX(MT6360_RANGE_IEOC, 100000, 0, 0x0F, 50000), 126 123 }; 127 124 128 125 struct mt6360_chg_info {
+6 -2
drivers/power/supply/power_supply_core.c
··· 750 750 int i, tab_len, size; 751 751 752 752 propname = kasprintf(GFP_KERNEL, "ocv-capacity-table-%d", index); 753 + if (!propname) { 754 + power_supply_put_battery_info(psy, info); 755 + err = -ENOMEM; 756 + goto out_put_node; 757 + } 753 758 list = of_get_property(battery_np, propname, &size); 754 759 if (!list || !size) { 755 760 dev_err(&psy->dev, "failed to get %s\n", propname); ··· 875 870 * power_supply_vbat2ri() - find the battery internal resistance 876 871 * from the battery voltage 877 872 * @info: The battery information container 878 - * @table: Pointer to battery resistance temperature table 879 873 * @vbat_uv: The battery voltage in microvolt 880 874 * @charging: If we are charging (true) or not (false) 881 875 * ··· 1391 1387 register_cooler_failed: 1392 1388 psy_unregister_thermal(psy); 1393 1389 register_thermal_failed: 1394 - device_del(dev); 1395 1390 wakeup_init_failed: 1391 + device_del(dev); 1396 1392 device_add_failed: 1397 1393 check_supplies_failed: 1398 1394 dev_set_name_failed:
+3 -1
drivers/power/supply/rk817_charger.c
··· 1060 1060 return -ENODEV; 1061 1061 1062 1062 charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL); 1063 - if (!charger) 1063 + if (!charger) { 1064 + of_node_put(node); 1064 1065 return -ENOMEM; 1066 + } 1065 1067 1066 1068 charger->rk808 = rk808; 1067 1069
+2 -3
drivers/power/supply/rt5033_battery.c
··· 112 112 .num_properties = ARRAY_SIZE(rt5033_battery_props), 113 113 }; 114 114 115 - static int rt5033_battery_probe(struct i2c_client *client, 116 - const struct i2c_device_id *id) 115 + static int rt5033_battery_probe(struct i2c_client *client) 117 116 { 118 117 struct i2c_adapter *adapter = client->adapter; 119 118 struct power_supply_config psy_cfg = {}; ··· 172 173 .name = "rt5033-battery", 173 174 .of_match_table = rt5033_battery_of_match, 174 175 }, 175 - .probe = rt5033_battery_probe, 176 + .probe_new = rt5033_battery_probe, 176 177 .remove = rt5033_battery_remove, 177 178 .id_table = rt5033_battery_id, 178 179 };
+2 -3
drivers/power/supply/rt9455_charger.c
··· 1581 1581 .cache_type = REGCACHE_RBTREE, 1582 1582 }; 1583 1583 1584 - static int rt9455_probe(struct i2c_client *client, 1585 - const struct i2c_device_id *id) 1584 + static int rt9455_probe(struct i2c_client *client) 1586 1585 { 1587 1586 struct i2c_adapter *adapter = client->adapter; 1588 1587 struct device *dev = &client->dev; ··· 1737 1738 #endif 1738 1739 1739 1740 static struct i2c_driver rt9455_driver = { 1740 - .probe = rt9455_probe, 1741 + .probe_new = rt9455_probe, 1741 1742 .remove = rt9455_remove, 1742 1743 .id_table = rt9455_i2c_id_table, 1743 1744 .driver = {
+2 -3
drivers/power/supply/sbs-charger.c
··· 162 162 .get_property = sbs_get_property, 163 163 }; 164 164 165 - static int sbs_probe(struct i2c_client *client, 166 - const struct i2c_device_id *id) 165 + static int sbs_probe(struct i2c_client *client) 167 166 { 168 167 struct power_supply_config psy_cfg = {}; 169 168 struct sbs_info *chip; ··· 240 241 MODULE_DEVICE_TABLE(i2c, sbs_id); 241 242 242 243 static struct i2c_driver sbs_driver = { 243 - .probe = sbs_probe, 244 + .probe_new = sbs_probe, 244 245 .id_table = sbs_id, 245 246 .driver = { 246 247 .name = "sbs-charger",
+3 -3
drivers/power/supply/sbs-manager.c
··· 315 315 i2c_mux_del_adapters(sbsm->muxc); 316 316 } 317 317 318 - static int sbsm_probe(struct i2c_client *client, 319 - const struct i2c_device_id *id) 318 + static int sbsm_probe(struct i2c_client *client) 320 319 { 320 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 321 321 struct i2c_adapter *adapter = client->adapter; 322 322 struct sbsm_data *data; 323 323 struct device *dev = &client->dev; ··· 409 409 .name = "sbsm", 410 410 .of_match_table = of_match_ptr(sbsm_dt_ids), 411 411 }, 412 - .probe = sbsm_probe, 412 + .probe_new = sbsm_probe, 413 413 .alert = sbsm_alert, 414 414 .id_table = sbsm_ids 415 415 };
+3 -3
drivers/power/supply/smb347-charger.c
··· 1528 1528 .n_voltages = 1, 1529 1529 }; 1530 1530 1531 - static int smb347_probe(struct i2c_client *client, 1532 - const struct i2c_device_id *id) 1531 + static int smb347_probe(struct i2c_client *client) 1533 1532 { 1533 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 1534 1534 struct power_supply_config mains_usb_cfg = {}; 1535 1535 struct regulator_config usb_rdev_cfg = {}; 1536 1536 struct device *dev = &client->dev; ··· 1629 1629 .name = "smb347", 1630 1630 .of_match_table = smb3xx_of_match, 1631 1631 }, 1632 - .probe = smb347_probe, 1632 + .probe_new = smb347_probe, 1633 1633 .remove = smb347_remove, 1634 1634 .shutdown = smb347_shutdown, 1635 1635 .id_table = smb347_id,
+2 -3
drivers/power/supply/ucs1002_power.c
··· 532 532 .n_voltages = 1, 533 533 }; 534 534 535 - static int ucs1002_probe(struct i2c_client *client, 536 - const struct i2c_device_id *dev_id) 535 + static int ucs1002_probe(struct i2c_client *client) 537 536 { 538 537 struct device *dev = &client->dev; 539 538 struct power_supply_config charger_config = {}; ··· 680 681 .name = "ucs1002", 681 682 .of_match_table = ucs1002_of_match, 682 683 }, 683 - .probe = ucs1002_probe, 684 + .probe_new = ucs1002_probe, 684 685 }; 685 686 module_i2c_driver(ucs1002_driver); 686 687
+6 -5
drivers/power/supply/z2_battery.c
··· 176 176 return 0; 177 177 } 178 178 179 - static int z2_batt_probe(struct i2c_client *client, 180 - const struct i2c_device_id *id) 179 + static int z2_batt_probe(struct i2c_client *client) 181 180 { 182 181 int ret = 0; 183 182 int props = 1; /* POWER_SUPPLY_PROP_PRESENT */ ··· 205 206 206 207 charger->charge_gpiod = devm_gpiod_get_optional(&client->dev, 207 208 NULL, GPIOD_IN); 208 - if (IS_ERR(charger->charge_gpiod)) 209 - return dev_err_probe(&client->dev, 209 + if (IS_ERR(charger->charge_gpiod)) { 210 + ret = dev_err_probe(&client->dev, 210 211 PTR_ERR(charger->charge_gpiod), 211 212 "failed to get charge GPIO\n"); 213 + goto err; 214 + } 212 215 213 216 if (charger->charge_gpiod) { 214 217 gpiod_set_consumer_name(charger->charge_gpiod, "BATT CHRG"); ··· 307 306 .name = "z2-battery", 308 307 .pm = Z2_BATTERY_PM_OPS 309 308 }, 310 - .probe = z2_batt_probe, 309 + .probe_new = z2_batt_probe, 311 310 .remove = z2_batt_remove, 312 311 .id_table = z2_batt_id, 313 312 };