Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp468078ybl; Tue, 28 Jan 2020 06:26:21 -0800 (PST) X-Google-Smtp-Source: APXvYqxXp7dv50xPhFNjyD/fhfrqtbye4cp80F3Q7p7ERRHcd17KMKdJZ1KW8odcESk6SrFj/ckW X-Received: by 2002:a05:6808:3c2:: with SMTP id o2mr3061658oie.45.1580221580988; Tue, 28 Jan 2020 06:26:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580221580; cv=none; d=google.com; s=arc-20160816; b=uIPTwfnypy8I3vinvyPx801Tlge3PylsvxrbwNl47XulZRPciOFkvBNasZPFLmYGxE b2f/3lz72VCxVR327IHmrzQBEZIVNJID+0ahdT7RmOq0OGHXUfnwLYieokx9FV07oACE pX6p53ZLEO6HXYDHheXkkMgjCrqhdz0tieRHl7rXxZYd4IgSSuZidAL6OPIeVfZWMRfn if+Rb9X/RFchgoRPo8u7RayVQNW4c/m2OIIVyw16kfzSEpJRZ6oc0blEuuD0MhrsLvnb oSkNMO4tEk/wjCTkjyP9it7uhB+KxuJQbT7ypjHLiA1BDoR2eJIPNeEEl8WIBoOBN9bO FWag== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Xx1QX9DaFOege//fEYaU5BmgtgJamXkazc6p6+azn/g=; b=samXIAHIgcSWMvBTAcKTuZk4qSAbWUQkkcytOHX2Od+h9w1OhAugZSA5jA0Oag2TPr 56JZ7yl5mUEXyYntDEBM/96K4XBT0slY2Cw/YjP1l7qqnXvrbd9R2aunGX+nDVHiFSjX 5kDXHvxz5mMyGe+8zpGVUW2Lejuvk7v2Sit6vyRH98pOlJuBhSrZ/Z7ey6p3AmJlAWdv UWwEJ5lLDdsAjQo5iu4L9gGSpFfsIbGxxhAgpbIt+fzoC41f0WUYxMtSdhdroFcpbrpe v9gL04L6XIE//5kcHFTkiki6vGcL7ILGadbDveWqsFVK2rXoSCs/r1RZ/HP9Wtvpmywk NmvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="gtZR/VQ4"; 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 w6si8433583oti.4.2020.01.28.06.26.08; Tue, 28 Jan 2020 06:26:20 -0800 (PST) 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=@kernel.org header.s=default header.b="gtZR/VQ4"; 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 S1731465AbgA1OYM (ORCPT + 99 others); Tue, 28 Jan 2020 09:24:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:50666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732478AbgA1OYI (ORCPT ); Tue, 28 Jan 2020 09:24:08 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 69DB92468A; Tue, 28 Jan 2020 14:24:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221447; bh=PSD4RbVSO0zobmFR8fcfHskmIxH8NTErBAtGouN9zxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gtZR/VQ4IZBD13k+KanoXpX7BXsFk0koMWGsP+fBxRVI0awS765JBR3/y6pVpYlJL LORzQhYT/WcSF/syQCwRoCHlvSc932kXvd5oEG/vPqr71+9lf2doR8u8NVLUCPoreN kDpJeXgBaiYZHYErCvgUhW5MjRTyTkZVTuszU3UU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tri Vo , Kalesh Singh , Ravi Chandra Sadineni , Viresh Kumar , Stephen Boyd , "Rafael J. Wysocki" , Sebastian Reichel , Sasha Levin Subject: [PATCH 4.9 191/271] power: supply: Init device wakeup after device_add() Date: Tue, 28 Jan 2020 15:05:40 +0100 Message-Id: <20200128135906.797802182@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stephen Boyd [ Upstream commit 8288022284859acbcc3cf1a073a1e2692d6c2543 ] 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: Viresh Kumar Signed-off-by: Stephen Boyd Acked-by: Rafael J. Wysocki Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- 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 9e05ae0430a99..cb0b3d3d132fc 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -764,14 +764,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; @@ -808,8 +808,8 @@ register_cooler_failed: 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); -- 2.20.1