Merge tag 'for-v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 17 Dec 2022 14:39:31 +0000 (08:39 -0600)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 17 Dec 2022 14:39:31 +0000 (08:39 -0600)
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()
  ...

43 files changed:
Documentation/devicetree/bindings/mfd/ene-kb930.yaml
Documentation/devicetree/bindings/mfd/rockchip,rk817.yaml
Documentation/devicetree/bindings/power/reset/gpio-restart.yaml
Documentation/devicetree/bindings/power/reset/restart-handler.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/power/supply/bq25890.yaml
Documentation/devicetree/bindings/power/supply/bq27xxx.yaml
Documentation/devicetree/bindings/power/supply/ingenic,battery.yaml
Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
Documentation/devicetree/bindings/power/supply/power-supply.yaml
Documentation/devicetree/bindings/power/supply/rohm,bd99954.yaml
Documentation/devicetree/bindings/power/supply/sc2731-charger.yaml
drivers/power/supply/88pm860x_charger.c
drivers/power/supply/ab8500_charger.c
drivers/power/supply/adp5061.c
drivers/power/supply/bd99954-charger.c
drivers/power/supply/bq2415x_charger.c
drivers/power/supply/bq24190_charger.c
drivers/power/supply/bq24257_charger.c
drivers/power/supply/bq24735-charger.c
drivers/power/supply/bq2515x_charger.c
drivers/power/supply/bq256xx_charger.c
drivers/power/supply/bq25890_charger.c
drivers/power/supply/bq25980_charger.c
drivers/power/supply/bq27xxx_battery_i2c.c
drivers/power/supply/cw2015_battery.c
drivers/power/supply/ds2782_battery.c
drivers/power/supply/lp8727_charger.c
drivers/power/supply/lp8788-charger.c
drivers/power/supply/ltc2941-battery-gauge.c
drivers/power/supply/ltc4162-l-charger.c
drivers/power/supply/max14656_charger_detector.c
drivers/power/supply/max17040_battery.c
drivers/power/supply/max17042_battery.c
drivers/power/supply/mt6360_charger.c
drivers/power/supply/power_supply_core.c
drivers/power/supply/rk817_charger.c
drivers/power/supply/rt5033_battery.c
drivers/power/supply/rt9455_charger.c
drivers/power/supply/sbs-charger.c
drivers/power/supply/sbs-manager.c
drivers/power/supply/smb347-charger.c
drivers/power/supply/ucs1002_power.c
drivers/power/supply/z2_battery.c

index 06ed9ec8f4bbce472cc0a7d52253f9e371ca031f..7c0a42390f18941fb980399ccb50340ca6df5bd8 100644 (file)
@@ -13,6 +13,8 @@ description: |
 maintainers:
   - Dmitry Osipenko <digetx@gmail.com>
 
+$ref: /schemas/power/supply/power-supply.yaml
+
 properties:
   compatible:
     items:
@@ -22,15 +24,13 @@ properties:
   reg:
     maxItems: 1
 
-  monitored-battery: true
-  power-supplies: true
   system-power-controller: true
 
 required:
   - compatible
   - reg
 
-additionalProperties: false
+unevaluatedProperties: false
 
 examples:
   - |
index 935e17099213febbe712abb1bc480a3ce493dc27..269fb85b20278c9a4507df8ee9752e235600f2ca 100644 (file)
@@ -124,6 +124,8 @@ properties:
       The child node for the charger to hold additional properties. If a
       battery is not in use, this node can be omitted.
     type: object
+    $ref: /schemas/power/supply/power-supply.yaml
+
     properties:
       monitored-battery:
         description: |
index a72d5c7215161af19348854dcc096496934bda47..d3d18e0f5db385240e645963aa6f8127a8e058f1 100644 (file)
@@ -25,6 +25,9 @@ description: >
   inactive-delay, the GPIO is driven active again.  After a delay specified by wait-delay, the
   restart handler completes allowing other restart handlers to be attempted.
 
+allOf:
+  - $ref: restart-handler.yaml#
+
 properties:
   compatible:
     const: gpio-restart
@@ -41,16 +44,6 @@ properties:
       in its inactive state.
 
   priority:
-    $ref: /schemas/types.yaml#/definitions/uint32
-    description: |
-      A priority ranging from 0 to 255 (default 129) according to the following guidelines:
-
-        0:   Restart handler of last resort, with limited restart capabilities.
-        128: Default restart handler; use if no other restart handler is expected to be available,
-             and/or if restart functionality is sufficient to restart the entire system.
-        255: Highest priority restart handler, will preempt all other restart handlers.
-    minimum: 0
-    maximum: 255
     default: 129
 
   active-delay:
diff --git a/Documentation/devicetree/bindings/power/reset/restart-handler.yaml b/Documentation/devicetree/bindings/power/reset/restart-handler.yaml
new file mode 100644 (file)
index 0000000..1f9a2aa
--- /dev/null
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/reset/restart-handler.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Restart and shutdown handler generic binding
+
+maintainers:
+  - Sebastian Reichel <sre@kernel.org>
+
+description:
+  Restart and shutdown handler device is responsible for powering off the
+  system, e.g. my cutting off the power.  System might have several restart
+  handlers, which usually are tried from most precise to last resort.
+
+properties:
+  priority:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: |
+      A priority ranging from 0 to 255 according to the following guidelines::
+        0::   Restart handler of last resort, with limited restart capabilities.
+        128:: Typical, default restart handler; use if no other restart handler
+              is expected to be available, and/or if restart functionality is
+              sufficient to restart the entire system.
+        255:: Highest priority restart handler, will preempt all other restart handlers.
+    minimum: 0
+    maximum: 255
+
+additionalProperties: true
index 204c0147188f2b06731c1b584fc5a501105d8875..ee51b6335e728e1f5a7bfbbff04ee4b341eff93b 100644 (file)
@@ -15,11 +15,15 @@ allOf:
 
 properties:
   compatible:
-    enum:
-      - ti,bq25890
-      - ti,bq25892
-      - ti,bq25895
-      - ti,bq25896
+    oneOf:
+      - enum:
+          - ti,bq25890
+      - items:
+          - enum:
+              - ti,bq25892
+              - ti,bq25895
+              - ti,bq25896
+          - const: ti,bq25890
 
   reg:
     maxItems: 1
@@ -93,7 +97,7 @@ required:
   - ti,boost-voltage
   - ti,boost-max-current
 
-additionalProperties: false
+unevaluatedProperties: false
 
 examples:
   - |
index 65fc6049efc1409fa8a91bc4a6c0f61174ed6c3e..347d4433adc5f560dd8ec0e77a79c60dc5604bd2 100644 (file)
@@ -60,13 +60,11 @@ properties:
 
   monitored-battery:
     description: |
-       phandle of battery characteristics node.
        The fuel gauge uses the following battery properties:
        - energy-full-design-microwatt-hours
        - charge-full-design-microamp-hours
        - voltage-min-design-microvolt
        Both or neither of the *-full-design-*-hours properties must be set.
-       See Documentation/devicetree/bindings/power/supply/battery.yaml
 
   power-supplies: true
 
index 46527038bf22743c36a414a96ec50dccb263cb33..42fcfc0269726c84fe1824f16e6691f753b59773 100644 (file)
@@ -10,6 +10,8 @@ title: Ingenic JZ47xx battery bindings
 maintainers:
   - Artur Rojek <contact@artur-rojek.eu>
 
+$ref: power-supply.yaml#
+
 properties:
   compatible:
     oneOf:
@@ -28,8 +30,6 @@ properties:
 
   monitored-battery:
     description: >
-      phandle to a "simple-battery" compatible node.
-
       This property must be a phandle to a node using the format described
       in battery.yaml, with the following properties being required:
       - voltage-min-design-microvolt: drained battery voltage,
index aff5d0792e0fef3b04ceeb42278bcccae944f742..64a0edb7bc473cdb7c5284356b49165ed77312a9 100644 (file)
@@ -59,6 +59,8 @@ properties:
       Voltage threshold to report battery as over voltage (in mV).
       Default is not to report over-voltage events.
 
+  power-supplies: true
+
 required:
   - compatible
   - reg
index 2f672e6e8d72c08ab7efdab9ceb3fc91e488e26c..4e54c937973ee71be411964360c7ca8e43bd1034 100644 (file)
@@ -18,4 +18,10 @@ properties:
       This property is added to a supply in order to list the devices which
       supply it power, referenced by their phandles.
 
+  monitored-battery:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      The battery (with "simple-battery" compatible) being monitored by this
+      power supply.
+
 additionalProperties: true
index 24b06957b4ca52058513f357667de1977f81b6ea..14d9b42eda27da20c254ef88db4124915838f478 100644 (file)
@@ -18,6 +18,7 @@ description: |
   provides a Dual-source Battery Charger, two port BC1.2 detection and a
   Battery Monitor.
 
+$ref: power-supply.yaml#
 
 properties:
   compatible:
index eeb043f9bb4f2fc264c86a874b3f1ae497295b7b..735f7d372ae172ac47f8e6a20ebaba1d85f68c4d 100644 (file)
@@ -28,7 +28,6 @@ properties:
       The charger uses the following battery properties
       - charge-term-current-microamp: current for charge termination phase.
       - constant-charge-voltage-max-microvolt: maximum constant input voltage.
-      See Documentation/devicetree/bindings/power/supply/battery.yaml
 
 additionalProperties: false
 
index f21ce52fbc0405f963f290a429f3c790607bd22b..2b9fcb7e71d79e0ce5f062d1c53db7948e4d7067 100644 (file)
@@ -690,8 +690,7 @@ static int pm860x_charger_probe(struct platform_device *pdev)
            (chip->id == CHIP_PM8607) ? chip->companion : chip->client;
        if (!info->i2c_8606) {
                dev_err(&pdev->dev, "Missed I2C address of 88PM8606!\n");
-               ret = -EINVAL;
-               goto out;
+               return -EINVAL;
        }
        info->dev = &pdev->dev;
 
@@ -704,44 +703,26 @@ static int pm860x_charger_probe(struct platform_device *pdev)
        psy_cfg.drv_data = info;
        psy_cfg.supplied_to = pm860x_supplied_to;
        psy_cfg.num_supplicants = ARRAY_SIZE(pm860x_supplied_to);
-       info->usb = power_supply_register(&pdev->dev, &pm860x_charger_desc,
-                                         &psy_cfg);
+       info->usb = devm_power_supply_register(&pdev->dev, &pm860x_charger_desc,
+                                              &psy_cfg);
        if (IS_ERR(info->usb)) {
-               ret = PTR_ERR(info->usb);
-               goto out;
+               return PTR_ERR(info->usb);
        }
 
        pm860x_init_charger(info);
 
        for (i = 0; i < ARRAY_SIZE(info->irq); i++) {
-               ret = request_threaded_irq(info->irq[i], NULL,
-                       pm860x_irq_descs[i].handler,
-                       IRQF_ONESHOT, pm860x_irq_descs[i].name, info);
+               ret = devm_request_threaded_irq(&pdev->dev, info->irq[i], NULL,
+                                               pm860x_irq_descs[i].handler,
+                                               IRQF_ONESHOT,
+                                               pm860x_irq_descs[i].name, info);
                if (ret < 0) {
                        dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n",
                                info->irq[i], ret);
-                       goto out_irq;
+                       return ret;
                }
        }
        return 0;
-
-out_irq:
-       power_supply_unregister(info->usb);
-       while (--i >= 0)
-               free_irq(info->irq[i], info);
-out:
-       return ret;
-}
-
-static int pm860x_charger_remove(struct platform_device *pdev)
-{
-       struct pm860x_charger_info *info = platform_get_drvdata(pdev);
-       int i;
-
-       power_supply_unregister(info->usb);
-       for (i = 0; i < info->irq_nums; i++)
-               free_irq(info->irq[i], info);
-       return 0;
 }
 
 static struct platform_driver pm860x_charger_driver = {
@@ -749,7 +730,6 @@ static struct platform_driver pm860x_charger_driver = {
                   .name = "88pm860x-charger",
        },
        .probe = pm860x_charger_probe,
-       .remove = pm860x_charger_remove,
 };
 module_platform_driver(pm860x_charger_driver);
 
index c19c50442761dc92cc7ed145eea355df0690b9fa..308e68545d44d4bc71a82c074ff0f1471b878770 100644 (file)
@@ -1940,7 +1940,7 @@ static int ab8500_charger_get_ext_psy_data(struct device *dev, void *data)
  *
  * Due to a asic bug it is necessary to lower the input current to the vbus
  * charger when charging with at some specific levels. This issue is only valid
- * for below a certain battery voltage. This function makes sure that the
+ * for below a certain battery voltage. This function makes sure that
  * the allowed current limit isn't exceeded.
  */
 static void ab8500_charger_check_vbat_work(struct work_struct *work)
@@ -3719,7 +3719,14 @@ static int __init ab8500_charger_init(void)
        if (ret)
                return ret;
 
-       return platform_driver_register(&ab8500_charger_driver);
+       ret = platform_driver_register(&ab8500_charger_driver);
+       if (ret) {
+               platform_unregister_drivers(ab8500_charger_component_drivers,
+                               ARRAY_SIZE(ab8500_charger_component_drivers));
+               return ret;
+       }
+
+       return 0;
 }
 
 static void __exit ab8500_charger_exit(void)
index fcf8ff0bc974b86c289580ed17a6d3230d042a98..840db629a46c34cdec1b8940065f1db34699aa3f 100644 (file)
@@ -694,8 +694,7 @@ static const struct power_supply_desc adp5061_desc = {
        .num_properties         = ARRAY_SIZE(adp5061_props),
 };
 
-static int adp5061_probe(struct i2c_client *client,
-                        const struct i2c_device_id *id)
+static int adp5061_probe(struct i2c_client *client)
 {
        struct power_supply_config psy_cfg = {};
        struct adp5061_state *st;
@@ -737,7 +736,7 @@ static struct i2c_driver adp5061_driver = {
        .driver = {
                .name = KBUILD_MODNAME,
        },
-       .probe = adp5061_probe,
+       .probe_new = adp5061_probe,
        .id_table = adp5061_id,
 };
 module_i2c_driver(adp5061_driver);
index 96e93e1b80949cb344f99c18a578cfa57563d4cc..250362e15c98ba2c18e23f5dccf4f3e23a8fcc56 100644 (file)
@@ -768,27 +768,13 @@ static const struct power_supply_desc bd9995x_power_supply_desc = {
  * Describe the setting in linear_range table.
  */
 static const struct linear_range input_current_limit_ranges[] = {
-       {
-               .min = 0,
-               .step = 32000,
-               .min_sel = 0x0,
-               .max_sel = 0x1ff,
-       },
+       LINEAR_RANGE(0, 0x0, 0x1ff, 32000),
 };
 
 /* Possible trickle, pre-charging and termination current values */
 static const struct linear_range charging_current_ranges[] = {
-       {
-               .min = 0,
-               .step = 64000,
-               .min_sel = 0x0,
-               .max_sel = 0x10,
-       }, {
-               .min = 1024000,
-               .step = 0,
-               .min_sel = 0x11,
-               .max_sel = 0x1f,
-       },
+       LINEAR_RANGE(0, 0x0, 0x10, 64000),
+       LINEAR_RANGE(1024000, 0x11, 0x1f, 0),
 };
 
 /*
@@ -796,72 +782,28 @@ static const struct linear_range charging_current_ranges[] = {
  * and battery over voltage protection have same possible values
  */
 static const struct linear_range charge_voltage_regulation_ranges[] = {
-       {
-               .min = 2560000,
-               .step = 0,
-               .min_sel = 0,
-               .max_sel = 0xA0,
-       }, {
-               .min = 2560000,
-               .step = 16000,
-               .min_sel = 0xA0,
-               .max_sel = 0x4B0,
-       }, {
-               .min = 19200000,
-               .step = 0,
-               .min_sel = 0x4B0,
-               .max_sel = 0x7FF,
-       },
+       LINEAR_RANGE(2560000, 0, 0xA0, 0),
+       LINEAR_RANGE(2560000, 0xA0, 0x4B0, 16000),
+       LINEAR_RANGE(19200000, 0x4B0, 0x7FF, 0),
 };
 
 /* Possible VSYS voltage regulation values */
 static const struct linear_range vsys_voltage_regulation_ranges[] = {
-       {
-               .min = 2560000,
-               .step = 0,
-               .min_sel = 0,
-               .max_sel = 0x28,
-       }, {
-               .min = 2560000,
-               .step = 64000,
-               .min_sel = 0x28,
-               .max_sel = 0x12C,
-       }, {
-               .min = 19200000,
-               .step = 0,
-               .min_sel = 0x12C,
-               .max_sel = 0x1FF,
-       },
+       LINEAR_RANGE(2560000, 0, 0x28, 0),
+       LINEAR_RANGE(2560000, 0x28, 0x12C, 64000),
+       LINEAR_RANGE(19200000, 0x12C, 0x1FF, 0),
 };
 
 /* Possible settings for switching from trickle to pre-charging limits */
 static const struct linear_range trickle_to_pre_threshold_ranges[] = {
-       {
-               .min = 2048000,
-               .step = 0,
-               .min_sel = 0,
-               .max_sel = 0x20,
-       }, {
-               .min = 2048000,
-               .step = 64000,
-               .min_sel = 0x20,
-               .max_sel = 0x12C,
-       }, {
-               .min = 19200000,
-               .step = 0,
-               .min_sel = 0x12C,
-               .max_sel = 0x1FF
-       }
+       LINEAR_RANGE(2048000, 0, 0x20, 0),
+       LINEAR_RANGE(2048000, 0x20, 0x12C, 64000),
+       LINEAR_RANGE(19200000, 0x12C, 0x1FF, 0),
 };
 
 /* Possible current values for fast-charging constant current phase */
 static const struct linear_range fast_charge_current_ranges[] = {
-       {
-               .min = 0,
-               .step = 64000,
-               .min_sel = 0,
-               .max_sel = 0xFF,
-       }
+       LINEAR_RANGE(0, 0, 0xFF, 64000),
 };
 
 struct battery_init {
index 6b99e1c675b87cacdcff64104c83eec077872076..d2cb7431dced00ae48fd7a3b540a149cb33c34d8 100644 (file)
@@ -1520,9 +1520,9 @@ static int bq2415x_power_supply_init(struct bq2415x_device *bq)
 }
 
 /* main bq2415x probe function */
-static int bq2415x_probe(struct i2c_client *client,
-                        const struct i2c_device_id *id)
+static int bq2415x_probe(struct i2c_client *client)
 {
+       const struct i2c_device_id *id = i2c_client_get_device_id(client);
        int ret;
        int num;
        char *name = NULL;
@@ -1780,7 +1780,7 @@ static struct i2c_driver bq2415x_driver = {
                .of_match_table = of_match_ptr(bq2415x_of_match_table),
                .acpi_match_table = ACPI_PTR(bq2415x_i2c_acpi_match),
        },
-       .probe = bq2415x_probe,
+       .probe_new = bq2415x_probe,
        .remove = bq2415x_remove,
        .id_table = bq2415x_i2c_id_table,
 };
index 2274679c5ddd215eac319a13cc982c6a7c531c76..2b2c3a4391c19bce97d4c4153d111576d5f50ace 100644 (file)
@@ -1767,9 +1767,9 @@ static int bq24190_get_config(struct bq24190_dev_info *bdi)
        return 0;
 }
 
-static int bq24190_probe(struct i2c_client *client,
-               const struct i2c_device_id *id)
+static int bq24190_probe(struct i2c_client *client)
 {
+       const struct i2c_device_id *id = i2c_client_get_device_id(client);
        struct i2c_adapter *adapter = client->adapter;
        struct device *dev = &client->dev;
        struct power_supply_config charger_cfg = {}, battery_cfg = {};
@@ -2032,7 +2032,7 @@ static const struct of_device_id bq24190_of_match[] = {
 MODULE_DEVICE_TABLE(of, bq24190_of_match);
 
 static struct i2c_driver bq24190_driver = {
-       .probe          = bq24190_probe,
+       .probe_new      = bq24190_probe,
        .remove         = bq24190_remove,
        .shutdown       = bq24190_shutdown,
        .id_table       = bq24190_i2c_ids,
index a309bbedfe521956d63d33b3f9dc174b04d9547a..ab4c49788c586224fa58708fad2d19bdf2752db9 100644 (file)
@@ -947,9 +947,9 @@ static int bq24257_fw_probe(struct bq24257_device *bq)
        return 0;
 }
 
-static int bq24257_probe(struct i2c_client *client,
-                        const struct i2c_device_id *id)
+static int bq24257_probe(struct i2c_client *client)
 {
+       const struct i2c_device_id *id = i2c_client_get_device_id(client);
        struct i2c_adapter *adapter = client->adapter;
        struct device *dev = &client->dev;
        const struct acpi_device_id *acpi_id;
@@ -1167,7 +1167,7 @@ static struct i2c_driver bq24257_driver = {
                .acpi_match_table = ACPI_PTR(bq24257_acpi_match),
                .pm = &bq24257_pm,
        },
-       .probe = bq24257_probe,
+       .probe_new = bq24257_probe,
        .remove = bq24257_remove,
        .id_table = bq24257_i2c_ids,
 };
index 3ce36d09c017cf1fb6ff118f36d46723431d0cae..cfca3a82d5a8d0d0bddf4a277f8b81ab0eb9a494 100644 (file)
@@ -352,8 +352,7 @@ static struct bq24735_platform *bq24735_parse_dt_data(struct i2c_client *client)
        return pdata;
 }
 
-static int bq24735_charger_probe(struct i2c_client *client,
-                                const struct i2c_device_id *id)
+static int bq24735_charger_probe(struct i2c_client *client)
 {
        int ret;
        struct bq24735 *charger;
@@ -506,7 +505,7 @@ static struct i2c_driver bq24735_charger_driver = {
                .name = "bq24735-charger",
                .of_match_table = bq24735_match_ids,
        },
-       .probe = bq24735_charger_probe,
+       .probe_new = bq24735_charger_probe,
        .id_table = bq24735_charger_id,
 };
 
index 4f76ad9c2f18e032bf6cb84844fc9fb3b2f50be2..da224ae8dc6155e6e1b97bbd5e1cd5f1e6864efa 100644 (file)
@@ -1078,9 +1078,9 @@ static const struct regmap_config bq25155_regmap_config = {
        .volatile_reg           = bq2515x_volatile_register,
 };
 
-static int bq2515x_probe(struct i2c_client *client,
-                        const struct i2c_device_id *id)
+static int bq2515x_probe(struct i2c_client *client)
 {
+       const struct i2c_device_id *id = i2c_client_get_device_id(client);
        struct device *dev = &client->dev;
        struct bq2515x_device *bq2515x;
        struct power_supply_config charger_cfg = {};
@@ -1158,7 +1158,7 @@ static struct i2c_driver bq2515x_driver = {
                .name = "bq2515x-charger",
                .of_match_table = bq2515x_of_match,
        },
-       .probe = bq2515x_probe,
+       .probe_new = bq2515x_probe,
        .id_table = bq2515x_i2c_ids,
 };
 module_i2c_driver(bq2515x_driver);
index 01ad84fd147c8ab131a2f36a130f81c90bcdca40..db13e288e439a8aa421a47b5800db5e876938b24 100644 (file)
@@ -1619,9 +1619,9 @@ static int bq256xx_parse_dt(struct bq256xx_device *bq,
        return 0;
 }
 
-static int bq256xx_probe(struct i2c_client *client,
-                        const struct i2c_device_id *id)
+static int bq256xx_probe(struct i2c_client *client)
 {
+       const struct i2c_device_id *id = i2c_client_get_device_id(client);
        struct device *dev = &client->dev;
        struct bq256xx_device *bq;
        struct power_supply_config psy_cfg = { };
@@ -1744,7 +1744,7 @@ static struct i2c_driver bq256xx_driver = {
                .of_match_table = bq256xx_of_match,
                .acpi_match_table = bq256xx_acpi_match,
        },
-       .probe = bq256xx_probe,
+       .probe_new = bq256xx_probe,
        .id_table = bq256xx_i2c_ids,
 };
 module_i2c_driver(bq256xx_driver);
index 6020b58c641d237de3cbc4da18d61bd64a353efd..2d731ea58323b54cfcbe6b239fe642375bb585f1 100644 (file)
@@ -529,8 +529,53 @@ static int bq25890_power_supply_get_property(struct power_supply *psy,
                        val->intval = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
                break;
 
-       case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
-               val->intval = bq25890_find_val(bq->init_data.ichg, TBL_ICHG);
+       case POWER_SUPPLY_PROP_PRECHARGE_CURRENT:
+               val->intval = bq25890_find_val(bq->init_data.iprechg, TBL_ITERM);
+               break;
+
+       case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT:
+               val->intval = bq25890_find_val(bq->init_data.iterm, TBL_ITERM);
+               break;
+
+       case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
+               ret = bq25890_field_read(bq, F_IINLIM);
+               if (ret < 0)
+                       return ret;
+
+               val->intval = bq25890_find_val(ret, TBL_IINLIM);
+               break;
+
+       case POWER_SUPPLY_PROP_CURRENT_NOW:     /* I_BAT now */
+               /*
+                * This is ADC-sampled immediate charge current supplied
+                * from charger to battery. The property name is confusing,
+                * for clarification refer to:
+                * Documentation/ABI/testing/sysfs-class-power
+                * /sys/class/power_supply/<supply_name>/current_now
+                */
+               ret = bq25890_field_read(bq, F_ICHGR); /* read measured value */
+               if (ret < 0)
+                       return ret;
+
+               /* converted_val = ADC_val * 50mA (table 10.3.19) */
+               val->intval = ret * -50000;
+               break;
+
+       case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: /* I_BAT user limit */
+               /*
+                * This is user-configured constant charge current supplied
+                * from charger to battery in first phase of charging, when
+                * battery voltage is below constant charge voltage.
+                *
+                * This value reflects the current hardware setting.
+                *
+                * The POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX is the
+                * maximum value of this property.
+                */
+               ret = bq25890_field_read(bq, F_ICHG);
+               if (ret < 0)
+                       return ret;
+               val->intval = bq25890_find_val(ret, TBL_ICHG);
 
                /* When temperature is too low, charge current is decreased */
                if (bq->state.ntc_fault == NTC_FAULT_COOL) {
@@ -545,12 +590,25 @@ static int bq25890_power_supply_get_property(struct power_supply *psy,
                }
                break;
 
-       case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
-               if (!state.online) {
-                       val->intval = 0;
-                       break;
-               }
+       case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:     /* I_BAT max */
+               /*
+                * This is maximum allowed constant charge current supplied
+                * from charger to battery in first phase of charging, when
+                * battery voltage is below constant charge voltage.
+                *
+                * This value is constant for each battery and set from DT.
+                */
+               val->intval = bq25890_find_val(bq->init_data.ichg, TBL_ICHG);
+               break;
 
+       case POWER_SUPPLY_PROP_VOLTAGE_NOW:     /* V_BAT now */
+               /*
+                * This is ADC-sampled immediate charge voltage supplied
+                * from charger to battery. The property name is confusing,
+                * for clarification refer to:
+                * Documentation/ABI/testing/sysfs-class-power
+                * /sys/class/power_supply/<supply_name>/voltage_now
+                */
                ret = bq25890_field_read(bq, F_BATV); /* read measured value */
                if (ret < 0)
                        return ret;
@@ -559,42 +617,33 @@ static int bq25890_power_supply_get_property(struct power_supply *psy,
                val->intval = 2304000 + ret * 20000;
                break;
 
-       case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX:
-               val->intval = bq25890_find_val(bq->init_data.vreg, TBL_VREG);
-               break;
-
-       case POWER_SUPPLY_PROP_PRECHARGE_CURRENT:
-               val->intval = bq25890_find_val(bq->init_data.iprechg, TBL_ITERM);
-               break;
-
-       case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT:
-               val->intval = bq25890_find_val(bq->init_data.iterm, TBL_ITERM);
-               break;
-
-       case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
-               ret = bq25890_field_read(bq, F_IINLIM);
-               if (ret < 0)
-                       return ret;
-
-               val->intval = bq25890_find_val(ret, TBL_IINLIM);
-               break;
-
-       case POWER_SUPPLY_PROP_VOLTAGE_NOW:
-               ret = bq25890_field_read(bq, F_SYSV); /* read measured value */
+       case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: /* V_BAT user limit */
+               /*
+                * This is user-configured constant charge voltage supplied
+                * from charger to battery in second phase of charging, when
+                * battery voltage reached constant charge voltage.
+                *
+                * This value reflects the current hardware setting.
+                *
+                * The POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX is the
+                * maximum value of this property.
+                */
+               ret = bq25890_field_read(bq, F_VREG);
                if (ret < 0)
                        return ret;
 
-               /* converted_val = 2.304V + ADC_val * 20mV (table 10.3.15) */
-               val->intval = 2304000 + ret * 20000;
+               val->intval = bq25890_find_val(ret, TBL_VREG);
                break;
 
-       case POWER_SUPPLY_PROP_CURRENT_NOW:
-               ret = bq25890_field_read(bq, F_ICHGR); /* read measured value */
-               if (ret < 0)
-                       return ret;
-
-               /* converted_val = ADC_val * 50mA (table 10.3.19) */
-               val->intval = ret * -50000;
+       case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX:     /* V_BAT max */
+               /*
+                * This is maximum allowed constant charge voltage supplied
+                * from charger to battery in second phase of charging, when
+                * battery voltage reached constant charge voltage.
+                *
+                * This value is constant for each battery and set from DT.
+                */
+               val->intval = bq25890_find_val(bq->init_data.vreg, TBL_VREG);
                break;
 
        case POWER_SUPPLY_PROP_TEMP:
@@ -618,9 +667,18 @@ static int bq25890_power_supply_set_property(struct power_supply *psy,
                                             const union power_supply_propval *val)
 {
        struct bq25890_device *bq = power_supply_get_drvdata(psy);
+       int maxval;
        u8 lval;
 
        switch (psp) {
+       case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
+               maxval = bq25890_find_val(bq->init_data.ichg, TBL_ICHG);
+               lval = bq25890_find_idx(min(val->intval, maxval), TBL_ICHG);
+               return bq25890_field_write(bq, F_ICHG, lval);
+       case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
+               maxval = bq25890_find_val(bq->init_data.vreg, TBL_VREG);
+               lval = bq25890_find_idx(min(val->intval, maxval), TBL_VREG);
+               return bq25890_field_write(bq, F_VREG, lval);
        case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
                lval = bq25890_find_idx(val->intval, TBL_IINLIM);
                return bq25890_field_write(bq, F_IINLIM, lval);
@@ -633,6 +691,8 @@ static int bq25890_power_supply_property_is_writeable(struct power_supply *psy,
                                                      enum power_supply_property psp)
 {
        switch (psp) {
+       case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
+       case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
        case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
                return true;
        default:
@@ -880,6 +940,7 @@ static const enum power_supply_property bq25890_power_supply_props[] = {
        POWER_SUPPLY_PROP_CHARGE_TYPE,
        POWER_SUPPLY_PROP_ONLINE,
        POWER_SUPPLY_PROP_HEALTH,
+       POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT,
        POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
        POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
        POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
@@ -1034,10 +1095,32 @@ static int bq25890_vbus_is_enabled(struct regulator_dev *rdev)
        return bq25890_field_read(bq, F_OTG_CFG);
 }
 
+static int bq25890_vbus_get_voltage(struct regulator_dev *rdev)
+{
+       struct bq25890_device *bq = rdev_get_drvdata(rdev);
+
+       return bq25890_get_vbus_voltage(bq);
+}
+
+static int bq25890_vsys_get_voltage(struct regulator_dev *rdev)
+{
+       struct bq25890_device *bq = rdev_get_drvdata(rdev);
+       int ret;
+
+       /* Should be some output voltage ? */
+       ret = bq25890_field_read(bq, F_SYSV); /* read measured value */
+       if (ret < 0)
+               return ret;
+
+       /* converted_val = 2.304V + ADC_val * 20mV (table 10.3.15) */
+       return 2304000 + ret * 20000;
+}
+
 static const struct regulator_ops bq25890_vbus_ops = {
        .enable = bq25890_vbus_enable,
        .disable = bq25890_vbus_disable,
        .is_enabled = bq25890_vbus_is_enabled,
+       .get_voltage = bq25890_vbus_get_voltage,
 };
 
 static const struct regulator_desc bq25890_vbus_desc = {
@@ -1046,9 +1129,54 @@ static const struct regulator_desc bq25890_vbus_desc = {
        .type = REGULATOR_VOLTAGE,
        .owner = THIS_MODULE,
        .ops = &bq25890_vbus_ops,
-       .fixed_uV = 5000000,
-       .n_voltages = 1,
 };
+
+static const struct regulator_ops bq25890_vsys_ops = {
+       .get_voltage = bq25890_vsys_get_voltage,
+};
+
+static const struct regulator_desc bq25890_vsys_desc = {
+       .name = "vsys",
+       .of_match = "vsys",
+       .type = REGULATOR_VOLTAGE,
+       .owner = THIS_MODULE,
+       .ops = &bq25890_vsys_ops,
+};
+
+static int bq25890_register_regulator(struct bq25890_device *bq)
+{
+       struct bq25890_platform_data *pdata = dev_get_platdata(bq->dev);
+       struct regulator_config cfg = {
+               .dev = bq->dev,
+               .driver_data = bq,
+       };
+       struct regulator_dev *reg;
+
+       if (pdata)
+               cfg.init_data = pdata->regulator_init_data;
+
+       reg = devm_regulator_register(bq->dev, &bq25890_vbus_desc, &cfg);
+       if (IS_ERR(reg)) {
+               return dev_err_probe(bq->dev, PTR_ERR(reg),
+                                    "registering vbus regulator");
+       }
+
+       /* pdata->regulator_init_data is for vbus only */
+       cfg.init_data = NULL;
+       reg = devm_regulator_register(bq->dev, &bq25890_vsys_desc, &cfg);
+       if (IS_ERR(reg)) {
+               return dev_err_probe(bq->dev, PTR_ERR(reg),
+                                    "registering vsys regulator");
+       }
+
+       return 0;
+}
+#else
+static inline int
+bq25890_register_regulator(struct bq25890_device *bq)
+{
+       return 0;
+}
 #endif
 
 static int bq25890_get_chip_version(struct bq25890_device *bq)
@@ -1189,8 +1317,14 @@ static int bq25890_fw_probe(struct bq25890_device *bq)
        return 0;
 }
 
-static int bq25890_probe(struct i2c_client *client,
-                        const struct i2c_device_id *id)
+static void bq25890_non_devm_cleanup(void *data)
+{
+       struct bq25890_device *bq = data;
+
+       cancel_delayed_work_sync(&bq->pump_express_work);
+}
+
+static int bq25890_probe(struct i2c_client *client)
 {
        struct device *dev = &client->dev;
        struct bq25890_device *bq;
@@ -1244,56 +1378,47 @@ static int bq25890_probe(struct i2c_client *client,
 
        /* OTG reporting */
        bq->usb_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
-       if (!IS_ERR_OR_NULL(bq->usb_phy)) {
-               INIT_WORK(&bq->usb_work, bq25890_usb_work);
-               bq->usb_nb.notifier_call = bq25890_usb_notifier;
-               usb_register_notifier(bq->usb_phy, &bq->usb_nb);
-       }
-#ifdef CONFIG_REGULATOR
-       else {
-               struct bq25890_platform_data *pdata = dev_get_platdata(dev);
-               struct regulator_config cfg = { };
-               struct regulator_dev *reg;
-
-               cfg.dev = dev;
-               cfg.driver_data = bq;
-               if (pdata)
-                       cfg.init_data = pdata->regulator_init_data;
-
-               reg = devm_regulator_register(dev, &bq25890_vbus_desc, &cfg);
-               if (IS_ERR(reg))
-                       return dev_err_probe(dev, PTR_ERR(reg), "registering regulator");
-       }
-#endif
+
+       /*
+        * This must be before bq25890_power_supply_init(), so that it runs
+        * after devm unregisters the power_supply.
+        */
+       ret = devm_add_action_or_reset(dev, bq25890_non_devm_cleanup, bq);
+       if (ret)
+               return ret;
+
+       ret = bq25890_register_regulator(bq);
+       if (ret)
+               return ret;
 
        ret = bq25890_power_supply_init(bq);
-       if (ret < 0) {
-               dev_err(dev, "Failed to register power supply\n");
-               goto err_unregister_usb_notifier;
-       }
+       if (ret < 0)
+               return dev_err_probe(dev, ret, "registering power supply\n");
 
        ret = devm_request_threaded_irq(dev, client->irq, NULL,
                                        bq25890_irq_handler_thread,
                                        IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
                                        BQ25890_IRQ_PIN, bq);
        if (ret)
-               goto err_unregister_usb_notifier;
-
-       return 0;
+               return ret;
 
-err_unregister_usb_notifier:
-       if (!IS_ERR_OR_NULL(bq->usb_phy))
-               usb_unregister_notifier(bq->usb_phy, &bq->usb_nb);
+       if (!IS_ERR_OR_NULL(bq->usb_phy)) {
+               INIT_WORK(&bq->usb_work, bq25890_usb_work);
+               bq->usb_nb.notifier_call = bq25890_usb_notifier;
+               usb_register_notifier(bq->usb_phy, &bq->usb_nb);
+       }
 
-       return ret;
+       return 0;
 }
 
 static void bq25890_remove(struct i2c_client *client)
 {
        struct bq25890_device *bq = i2c_get_clientdata(client);
 
-       if (!IS_ERR_OR_NULL(bq->usb_phy))
+       if (!IS_ERR_OR_NULL(bq->usb_phy)) {
                usb_unregister_notifier(bq->usb_phy, &bq->usb_nb);
+               cancel_work_sync(&bq->usb_work);
+       }
 
        if (!bq->skip_reset) {
                /* reset all registers to default values */
@@ -1400,7 +1525,7 @@ static struct i2c_driver bq25890_driver = {
                .acpi_match_table = ACPI_PTR(bq25890_acpi_match),
                .pm = &bq25890_pm,
        },
-       .probe = bq25890_probe,
+       .probe_new = bq25890_probe,
        .remove = bq25890_remove,
        .shutdown = bq25890_shutdown,
        .id_table = bq25890_i2c_ids,
index 9339f5649282786fbf3628b7fbb16ab6ebbbc5f6..a59d9762bc91684aa73fa3bd49d40bb5c7fa0eb1 100644 (file)
@@ -1207,9 +1207,9 @@ static int bq25980_parse_dt(struct bq25980_device *bq)
        return 0;
 }
 
-static int bq25980_probe(struct i2c_client *client,
-                        const struct i2c_device_id *id)
+static int bq25980_probe(struct i2c_client *client)
 {
+       const struct i2c_device_id *id = i2c_client_get_device_id(client);
        struct device *dev = &client->dev;
        struct bq25980_device *bq;
        int ret;
@@ -1287,7 +1287,7 @@ static struct i2c_driver bq25980_driver = {
                .name = "bq25980-charger",
                .of_match_table = bq25980_of_match,
        },
-       .probe = bq25980_probe,
+       .probe_new = bq25980_probe,
        .id_table = bq25980_i2c_ids,
 };
 module_i2c_driver(bq25980_driver);
index 94b00bb89c177fe80df9c7a8465a10419192e744..f8768997333bc59412d040cee7427efad086a7f2 100644 (file)
@@ -136,9 +136,9 @@ static int bq27xxx_battery_i2c_bulk_write(struct bq27xxx_device_info *di,
        return 0;
 }
 
-static int bq27xxx_battery_i2c_probe(struct i2c_client *client,
-                                    const struct i2c_device_id *id)
+static int bq27xxx_battery_i2c_probe(struct i2c_client *client)
 {
+       const struct i2c_device_id *id = i2c_client_get_device_id(client);
        struct bq27xxx_device_info *di;
        int ret;
        char *name;
@@ -295,7 +295,7 @@ static struct i2c_driver bq27xxx_battery_i2c_driver = {
                .name = "bq27xxx-battery",
                .of_match_table = of_match_ptr(bq27xxx_battery_i2c_of_match_table),
        },
-       .probe = bq27xxx_battery_i2c_probe,
+       .probe_new = bq27xxx_battery_i2c_probe,
        .remove = bq27xxx_battery_i2c_remove,
        .id_table = bq27xxx_i2c_id_table,
 };
index 6d52641151d9ac4a1eb9dcade7ce1f1e32eb0d08..473522b4326adc5f84aebfbf8962e2b7e2ef1089 100644 (file)
@@ -699,6 +699,9 @@ static int cw_bat_probe(struct i2c_client *client)
        }
 
        cw_bat->battery_workqueue = create_singlethread_workqueue("rk_battery");
+       if (!cw_bat->battery_workqueue)
+               return -ENOMEM;
+
        devm_delayed_work_autocancel(&client->dev,
                                                          &cw_bat->battery_delay_work, cw_bat_work);
        queue_delayed_work(cw_bat->battery_workqueue,
index d78cd05402f66cafe86fd6b5b6cd9e05ac614385..9b9619246902c66e5541302b19e7693a558155c6 100644 (file)
@@ -368,9 +368,9 @@ static const struct ds278x_battery_ops ds278x_ops[] = {
        }
 };
 
-static int ds278x_battery_probe(struct i2c_client *client,
-                               const struct i2c_device_id *id)
+static int ds278x_battery_probe(struct i2c_client *client)
 {
+       const struct i2c_device_id *id = i2c_client_get_device_id(client);
        struct ds278x_platform_data *pdata = client->dev.platform_data;
        struct power_supply_config psy_cfg = {};
        struct ds278x_info *info;
@@ -458,7 +458,7 @@ static struct i2c_driver ds278x_battery_driver = {
                .name   = "ds2782-battery",
                .pm     = &ds278x_battery_pm_ops,
        },
-       .probe          = ds278x_battery_probe,
+       .probe_new      = ds278x_battery_probe,
        .remove         = ds278x_battery_remove,
        .id_table       = ds278x_id,
 };
index 384a374b52c1955d35a0e24d6206e93e66408ff0..e6c21377d53c2e576af1404b36a5a0d7e074e3d3 100644 (file)
@@ -540,7 +540,7 @@ static struct lp8727_platform_data *lp8727_parse_dt(struct device *dev)
 }
 #endif
 
-static int lp8727_probe(struct i2c_client *cl, const struct i2c_device_id *id)
+static int lp8727_probe(struct i2c_client *cl)
 {
        struct lp8727_chg *pchg;
        struct lp8727_platform_data *pdata;
@@ -615,7 +615,7 @@ static struct i2c_driver lp8727_driver = {
                   .name = "lp8727",
                   .of_match_table = of_match_ptr(lp8727_dt_ids),
                   },
-       .probe = lp8727_probe,
+       .probe_new = lp8727_probe,
        .remove = lp8727_remove,
        .id_table = lp8727_ids,
 };
index 56c57529c2287ffc09d58a5c320fdb642e9fe29a..f5f47a0aa1e3d5c7a22f83e5c8b7439b7b9c6185 100644 (file)
@@ -520,7 +520,7 @@ err_free_irq:
 static int lp8788_irq_register(struct platform_device *pdev,
                                struct lp8788_charger *pchg)
 {
-       const char *name[] = {
+       static const char * const name[] = {
                LP8788_CHG_IRQ, LP8788_PRSW_IRQ, LP8788_BATT_IRQ
        };
        int i;
index 657305214d68dcc150b1eec03c1a47ecd298c13d..d3fb42825983939fdd9335a6f0fc0174f43662a4 100644 (file)
@@ -439,8 +439,7 @@ static enum power_supply_property ltc294x_properties[] = {
        POWER_SUPPLY_PROP_CURRENT_NOW,
 };
 
-static int ltc294x_i2c_probe(struct i2c_client *client,
-       const struct i2c_device_id *id)
+static int ltc294x_i2c_probe(struct i2c_client *client)
 {
        struct power_supply_config psy_cfg = {};
        struct ltc294x_info *info;
@@ -636,7 +635,7 @@ static struct i2c_driver ltc294x_driver = {
                .of_match_table = ltc294x_i2c_of_match,
                .pm     = LTC294X_PM_OPS,
        },
-       .probe          = ltc294x_i2c_probe,
+       .probe_new      = ltc294x_i2c_probe,
        .shutdown       = ltc294x_i2c_shutdown,
        .id_table       = ltc294x_i2c_id,
 };
index 1a5cb4405ee3ca76e29a4e316473309cf2200071..db2bb523357052e0f367d5b64615fba578165e7b 100644 (file)
@@ -819,8 +819,7 @@ static void ltc4162l_clear_interrupts(struct ltc4162l_info *info)
        regmap_write(info->regmap, LTC4162L_CHARGE_STATUS_ALERTS_REG, 0);
 }
 
-static int ltc4162l_probe(struct i2c_client *client,
-                       const struct i2c_device_id *id)
+static int ltc4162l_probe(struct i2c_client *client)
 {
        struct i2c_adapter *adapter = client->adapter;
        struct device *dev = &client->dev;
@@ -916,7 +915,7 @@ static const struct of_device_id ltc4162l_of_match[] = {
 MODULE_DEVICE_TABLE(of, ltc4162l_of_match);
 
 static struct i2c_driver ltc4162l_driver = {
-       .probe          = ltc4162l_probe,
+       .probe_new      = ltc4162l_probe,
        .alert          = ltc4162l_alert,
        .id_table       = ltc4162l_i2c_id_table,
        .driver = {
index fc36828895bf66996eb76a9b39fd2734c111e5f2..0d0180fcfa63bb8918432bd10df331df2e8d1070 100644 (file)
@@ -234,8 +234,7 @@ static enum power_supply_property max14656_battery_props[] = {
        POWER_SUPPLY_PROP_MANUFACTURER,
 };
 
-static int max14656_probe(struct i2c_client *client,
-                         const struct i2c_device_id *id)
+static int max14656_probe(struct i2c_client *client)
 {
        struct i2c_adapter *adapter = client->adapter;
        struct device *dev = &client->dev;
@@ -317,7 +316,7 @@ static struct i2c_driver max14656_i2c_driver = {
                .name   = "max14656",
                .of_match_table = max14656_match_table,
        },
-       .probe          = max14656_probe,
+       .probe_new      = max14656_probe,
        .id_table       = max14656_id,
 };
 module_i2c_driver(max14656_i2c_driver);
index a9aef1e8b186e956cdd17e36c81172f44213d7c1..d1075959dd466b402730e0e16e04d9662fb65631 100644 (file)
@@ -430,9 +430,9 @@ static const struct power_supply_desc max17040_battery_desc = {
        .num_properties         = ARRAY_SIZE(max17040_battery_props),
 };
 
-static int max17040_probe(struct i2c_client *client,
-                       const struct i2c_device_id *id)
+static int max17040_probe(struct i2c_client *client)
 {
+       const struct i2c_device_id *id = i2c_client_get_device_id(client);
        struct i2c_adapter *adapter = client->adapter;
        struct power_supply_config psy_cfg = {};
        struct max17040_chip *chip;
@@ -599,7 +599,7 @@ static struct i2c_driver max17040_i2c_driver = {
                .of_match_table = max17040_of_match,
                .pm     = MAX17040_PM_OPS,
        },
-       .probe          = max17040_probe,
+       .probe_new      = max17040_probe,
        .id_table       = max17040_id,
 };
 module_i2c_driver(max17040_i2c_driver);
index ab031bbfbe785b8ebec1ea48a264c8a6e569012e..89cabe8ed3b06edc9b3c755ec03f43ea12a5ee8c 100644 (file)
@@ -1031,9 +1031,9 @@ static const struct power_supply_desc max17042_no_current_sense_psy_desc = {
        .num_properties = ARRAY_SIZE(max17042_battery_props) - 2,
 };
 
-static int max17042_probe(struct i2c_client *client,
-                       const struct i2c_device_id *id)
+static int max17042_probe(struct i2c_client *client)
 {
+       const struct i2c_device_id *id = i2c_client_get_device_id(client);
        struct i2c_adapter *adapter = client->adapter;
        const struct power_supply_desc *max17042_desc = &max17042_psy_desc;
        struct power_supply_config psy_cfg = {};
@@ -1220,7 +1220,7 @@ static struct i2c_driver max17042_i2c_driver = {
                .of_match_table = of_match_ptr(max17042_dt_match),
                .pm     = &max17042_pm_ops,
        },
-       .probe          = max17042_probe,
+       .probe_new      = max17042_probe,
        .id_table       = max17042_id,
 };
 module_i2c_driver(max17042_i2c_driver);
index 3abaa72e06683c2a2eba447695f2d026aea6b04a..92e48e3a485364dd154e8489398488494215874c 100644 (file)
@@ -113,16 +113,13 @@ enum {
        MT6360_RANGE_MAX,
 };
 
-#define MT6360_LINEAR_RANGE(idx, _min, _min_sel, _max_sel, _step) \
-       [idx] = REGULATOR_LINEAR_RANGE(_min, _min_sel, _max_sel, _step)
-
 static const struct linear_range mt6360_chg_range[MT6360_RANGE_MAX] = {
-       MT6360_LINEAR_RANGE(MT6360_RANGE_VMIVR, 3900000, 0, 0x5F, 100000),
-       MT6360_LINEAR_RANGE(MT6360_RANGE_ICHG, 100000, 0, 0x31, 100000),
-       MT6360_LINEAR_RANGE(MT6360_RANGE_VOREG, 3900000, 0, 0x51, 10000),
-       MT6360_LINEAR_RANGE(MT6360_RANGE_AICR, 100000, 0, 0x3F, 50000),
-       MT6360_LINEAR_RANGE(MT6360_RANGE_IPREC, 100000, 0, 0x0F, 50000),
-       MT6360_LINEAR_RANGE(MT6360_RANGE_IEOC, 100000, 0, 0x0F, 50000),
+       LINEAR_RANGE_IDX(MT6360_RANGE_VMIVR, 3900000, 0, 0x5F, 100000),
+       LINEAR_RANGE_IDX(MT6360_RANGE_ICHG, 100000, 0, 0x31, 100000),
+       LINEAR_RANGE_IDX(MT6360_RANGE_VOREG, 3900000, 0, 0x51, 10000),
+       LINEAR_RANGE_IDX(MT6360_RANGE_AICR, 100000, 0, 0x3F, 50000),
+       LINEAR_RANGE_IDX(MT6360_RANGE_IPREC, 100000, 0, 0x0F, 50000),
+       LINEAR_RANGE_IDX(MT6360_RANGE_IEOC, 100000, 0, 0x0F, 50000),
 };
 
 struct mt6360_chg_info {
index 4b5fb172fa994baa499d63a34e6f7734ca6f0484..7c790c41e2fe31a7b2ff9807c5b0dec5a685b5e4 100644 (file)
@@ -750,6 +750,11 @@ int power_supply_get_battery_info(struct power_supply *psy,
                int i, tab_len, size;
 
                propname = kasprintf(GFP_KERNEL, "ocv-capacity-table-%d", index);
+               if (!propname) {
+                       power_supply_put_battery_info(psy, info);
+                       err = -ENOMEM;
+                       goto out_put_node;
+               }
                list = of_get_property(battery_np, propname, &size);
                if (!list || !size) {
                        dev_err(&psy->dev, "failed to get %s\n", propname);
@@ -870,7 +875,6 @@ EXPORT_SYMBOL_GPL(power_supply_temp2resist_simple);
  * power_supply_vbat2ri() - find the battery internal resistance
  * from the battery voltage
  * @info: The battery information container
- * @table: Pointer to battery resistance temperature table
  * @vbat_uv: The battery voltage in microvolt
  * @charging: If we are charging (true) or not (false)
  *
@@ -1387,8 +1391,8 @@ create_triggers_failed:
 register_cooler_failed:
        psy_unregister_thermal(psy);
 register_thermal_failed:
-       device_del(dev);
 wakeup_init_failed:
+       device_del(dev);
 device_add_failed:
 check_supplies_failed:
 dev_set_name_failed:
index f20a6ac584ccdb531be616d36b2588d15c4abe10..4f9c1c417916550d76706253347acc7e64d18f3d 100644 (file)
@@ -1060,8 +1060,10 @@ static int rk817_charger_probe(struct platform_device *pdev)
                return -ENODEV;
 
        charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL);
-       if (!charger)
+       if (!charger) {
+               of_node_put(node);
                return -ENOMEM;
+       }
 
        charger->rk808 = rk808;
 
index 736dec608ff6d9e66c2cbd4b776a26faed46d5f4..5c04cf30521931c74d52a39cabd502553011faf0 100644 (file)
@@ -112,8 +112,7 @@ static const struct power_supply_desc rt5033_battery_desc = {
        .num_properties = ARRAY_SIZE(rt5033_battery_props),
 };
 
-static int rt5033_battery_probe(struct i2c_client *client,
-               const struct i2c_device_id *id)
+static int rt5033_battery_probe(struct i2c_client *client)
 {
        struct i2c_adapter *adapter = client->adapter;
        struct power_supply_config psy_cfg = {};
@@ -173,7 +172,7 @@ static struct i2c_driver rt5033_battery_driver = {
                .name = "rt5033-battery",
                .of_match_table = rt5033_battery_of_match,
        },
-       .probe = rt5033_battery_probe,
+       .probe_new = rt5033_battery_probe,
        .remove = rt5033_battery_remove,
        .id_table = rt5033_battery_id,
 };
index 72962286d70459eee3c4f3e35ceda5e823c45796..31fb6526a1fdf129b2ce01b8104f3bc512034771 100644 (file)
@@ -1581,8 +1581,7 @@ static const struct regmap_config rt9455_regmap_config = {
        .cache_type     = REGCACHE_RBTREE,
 };
 
-static int rt9455_probe(struct i2c_client *client,
-                       const struct i2c_device_id *id)
+static int rt9455_probe(struct i2c_client *client)
 {
        struct i2c_adapter *adapter = client->adapter;
        struct device *dev = &client->dev;
@@ -1738,7 +1737,7 @@ MODULE_DEVICE_TABLE(acpi, rt9455_i2c_acpi_match);
 #endif
 
 static struct i2c_driver rt9455_driver = {
-       .probe          = rt9455_probe,
+       .probe_new      = rt9455_probe,
        .remove         = rt9455_remove,
        .id_table       = rt9455_i2c_id_table,
        .driver = {
index b08f7d0c4181599d3e25e84ef920d633b6bc339f..75ebcbf0a7883750b009ef21a6bd10692f138b1a 100644 (file)
@@ -162,8 +162,7 @@ static const struct power_supply_desc sbs_desc = {
        .get_property = sbs_get_property,
 };
 
-static int sbs_probe(struct i2c_client *client,
-                    const struct i2c_device_id *id)
+static int sbs_probe(struct i2c_client *client)
 {
        struct power_supply_config psy_cfg = {};
        struct sbs_info *chip;
@@ -241,7 +240,7 @@ static const struct i2c_device_id sbs_id[] = {
 MODULE_DEVICE_TABLE(i2c, sbs_id);
 
 static struct i2c_driver sbs_driver = {
-       .probe          = sbs_probe,
+       .probe_new      = sbs_probe,
        .id_table       = sbs_id,
        .driver = {
                .name   = "sbs-charger",
index 71ec8f74f83596391a86cbd5e43af3879d479c19..bde977391fd4c172304e08c9f2430b3d9c97042d 100644 (file)
@@ -315,9 +315,9 @@ static void sbsm_del_mux_adapter(void *data)
        i2c_mux_del_adapters(sbsm->muxc);
 }
 
-static int sbsm_probe(struct i2c_client *client,
-                     const struct i2c_device_id *id)
+static int sbsm_probe(struct i2c_client *client)
 {
+       const struct i2c_device_id *id = i2c_client_get_device_id(client);
        struct i2c_adapter *adapter = client->adapter;
        struct sbsm_data *data;
        struct device *dev = &client->dev;
@@ -409,7 +409,7 @@ static struct i2c_driver sbsm_driver = {
                .name = "sbsm",
                .of_match_table = of_match_ptr(sbsm_dt_ids),
        },
-       .probe          = sbsm_probe,
+       .probe_new      = sbsm_probe,
        .alert          = sbsm_alert,
        .id_table       = sbsm_ids
 };
index 996a82f8a2a1dd11a9c6e2dd809355f12bc6f981..b5f0383102824ebfface63580aae6e9f722801f5 100644 (file)
@@ -1528,9 +1528,9 @@ static const struct regulator_desc smb347_usb_vbus_regulator_desc = {
        .n_voltages     = 1,
 };
 
-static int smb347_probe(struct i2c_client *client,
-                       const struct i2c_device_id *id)
+static int smb347_probe(struct i2c_client *client)
 {
+       const struct i2c_device_id *id = i2c_client_get_device_id(client);
        struct power_supply_config mains_usb_cfg = {};
        struct regulator_config usb_rdev_cfg = {};
        struct device *dev = &client->dev;
@@ -1629,7 +1629,7 @@ static struct i2c_driver smb347_driver = {
                .name = "smb347",
                .of_match_table = smb3xx_of_match,
        },
-       .probe = smb347_probe,
+       .probe_new = smb347_probe,
        .remove = smb347_remove,
        .shutdown = smb347_shutdown,
        .id_table = smb347_id,
index ef673ec3db568a16c4ff99278cde344fe209e45b..836d44c9fb74f75cddafc5472d256ef7025cfb69 100644 (file)
@@ -532,8 +532,7 @@ static const struct regulator_desc ucs1002_regulator_descriptor = {
        .n_voltages     = 1,
 };
 
-static int ucs1002_probe(struct i2c_client *client,
-                        const struct i2c_device_id *dev_id)
+static int ucs1002_probe(struct i2c_client *client)
 {
        struct device *dev = &client->dev;
        struct power_supply_config charger_config = {};
@@ -681,7 +680,7 @@ static struct i2c_driver ucs1002_driver = {
                   .name = "ucs1002",
                   .of_match_table = ucs1002_of_match,
        },
-       .probe = ucs1002_probe,
+       .probe_new = ucs1002_probe,
 };
 module_i2c_driver(ucs1002_driver);
 
index 1897c29848600b6c214732f927295ac191961f21..0ba4a590a0a5fc529edf2dee7847a45f7f1e807a 100644 (file)
@@ -176,8 +176,7 @@ static int z2_batt_ps_init(struct z2_charger *charger, int props)
        return 0;
 }
 
-static int z2_batt_probe(struct i2c_client *client,
-                               const struct i2c_device_id *id)
+static int z2_batt_probe(struct i2c_client *client)
 {
        int ret = 0;
        int props = 1;  /* POWER_SUPPLY_PROP_PRESENT */
@@ -206,10 +205,12 @@ static int z2_batt_probe(struct i2c_client *client,
 
        charger->charge_gpiod = devm_gpiod_get_optional(&client->dev,
                                                        NULL, GPIOD_IN);
-       if (IS_ERR(charger->charge_gpiod))
-               return dev_err_probe(&client->dev,
+       if (IS_ERR(charger->charge_gpiod)) {
+               ret = dev_err_probe(&client->dev,
                                     PTR_ERR(charger->charge_gpiod),
                                     "failed to get charge GPIO\n");
+               goto err;
+       }
 
        if (charger->charge_gpiod) {
                gpiod_set_consumer_name(charger->charge_gpiod, "BATT CHRG");
@@ -306,7 +307,7 @@ static struct i2c_driver z2_batt_driver = {
                .name   = "z2-battery",
                .pm     = Z2_BATTERY_PM_OPS
        },
-       .probe          = z2_batt_probe,
+       .probe_new      = z2_batt_probe,
        .remove         = z2_batt_remove,
        .id_table       = z2_batt_id,
 };