Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751719AbdHFOyb (ORCPT ); Sun, 6 Aug 2017 10:54:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35676 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751304AbdHFOy2 (ORCPT ); Sun, 6 Aug 2017 10:54:28 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 80446859FA Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=hdegoede@redhat.com Subject: Re: [PATCH 11/18] power: supply: Fix power_supply_am_i_supplied to return -ENODEV when apropriate To: Guenter Roeck , Darren Hart , Andy Shevchenko , Wolfram Sang , Sebastian Reichel , Greg Kroah-Hartman , Heikki Krogerus Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, Liam Breck , Tony Lindgren , linux-pm@vger.kernel.org, devel@driverdev.osuosl.org References: <20170806123555.5124-1-hdegoede@redhat.com> <20170806123555.5124-12-hdegoede@redhat.com> <31e2a928-61f8-4706-9981-0d2e9ab2bc10@roeck-us.net> From: Hans de Goede Message-ID: Date: Sun, 6 Aug 2017 16:54:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <31e2a928-61f8-4706-9981-0d2e9ab2bc10@roeck-us.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 06 Aug 2017 14:54:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1805 Lines: 54 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 > > 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; >> } >> >