All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/3] adp5061: Add support for battery charging enable
@ 2018-04-04  8:17 ` Stefan Popa
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Popa @ 2018-04-04  8:17 UTC (permalink / raw)
  To: sre
  Cc: davem, mchehab, gregkh, linus.walleij, akpm, rdunlap, linux-pm,
	linux-kernel, stefan.popa

This patch adds the option to enable/disable battery charging. This
option is not configurable via the power_supply properties, therefore,
access via sysfs was provided to examine and modify this attribute on the
fly.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
---
 .../ABI/testing/sysfs-class-power-adp5061          | 10 ++++
 MAINTAINERS                                        |  1 +
 drivers/power/supply/adp5061.c                     | 62 ++++++++++++++++++++++
 3 files changed, 73 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-power-adp5061

diff --git a/Documentation/ABI/testing/sysfs-class-power-adp5061 b/Documentation/ABI/testing/sysfs-class-power-adp5061
new file mode 100644
index 0000000..0d056aa
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-power-adp5061
@@ -0,0 +1,10 @@
+What: /sys/class/power_supply/adp5061/charging_enabled
+Description:
+	Enable/disable battery charging.
+
+	The ADP5061 charging function can be enabled by setting
+	this attribute to 1. See device datasheet for details.
+
+	Valid values:
+		- 1: enabled
+		- 0: disabled
diff --git a/MAINTAINERS b/MAINTAINERS
index a9ca73b..9271246 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -804,6 +804,7 @@ W:	http://ez.analog.com/community/linux-device-drivers
 S:	Supported
 F:	Documentation/devicetree/bindings/power/supply/adp5061.txt
 F:	drivers/power/supply/adp5061.c
+F:	Documentation/ABI/testing/sysfs-class-power-adp5061
 
 ANALOG DEVICES INC ADV7180 DRIVER
 M:	Lars-Peter Clausen <lars@metafoo.de>
diff --git a/drivers/power/supply/adp5061.c b/drivers/power/supply/adp5061.c
index c00a02e..7cd2e67 100644
--- a/drivers/power/supply/adp5061.c
+++ b/drivers/power/supply/adp5061.c
@@ -79,6 +79,10 @@
 #define ADP5061_IEND_IEND_MSK			GENMASK(7, 5)
 #define ADP5061_IEND_IEND_MODE(x)		(((x) & 0x07) << 5)
 
+/* ADP5061_FUNC_SET_1 */
+#define ADP5061_FUNC_SET_1_EN_CHG_MSK		BIT(0)
+#define ADP5061_FUNC_SET_1_EN_CHG_MODE(x)	(((x) & 0x01) << 0)
+
 #define ADP5061_NO_BATTERY	0x01
 #define ADP5061_ICHG_MAX	1300 // mA
 
@@ -692,11 +696,63 @@ static const struct power_supply_desc adp5061_desc = {
 	.num_properties		= ARRAY_SIZE(adp5061_props),
 };
 
+static int charging_enabled_show(struct device *dev,
+				 struct device_attribute *attr,
+				 char *buf)
+{
+	struct power_supply *psy = dev_get_drvdata(dev);
+	struct adp5061_state *st = power_supply_get_drvdata(psy);
+	unsigned int regval;
+	int ret;
+
+	ret = regmap_read(st->regmap, ADP5061_FUNC_SET_1, &regval);
+	if (ret < 0)
+		return ret;
+
+	regval &= ADP5061_FUNC_SET_1_EN_CHG_MSK;
+	return sprintf(buf, "%d\n", regval);
+}
+
+static int charging_enabled_store(struct device *dev,
+				  struct device_attribute *attr,
+				  const char *buf, size_t count)
+{
+	struct power_supply *psy = dev_get_drvdata(dev);
+	struct adp5061_state *st = power_supply_get_drvdata(psy);
+	u8 chg_en;
+	int ret;
+
+	ret = kstrtou8(buf, 0, &chg_en);
+	if (ret < 0)
+		return ret;
+
+	ret = regmap_update_bits(st->regmap, ADP5061_FUNC_SET_1,
+				 ADP5061_FUNC_SET_1_EN_CHG_MSK,
+				 ADP5061_FUNC_SET_1_EN_CHG_MODE(!!chg_en));
+
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static DEVICE_ATTR_RW(charging_enabled);
+
+static struct attribute *adp5061_attributes[] = {
+	&dev_attr_charging_enabled.attr,
+	NULL
+};
+
+static const struct attribute_group adp5061_attr_group = {
+	.attrs = adp5061_attributes,
+};
+
 static int adp5061_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
 	struct power_supply_config psy_cfg = {};
 	struct adp5061_state *st;
+	int ret;
 
 	st = devm_kzalloc(&client->dev, sizeof(*st), GFP_KERNEL);
 	if (!st)
@@ -722,6 +778,12 @@ static int adp5061_probe(struct i2c_client *client,
 		return PTR_ERR(st->psy);
 	}
 
+	ret = sysfs_create_group(&st->psy->dev.kobj, &adp5061_attr_group);
+	if (ret < 0) {
+		dev_err(&client->dev, "failed to create sysfs group\n");
+		return ret;
+	}
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/3] adp5061: Add support for battery charging enable
@ 2018-04-04  8:17 ` Stefan Popa
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Popa @ 2018-04-04  8:17 UTC (permalink / raw)
  To: sre
  Cc: davem, mchehab, gregkh, linus.walleij, akpm, rdunlap, linux-pm,
	linux-kernel, stefan.popa

This patch adds the option to enable/disable battery charging. This
option is not configurable via the power_supply properties, therefore,
access via sysfs was provided to examine and modify this attribute on the
fly.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
---
 .../ABI/testing/sysfs-class-power-adp5061          | 10 ++++
 MAINTAINERS                                        |  1 +
 drivers/power/supply/adp5061.c                     | 62 ++++++++++++++++++++++
 3 files changed, 73 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-power-adp5061

diff --git a/Documentation/ABI/testing/sysfs-class-power-adp5061 b/Documentation/ABI/testing/sysfs-class-power-adp5061
new file mode 100644
index 0000000..0d056aa
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-power-adp5061
@@ -0,0 +1,10 @@
+What: /sys/class/power_supply/adp5061/charging_enabled
+Description:
+	Enable/disable battery charging.
+
+	The ADP5061 charging function can be enabled by setting
+	this attribute to 1. See device datasheet for details.
+
+	Valid values:
+		- 1: enabled
+		- 0: disabled
diff --git a/MAINTAINERS b/MAINTAINERS
index a9ca73b..9271246 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -804,6 +804,7 @@ W:	http://ez.analog.com/community/linux-device-drivers
 S:	Supported
 F:	Documentation/devicetree/bindings/power/supply/adp5061.txt
 F:	drivers/power/supply/adp5061.c
+F:	Documentation/ABI/testing/sysfs-class-power-adp5061
 
 ANALOG DEVICES INC ADV7180 DRIVER
 M:	Lars-Peter Clausen <lars@metafoo.de>
diff --git a/drivers/power/supply/adp5061.c b/drivers/power/supply/adp5061.c
index c00a02e..7cd2e67 100644
--- a/drivers/power/supply/adp5061.c
+++ b/drivers/power/supply/adp5061.c
@@ -79,6 +79,10 @@
 #define ADP5061_IEND_IEND_MSK			GENMASK(7, 5)
 #define ADP5061_IEND_IEND_MODE(x)		(((x) & 0x07) << 5)
 
+/* ADP5061_FUNC_SET_1 */
+#define ADP5061_FUNC_SET_1_EN_CHG_MSK		BIT(0)
+#define ADP5061_FUNC_SET_1_EN_CHG_MODE(x)	(((x) & 0x01) << 0)
+
 #define ADP5061_NO_BATTERY	0x01
 #define ADP5061_ICHG_MAX	1300 // mA
 
@@ -692,11 +696,63 @@ static const struct power_supply_desc adp5061_desc = {
 	.num_properties		= ARRAY_SIZE(adp5061_props),
 };
 
+static int charging_enabled_show(struct device *dev,
+				 struct device_attribute *attr,
+				 char *buf)
+{
+	struct power_supply *psy = dev_get_drvdata(dev);
+	struct adp5061_state *st = power_supply_get_drvdata(psy);
+	unsigned int regval;
+	int ret;
+
+	ret = regmap_read(st->regmap, ADP5061_FUNC_SET_1, &regval);
+	if (ret < 0)
+		return ret;
+
+	regval &= ADP5061_FUNC_SET_1_EN_CHG_MSK;
+	return sprintf(buf, "%d\n", regval);
+}
+
+static int charging_enabled_store(struct device *dev,
+				  struct device_attribute *attr,
+				  const char *buf, size_t count)
+{
+	struct power_supply *psy = dev_get_drvdata(dev);
+	struct adp5061_state *st = power_supply_get_drvdata(psy);
+	u8 chg_en;
+	int ret;
+
+	ret = kstrtou8(buf, 0, &chg_en);
+	if (ret < 0)
+		return ret;
+
+	ret = regmap_update_bits(st->regmap, ADP5061_FUNC_SET_1,
+				 ADP5061_FUNC_SET_1_EN_CHG_MSK,
+				 ADP5061_FUNC_SET_1_EN_CHG_MODE(!!chg_en));
+
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static DEVICE_ATTR_RW(charging_enabled);
+
+static struct attribute *adp5061_attributes[] = {
+	&dev_attr_charging_enabled.attr,
+	NULL
+};
+
+static const struct attribute_group adp5061_attr_group = {
+	.attrs = adp5061_attributes,
+};
+
 static int adp5061_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
 	struct power_supply_config psy_cfg = {};
 	struct adp5061_state *st;
+	int ret;
 
 	st = devm_kzalloc(&client->dev, sizeof(*st), GFP_KERNEL);
 	if (!st)
@@ -722,6 +778,12 @@ static int adp5061_probe(struct i2c_client *client,
 		return PTR_ERR(st->psy);
 	}
 
+	ret = sysfs_create_group(&st->psy->dev.kobj, &adp5061_attr_group);
+	if (ret < 0) {
+		dev_err(&client->dev, "failed to create sysfs group\n");
+		return ret;
+	}
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/3] adp5061: Add support for battery charging enable
  2018-04-04  8:17 ` Stefan Popa
@ 2018-04-04 17:01   ` kbuild test robot
  -1 siblings, 0 replies; 13+ messages in thread
From: kbuild test robot @ 2018-04-04 17:01 UTC (permalink / raw)
  To: Stefan Popa
  Cc: kbuild-all, sre, davem, mchehab, gregkh, linus.walleij, akpm,
	rdunlap, linux-pm, linux-kernel, stefan.popa

[-- Attachment #1: Type: text/plain, Size: 3919 bytes --]

Hi Stefan,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.16 next-20180404]
[cannot apply to battery/master]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Stefan-Popa/adp5061-New-driver-for-ADP5061-I2C-battery-charger/20180405-000342
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=ia64 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/kobject.h:20:0,
                    from include/linux/module.h:17,
                    from drivers/power/supply/adp5061.c:10:
>> drivers/power/supply/adp5061.c:739:23: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
    static DEVICE_ATTR_RW(charging_enabled);
                          ^
   include/linux/sysfs.h:104:10: note: in definition of macro '__ATTR'
     .show = _show,      \
             ^~~~~
   include/linux/device.h:581:45: note: in expansion of macro '__ATTR_RW'
     struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
                                                ^~~~~~~~~
>> drivers/power/supply/adp5061.c:739:8: note: in expansion of macro 'DEVICE_ATTR_RW'
    static DEVICE_ATTR_RW(charging_enabled);
           ^~~~~~~~~~~~~~
   drivers/power/supply/adp5061.c:739:23: note: (near initialization for 'dev_attr_charging_enabled.show')
    static DEVICE_ATTR_RW(charging_enabled);
                          ^
   include/linux/sysfs.h:104:10: note: in definition of macro '__ATTR'
     .show = _show,      \
             ^~~~~
   include/linux/device.h:581:45: note: in expansion of macro '__ATTR_RW'
     struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
                                                ^~~~~~~~~
>> drivers/power/supply/adp5061.c:739:8: note: in expansion of macro 'DEVICE_ATTR_RW'
    static DEVICE_ATTR_RW(charging_enabled);
           ^~~~~~~~~~~~~~
>> drivers/power/supply/adp5061.c:739:23: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
    static DEVICE_ATTR_RW(charging_enabled);
                          ^
   include/linux/sysfs.h:105:11: note: in definition of macro '__ATTR'
     .store = _store,      \
              ^~~~~~
   include/linux/device.h:581:45: note: in expansion of macro '__ATTR_RW'
     struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
                                                ^~~~~~~~~
>> drivers/power/supply/adp5061.c:739:8: note: in expansion of macro 'DEVICE_ATTR_RW'
    static DEVICE_ATTR_RW(charging_enabled);
           ^~~~~~~~~~~~~~
   drivers/power/supply/adp5061.c:739:23: note: (near initialization for 'dev_attr_charging_enabled.store')
    static DEVICE_ATTR_RW(charging_enabled);
                          ^
   include/linux/sysfs.h:105:11: note: in definition of macro '__ATTR'
     .store = _store,      \
              ^~~~~~
   include/linux/device.h:581:45: note: in expansion of macro '__ATTR_RW'
     struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
                                                ^~~~~~~~~
>> drivers/power/supply/adp5061.c:739:8: note: in expansion of macro 'DEVICE_ATTR_RW'
    static DEVICE_ATTR_RW(charging_enabled);
           ^~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +739 drivers/power/supply/adp5061.c

   738	
 > 739	static DEVICE_ATTR_RW(charging_enabled);
   740	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 49774 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/3] adp5061: Add support for battery charging enable
@ 2018-04-04 17:01   ` kbuild test robot
  0 siblings, 0 replies; 13+ messages in thread
From: kbuild test robot @ 2018-04-04 17:01 UTC (permalink / raw)
  Cc: kbuild-all, sre, davem, mchehab, gregkh, linus.walleij, akpm,
	rdunlap, linux-pm, linux-kernel, stefan.popa

[-- Attachment #1: Type: text/plain, Size: 3919 bytes --]

Hi Stefan,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.16 next-20180404]
[cannot apply to battery/master]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Stefan-Popa/adp5061-New-driver-for-ADP5061-I2C-battery-charger/20180405-000342
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=ia64 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/kobject.h:20:0,
                    from include/linux/module.h:17,
                    from drivers/power/supply/adp5061.c:10:
>> drivers/power/supply/adp5061.c:739:23: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
    static DEVICE_ATTR_RW(charging_enabled);
                          ^
   include/linux/sysfs.h:104:10: note: in definition of macro '__ATTR'
     .show = _show,      \
             ^~~~~
   include/linux/device.h:581:45: note: in expansion of macro '__ATTR_RW'
     struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
                                                ^~~~~~~~~
>> drivers/power/supply/adp5061.c:739:8: note: in expansion of macro 'DEVICE_ATTR_RW'
    static DEVICE_ATTR_RW(charging_enabled);
           ^~~~~~~~~~~~~~
   drivers/power/supply/adp5061.c:739:23: note: (near initialization for 'dev_attr_charging_enabled.show')
    static DEVICE_ATTR_RW(charging_enabled);
                          ^
   include/linux/sysfs.h:104:10: note: in definition of macro '__ATTR'
     .show = _show,      \
             ^~~~~
   include/linux/device.h:581:45: note: in expansion of macro '__ATTR_RW'
     struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
                                                ^~~~~~~~~
>> drivers/power/supply/adp5061.c:739:8: note: in expansion of macro 'DEVICE_ATTR_RW'
    static DEVICE_ATTR_RW(charging_enabled);
           ^~~~~~~~~~~~~~
>> drivers/power/supply/adp5061.c:739:23: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
    static DEVICE_ATTR_RW(charging_enabled);
                          ^
   include/linux/sysfs.h:105:11: note: in definition of macro '__ATTR'
     .store = _store,      \
              ^~~~~~
   include/linux/device.h:581:45: note: in expansion of macro '__ATTR_RW'
     struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
                                                ^~~~~~~~~
>> drivers/power/supply/adp5061.c:739:8: note: in expansion of macro 'DEVICE_ATTR_RW'
    static DEVICE_ATTR_RW(charging_enabled);
           ^~~~~~~~~~~~~~
   drivers/power/supply/adp5061.c:739:23: note: (near initialization for 'dev_attr_charging_enabled.store')
    static DEVICE_ATTR_RW(charging_enabled);
                          ^
   include/linux/sysfs.h:105:11: note: in definition of macro '__ATTR'
     .store = _store,      \
              ^~~~~~
   include/linux/device.h:581:45: note: in expansion of macro '__ATTR_RW'
     struct device_attribute dev_attr_##_name = __ATTR_RW(_name)
                                                ^~~~~~~~~
>> drivers/power/supply/adp5061.c:739:8: note: in expansion of macro 'DEVICE_ATTR_RW'
    static DEVICE_ATTR_RW(charging_enabled);
           ^~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +739 drivers/power/supply/adp5061.c

   738	
 > 739	static DEVICE_ATTR_RW(charging_enabled);
   740	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 49774 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 2/3] adp5061: Add support for battery charging enable
  2018-04-04  8:17 ` Stefan Popa
@ 2018-04-10  9:51   ` Stefan Popa
  -1 siblings, 0 replies; 13+ messages in thread
From: Stefan Popa @ 2018-04-10  9:51 UTC (permalink / raw)
  To: sre
  Cc: davem, mchehab, gregkh, linus.walleij, akpm, rdunlap, linux-pm,
	linux-kernel, stefan.popa

This patch adds the option to enable/disable battery charging. This
option is not configurable via the power_supply properties, therefore,
access via sysfs was provided to examine and modify this attribute on the
fly.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
---
Changes in v2:
  - Fixed kbuild test error by changing the type of the
    charging_enabled_show() and charging_enabled_store() functions from
    int to ssize_t.

 .../ABI/testing/sysfs-class-power-adp5061          | 10 ++++
 MAINTAINERS                                        |  1 +
 drivers/power/supply/adp5061.c                     | 63 ++++++++++++++++++++++
 3 files changed, 74 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-power-adp5061

diff --git a/Documentation/ABI/testing/sysfs-class-power-adp5061 b/Documentation/ABI/testing/sysfs-class-power-adp5061
new file mode 100644
index 0000000..0d056aa
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-power-adp5061
@@ -0,0 +1,10 @@
+What: /sys/class/power_supply/adp5061/charging_enabled
+Description:
+	Enable/disable battery charging.
+
+	The ADP5061 charging function can be enabled by setting
+	this attribute to 1. See device datasheet for details.
+
+	Valid values:
+		- 1: enabled
+		- 0: disabled
diff --git a/MAINTAINERS b/MAINTAINERS
index a9ca73b..9271246 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -804,6 +804,7 @@ W:	http://ez.analog.com/community/linux-device-drivers
 S:	Supported
 F:	Documentation/devicetree/bindings/power/supply/adp5061.txt
 F:	drivers/power/supply/adp5061.c
+F:	Documentation/ABI/testing/sysfs-class-power-adp5061
 
 ANALOG DEVICES INC ADV7180 DRIVER
 M:	Lars-Peter Clausen <lars@metafoo.de>
diff --git a/drivers/power/supply/adp5061.c b/drivers/power/supply/adp5061.c
index c00a02e..99871e6 100644
--- a/drivers/power/supply/adp5061.c
+++ b/drivers/power/supply/adp5061.c
@@ -18,6 +18,7 @@
 #include <linux/of.h>
 #include <linux/regmap.h>
 
+
 /* ADP5061 registers definition */
 #define ADP5061_ID			0x00
 #define ADP5061_REV			0x01
@@ -79,6 +80,10 @@
 #define ADP5061_IEND_IEND_MSK			GENMASK(7, 5)
 #define ADP5061_IEND_IEND_MODE(x)		(((x) & 0x07) << 5)
 
+/* ADP5061_FUNC_SET_1 */
+#define ADP5061_FUNC_SET_1_EN_CHG_MSK		BIT(0)
+#define ADP5061_FUNC_SET_1_EN_CHG_MODE(x)	(((x) & 0x01) << 0)
+
 #define ADP5061_NO_BATTERY	0x01
 #define ADP5061_ICHG_MAX	1300 // mA
 
@@ -692,11 +697,63 @@ static const struct power_supply_desc adp5061_desc = {
 	.num_properties		= ARRAY_SIZE(adp5061_props),
 };
 
+static ssize_t charging_enabled_show(struct device *dev,
+				 struct device_attribute *attr,
+				 char *buf)
+{
+	struct power_supply *psy = dev_get_drvdata(dev);
+	struct adp5061_state *st = power_supply_get_drvdata(psy);
+	unsigned int regval;
+	int ret;
+
+	ret = regmap_read(st->regmap, ADP5061_FUNC_SET_1, &regval);
+	if (ret < 0)
+		return ret;
+
+	regval &= ADP5061_FUNC_SET_1_EN_CHG_MSK;
+	return sprintf(buf, "%d\n", regval);
+}
+
+static ssize_t charging_enabled_store(struct device *dev,
+				  struct device_attribute *attr,
+				  const char *buf, size_t count)
+{
+	struct power_supply *psy = dev_get_drvdata(dev);
+	struct adp5061_state *st = power_supply_get_drvdata(psy);
+	u8 chg_en;
+	int ret;
+
+	ret = kstrtou8(buf, 0, &chg_en);
+	if (ret < 0)
+		return ret;
+
+	ret = regmap_update_bits(st->regmap, ADP5061_FUNC_SET_1,
+				 ADP5061_FUNC_SET_1_EN_CHG_MSK,
+				 ADP5061_FUNC_SET_1_EN_CHG_MODE(!!chg_en));
+
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static DEVICE_ATTR_RW(charging_enabled);
+
+static struct attribute *adp5061_attributes[] = {
+	&dev_attr_charging_enabled.attr,
+	NULL
+};
+
+static const struct attribute_group adp5061_attr_group = {
+	.attrs = adp5061_attributes,
+};
+
 static int adp5061_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
 	struct power_supply_config psy_cfg = {};
 	struct adp5061_state *st;
+	int ret;
 
 	st = devm_kzalloc(&client->dev, sizeof(*st), GFP_KERNEL);
 	if (!st)
@@ -722,6 +779,12 @@ static int adp5061_probe(struct i2c_client *client,
 		return PTR_ERR(st->psy);
 	}
 
+	ret = sysfs_create_group(&st->psy->dev.kobj, &adp5061_attr_group);
+	if (ret < 0) {
+		dev_err(&client->dev, "failed to create sysfs group\n");
+		return ret;
+	}
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 2/3] adp5061: Add support for battery charging enable
@ 2018-04-10  9:51   ` Stefan Popa
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Popa @ 2018-04-10  9:51 UTC (permalink / raw)
  To: sre
  Cc: davem, mchehab, gregkh, linus.walleij, akpm, rdunlap, linux-pm,
	linux-kernel, stefan.popa

This patch adds the option to enable/disable battery charging. This
option is not configurable via the power_supply properties, therefore,
access via sysfs was provided to examine and modify this attribute on the
fly.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
---
Changes in v2:
  - Fixed kbuild test error by changing the type of the
    charging_enabled_show() and charging_enabled_store() functions from
    int to ssize_t.

 .../ABI/testing/sysfs-class-power-adp5061          | 10 ++++
 MAINTAINERS                                        |  1 +
 drivers/power/supply/adp5061.c                     | 63 ++++++++++++++++++++++
 3 files changed, 74 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-power-adp5061

diff --git a/Documentation/ABI/testing/sysfs-class-power-adp5061 b/Documentation/ABI/testing/sysfs-class-power-adp5061
new file mode 100644
index 0000000..0d056aa
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-power-adp5061
@@ -0,0 +1,10 @@
+What: /sys/class/power_supply/adp5061/charging_enabled
+Description:
+	Enable/disable battery charging.
+
+	The ADP5061 charging function can be enabled by setting
+	this attribute to 1. See device datasheet for details.
+
+	Valid values:
+		- 1: enabled
+		- 0: disabled
diff --git a/MAINTAINERS b/MAINTAINERS
index a9ca73b..9271246 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -804,6 +804,7 @@ W:	http://ez.analog.com/community/linux-device-drivers
 S:	Supported
 F:	Documentation/devicetree/bindings/power/supply/adp5061.txt
 F:	drivers/power/supply/adp5061.c
+F:	Documentation/ABI/testing/sysfs-class-power-adp5061
 
 ANALOG DEVICES INC ADV7180 DRIVER
 M:	Lars-Peter Clausen <lars@metafoo.de>
diff --git a/drivers/power/supply/adp5061.c b/drivers/power/supply/adp5061.c
index c00a02e..99871e6 100644
--- a/drivers/power/supply/adp5061.c
+++ b/drivers/power/supply/adp5061.c
@@ -18,6 +18,7 @@
 #include <linux/of.h>
 #include <linux/regmap.h>
 
+
 /* ADP5061 registers definition */
 #define ADP5061_ID			0x00
 #define ADP5061_REV			0x01
@@ -79,6 +80,10 @@
 #define ADP5061_IEND_IEND_MSK			GENMASK(7, 5)
 #define ADP5061_IEND_IEND_MODE(x)		(((x) & 0x07) << 5)
 
+/* ADP5061_FUNC_SET_1 */
+#define ADP5061_FUNC_SET_1_EN_CHG_MSK		BIT(0)
+#define ADP5061_FUNC_SET_1_EN_CHG_MODE(x)	(((x) & 0x01) << 0)
+
 #define ADP5061_NO_BATTERY	0x01
 #define ADP5061_ICHG_MAX	1300 // mA
 
@@ -692,11 +697,63 @@ static const struct power_supply_desc adp5061_desc = {
 	.num_properties		= ARRAY_SIZE(adp5061_props),
 };
 
+static ssize_t charging_enabled_show(struct device *dev,
+				 struct device_attribute *attr,
+				 char *buf)
+{
+	struct power_supply *psy = dev_get_drvdata(dev);
+	struct adp5061_state *st = power_supply_get_drvdata(psy);
+	unsigned int regval;
+	int ret;
+
+	ret = regmap_read(st->regmap, ADP5061_FUNC_SET_1, &regval);
+	if (ret < 0)
+		return ret;
+
+	regval &= ADP5061_FUNC_SET_1_EN_CHG_MSK;
+	return sprintf(buf, "%d\n", regval);
+}
+
+static ssize_t charging_enabled_store(struct device *dev,
+				  struct device_attribute *attr,
+				  const char *buf, size_t count)
+{
+	struct power_supply *psy = dev_get_drvdata(dev);
+	struct adp5061_state *st = power_supply_get_drvdata(psy);
+	u8 chg_en;
+	int ret;
+
+	ret = kstrtou8(buf, 0, &chg_en);
+	if (ret < 0)
+		return ret;
+
+	ret = regmap_update_bits(st->regmap, ADP5061_FUNC_SET_1,
+				 ADP5061_FUNC_SET_1_EN_CHG_MSK,
+				 ADP5061_FUNC_SET_1_EN_CHG_MODE(!!chg_en));
+
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static DEVICE_ATTR_RW(charging_enabled);
+
+static struct attribute *adp5061_attributes[] = {
+	&dev_attr_charging_enabled.attr,
+	NULL
+};
+
+static const struct attribute_group adp5061_attr_group = {
+	.attrs = adp5061_attributes,
+};
+
 static int adp5061_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
 	struct power_supply_config psy_cfg = {};
 	struct adp5061_state *st;
+	int ret;
 
 	st = devm_kzalloc(&client->dev, sizeof(*st), GFP_KERNEL);
 	if (!st)
@@ -722,6 +779,12 @@ static int adp5061_probe(struct i2c_client *client,
 		return PTR_ERR(st->psy);
 	}
 
+	ret = sysfs_create_group(&st->psy->dev.kobj, &adp5061_attr_group);
+	if (ret < 0) {
+		dev_err(&client->dev, "failed to create sysfs group\n");
+		return ret;
+	}
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 3/4] adp5061: Add support for battery charging enable
  2018-04-10  9:51   ` Stefan Popa
@ 2018-04-11 15:10     ` Stefan Popa
  -1 siblings, 0 replies; 13+ messages in thread
From: Stefan Popa @ 2018-04-11 15:10 UTC (permalink / raw)
  To: sre
  Cc: davem, mchehab, gregkh, linus.walleij, akpm, rdunlap, linux-pm,
	linux-kernel, stefan.popa

This patch adds the option to enable/disable battery charging. This
option is not configurable via the power_supply properties, therefore,
access via sysfs was provided to examine and modify this attribute on the
fly.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
---
Changes in v2:
	- Fixed kbuild test error by changing the type of the
	  charging_enabled_show() and charging_enabled_store() functions
	  from int to ssize_t.
Changes in v3:
	- Nothing changed, just to follow the patch set version.

 .../ABI/testing/sysfs-class-power-adp5061          | 10 ++++
 MAINTAINERS                                        |  1 +
 drivers/power/supply/adp5061.c                     | 63 ++++++++++++++++++++++
 3 files changed, 74 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-power-adp5061

diff --git a/Documentation/ABI/testing/sysfs-class-power-adp5061 b/Documentation/ABI/testing/sysfs-class-power-adp5061
new file mode 100644
index 0000000..0d056aa
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-power-adp5061
@@ -0,0 +1,10 @@
+What: /sys/class/power_supply/adp5061/charging_enabled
+Description:
+	Enable/disable battery charging.
+
+	The ADP5061 charging function can be enabled by setting
+	this attribute to 1. See device datasheet for details.
+
+	Valid values:
+		- 1: enabled
+		- 0: disabled
diff --git a/MAINTAINERS b/MAINTAINERS
index a9ca73b..9271246 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -804,6 +804,7 @@ W:	http://ez.analog.com/community/linux-device-drivers
 S:	Supported
 F:	Documentation/devicetree/bindings/power/supply/adp5061.txt
 F:	drivers/power/supply/adp5061.c
+F:	Documentation/ABI/testing/sysfs-class-power-adp5061
 
 ANALOG DEVICES INC ADV7180 DRIVER
 M:	Lars-Peter Clausen <lars@metafoo.de>
diff --git a/drivers/power/supply/adp5061.c b/drivers/power/supply/adp5061.c
index c00a02e..99871e6 100644
--- a/drivers/power/supply/adp5061.c
+++ b/drivers/power/supply/adp5061.c
@@ -18,6 +18,7 @@
 #include <linux/of.h>
 #include <linux/regmap.h>
 
+
 /* ADP5061 registers definition */
 #define ADP5061_ID			0x00
 #define ADP5061_REV			0x01
@@ -79,6 +80,10 @@
 #define ADP5061_IEND_IEND_MSK			GENMASK(7, 5)
 #define ADP5061_IEND_IEND_MODE(x)		(((x) & 0x07) << 5)
 
+/* ADP5061_FUNC_SET_1 */
+#define ADP5061_FUNC_SET_1_EN_CHG_MSK		BIT(0)
+#define ADP5061_FUNC_SET_1_EN_CHG_MODE(x)	(((x) & 0x01) << 0)
+
 #define ADP5061_NO_BATTERY	0x01
 #define ADP5061_ICHG_MAX	1300 // mA
 
@@ -692,11 +697,63 @@ static const struct power_supply_desc adp5061_desc = {
 	.num_properties		= ARRAY_SIZE(adp5061_props),
 };
 
+static ssize_t charging_enabled_show(struct device *dev,
+				 struct device_attribute *attr,
+				 char *buf)
+{
+	struct power_supply *psy = dev_get_drvdata(dev);
+	struct adp5061_state *st = power_supply_get_drvdata(psy);
+	unsigned int regval;
+	int ret;
+
+	ret = regmap_read(st->regmap, ADP5061_FUNC_SET_1, &regval);
+	if (ret < 0)
+		return ret;
+
+	regval &= ADP5061_FUNC_SET_1_EN_CHG_MSK;
+	return sprintf(buf, "%d\n", regval);
+}
+
+static ssize_t charging_enabled_store(struct device *dev,
+				  struct device_attribute *attr,
+				  const char *buf, size_t count)
+{
+	struct power_supply *psy = dev_get_drvdata(dev);
+	struct adp5061_state *st = power_supply_get_drvdata(psy);
+	u8 chg_en;
+	int ret;
+
+	ret = kstrtou8(buf, 0, &chg_en);
+	if (ret < 0)
+		return ret;
+
+	ret = regmap_update_bits(st->regmap, ADP5061_FUNC_SET_1,
+				 ADP5061_FUNC_SET_1_EN_CHG_MSK,
+				 ADP5061_FUNC_SET_1_EN_CHG_MODE(!!chg_en));
+
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static DEVICE_ATTR_RW(charging_enabled);
+
+static struct attribute *adp5061_attributes[] = {
+	&dev_attr_charging_enabled.attr,
+	NULL
+};
+
+static const struct attribute_group adp5061_attr_group = {
+	.attrs = adp5061_attributes,
+};
+
 static int adp5061_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
 	struct power_supply_config psy_cfg = {};
 	struct adp5061_state *st;
+	int ret;
 
 	st = devm_kzalloc(&client->dev, sizeof(*st), GFP_KERNEL);
 	if (!st)
@@ -722,6 +779,12 @@ static int adp5061_probe(struct i2c_client *client,
 		return PTR_ERR(st->psy);
 	}
 
+	ret = sysfs_create_group(&st->psy->dev.kobj, &adp5061_attr_group);
+	if (ret < 0) {
+		dev_err(&client->dev, "failed to create sysfs group\n");
+		return ret;
+	}
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3 3/4] adp5061: Add support for battery charging enable
@ 2018-04-11 15:10     ` Stefan Popa
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Popa @ 2018-04-11 15:10 UTC (permalink / raw)
  To: sre
  Cc: davem, mchehab, gregkh, linus.walleij, akpm, rdunlap, linux-pm,
	linux-kernel, stefan.popa

This patch adds the option to enable/disable battery charging. This
option is not configurable via the power_supply properties, therefore,
access via sysfs was provided to examine and modify this attribute on the
fly.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
---
Changes in v2:
	- Fixed kbuild test error by changing the type of the
	  charging_enabled_show() and charging_enabled_store() functions
	  from int to ssize_t.
Changes in v3:
	- Nothing changed, just to follow the patch set version.

 .../ABI/testing/sysfs-class-power-adp5061          | 10 ++++
 MAINTAINERS                                        |  1 +
 drivers/power/supply/adp5061.c                     | 63 ++++++++++++++++++++++
 3 files changed, 74 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-power-adp5061

diff --git a/Documentation/ABI/testing/sysfs-class-power-adp5061 b/Documentation/ABI/testing/sysfs-class-power-adp5061
new file mode 100644
index 0000000..0d056aa
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-power-adp5061
@@ -0,0 +1,10 @@
+What: /sys/class/power_supply/adp5061/charging_enabled
+Description:
+	Enable/disable battery charging.
+
+	The ADP5061 charging function can be enabled by setting
+	this attribute to 1. See device datasheet for details.
+
+	Valid values:
+		- 1: enabled
+		- 0: disabled
diff --git a/MAINTAINERS b/MAINTAINERS
index a9ca73b..9271246 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -804,6 +804,7 @@ W:	http://ez.analog.com/community/linux-device-drivers
 S:	Supported
 F:	Documentation/devicetree/bindings/power/supply/adp5061.txt
 F:	drivers/power/supply/adp5061.c
+F:	Documentation/ABI/testing/sysfs-class-power-adp5061
 
 ANALOG DEVICES INC ADV7180 DRIVER
 M:	Lars-Peter Clausen <lars@metafoo.de>
diff --git a/drivers/power/supply/adp5061.c b/drivers/power/supply/adp5061.c
index c00a02e..99871e6 100644
--- a/drivers/power/supply/adp5061.c
+++ b/drivers/power/supply/adp5061.c
@@ -18,6 +18,7 @@
 #include <linux/of.h>
 #include <linux/regmap.h>
 
+
 /* ADP5061 registers definition */
 #define ADP5061_ID			0x00
 #define ADP5061_REV			0x01
@@ -79,6 +80,10 @@
 #define ADP5061_IEND_IEND_MSK			GENMASK(7, 5)
 #define ADP5061_IEND_IEND_MODE(x)		(((x) & 0x07) << 5)
 
+/* ADP5061_FUNC_SET_1 */
+#define ADP5061_FUNC_SET_1_EN_CHG_MSK		BIT(0)
+#define ADP5061_FUNC_SET_1_EN_CHG_MODE(x)	(((x) & 0x01) << 0)
+
 #define ADP5061_NO_BATTERY	0x01
 #define ADP5061_ICHG_MAX	1300 // mA
 
@@ -692,11 +697,63 @@ static const struct power_supply_desc adp5061_desc = {
 	.num_properties		= ARRAY_SIZE(adp5061_props),
 };
 
+static ssize_t charging_enabled_show(struct device *dev,
+				 struct device_attribute *attr,
+				 char *buf)
+{
+	struct power_supply *psy = dev_get_drvdata(dev);
+	struct adp5061_state *st = power_supply_get_drvdata(psy);
+	unsigned int regval;
+	int ret;
+
+	ret = regmap_read(st->regmap, ADP5061_FUNC_SET_1, &regval);
+	if (ret < 0)
+		return ret;
+
+	regval &= ADP5061_FUNC_SET_1_EN_CHG_MSK;
+	return sprintf(buf, "%d\n", regval);
+}
+
+static ssize_t charging_enabled_store(struct device *dev,
+				  struct device_attribute *attr,
+				  const char *buf, size_t count)
+{
+	struct power_supply *psy = dev_get_drvdata(dev);
+	struct adp5061_state *st = power_supply_get_drvdata(psy);
+	u8 chg_en;
+	int ret;
+
+	ret = kstrtou8(buf, 0, &chg_en);
+	if (ret < 0)
+		return ret;
+
+	ret = regmap_update_bits(st->regmap, ADP5061_FUNC_SET_1,
+				 ADP5061_FUNC_SET_1_EN_CHG_MSK,
+				 ADP5061_FUNC_SET_1_EN_CHG_MODE(!!chg_en));
+
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static DEVICE_ATTR_RW(charging_enabled);
+
+static struct attribute *adp5061_attributes[] = {
+	&dev_attr_charging_enabled.attr,
+	NULL
+};
+
+static const struct attribute_group adp5061_attr_group = {
+	.attrs = adp5061_attributes,
+};
+
 static int adp5061_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
 	struct power_supply_config psy_cfg = {};
 	struct adp5061_state *st;
+	int ret;
 
 	st = devm_kzalloc(&client->dev, sizeof(*st), GFP_KERNEL);
 	if (!st)
@@ -722,6 +779,12 @@ static int adp5061_probe(struct i2c_client *client,
 		return PTR_ERR(st->psy);
 	}
 
+	ret = sysfs_create_group(&st->psy->dev.kobj, &adp5061_attr_group);
+	if (ret < 0) {
+		dev_err(&client->dev, "failed to create sysfs group\n");
+		return ret;
+	}
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v3][RESEND] adp5061: Add support for battery charging enable
  2018-04-11 15:10     ` Stefan Popa
  (?)
@ 2019-10-11 10:56     ` Alexandru Ardelean
  2019-10-13 23:10         ` kbuild test robot
  -1 siblings, 1 reply; 13+ messages in thread
From: Alexandru Ardelean @ 2019-10-11 10:56 UTC (permalink / raw)
  To: linux-pm, linux-kernel; +Cc: sre, Stefan Popa, Alexandru Ardelean

From: Stefan Popa <stefan.popa@analog.com>

This patch adds the option to enable/disable battery charging. This
option is not configurable via the power_supply properties, therefore,
access via sysfs was provided to examine and modify this attribute on the
fly.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---

I could not find any traces about this patch being denied and why.
So this is a RESEND to [re]trigger a discussion if needed.

 .../ABI/testing/sysfs-class-power-adp5061     | 10 +++
 drivers/power/supply/adp5061.c                | 63 +++++++++++++++++++
 2 files changed, 73 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-power-adp5061

diff --git a/Documentation/ABI/testing/sysfs-class-power-adp5061 b/Documentation/ABI/testing/sysfs-class-power-adp5061
new file mode 100644
index 000000000000..0d056aa103b5
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-power-adp5061
@@ -0,0 +1,10 @@
+What: /sys/class/power_supply/adp5061/charging_enabled
+Description:
+	Enable/disable battery charging.
+
+	The ADP5061 charging function can be enabled by setting
+	this attribute to 1. See device datasheet for details.
+
+	Valid values:
+		- 1: enabled
+		- 0: disabled
diff --git a/drivers/power/supply/adp5061.c b/drivers/power/supply/adp5061.c
index 003557043ab3..6e09a6b710e8 100644
--- a/drivers/power/supply/adp5061.c
+++ b/drivers/power/supply/adp5061.c
@@ -74,6 +74,10 @@
 #define ADP5061_CHG_STATUS_2_RCH_LIM_INFO(x)	(((x) >> 3) & 0x1)
 #define ADP5061_CHG_STATUS_2_BAT_STATUS(x)	(((x) >> 0) & 0x7)
 
+/* ADP5061_FUNC_SET_1 */
+#define ADP5061_FUNC_SET_1_EN_CHG_MSK		BIT(0)
+#define ADP5061_FUNC_SET_1_EN_CHG_MODE(x)	(((x) & 0x01) << 0)
+
 /* ADP5061_IEND */
 #define ADP5061_IEND_IEND_MSK			GENMASK(7, 5)
 #define ADP5061_IEND_IEND_MODE(x)		(((x) & 0x07) << 5)
@@ -691,11 +695,64 @@ static const struct power_supply_desc adp5061_desc = {
 	.num_properties		= ARRAY_SIZE(adp5061_props),
 };
 
+static int adp5061_get_charging_enabled(struct device *dev,
+					struct device_attribute *attr,
+					char *buf)
+{
+	struct power_supply *psy = dev_get_drvdata(dev);
+	struct adp5061_state *st = power_supply_get_drvdata(psy);
+	unsigned int regval;
+	int ret;
+
+	ret = regmap_read(st->regmap, ADP5061_FUNC_SET_1, &regval);
+	if (ret < 0)
+		return ret;
+
+	regval &= ADP5061_FUNC_SET_1_EN_CHG_MSK;
+	return sprintf(buf, "%d\n", regval);
+}
+
+static int adp5061_set_charging_enabled(struct device *dev,
+					struct device_attribute *attr,
+					const char *buf, size_t count)
+{
+	struct power_supply *psy = dev_get_drvdata(dev);
+	struct adp5061_state *st = power_supply_get_drvdata(psy);
+	u8 chg_en;
+	int ret;
+
+	ret = kstrtou8(buf, 0, &chg_en);
+	if (ret < 0)
+		return ret;
+
+	ret = regmap_update_bits(st->regmap, ADP5061_FUNC_SET_1,
+				 ADP5061_FUNC_SET_1_EN_CHG_MSK,
+				 ADP5061_FUNC_SET_1_EN_CHG_MODE(!!chg_en));
+
+	if (ret < 0)
+		return ret;
+
+	return count;
+}
+
+static DEVICE_ATTR(charging_enabled, 0644, adp5061_get_charging_enabled,
+		   adp5061_set_charging_enabled);
+
+static struct attribute *adp5061_attributes[] = {
+	&dev_attr_charging_enabled.attr,
+	NULL
+};
+
+static const struct attribute_group adp5061_attr_group = {
+	.attrs = adp5061_attributes,
+};
+
 static int adp5061_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
 	struct power_supply_config psy_cfg = {};
 	struct adp5061_state *st;
+	int ret;
 
 	st = devm_kzalloc(&client->dev, sizeof(*st), GFP_KERNEL);
 	if (!st)
@@ -721,6 +778,12 @@ static int adp5061_probe(struct i2c_client *client,
 		return PTR_ERR(st->psy);
 	}
 
+	ret = sysfs_create_group(&st->psy->dev.kobj, &adp5061_attr_group);
+	if (ret < 0) {
+		dev_err(&client->dev, "failed to create sysfs group\n");
+		return ret;
+	}
+
 	return 0;
 }
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v3][RESEND] adp5061: Add support for battery charging enable
  2019-10-11 10:56     ` [PATCH v3][RESEND] " Alexandru Ardelean
@ 2019-10-13 23:10         ` kbuild test robot
  0 siblings, 0 replies; 13+ messages in thread
From: kbuild test robot @ 2019-10-13 23:10 UTC (permalink / raw)
  To: Alexandru Ardelean
  Cc: kbuild-all, linux-pm, linux-kernel, sre, Stefan Popa, Alexandru Ardelean

[-- Attachment #1: Type: text/plain, Size: 3699 bytes --]

Hi Alexandru,

I love your patch! Yet something to improve:

[auto build test ERROR on power-supply/for-next]
[cannot apply to v5.4-rc2 next-20191011]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Alexandru-Ardelean/adp5061-Add-support-for-battery-charging-enable/20191014-035456
base:   https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=sparc64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/kobject.h:20:0,
                    from include/linux/module.h:17,
                    from drivers/power/supply/adp5061.c:9:
>> drivers/power/supply/adp5061.c:738:44: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
    static DEVICE_ATTR(charging_enabled, 0644, adp5061_get_charging_enabled,
                                               ^
   include/linux/sysfs.h:104:10: note: in definition of macro '__ATTR'
     .show = _show,      \
             ^~~~~
>> drivers/power/supply/adp5061.c:738:8: note: in expansion of macro 'DEVICE_ATTR'
    static DEVICE_ATTR(charging_enabled, 0644, adp5061_get_charging_enabled,
           ^~~~~~~~~~~
   drivers/power/supply/adp5061.c:738:44: note: (near initialization for 'dev_attr_charging_enabled.show')
    static DEVICE_ATTR(charging_enabled, 0644, adp5061_get_charging_enabled,
                                               ^
   include/linux/sysfs.h:104:10: note: in definition of macro '__ATTR'
     .show = _show,      \
             ^~~~~
>> drivers/power/supply/adp5061.c:738:8: note: in expansion of macro 'DEVICE_ATTR'
    static DEVICE_ATTR(charging_enabled, 0644, adp5061_get_charging_enabled,
           ^~~~~~~~~~~
   drivers/power/supply/adp5061.c:739:6: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
         adp5061_set_charging_enabled);
         ^
   include/linux/sysfs.h:105:11: note: in definition of macro '__ATTR'
     .store = _store,      \
              ^~~~~~
>> drivers/power/supply/adp5061.c:738:8: note: in expansion of macro 'DEVICE_ATTR'
    static DEVICE_ATTR(charging_enabled, 0644, adp5061_get_charging_enabled,
           ^~~~~~~~~~~
   drivers/power/supply/adp5061.c:739:6: note: (near initialization for 'dev_attr_charging_enabled.store')
         adp5061_set_charging_enabled);
         ^
   include/linux/sysfs.h:105:11: note: in definition of macro '__ATTR'
     .store = _store,      \
              ^~~~~~
>> drivers/power/supply/adp5061.c:738:8: note: in expansion of macro 'DEVICE_ATTR'
    static DEVICE_ATTR(charging_enabled, 0644, adp5061_get_charging_enabled,
           ^~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +738 drivers/power/supply/adp5061.c

   737	
 > 738	static DEVICE_ATTR(charging_enabled, 0644, adp5061_get_charging_enabled,
   739			   adp5061_set_charging_enabled);
   740	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 58669 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3][RESEND] adp5061: Add support for battery charging enable
@ 2019-10-13 23:10         ` kbuild test robot
  0 siblings, 0 replies; 13+ messages in thread
From: kbuild test robot @ 2019-10-13 23:10 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3775 bytes --]

Hi Alexandru,

I love your patch! Yet something to improve:

[auto build test ERROR on power-supply/for-next]
[cannot apply to v5.4-rc2 next-20191011]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Alexandru-Ardelean/adp5061-Add-support-for-battery-charging-enable/20191014-035456
base:   https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=sparc64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/kobject.h:20:0,
                    from include/linux/module.h:17,
                    from drivers/power/supply/adp5061.c:9:
>> drivers/power/supply/adp5061.c:738:44: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
    static DEVICE_ATTR(charging_enabled, 0644, adp5061_get_charging_enabled,
                                               ^
   include/linux/sysfs.h:104:10: note: in definition of macro '__ATTR'
     .show = _show,      \
             ^~~~~
>> drivers/power/supply/adp5061.c:738:8: note: in expansion of macro 'DEVICE_ATTR'
    static DEVICE_ATTR(charging_enabled, 0644, adp5061_get_charging_enabled,
           ^~~~~~~~~~~
   drivers/power/supply/adp5061.c:738:44: note: (near initialization for 'dev_attr_charging_enabled.show')
    static DEVICE_ATTR(charging_enabled, 0644, adp5061_get_charging_enabled,
                                               ^
   include/linux/sysfs.h:104:10: note: in definition of macro '__ATTR'
     .show = _show,      \
             ^~~~~
>> drivers/power/supply/adp5061.c:738:8: note: in expansion of macro 'DEVICE_ATTR'
    static DEVICE_ATTR(charging_enabled, 0644, adp5061_get_charging_enabled,
           ^~~~~~~~~~~
   drivers/power/supply/adp5061.c:739:6: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
         adp5061_set_charging_enabled);
         ^
   include/linux/sysfs.h:105:11: note: in definition of macro '__ATTR'
     .store = _store,      \
              ^~~~~~
>> drivers/power/supply/adp5061.c:738:8: note: in expansion of macro 'DEVICE_ATTR'
    static DEVICE_ATTR(charging_enabled, 0644, adp5061_get_charging_enabled,
           ^~~~~~~~~~~
   drivers/power/supply/adp5061.c:739:6: note: (near initialization for 'dev_attr_charging_enabled.store')
         adp5061_set_charging_enabled);
         ^
   include/linux/sysfs.h:105:11: note: in definition of macro '__ATTR'
     .store = _store,      \
              ^~~~~~
>> drivers/power/supply/adp5061.c:738:8: note: in expansion of macro 'DEVICE_ATTR'
    static DEVICE_ATTR(charging_enabled, 0644, adp5061_get_charging_enabled,
           ^~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +738 drivers/power/supply/adp5061.c

   737	
 > 738	static DEVICE_ATTR(charging_enabled, 0644, adp5061_get_charging_enabled,
   739			   adp5061_set_charging_enabled);
   740	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 58669 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3][RESEND] adp5061: Add support for battery charging enable
  2019-10-13 23:10         ` kbuild test robot
@ 2019-11-01 13:52           ` Ardelean, Alexandru
  -1 siblings, 0 replies; 13+ messages in thread
From: Ardelean, Alexandru @ 2019-11-01 13:52 UTC (permalink / raw)
  To: lkp; +Cc: kbuild-all, Popa, Stefan Serban, linux-pm, sre, linux-kernel

On Mon, 2019-10-14 at 07:10 +0800, kbuild test robot wrote:
> [External]
> 
> Hi Alexandru,
> 

Phew.
My bad here.
Either I have based it an older tree probably, or the ARM compilers did not
catch this.
The x86_64 compiler seems pretty nitpick-y [which is good[.
Will fix.


> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on power-supply/for-next]
> [cannot apply to v5.4-rc2 next-20191011]
> [if your patch is applied to the wrong git tree, please drop us a note to
> help
> improve the system. BTW, we also suggest to use '--base' option to
> specify the
> base tree in git format-patch, please see 
> https://stackoverflow.com/a/37406982]
> 
> url:    
> https://github.com/0day-ci/linux/commits/Alexandru-Ardelean/adp5061-Add-support-for-battery-charging-enable/20191014-035456
> base:   
> https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git
> for-next
> config: sparc64-allmodconfig (attached as .config)
> compiler: sparc64-linux-gcc (GCC) 7.4.0
> reproduce:
>         wget 
> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross
> -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         GCC_VERSION=7.4.0 make.cross ARCH=sparc64 
> 
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@intel.com>
> 
> All error/warnings (new ones prefixed by >>):
> 
>    In file included from include/linux/kobject.h:20:0,
>                     from include/linux/module.h:17,
>                     from drivers/power/supply/adp5061.c:9:
> > > drivers/power/supply/adp5061.c:738:44: error: initialization from
> > > incompatible pointer type [-Werror=incompatible-pointer-types]
>     static DEVICE_ATTR(charging_enabled, 0644,
> adp5061_get_charging_enabled,
>                                                ^
>    include/linux/sysfs.h:104:10: note: in definition of macro '__ATTR'
>      .show = _show,      \
>              ^~~~~
> > > drivers/power/supply/adp5061.c:738:8: note: in expansion of macro
> > > 'DEVICE_ATTR'
>     static DEVICE_ATTR(charging_enabled, 0644,
> adp5061_get_charging_enabled,
>            ^~~~~~~~~~~
>    drivers/power/supply/adp5061.c:738:44: note: (near initialization for
> 'dev_attr_charging_enabled.show')
>     static DEVICE_ATTR(charging_enabled, 0644,
> adp5061_get_charging_enabled,
>                                                ^
>    include/linux/sysfs.h:104:10: note: in definition of macro '__ATTR'
>      .show = _show,      \
>              ^~~~~
> > > drivers/power/supply/adp5061.c:738:8: note: in expansion of macro
> > > 'DEVICE_ATTR'
>     static DEVICE_ATTR(charging_enabled, 0644,
> adp5061_get_charging_enabled,
>            ^~~~~~~~~~~
>    drivers/power/supply/adp5061.c:739:6: error: initialization from
> incompatible pointer type [-Werror=incompatible-pointer-types]
>          adp5061_set_charging_enabled);
>          ^
>    include/linux/sysfs.h:105:11: note: in definition of macro '__ATTR'
>      .store = _store,      \
>               ^~~~~~
> > > drivers/power/supply/adp5061.c:738:8: note: in expansion of macro
> > > 'DEVICE_ATTR'
>     static DEVICE_ATTR(charging_enabled, 0644,
> adp5061_get_charging_enabled,
>            ^~~~~~~~~~~
>    drivers/power/supply/adp5061.c:739:6: note: (near initialization for
> 'dev_attr_charging_enabled.store')
>          adp5061_set_charging_enabled);
>          ^
>    include/linux/sysfs.h:105:11: note: in definition of macro '__ATTR'
>      .store = _store,      \
>               ^~~~~~
> > > drivers/power/supply/adp5061.c:738:8: note: in expansion of macro
> > > 'DEVICE_ATTR'
>     static DEVICE_ATTR(charging_enabled, 0644,
> adp5061_get_charging_enabled,
>            ^~~~~~~~~~~
>    cc1: some warnings being treated as errors
> 
> vim +738 drivers/power/supply/adp5061.c
> 
>    737	
>  > 738	static DEVICE_ATTR(charging_enabled, 0644,
> adp5061_get_charging_enabled,
>    739			   adp5061_set_charging_enabled);
>    740	
> 
> ---
> 0-DAY kernel test infrastructure                Open Source Technology
> Center
> https://lists.01.org/pipermail/kbuild-all                   Intel
> Corporation

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v3][RESEND] adp5061: Add support for battery charging enable
@ 2019-11-01 13:52           ` Ardelean, Alexandru
  0 siblings, 0 replies; 13+ messages in thread
From: Ardelean, Alexandru @ 2019-11-01 13:52 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 4299 bytes --]

On Mon, 2019-10-14 at 07:10 +0800, kbuild test robot wrote:
> [External]
> 
> Hi Alexandru,
> 

Phew.
My bad here.
Either I have based it an older tree probably, or the ARM compilers did not
catch this.
The x86_64 compiler seems pretty nitpick-y [which is good[.
Will fix.


> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on power-supply/for-next]
> [cannot apply to v5.4-rc2 next-20191011]
> [if your patch is applied to the wrong git tree, please drop us a note to
> help
> improve the system. BTW, we also suggest to use '--base' option to
> specify the
> base tree in git format-patch, please see 
> https://stackoverflow.com/a/37406982]
> 
> url:    
> https://github.com/0day-ci/linux/commits/Alexandru-Ardelean/adp5061-Add-support-for-battery-charging-enable/20191014-035456
> base:   
> https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git
> for-next
> config: sparc64-allmodconfig (attached as .config)
> compiler: sparc64-linux-gcc (GCC) 7.4.0
> reproduce:
>         wget 
> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross
> -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         GCC_VERSION=7.4.0 make.cross ARCH=sparc64 
> 
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@intel.com>
> 
> All error/warnings (new ones prefixed by >>):
> 
>    In file included from include/linux/kobject.h:20:0,
>                     from include/linux/module.h:17,
>                     from drivers/power/supply/adp5061.c:9:
> > > drivers/power/supply/adp5061.c:738:44: error: initialization from
> > > incompatible pointer type [-Werror=incompatible-pointer-types]
>     static DEVICE_ATTR(charging_enabled, 0644,
> adp5061_get_charging_enabled,
>                                                ^
>    include/linux/sysfs.h:104:10: note: in definition of macro '__ATTR'
>      .show = _show,      \
>              ^~~~~
> > > drivers/power/supply/adp5061.c:738:8: note: in expansion of macro
> > > 'DEVICE_ATTR'
>     static DEVICE_ATTR(charging_enabled, 0644,
> adp5061_get_charging_enabled,
>            ^~~~~~~~~~~
>    drivers/power/supply/adp5061.c:738:44: note: (near initialization for
> 'dev_attr_charging_enabled.show')
>     static DEVICE_ATTR(charging_enabled, 0644,
> adp5061_get_charging_enabled,
>                                                ^
>    include/linux/sysfs.h:104:10: note: in definition of macro '__ATTR'
>      .show = _show,      \
>              ^~~~~
> > > drivers/power/supply/adp5061.c:738:8: note: in expansion of macro
> > > 'DEVICE_ATTR'
>     static DEVICE_ATTR(charging_enabled, 0644,
> adp5061_get_charging_enabled,
>            ^~~~~~~~~~~
>    drivers/power/supply/adp5061.c:739:6: error: initialization from
> incompatible pointer type [-Werror=incompatible-pointer-types]
>          adp5061_set_charging_enabled);
>          ^
>    include/linux/sysfs.h:105:11: note: in definition of macro '__ATTR'
>      .store = _store,      \
>               ^~~~~~
> > > drivers/power/supply/adp5061.c:738:8: note: in expansion of macro
> > > 'DEVICE_ATTR'
>     static DEVICE_ATTR(charging_enabled, 0644,
> adp5061_get_charging_enabled,
>            ^~~~~~~~~~~
>    drivers/power/supply/adp5061.c:739:6: note: (near initialization for
> 'dev_attr_charging_enabled.store')
>          adp5061_set_charging_enabled);
>          ^
>    include/linux/sysfs.h:105:11: note: in definition of macro '__ATTR'
>      .store = _store,      \
>               ^~~~~~
> > > drivers/power/supply/adp5061.c:738:8: note: in expansion of macro
> > > 'DEVICE_ATTR'
>     static DEVICE_ATTR(charging_enabled, 0644,
> adp5061_get_charging_enabled,
>            ^~~~~~~~~~~
>    cc1: some warnings being treated as errors
> 
> vim +738 drivers/power/supply/adp5061.c
> 
>    737	
>  > 738	static DEVICE_ATTR(charging_enabled, 0644,
> adp5061_get_charging_enabled,
>    739			   adp5061_set_charging_enabled);
>    740	
> 
> ---
> 0-DAY kernel test infrastructure                Open Source Technology
> Center
> https://lists.01.org/pipermail/kbuild-all                   Intel
> Corporation

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-11-01 13:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-04  8:17 [PATCH 2/3] adp5061: Add support for battery charging enable Stefan Popa
2018-04-04  8:17 ` Stefan Popa
2018-04-04 17:01 ` kbuild test robot
2018-04-04 17:01   ` kbuild test robot
2018-04-10  9:51 ` [PATCH v2 " Stefan Popa
2018-04-10  9:51   ` Stefan Popa
2018-04-11 15:10   ` [PATCH v3 3/4] " Stefan Popa
2018-04-11 15:10     ` Stefan Popa
2019-10-11 10:56     ` [PATCH v3][RESEND] " Alexandru Ardelean
2019-10-13 23:10       ` kbuild test robot
2019-10-13 23:10         ` kbuild test robot
2019-11-01 13:52         ` Ardelean, Alexandru
2019-11-01 13:52           ` Ardelean, Alexandru

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.