Skip to contentSkip to conversation

Add battery charger driver support for MP2629

PATCH Superseded Saravanan Sekar 3 participants 17 messages Mar 28, 2020 – Mar 29, 2020

Subsystems (5)

v5 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

Saravanan Sekar

author maintainer
#0 lore raw

v5 cover Add battery charger driver support for MP2629

changes in v5:
- removed platfrom data stored in mfd and directly accessed mfd struct in child
- fixed spell check and capitalization in mfd and documentation

changes in v4:
- fixed capitalization in mfg Kconfig and documentation

changes in v3:
- regmap for children passed using platform data and remove mfd driver info access directly from children

changes in v2:
- removed EXPORT_SYMBOL of register set/get helper
- regmap bit filed used, fixed other review comments

This patch series add support for Battery charger control driver for Monolithic Power System's MP2629 chipset, includes MFD driver for ADC battery & input power supply measurement and battery charger control driver.

Thanks,
Saravanan

Saravanan Sekar (5):
dt-bindings: mfd: add document bindings for mp2629
mfd: mp2629: Add support for mps battery charger
iio: adc: mp2629: Add support for mp2629 ADC driver
power: supply: Add support for mps mp2629 battery charger
MAINTAINERS: Add entry for mp2629 Battery Charger driver

 .../devicetree/bindings/mfd/mps,mp2629.yaml   |  60 ++
 MAINTAINERS                                   |   5 +
 drivers/iio/adc/Kconfig                       |  10 +
 drivers/iio/adc/Makefile                      |   1 +
 drivers/iio/adc/mp2629_adc.c                  | 209 ++++++
 drivers/mfd/Kconfig                           |   9 +
 drivers/mfd/Makefile                          |   2 +
 drivers/mfd/mp2629.c                          |  86 +++
 drivers/power/supply/Kconfig                  |  10 +
 drivers/power/supply/Makefile                 |   1 +
 drivers/power/supply/mp2629_charger.c         | 686 ++++++++++++++++++
 include/linux/mfd/mp2629.h                    |  29 +
 12 files changed, 1108 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/mps,mp2629.yaml
 create mode 100644 drivers/iio/adc/mp2629_adc.c
 create mode 100644 drivers/mfd/mp2629.c
 create mode 100644 drivers/power/supply/mp2629_charger.c
 create mode 100644 include/linux/mfd/mp2629.h
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH v5 1/5 dt-bindings: mfd: add document bindings for mp2629

Add device tree binding information for mp2629 mfd driver.

---
 .../devicetree/bindings/mfd/mps,mp2629.yaml   | 60 +++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/mps,mp2629.yaml
Documentation/devicetree/bindings/mfd/mps,mp2629.yaml new file +60 -0
new file mode 100644
index 000000000000..3c3cd023256a
@@ -0,0 +1,60 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/mps,mp2629.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MP2629 Battery Charger PMIC from Monolithic Power System.
+
+maintainers:
+  - Saravanan Sekar <[email protected]>
+
+description: |
+  MP2629 is a PMIC providing battery charging and power supply for smartphones,
+  wireless camera and portable devices. Chip is contrlled over I2C.
+
+  The battery charge management device handles battery charger controller and
+  ADC IIO device for battery, system voltage
+
+properties:
+  compatible:
+    const: mps,mp2629
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-controller: true
+
+  "#interrupt-cells":
+    const: 2
+    description:
+      The first cell is the IRQ number, the second cell is the trigger type.
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - "#interrupt-cells"
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/input/linux-event-codes.h>
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        pmic@4b {
+            compatible = "mps,mp2629";
+            reg = <0x4b>;
+
+            interrupt-controller;
+            interrupt-parent = <&gpio2>;
+            #interrupt-cells = <2>;
+            interrupts = <3 IRQ_TYPE_LEVEL_HIGH>;
+        };
+    };
Signature · 1 line
2.17.1
author maintainer
#2 lore raw

PATCH v5 2/5 mfd: mp2629: Add support for mps battery charger

In reply to Saravanan Sekar

mp2629 is a highly-integrated switching-mode battery charge management device for single-cell Li-ion or Li-polymer battery.

Add MFD core enables chip access for ADC driver for battery readings, and a power supply battery-charger driver

---
 drivers/mfd/Kconfig        |  9 ++++
 drivers/mfd/Makefile       |  2 +
 drivers/mfd/mp2629.c       | 86 ++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/mp2629.h | 20 +++++++++
 4 files changed, 117 insertions(+)
 create mode 100644 drivers/mfd/mp2629.c
 create mode 100644 include/linux/mfd/mp2629.h
drivers/mfd/Kconfig +9 -0
index 3c547ed575e6..85be799795aa 100644
@@ -434,6 +434,15 @@ config MFD_MC13XXX_I2C
 	help
 	  Select this if your MC13xxx is connected via an I2C bus.
 
+config MFD_MP2629
+	tristate "Monolithic power system MP2629 ADC and Battery charger"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  Select this option to enable support for monolithic power system
+	  battery charger. This provides ADC, thermal, battery charger power
+	  management functions on the systems.
+
 config MFD_MXS_LRADC
 	tristate "Freescale i.MX23/i.MX28 LRADC"
 	depends on ARCH_MXS || COMPILE_TEST
drivers/mfd/Makefile +2 -0
index f935d10cbf0f..d6c210f96d02 100644
@@ -170,6 +170,8 @@ obj-$(CONFIG_MFD_MAX8925)	+= max8925.o
 obj-$(CONFIG_MFD_MAX8997)	+= max8997.o max8997-irq.o
 obj-$(CONFIG_MFD_MAX8998)	+= max8998.o max8998-irq.o
 
+obj-$(CONFIG_MFD_MP2629)	+= mp2629.o
+
 pcf50633-objs			:= pcf50633-core.o pcf50633-irq.o
 obj-$(CONFIG_MFD_PCF50633)	+= pcf50633.o
 obj-$(CONFIG_PCF50633_ADC)	+= pcf50633-adc.o
drivers/mfd/mp2629.c new file +86 -0

86 lines not on this page · raw message

include/linux/mfd/mp2629.h new file +20 -0
new file mode 100644
index 000000000000..7f071f1f352b
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * register definitions for MP2629 charger
+ *
+ * Copyright 2020 Monolithic Power Systems, Inc
+ */
+
+#ifndef __MP2629_H__
+#define __MP2629_H__
+
+#include <linux/device.h>
+#include <linux/regmap.h>
+#include <linux/types.h>
+
+struct mp2629_info {
+	struct device *dev;
+	struct regmap *regmap;
+};
+
+#endif
Signature · 1 line
2.17.1
#3 lore raw

Re: [PATCH v5 2/5] mfd: mp2629: Add support for mps battery charger

Quoted 6 lines · Saravanan Sekar

mp2629 is a highly-integrated switching-mode battery charge management device for single-cell Li-ion or Li-polymer battery.

Add MFD core enables chip access for ADC driver for battery readings, and a power supply battery-charger driver

...

include/linux/mfd/mp2629.h line 13

Quoted 6 lines
include/linux/mfd/mp2629.h new file +5 -0
+#ifndef __MP2629_H__
+#define __MP2629_H__
 
+#include <linux/device.h>
+#include <linux/regmap.h>
+#include <linux/types.h>

None of these header is in use here.

struct device;
struct regmap;

would be enough.

Quoted 6 lines
include/linux/mfd/mp2629.h new file +6 -0
+struct mp2629_info {
+       struct device *dev;
+       struct regmap *regmap;
+};
+
+#endif
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#4 lore raw

Re: [PATCH v5 2/5] mfd: mp2629: Add support for mps battery charger

Hi Andy,

Quoted 15 lines · Andy Shevchenko
Quoted 5 lines · Saravanan Sekar

mp2629 is a highly-integrated switching-mode battery charge management device for single-cell Li-ion or Li-polymer battery.

Add MFD core enables chip access for ADC driver for battery readings, and a power supply battery-charger driver

...

include/linux/mfd/mp2629.h line 13

Quoted 5 lines
include/linux/mfd/mp2629.h new file +5 -0
+#ifndef __MP2629_H__
+#define __MP2629_H__
+#include <linux/device.h>
+#include <linux/regmap.h>
+#include <linux/types.h>

None of these header is in use here.

Quoted 4 lines

struct device;
struct regmap;

would be enough.

Yesterday I conveyed to you that Lee is not recommended to use forward declaration and asked me

to use includes, then you agreed with the same. Again same comments !! sorry I am lost.

Quoted 6 lines
Quoted 6 lines
include/linux/mfd/mp2629.h new file +6 -0
+struct mp2629_info {
+       struct device *dev;
+       struct regmap *regmap;
+};
+
+#endif
#5 lore raw

Re: [PATCH v5 2/5] mfd: mp2629: Add support for mps battery charger

Quoted 22 lines · saravanan sekar

Hi Andy,

Quoted 18 lines · Andy Shevchenko
Quoted 5 lines · Saravanan Sekar

mp2629 is a highly-integrated switching-mode battery charge management device for single-cell Li-ion or Li-polymer battery.

Add MFD core enables chip access for ADC driver for battery readings, and a power supply battery-charger driver

...

include/linux/mfd/mp2629.h line 13

Quoted 5 lines
include/linux/mfd/mp2629.h new file +5 -0
+#ifndef __MP2629_H__
+#define __MP2629_H__
+#include <linux/device.h>
+#include <linux/regmap.h>
+#include <linux/types.h>

None of these header is in use here.

struct device;
struct regmap;

Quoted 7 lines
Quoted 1 line

would be enough.

Yesterday I conveyed to you that Lee is not recommended to use forward declaration and asked me

to use includes, then you agreed with the same. Again same comments !! sorry I am lost.

Ah, okay. I missed that.
But types.h is still not needed, all data types are provided either by C or by rest two headers.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
include/linux/mfd/mp2629.h new file +6 -0
+struct mp2629_info {
+       struct device *dev;
+       struct regmap *regmap;
+};
+
+#endif
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#6 lore raw

PATCH v5 3/5 iio: adc: mp2629: Add support for mp2629 ADC driver

In reply to Saravanan Sekar

Add support for 8-bit resolution ADC readings for input power supply and battery charging measurement. Provides voltage, current readings to mp2629 power supply driver.

---
 drivers/iio/adc/Kconfig      |  10 ++
 drivers/iio/adc/Makefile     |   1 +
 drivers/iio/adc/mp2629_adc.c | 209 +++++++++++++++++++++++++++++++++++
 include/linux/mfd/mp2629.h   |   9 ++
 4 files changed, 229 insertions(+)
 create mode 100644 drivers/iio/adc/mp2629_adc.c
drivers/iio/adc/Kconfig +10 -0
index 82e33082958c..ef0c0cd31855 100644
@@ -680,6 +680,16 @@ config MESON_SARADC
 	  To compile this driver as a module, choose M here: the
 	  module will be called meson_saradc.
 
+config MP2629_ADC
+	tristate "Monolithic MP2629 ADC driver"
+	depends on MFD_MP2629
+	help
+	  Say yes to have support for battery charger IC MP2629 ADC device
+	  accessed over I2C.
+
+	  This driver provides ADC conversion of system, input power supply
+	  and battery voltage & current information.
+
 config NAU7802
 	tristate "Nuvoton NAU7802 ADC driver"
 	depends on I2C
drivers/iio/adc/Makefile +1 -0
index 919228900df9..f14416c245a6 100644
@@ -64,6 +64,7 @@ obj-$(CONFIG_MCP3911) += mcp3911.o
 obj-$(CONFIG_MEDIATEK_MT6577_AUXADC) += mt6577_auxadc.o
 obj-$(CONFIG_MEN_Z188_ADC) += men_z188_adc.o
 obj-$(CONFIG_MESON_SARADC) += meson_saradc.o
+obj-$(CONFIG_MP2629_ADC) += mp2629_adc.o
 obj-$(CONFIG_MXS_LRADC_ADC) += mxs-lradc-adc.o
 obj-$(CONFIG_NAU7802) += nau7802.o
 obj-$(CONFIG_NPCM_ADC) += npcm_adc.o
drivers/iio/adc/mp2629_adc.c new file +209 -0

209 lines not on this page · raw message

include/linux/mfd/mp2629.h +9 -0
index 7f071f1f352b..cf4ec4febefe 100644
@@ -17,4 +17,13 @@ struct mp2629_info {
 	struct regmap *regmap;
 };
 
+enum mp2629_adc_chan {
+	MP2629_BATT_VOLT,
+	MP2629_SYSTEM_VOLT,
+	MP2629_INPUT_VOLT,
+	MP2629_BATT_CURRENT,
+	MP2629_INPUT_CURRENT,
+	MP2629_ADC_CHAN_END
+};
+
 #endif
Signature · 1 line
2.17.1
#7 lore raw

Re: [PATCH v5 3/5] iio: adc: mp2629: Add support for mp2629 ADC driver

Quoted 4 lines · Saravanan Sekar

Add support for 8-bit resolution ADC readings for input power supply and battery charging measurement. Provides voltage, current readings to mp2629 power supply driver.

...

drivers/iio/adc/mp2629_adc.c line 73

Quoted 2 lines
drivers/iio/adc/mp2629_adc.c new file +2 -0
+               ret = regmap_read(info->regmap, chan->address, &rval);
+               if (ret < 0)

' < 0' is not needed for regmap call.

..

Quoted 5 lines
drivers/iio/adc/mp2629_adc.c new file +5 -0
+               case MP2629_INPUT_CURRENT:
+                       *val = 133;
+                       *val2 = 10;
+                       return IIO_VAL_FRACTIONAL;
+

drivers/iio/adc/mp2629_adc.c line 110

Quoted 10 lines
drivers/iio/adc/mp2629_adc.c new file +9 -0
+               default:
+                       return -EINVAL;
+               }
+
+       default:
+               return -EINVAL;
+       }
 
+
+       return 0;

Do you really need this? Looks to me as dead code.

...

Quoted 1 line

+ indio_dev->name = dev_name(dev);

Shouldn't be this a part number?
I heard something, so, I might be mistaken, but I hope maintainers will help here.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#8 lore raw

Re: [PATCH v5 3/5] iio: adc: mp2629: Add support for mp2629 ADC driver

Quoted 33 lines · On Sat, 28 Mar 2020 12:52:11 +0200 Andy Shevchenko <[email protected]>…
Quoted 4 lines · Saravanan Sekar

Add support for 8-bit resolution ADC readings for input power supply and battery charging measurement. Provides voltage, current readings to mp2629 power supply driver.

...

drivers/iio/adc/mp2629_adc.c line 73

Quoted 2 lines
drivers/iio/adc/mp2629_adc.c new file +2 -0
+               ret = regmap_read(info->regmap, chan->address, &rval);
+               if (ret < 0)  

' < 0' is not needed for regmap call.

..

Quoted 5 lines
drivers/iio/adc/mp2629_adc.c new file +5 -0
+               case MP2629_INPUT_CURRENT:
+                       *val = 133;
+                       *val2 = 10;
+                       return IIO_VAL_FRACTIONAL;
+

drivers/iio/adc/mp2629_adc.c line 110

Quoted 10 lines
drivers/iio/adc/mp2629_adc.c new file +9 -0
+               default:
+                       return -EINVAL;
+               }
+
+       default:
+               return -EINVAL;
+       }  
 
+
+       return 0;  

Do you really need this? Looks to me as dead code.

Quoted 7 lines

...

Quoted 1 line

+ indio_dev->name = dev_name(dev);

Shouldn't be this a part number?
I heard something, so, I might be mistaken, but I hope maintainers will help here.

It should indeed. I have a nasty habit of missing this in review so thanks for pointing it out!

Jonathan

author maintainer
#9 lore raw

PATCH v5 4/5 power: supply: Add support for mps mp2629 battery charger

In reply to Saravanan Sekar

The mp2629 provides switching-mode battery charge management for single-cell Li-ion or Li-polymer battery. Driver supports the access/control input source and battery charging parameters.

---
 drivers/power/supply/Kconfig          |  10 +
 drivers/power/supply/Makefile         |   1 +
 drivers/power/supply/mp2629_charger.c | 686 ++++++++++++++++++++++++++
 3 files changed, 697 insertions(+)
 create mode 100644 drivers/power/supply/mp2629_charger.c
drivers/power/supply/Kconfig +10 -0
index f3424fdce341..05b3f66946ad 100644
@@ -541,6 +541,16 @@ config CHARGER_MAX8998
 	  Say Y to enable support for the battery charger control sysfs and
 	  platform data of MAX8998/LP3974 PMICs.
 
+config CHARGER_MP2629
+	tristate "Monolithic power system MP2629 Battery charger"
+	depends on MFD_MP2629
+	depends on MP2629_ADC
+	depends on IIO
+	help
+	  Select this option to enable support for Monolithic power system
+	  Battery charger. This driver provies Battery charger power management
+	  functions on the systems.
+
 config CHARGER_QCOM_SMBB
 	tristate "Qualcomm Switch-Mode Battery Charger and Boost"
 	depends on MFD_SPMI_PMIC || COMPILE_TEST
drivers/power/supply/Makefile +1 -0
index 6c7da920ea83..41cb64f09e49 100644
@@ -75,6 +75,7 @@ obj-$(CONFIG_CHARGER_MAX77650)	+= max77650-charger.o
 obj-$(CONFIG_CHARGER_MAX77693)	+= max77693_charger.o
 obj-$(CONFIG_CHARGER_MAX8997)	+= max8997_charger.o
 obj-$(CONFIG_CHARGER_MAX8998)	+= max8998_charger.o
+obj-$(CONFIG_CHARGER_MP2629)	+= mp2629_charger.o
 obj-$(CONFIG_CHARGER_QCOM_SMBB)	+= qcom_smbb.o
 obj-$(CONFIG_CHARGER_BQ2415X)	+= bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)	+= bq24190_charger.o
drivers/power/supply/mp2629_charger.c new file +686 -0

686 lines not on this page · raw message

Signature · 1 line
2.17.1
#10 lore raw

Re: [PATCH v5 4/5] power: supply: Add support for mps mp2629 battery charger

Quoted 4 lines · Saravanan Sekar

The mp2629 provides switching-mode battery charge management for single-cell Li-ion or Li-polymer battery. Driver supports the access/control input source and battery charging parameters.

...

drivers/power/supply/mp2629_charger.c line 15

Quoted 2 lines
drivers/power/supply/mp2629_charger.c new file +2 -0
+#include <linux/module.h>
+#include <linux/of_device.h>

Missed header bits.h.

...

drivers/power/supply/mp2629_charger.c line 164

Quoted 3 lines
drivers/power/supply/mp2629_charger.c new file +2 -0
+       ret = iio_read_channel_processed(charger->iiochan[ch], &chval);
 
+       if (ret < 0)

Is it possible to get positive returned value?

Quoted 1 line

+ return ret;

...

Quoted 1 line

+ val->intval = (rval * props[fld].step) + props[fld].min;

Too many parentheses.

...

drivers/power/supply/mp2629_charger.c line 437

Quoted 4 lines
drivers/power/supply/mp2629_charger.c new file +4 -0
+       return ((psp == POWER_SUPPLY_PROP_PRECHARGE_CURRENT) ||
+               (psp == POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT) ||
+               (psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT) ||
+               (psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE));

Ditto.

...

drivers/power/supply/mp2629_charger.c line 444

Quoted 2 lines
drivers/power/supply/mp2629_charger.c new file +2 -0
+       return ((psp == POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT) ||
+               (psp == POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT));

Ditto.

...

Quoted 1 line

+ return sprintf(buf, "%d mohm\n", rval);

Hmm... For units we usually have separate node, but it is up to maintainer, I dunno what the common practice is there.

...

drivers/power/supply/mp2629_charger.c line 547

Quoted 9 lines
drivers/power/supply/mp2629_charger.c new file +8 -0
+       int val;
+       int ret;
+
+       ret = kstrtoint(buf, 10, &val);
+       if (ret)
+               return ret;
+
 
+       if (val < 0 && val > 140)

What the point to convert negative values in the first place? kstrtouint()

Quoted 1 line

+ return -ERANGE;

...

Quoted 1 line

+ struct power_supply_config psy_cfg = {NULL};

{ 0 }

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#11 lore raw

Re: [PATCH v5 4/5] power: supply: Add support for mps mp2629 battery charger

Quoted 3 lines · Andy Shevchenko
Quoted 1 line · Saravanan Sekar

+#include <linux/of_device.h>

Forget to tell, I haven't found evidence of the above being used.

Quoted 1 line

Missed header bits.h.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#12 lore raw

Re: [PATCH v5 4/5] power: supply: Add support for mps mp2629 battery charger

In reply to Andy Shevchenko

Hi Andy,

Quoted 10 lines · Andy Shevchenko
Quoted 3 lines · Saravanan Sekar

The mp2629 provides switching-mode battery charge management for single-cell Li-ion or Li-polymer battery. Driver supports the access/control input source and battery charging parameters.

...

drivers/power/supply/mp2629_charger.c line 15

Quoted 2 lines
drivers/power/supply/mp2629_charger.c new file +2 -0
+#include <linux/module.h>
+#include <linux/of_device.h>

Missed header bits.h.

Quoted 5 lines

...

drivers/power/supply/mp2629_charger.c line 164

Quoted 2 lines
drivers/power/supply/mp2629_charger.c new file +2 -0
+       ret = iio_read_channel_processed(charger->iiochan[ch], &chval);
+       if (ret < 0)

Is it possible to get positive returned value?

Really not for processed

Quoted 6 lines
Quoted 1 line

+ return ret;

...

Quoted 1 line

+ val->intval = (rval * props[fld].step) + props[fld].min;

Too many parentheses.

Quoted 7 lines

...

drivers/power/supply/mp2629_charger.c line 437

Quoted 4 lines
drivers/power/supply/mp2629_charger.c new file +4 -0
+       return ((psp == POWER_SUPPLY_PROP_PRECHARGE_CURRENT) ||
+               (psp == POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT) ||
+               (psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT) ||
+               (psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE));

Ditto.

I think I misunderstood you previous review comment "Redundant parentheses", no sure what is the expectation

Quoted 15 lines

...

drivers/power/supply/mp2629_charger.c line 444

Quoted 2 lines
drivers/power/supply/mp2629_charger.c new file +2 -0
+       return ((psp == POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT) ||
+               (psp == POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT));

Ditto.

...

Quoted 1 line

+ return sprintf(buf, "%d mohm\n", rval);

Hmm... For units we usually have separate node, but it is up to maintainer, I dunno what the common practice is there.

...

Quoted 9 lines

drivers/power/supply/mp2629_charger.c line 547

Quoted 8 lines
drivers/power/supply/mp2629_charger.c new file +8 -0
+       int val;
+       int ret;
+
+       ret = kstrtoint(buf, 10, &val);
+       if (ret)
+               return ret;
+
+       if (val < 0 && val > 140)

What the point to convert negative values in the first place? kstrtouint()

Done

Quoted 6 lines
Quoted 1 line

+ return -ERANGE;

...

Quoted 1 line

+ struct power_supply_config psy_cfg = {NULL};

{ 0 }

NULL to make compiler happy.

#13 lore raw

Re: [PATCH v5 4/5] power: supply: Add support for mps mp2629 battery charger

Quoted 2 lines · saravanan sekar
Quoted 1 line · Andy Shevchenko

On Sat, Mar 28, 2020 at 2:12 AM Saravanan Sekar <[email protected]> wrote:

...

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

+ val->intval = (rval * props[fld].step) + props[fld].min;

Too many parentheses.

...

Quoted 7 lines
Quoted 5 lines

drivers/power/supply/mp2629_charger.c line 437

Quoted 4 lines
drivers/power/supply/mp2629_charger.c new file +4 -0
+       return ((psp == POWER_SUPPLY_PROP_PRECHARGE_CURRENT) ||
+               (psp == POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT) ||
+               (psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT) ||
+               (psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE));

Ditto.

I think I misunderstood you previous review comment "Redundant parentheses", no sure what is the expectation

(At least) surrounding pair is not needed, return (a == b) || (c == d);

Quoted 5 lines
Quoted 5 lines

...

drivers/power/supply/mp2629_charger.c line 444

Quoted 2 lines
drivers/power/supply/mp2629_charger.c new file +2 -0
+       return ((psp == POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT) ||
+               (psp == POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT));

Ditto.

...

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

+ struct power_supply_config psy_cfg = {NULL};

{ 0 }

NULL to make compiler happy.

Hmm... Can you share warning / error compiler issued in 0 case?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#14 lore raw

Re: [PATCH v5 4/5] power: supply: Add support for mps mp2629 battery charger

Hi Andy,

Quoted 10 lines · Andy Shevchenko
Quoted 2 lines · saravanan sekar
Quoted 1 line · Andy Shevchenko

On Sat, Mar 28, 2020 at 2:12 AM Saravanan Sekar <[email protected]> wrote:

...

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

+ val->intval = (rval * props[fld].step) + props[fld].min;

Too many parentheses.

...

Quoted 8 lines
Quoted 7 lines
Quoted 5 lines

drivers/power/supply/mp2629_charger.c line 437

Quoted 4 lines
drivers/power/supply/mp2629_charger.c new file +4 -0
+       return ((psp == POWER_SUPPLY_PROP_PRECHARGE_CURRENT) ||
+               (psp == POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT) ||
+               (psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT) ||
+               (psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE));

Ditto.

I think I misunderstood you previous review comment "Redundant parentheses", no sure what is the expectation

(At least) surrounding pair is not needed, return (a == b) || (c == d);

ok, I will remove outer ().

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

...

Quoted 2 lines
drivers/power/supply/mp2629_charger.c new file +2 -0
+       return ((psp == POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT) ||
+               (psp == POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT));
Quoted 9 lines
Quoted 1 line
Quoted 1 line

Ditto.

...

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

+ struct power_supply_config psy_cfg = {NULL};

{ 0 }

NULL to make compiler happy.

Hmm... Can you share warning / error compiler issued in 0 case?

Please see the 0-day warning.

"Reported-by: kbuild test robot <[email protected]>
sparse warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

drivers/power/supply/mp2629_charger.c:584:47: sparse: sparse: Using plain integer as NULL pointer"

#15 lore raw

Re: [PATCH v5 4/5] power: supply: Add support for mps mp2629 battery charger

Quoted 4 lines · saravanan sekar
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · saravanan sekar
Quoted 1 line · Andy Shevchenko

On Sat, Mar 28, 2020 at 2:12 AM Saravanan Sekar <[email protected]> wrote:

...

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

+ struct power_supply_config psy_cfg = {NULL};

{ 0 }

NULL to make compiler happy.

Quoted 8 lines
Quoted 2 lines

Hmm... Can you share warning / error compiler issued in 0 case?

Please see the 0-day warning.

"Reported-by: kbuild test robot <[email protected]>
sparse warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

drivers/power/supply/mp2629_charger.c:584:47: sparse: sparse: Using

plain integer as NULL pointer"

I see. Grepping the code shows that for this certain structure other drivers are using simple '{}'. Can you align with them?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#16 lore raw

PATCH v5 5/5 MAINTAINERS: Add entry for mp2629 Battery Charger driver

In reply to Saravanan Sekar

Add MAINTAINERS entry for Monolithic Power Systems mp2629 Charger driver.

---
 MAINTAINERS | 5 +++++
 1 file changed, 5 insertions(+)
MAINTAINERS +5 -0
index 32a95d162f06..0f82d5a7a614 100644
@@ -11358,10 +11358,15 @@ F:	drivers/tty/mxser.*
 MONOLITHIC POWER SYSTEM PMIC DRIVER
 M:	Saravanan Sekar <[email protected]>
 S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/mps,mp2629.yaml
 F:	Documentation/devicetree/bindings/regulator/mps,mp*.yaml
+F:	drivers/iio/adc/mp2629_adc.c
+F:	drivers/mfd/mp2629.c
+F:	drivers/power/supply/mp2629_charger.c
 F:	drivers/regulator/mp5416.c
 F:	drivers/regulator/mpq7920.c
 F:	drivers/regulator/mpq7920.h
+F:	include/linux/mfd/mp2629.h
 
 MR800 AVERMEDIA USB FM RADIO DRIVER
 M:	Alexey Klimov <[email protected]>
Signature · 1 line
2.17.1