Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp295972ybi; Thu, 1 Aug 2019 19:18:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPhxah4YlYQjXnEK0hpUIddEp85xD+hZqtwiRvYfQ3WhzZg6IVQ57YsWRxu3s721tL6Ocn X-Received: by 2002:aa7:8e18:: with SMTP id c24mr57184698pfr.24.1564712294645; Thu, 01 Aug 2019 19:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564712294; cv=none; d=google.com; s=arc-20160816; b=kutsVM0O2U0raAi+/u6ebwWZfsTzz+yERGvPzDTE9BMgvQErLOORus6cvnq6ZQzULo EsrDpP27QJiAIQClSdQSjGdTV0iW3ln9D+mZUTbzFJv74aUDv3F5iv7ncWkRHEsSvB2y /waJi9pQxLwSgNK3jR8JwQIwwA+4Ajd2+tPp3LuRhzxaaZMUHUBNI2AeH4+Qsoq+1BxI iYZ1OwnM3ggqiJrOI2mcw8EFySkxWe7oA1ATDkbgXRB5hOxA7+b86tNwuOuyXvMWlCbo zgoRJtz2GfsqgR8T9xtMBqKZsAVcaHNlh38altQoFmHSxRrPAhuK4NwtOCEecvE5m0kq D2LA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=RWmARDo48Z8Dv81pG22MrnEPvg/7991SYFzMS48qKnE=; b=LO4TE0psNYPQaoL1p8ELd8O9Nlp89dGEWEWYOHPSpeogOqAP/7JGNmVIov0ZXk7Wpu gij/WB8SAyKOWwzxzX1Mi7kmtTfGC4XzHLq/Io1gox9k6pWZifNS82dtpWW1zSS0YV6P v3Hdd+PvXcPW2+xVxVE64CPG8coPy08BgHpWPQf7hyXi7UWuetFLUJEr0WHMg8SyBSkG K3ihQSySGdYg/mGJjCYu9gkvFfEPVM7RjkW7in71Eh3tGQZfNUfaLuewCoKo+xIhqfAu N+8B1i7pIUk/5yskxdzfkhILAX/EULRRjYjaPOG0VjJKcs1L0wb2glJvmUfpLMrA50OU nLZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cyRZJ1yR; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si39218362pgu.504.2019.08.01.19.17.59; Thu, 01 Aug 2019 19:18:14 -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; dkim=pass header.i=@chromium.org header.s=google header.b=cyRZJ1yR; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732631AbfHAVdd (ORCPT + 99 others); Thu, 1 Aug 2019 17:33:33 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:46225 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728248AbfHAVdd (ORCPT ); Thu, 1 Aug 2019 17:33:33 -0400 Received: by mail-pg1-f195.google.com with SMTP id k189so15857369pgk.13 for ; Thu, 01 Aug 2019 14:33:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RWmARDo48Z8Dv81pG22MrnEPvg/7991SYFzMS48qKnE=; b=cyRZJ1yRaVu6PJnIyZ0m2XF/aeI4KSucQmlgOYSbGhPKcG5yUcoM8+RdJ8DbmCDMnc RkHD86VRMuw7CevSp88Ee4Ezex7hFoeV3tSzVJFbBo0dyrpIsh0i+pZZIPAhDK8CzAxX UpJhLcrmpqLJsBs7zYMLqfQrw6B4tik6LogGI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RWmARDo48Z8Dv81pG22MrnEPvg/7991SYFzMS48qKnE=; b=m7mQmCrONL2xy05L/Z8nf71xuNLXffmHRx/jMpkFN9qB/p2jlWCfrMx0YmKKJUoHZt WOC0joiz4ANoGCg//0TkGNB5GCjDF4NBnKoj7RS4BYNL9xpBLdIeJq6LSAXW4Lq7L0zt lQ5zMpL9a2pizUw27J0xhxprKbL29JOBjLCES7wDzIBBsocFZjIDvbGZ2lffCPrgWKfY HXarwVHn+f2aiRCIwFKmnvV4St6YJ9K+Apg2LuzL6suEvgnMPlKxARkJv/R7ty+8KUZg 1pAh3cV7W36T7YD9PEM8LVGJ8JK1IhMXPFe/V8mphVnoPR3CTHgP9fUGk8Jzr4qYmxpw gNfg== X-Gm-Message-State: APjAAAVRbyHyZV4KJS8VEU2xeoO0jQjQS66sl4kzJwJw44HtF0poQLG4 rFqxf3TzWZxr4AdQtkF3+cKuRw== X-Received: by 2002:a63:5945:: with SMTP id j5mr120457107pgm.452.1564695212134; Thu, 01 Aug 2019 14:33:32 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id v138sm83854994pfc.15.2019.08.01.14.33.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 14:33:31 -0700 (PDT) From: Stephen Boyd To: Sebastian Reichel Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, kernel-team@android.com, Greg Kroah-Hartman , Tri Vo , Kalesh Singh , Ravi Chandra Sadineni , "Rafael J. Wysocki" , Viresh Kumar Subject: [PATCH] power: supply: Init device wakeup after device_add() Date: Thu, 1 Aug 2019 14:33:30 -0700 Message-Id: <20190801213330.81079-1-swboyd@chromium.org> X-Mailer: git-send-email 2.22.0.770.g0f2c4a37fd-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- Sent by a computer through tubes