Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751681AbdHFObP (ORCPT ); Sun, 6 Aug 2017 10:31:15 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:56697 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751358AbdHFObN (ORCPT ); Sun, 6 Aug 2017 10:31:13 -0400 Subject: Re: [PATCH 11/18] power: supply: Fix power_supply_am_i_supplied to return -ENODEV when apropriate To: Hans de Goede , 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> From: Guenter Roeck Message-ID: <31e2a928-61f8-4706-9981-0d2e9ab2bc10@roeck-us.net> Date: Sun, 6 Aug 2017 07:31:09 -0700 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: <20170806123555.5124-12-hdegoede@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: linux@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: linux@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1558 Lines: 40 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 ? > --- > 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; > } >