diff mbox

[v3,3/3] drivers:power:twl4030-charger: remove nonstandard max_current sysfs attribute

Message ID 38afc4e7faaeabb32f153a0956899fa8e97c1b3a.1492194356.git.hns@goldelico.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

H. Nikolaus Schaller April 14, 2017, 6:25 p.m. UTC
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/power/supply/twl4030_charger.c | 63 ----------------------------------
 1 file changed, 63 deletions(-)

Comments

Sebastian Reichel May 1, 2017, 11:26 a.m. UTC | #1
Hi,

On Fri, Apr 14, 2017 at 08:25:57PM +0200, H. Nikolaus Schaller wrote:
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>

I'm not queuing this. Please change the following things for the
v4 of this patch:

 - Kernel patches should always have a long description
 - Patch needs to update Documentation/ABI/testing/sysfs-class-power-twl4030
 - Make sure to use recent MAINTAINERS file for getting patch
   destination (Dmitry and David are no longer listed).
 - And for this case: please also Cc NeilBrown <neil@brown.name>. If
   the ABI is in use we cannot simply remove it. If its unlikely,
   that its used I will queue the patch and revert if any problems
   are reported.

-- Sebastian
H. Nikolaus Schaller May 3, 2017, 12:20 p.m. UTC | #2
Hi,

> Am 01.05.2017 um 13:26 schrieb Sebastian Reichel <sebastian.reichel@collabora.co.uk>:
> 
> Hi,
> 
> On Fri, Apr 14, 2017 at 08:25:57PM +0200, H. Nikolaus Schaller wrote:
>> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> 
> I'm not queuing this. Please change the following things for the
> v4 of this patch:
> 
> - Kernel patches should always have a long description

Ok.

> - Patch needs to update Documentation/ABI/testing/sysfs-class-power-twl4030

Ok, forgot about this.

> - Make sure to use recent MAINTAINERS file for getting patch
>   destination (Dmitry and David are no longer listed).
> - And for this case: please also Cc NeilBrown <neil@brown.name>. If
>   the ABI is in use we cannot simply remove it. If its unlikely,
>   that its used I will queue the patch and revert if any problems
>   are reported.

Well, Neil did also work for the GTA04 project, so it is the same project.
But I will add him for V4 so that he can comment himself.

> 
> -- Sebastian


BR and thanks,
Nikolaus
Pavel Machek May 11, 2017, 10:35 p.m. UTC | #3
On Fri 2017-04-14 20:25:57, H. Nikolaus Schaller wrote:
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>

You should explain how to obtain equivalent functionality without that
attribute.

									Pavel

> ---
>  drivers/power/supply/twl4030_charger.c | 63 ----------------------------------
>  1 file changed, 63 deletions(-)
> 
> diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c
> index e70c4ed..e02e150 100644
> --- a/drivers/power/supply/twl4030_charger.c
> +++ b/drivers/power/supply/twl4030_charger.c
> @@ -624,63 +624,6 @@ static irqreturn_t twl4030_bci_interrupt(int irq, void *arg)
>  	return IRQ_HANDLED;
>  }
>  
> -/*
> - * Provide "max_current" attribute in sysfs.
> - */
> -static ssize_t
> -twl4030_bci_max_current_store(struct device *dev, struct device_attribute *attr,
> -	const char *buf, size_t n)
> -{
> -	struct twl4030_bci *bci = dev_get_drvdata(dev->parent);
> -	int cur = 0;
> -	int status = 0;
> -	status = kstrtoint(buf, 10, &cur);
> -	if (status)
> -		return status;
> -	if (cur < 0)
> -		return -EINVAL;
> -	if (dev == &bci->ac->dev)
> -		bci->ac_cur = cur;
> -	else
> -		bci->usb_cur_target = cur;
> -
> -	twl4030_charger_update_current(bci);
> -	return n;
> -}
> -
> -/*
> - * sysfs max_current show
> - */
> -static ssize_t twl4030_bci_max_current_show(struct device *dev,
> -	struct device_attribute *attr, char *buf)
> -{
> -	int status = 0;
> -	int cur = -1;
> -	u8 bcictl1;
> -	struct twl4030_bci *bci = dev_get_drvdata(dev->parent);
> -
> -	if (dev == &bci->ac->dev) {
> -		if (!bci->ac_is_active)
> -			cur = bci->ac_cur;
> -	} else {
> -		if (bci->ac_is_active)
> -			cur = bci->usb_cur_target;
> -	}
> -	if (cur < 0) {
> -		cur = twl4030bci_read_adc_val(TWL4030_BCIIREF1);
> -		if (cur < 0)
> -			return cur;
> -		status = twl4030_bci_read(TWL4030_BCICTL1, &bcictl1);
> -		if (status < 0)
> -			return status;
> -		cur = regval2ua(cur, bcictl1 & TWL4030_CGAIN);
> -	}
> -	return scnprintf(buf, PAGE_SIZE, "%u\n", cur);
> -}
> -
> -static DEVICE_ATTR(max_current, 0644, twl4030_bci_max_current_show,
> -			twl4030_bci_max_current_store);
> -
>  static void twl4030_bci_usb_work(struct work_struct *data)
>  {
>  	struct twl4030_bci *bci = container_of(data, struct twl4030_bci, work);
> @@ -1118,14 +1061,10 @@ static int twl4030_bci_probe(struct platform_device *pdev)
>  		dev_warn(&pdev->dev, "failed to unmask interrupts: %d\n", ret);
>  
>  	twl4030_charger_update_current(bci);
> -	if (device_create_file(&bci->usb->dev, &dev_attr_max_current))
> -		dev_warn(&pdev->dev, "could not create sysfs file\n");
>  	if (device_create_file(&bci->usb->dev, &dev_attr_mode))
>  		dev_warn(&pdev->dev, "could not create sysfs file\n");
>  	if (device_create_file(&bci->ac->dev, &dev_attr_mode))
>  		dev_warn(&pdev->dev, "could not create sysfs file\n");
> -	if (device_create_file(&bci->ac->dev, &dev_attr_max_current))
> -		dev_warn(&pdev->dev, "could not create sysfs file\n");
>  
>  	twl4030_charger_enable_ac(bci, true);
>  	if (!IS_ERR_OR_NULL(bci->transceiver))
> @@ -1157,9 +1096,7 @@ static int __exit twl4030_bci_remove(struct platform_device *pdev)
>  
>  	iio_channel_release(bci->channel_vac);
>  
> -	device_remove_file(&bci->usb->dev, &dev_attr_max_current);
>  	device_remove_file(&bci->usb->dev, &dev_attr_mode);
> -	device_remove_file(&bci->ac->dev, &dev_attr_max_current);
>  	device_remove_file(&bci->ac->dev, &dev_attr_mode);
>  	/* mask interrupts */
>  	twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xff,
H. Nikolaus Schaller May 12, 2017, 8:07 a.m. UTC | #4
Hi Pavel,

> Am 12.05.2017 um 00:35 schrieb Pavel Machek <pavel@ucw.cz>:
> 
> On Fri 2017-04-14 20:25:57, H. Nikolaus Schaller wrote:
>> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> 
> You should explain how to obtain equivalent functionality without that
> attribute.

By using the standard attribute as defined here:

http://elixir.free-electrons.com/linux/latest/source/Documentation/power/power_supply_class.txt#L125

It was introduced by 6bb1d272d7c9f.

This patch 3/3 here was intended to follow right after the one that adds the
input_current_limit property where it is (partially) described.

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=3fb319c2cdcd10f775f4d4a05a7d12fa1a5679c1

But since the patches are broken apart now, we should indeed document this
explicitly in the commit message to avoid any confusion. I had already
planned that for the next patch version.

BR,
Nikolaus

> 
> 									Pavel
> 
>> ---
>> drivers/power/supply/twl4030_charger.c | 63 ----------------------------------
>> 1 file changed, 63 deletions(-)
>> 
>> diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c
>> index e70c4ed..e02e150 100644
>> --- a/drivers/power/supply/twl4030_charger.c
>> +++ b/drivers/power/supply/twl4030_charger.c
>> @@ -624,63 +624,6 @@ static irqreturn_t twl4030_bci_interrupt(int irq, void *arg)
>> 	return IRQ_HANDLED;
>> }
>> 
>> -/*
>> - * Provide "max_current" attribute in sysfs.
>> - */
>> -static ssize_t
>> -twl4030_bci_max_current_store(struct device *dev, struct device_attribute *attr,
>> -	const char *buf, size_t n)
>> -{
>> -	struct twl4030_bci *bci = dev_get_drvdata(dev->parent);
>> -	int cur = 0;
>> -	int status = 0;
>> -	status = kstrtoint(buf, 10, &cur);
>> -	if (status)
>> -		return status;
>> -	if (cur < 0)
>> -		return -EINVAL;
>> -	if (dev == &bci->ac->dev)
>> -		bci->ac_cur = cur;
>> -	else
>> -		bci->usb_cur_target = cur;
>> -
>> -	twl4030_charger_update_current(bci);
>> -	return n;
>> -}
>> -
>> -/*
>> - * sysfs max_current show
>> - */
>> -static ssize_t twl4030_bci_max_current_show(struct device *dev,
>> -	struct device_attribute *attr, char *buf)
>> -{
>> -	int status = 0;
>> -	int cur = -1;
>> -	u8 bcictl1;
>> -	struct twl4030_bci *bci = dev_get_drvdata(dev->parent);
>> -
>> -	if (dev == &bci->ac->dev) {
>> -		if (!bci->ac_is_active)
>> -			cur = bci->ac_cur;
>> -	} else {
>> -		if (bci->ac_is_active)
>> -			cur = bci->usb_cur_target;
>> -	}
>> -	if (cur < 0) {
>> -		cur = twl4030bci_read_adc_val(TWL4030_BCIIREF1);
>> -		if (cur < 0)
>> -			return cur;
>> -		status = twl4030_bci_read(TWL4030_BCICTL1, &bcictl1);
>> -		if (status < 0)
>> -			return status;
>> -		cur = regval2ua(cur, bcictl1 & TWL4030_CGAIN);
>> -	}
>> -	return scnprintf(buf, PAGE_SIZE, "%u\n", cur);
>> -}
>> -
>> -static DEVICE_ATTR(max_current, 0644, twl4030_bci_max_current_show,
>> -			twl4030_bci_max_current_store);
>> -
>> static void twl4030_bci_usb_work(struct work_struct *data)
>> {
>> 	struct twl4030_bci *bci = container_of(data, struct twl4030_bci, work);
>> @@ -1118,14 +1061,10 @@ static int twl4030_bci_probe(struct platform_device *pdev)
>> 		dev_warn(&pdev->dev, "failed to unmask interrupts: %d\n", ret);
>> 
>> 	twl4030_charger_update_current(bci);
>> -	if (device_create_file(&bci->usb->dev, &dev_attr_max_current))
>> -		dev_warn(&pdev->dev, "could not create sysfs file\n");
>> 	if (device_create_file(&bci->usb->dev, &dev_attr_mode))
>> 		dev_warn(&pdev->dev, "could not create sysfs file\n");
>> 	if (device_create_file(&bci->ac->dev, &dev_attr_mode))
>> 		dev_warn(&pdev->dev, "could not create sysfs file\n");
>> -	if (device_create_file(&bci->ac->dev, &dev_attr_max_current))
>> -		dev_warn(&pdev->dev, "could not create sysfs file\n");
>> 
>> 	twl4030_charger_enable_ac(bci, true);
>> 	if (!IS_ERR_OR_NULL(bci->transceiver))
>> @@ -1157,9 +1096,7 @@ static int __exit twl4030_bci_remove(struct platform_device *pdev)
>> 
>> 	iio_channel_release(bci->channel_vac);
>> 
>> -	device_remove_file(&bci->usb->dev, &dev_attr_max_current);
>> 	device_remove_file(&bci->usb->dev, &dev_attr_mode);
>> -	device_remove_file(&bci->ac->dev, &dev_attr_max_current);
>> 	device_remove_file(&bci->ac->dev, &dev_attr_mode);
>> 	/* mask interrupts */
>> 	twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xff,
> 
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
diff mbox

Patch

diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c
index e70c4ed..e02e150 100644
--- a/drivers/power/supply/twl4030_charger.c
+++ b/drivers/power/supply/twl4030_charger.c
@@ -624,63 +624,6 @@  static irqreturn_t twl4030_bci_interrupt(int irq, void *arg)
 	return IRQ_HANDLED;
 }
 
-/*
- * Provide "max_current" attribute in sysfs.
- */
-static ssize_t
-twl4030_bci_max_current_store(struct device *dev, struct device_attribute *attr,
-	const char *buf, size_t n)
-{
-	struct twl4030_bci *bci = dev_get_drvdata(dev->parent);
-	int cur = 0;
-	int status = 0;
-	status = kstrtoint(buf, 10, &cur);
-	if (status)
-		return status;
-	if (cur < 0)
-		return -EINVAL;
-	if (dev == &bci->ac->dev)
-		bci->ac_cur = cur;
-	else
-		bci->usb_cur_target = cur;
-
-	twl4030_charger_update_current(bci);
-	return n;
-}
-
-/*
- * sysfs max_current show
- */
-static ssize_t twl4030_bci_max_current_show(struct device *dev,
-	struct device_attribute *attr, char *buf)
-{
-	int status = 0;
-	int cur = -1;
-	u8 bcictl1;
-	struct twl4030_bci *bci = dev_get_drvdata(dev->parent);
-
-	if (dev == &bci->ac->dev) {
-		if (!bci->ac_is_active)
-			cur = bci->ac_cur;
-	} else {
-		if (bci->ac_is_active)
-			cur = bci->usb_cur_target;
-	}
-	if (cur < 0) {
-		cur = twl4030bci_read_adc_val(TWL4030_BCIIREF1);
-		if (cur < 0)
-			return cur;
-		status = twl4030_bci_read(TWL4030_BCICTL1, &bcictl1);
-		if (status < 0)
-			return status;
-		cur = regval2ua(cur, bcictl1 & TWL4030_CGAIN);
-	}
-	return scnprintf(buf, PAGE_SIZE, "%u\n", cur);
-}
-
-static DEVICE_ATTR(max_current, 0644, twl4030_bci_max_current_show,
-			twl4030_bci_max_current_store);
-
 static void twl4030_bci_usb_work(struct work_struct *data)
 {
 	struct twl4030_bci *bci = container_of(data, struct twl4030_bci, work);
@@ -1118,14 +1061,10 @@  static int twl4030_bci_probe(struct platform_device *pdev)
 		dev_warn(&pdev->dev, "failed to unmask interrupts: %d\n", ret);
 
 	twl4030_charger_update_current(bci);
-	if (device_create_file(&bci->usb->dev, &dev_attr_max_current))
-		dev_warn(&pdev->dev, "could not create sysfs file\n");
 	if (device_create_file(&bci->usb->dev, &dev_attr_mode))
 		dev_warn(&pdev->dev, "could not create sysfs file\n");
 	if (device_create_file(&bci->ac->dev, &dev_attr_mode))
 		dev_warn(&pdev->dev, "could not create sysfs file\n");
-	if (device_create_file(&bci->ac->dev, &dev_attr_max_current))
-		dev_warn(&pdev->dev, "could not create sysfs file\n");
 
 	twl4030_charger_enable_ac(bci, true);
 	if (!IS_ERR_OR_NULL(bci->transceiver))
@@ -1157,9 +1096,7 @@  static int __exit twl4030_bci_remove(struct platform_device *pdev)
 
 	iio_channel_release(bci->channel_vac);
 
-	device_remove_file(&bci->usb->dev, &dev_attr_max_current);
 	device_remove_file(&bci->usb->dev, &dev_attr_mode);
-	device_remove_file(&bci->ac->dev, &dev_attr_max_current);
 	device_remove_file(&bci->ac->dev, &dev_attr_mode);
 	/* mask interrupts */
 	twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, 0xff,