Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1704822 > unrolled thread

[PATCH 11/18] power: supply: Fix power_supply_am_i_supplied to return -ENODEV when apropriate

Started byHans de Goede <hdegoede@redhat.com>
First post2017-08-06 14:40 +0200
Last post2017-08-06 17:00 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 11/18] power: supply: Fix power_supply_am_i_supplied to return -ENODEV when apropriate Hans de Goede <hdegoede@redhat.com> - 2017-08-06 14:40 +0200
    Re: [PATCH 11/18] power: supply: Fix power_supply_am_i_supplied to  return -ENODEV when apropriate Guenter Roeck <linux@roeck-us.net> - 2017-08-06 16:40 +0200
      Re: [PATCH 11/18] power: supply: Fix power_supply_am_i_supplied to  return -ENODEV when apropriate Hans de Goede <hdegoede@redhat.com> - 2017-08-06 17:00 +0200

#1704822 — [PATCH 11/18] power: supply: Fix power_supply_am_i_supplied to return -ENODEV when apropriate

FromHans de Goede <hdegoede@redhat.com>
Date2017-08-06 14:40 +0200
Subject[PATCH 11/18] power: supply: Fix power_supply_am_i_supplied to return -ENODEV when apropriate
Message-ID<ubt0C-2al-15@gated-at.bofh.it>
Commit 2848e039c562 ("power: supply: Make power_supply_am_i_supplied return
-ENODEV if there are no suppliers") was supposed to make
power_supply_am_i_supplied() return -ENODEV when there are no supplies
which supply the supply passed to it.

But instead it will only return -ENODEV when there are no supplies at
all as data->count++; is incremented on every call of the iterator, rather
then only when __power_supply_is_supplied_by returns true. This commit
fixes this.

Fixes: 2848e039c562 ("power: supply: Make power_supply_am_i_supplied ...")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/power/supply/power_supply_core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 540d3e0aa011..0741fcef3b44 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -314,11 +314,12 @@ static int __power_supply_am_i_supplied(struct device *dev, void *_data)
 	struct power_supply *epsy = dev_get_drvdata(dev);
 	struct psy_am_i_supplied_data *data = _data;
 
-	data->count++;
-	if (__power_supply_is_supplied_by(epsy, data->psy))
+	if (__power_supply_is_supplied_by(epsy, data->psy)) {
+		data->count++;
 		if (!epsy->desc->get_property(epsy, POWER_SUPPLY_PROP_ONLINE,
 					&ret))
 			return ret.intval;
+	}
 
 	return 0;
 }
-- 
2.13.3

[toc] | [next] | [standalone]


#1704861 — Re: [PATCH 11/18] power: supply: Fix power_supply_am_i_supplied to return -ENODEV when apropriate

FromGuenter Roeck <linux@roeck-us.net>
Date2017-08-06 16:40 +0200
SubjectRe: [PATCH 11/18] power: supply: Fix power_supply_am_i_supplied to return -ENODEV when apropriate
Message-ID<ubuSK-3qA-7@gated-at.bofh.it>
In reply to#1704822
On 08/06/2017 05:35 AM, Hans de Goede wrote:
> Commit 2848e039c562 ("power: supply: Make power_supply_am_i_supplied return
> -ENODEV if there are no suppliers") was supposed to make
> power_supply_am_i_supplied() return -ENODEV when there are no supplies
> which supply the supply passed to it.
> 
> But instead it will only return -ENODEV when there are no supplies at
> all as data->count++; is incremented on every call of the iterator, rather
> then only when __power_supply_is_supplied_by returns true. This commit
> fixes this.
> 
> Fixes: 2848e039c562 ("power: supply: Make power_supply_am_i_supplied ...")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Independent of this series ?

> ---
>   drivers/power/supply/power_supply_core.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
> index 540d3e0aa011..0741fcef3b44 100644
> --- a/drivers/power/supply/power_supply_core.c
> +++ b/drivers/power/supply/power_supply_core.c
> @@ -314,11 +314,12 @@ static int __power_supply_am_i_supplied(struct device *dev, void *_data)
>   	struct power_supply *epsy = dev_get_drvdata(dev);
>   	struct psy_am_i_supplied_data *data = _data;
>   
> -	data->count++;
> -	if (__power_supply_is_supplied_by(epsy, data->psy))
> +	if (__power_supply_is_supplied_by(epsy, data->psy)) {
> +		data->count++;
>   		if (!epsy->desc->get_property(epsy, POWER_SUPPLY_PROP_ONLINE,
>   					&ret))
>   			return ret.intval;
> +	}
>   
>   	return 0;
>   }
> 

[toc] | [prev] | [next] | [standalone]


#1704869 — Re: [PATCH 11/18] power: supply: Fix power_supply_am_i_supplied to return -ENODEV when apropriate

FromHans de Goede <hdegoede@redhat.com>
Date2017-08-06 17:00 +0200
SubjectRe: [PATCH 11/18] power: supply: Fix power_supply_am_i_supplied to return -ENODEV when apropriate
Message-ID<ubvc6-3xe-21@gated-at.bofh.it>
In reply to#1704861
Hi,

On 06-08-17 16:31, Guenter Roeck wrote:
> On 08/06/2017 05:35 AM, Hans de Goede wrote:
>> Commit 2848e039c562 ("power: supply: Make power_supply_am_i_supplied return
>> -ENODEV if there are no suppliers") was supposed to make
>> power_supply_am_i_supplied() return -ENODEV when there are no supplies
>> which supply the supply passed to it.
>>
>> But instead it will only return -ENODEV when there are no supplies at
>> all as data->count++; is incremented on every call of the iterator, rather
>> then only when __power_supply_is_supplied_by returns true. This commit
>> fixes this.
>>
>> Fixes: 2848e039c562 ("power: supply: Make power_supply_am_i_supplied ...")
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> 
> Independent of this series ?

Correct, in hindsight I should have send it out as a standalone patch, I will
do so for v2.

Regards,

Hans





> 
>> ---
>>   drivers/power/supply/power_supply_core.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
>> index 540d3e0aa011..0741fcef3b44 100644
>> --- a/drivers/power/supply/power_supply_core.c
>> +++ b/drivers/power/supply/power_supply_core.c
>> @@ -314,11 +314,12 @@ static int __power_supply_am_i_supplied(struct device *dev, void *_data)
>>       struct power_supply *epsy = dev_get_drvdata(dev);
>>       struct psy_am_i_supplied_data *data = _data;
>> -    data->count++;
>> -    if (__power_supply_is_supplied_by(epsy, data->psy))
>> +    if (__power_supply_is_supplied_by(epsy, data->psy)) {
>> +        data->count++;
>>           if (!epsy->desc->get_property(epsy, POWER_SUPPLY_PROP_ONLINE,
>>                       &ret))
>>               return ret.intval;
>> +    }
>>       return 0;
>>   }
>>
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web