Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp700008ybi; Fri, 2 Aug 2019 02:51:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpxJdgWuu08l6hZda3P4+AdajvZzsKvA/H3vD1uh11XO2GdbaGced2pCqX0JcFTYcyYUSH X-Received: by 2002:a17:902:f089:: with SMTP id go9mr130077270plb.81.1564739464246; Fri, 02 Aug 2019 02:51:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564739464; cv=none; d=google.com; s=arc-20160816; b=cR6wSUSd4Os64tqLNl2T+aLuS9QD8punp4XvhgGFY+5VZ2IEzdR4UvfMbROnbWy0Oj BLzCBsODqs8uvhXhDQed5Q8tSDCTSvOTq27VwTvlfPtGAuNwCKZJuKt+pwiOiiDdWQQF l2DSbJMLv0S/CNT9Z/KqR2mdviiOf1OlQ7lytMypyXlqLHGlmx0CV6No8pGi3p7ZoBa9 KIGlTEeTynffPo1yDXfA2QY0j+WYXlgkkmkH4OdAeBzBgK7zUguV2aqU6DiK4HXdSID3 qkt/5LeClpMNoRe5KW+SodC+xCbR/UX5j2Yv/1AHmnBScP+cp0xz6zMXS/UlfzIIB/t8 uiBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=XuT3x2ukXHJOb84WNnrMsPTnECiW2vZ8W5HOQOEZMy4=; b=BXIM1AadKpHxYCiSUbxWu29SUy3MoJZy08UQPJkD+Gh1Zw6Y/uJHotbDrYU47znYjs t+9+sH5uJndccq4ueq/i6Oys6sakPw/3QQPkl37RWKWIESF5FDv9SOHxgZysOdILQ5eD jlb8LW9NWOqxeGzDFEktJxvy0tePn8bxzHwPJZ2nJwVsF8TYmSey7j3u1heofYF1esBU ohjPc14iMxLdA2r56tfBLG+5QpWG2vExWp4+RDwxG7BizXq/oRIztDkWuIiSlAZKKd/l oj0xAf/jmORaCIMyq8Hfissvv/78nwOadn1NWWBxavwOtfIclFmLgLdyis3zTXQaP+20 gj3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y21si33234823plp.332.2019.08.02.02.50.48; Fri, 02 Aug 2019 02:51:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405977AbfHBJt2 (ORCPT + 99 others); Fri, 2 Aug 2019 05:49:28 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:64240 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405137AbfHBJt0 (ORCPT ); Fri, 2 Aug 2019 05:49:26 -0400 Received: from 79.184.255.110.ipv4.supernova.orange.pl (79.184.255.110) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.275) id e1982bc9eb5b63f9; Fri, 2 Aug 2019 11:49:24 +0200 From: "Rafael J. Wysocki" To: Stephen Boyd Cc: Sebastian Reichel , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, kernel-team@android.com, Greg Kroah-Hartman , Tri Vo , Kalesh Singh , Ravi Chandra Sadineni , Viresh Kumar Subject: Re: [PATCH] power: supply: Init device wakeup after device_add() Date: Fri, 02 Aug 2019 11:49:24 +0200 Message-ID: <5888477.sfNfyo0UZj@kreacher> In-Reply-To: <20190801213330.81079-1-swboyd@chromium.org> References: <20190801213330.81079-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday, August 1, 2019 11:33:30 PM CEST Stephen Boyd wrote: > We may want to use the device pointer in device_init_wakeup() with > functions that expect the device to already be added with device_add(). > For example, if we were to link the device initializing wakeup to > something in sysfs such as a class for wakeups we'll run into an error. > It looks like this code was written with the assumption that the device > would be added before initializing wakeup due to the order of operations > in power_supply_unregister(). > > Let's change the order of operations so we don't run into problems here. > > Fixes: 948dcf966228 ("power_supply: Prevent suspend until power supply events are processed") > Cc: Greg Kroah-Hartman > Cc: Tri Vo > Cc: Kalesh Singh > Cc: Ravi Chandra Sadineni > Cc: "Rafael J. Wysocki" > Cc: Viresh Kumar > Signed-off-by: Stephen Boyd > --- > > See this thread[1] for more information on how this will be necessary. > > [1] https://lkml.kernel.org/r/20190731215514.212215-1-trong@android.com > > > drivers/power/supply/power_supply_core.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c > index 82e84801264c..5c36c430ce8b 100644 > --- a/drivers/power/supply/power_supply_core.c > +++ b/drivers/power/supply/power_supply_core.c > @@ -1051,14 +1051,14 @@ __power_supply_register(struct device *parent, > } > > spin_lock_init(&psy->changed_lock); > - rc = device_init_wakeup(dev, ws); > - if (rc) > - goto wakeup_init_failed; > - > rc = device_add(dev); > if (rc) > goto device_add_failed; > > + rc = device_init_wakeup(dev, ws); > + if (rc) > + goto wakeup_init_failed; > + > rc = psy_register_thermal(psy); > if (rc) > goto register_thermal_failed; > @@ -1101,8 +1101,8 @@ __power_supply_register(struct device *parent, > psy_unregister_thermal(psy); > register_thermal_failed: > device_del(dev); > -device_add_failed: > wakeup_init_failed: > +device_add_failed: > check_supplies_failed: > dev_set_name_failed: > put_device(dev); > Acked-by: Rafael J. Wysocki