Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp894246iol; Sat, 11 Jun 2022 23:44:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwgFb6eB3dyb8Gr4+nb0ybo/Dv6jzSI0gUjYkg/Y0XDwna0yxjIFqWUvBxh1CUgr8h1bjh X-Received: by 2002:a63:6b02:0:b0:3fb:da3f:4926 with SMTP id g2-20020a636b02000000b003fbda3f4926mr48223364pgc.346.1655016257977; Sat, 11 Jun 2022 23:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655016257; cv=none; d=google.com; s=arc-20160816; b=a9I+Kx/EDxzqOHw7pBXujNXjjkXVq760IA+78/mrigCqeuqaxGEjcaV9ems7bW3nsl G5tjvo54p1vVyAU99aLJ2B8mNfDpvC6JSUqRbu5sDaazNyIByRXkdwKEcFafKzR0EmM4 19w+mpVzXSDbu7VhmqjuZLORyrlHnJ+fjhz2CvaM+mGZiejvLdfA5U+Ch3PdSYph5i8t tQ5erODig82+TLUJlajGezBzy7oh1KbSfIUDQqQMgWzuufLV0Zsw8oWKlKV6pfPLuo35 F8W/DLowCwBzQA1W/iELE8IdW9vuyk0lbLBlisVWfmMloWvMEn51b3CsLMRP3oWFkMYq 3WQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kpvfGA3E90a/N/yXBIt8Q1EExXf7xd0mNjvb4dzHJKU=; b=NNbUlTAZ8aPsUU4bSdbGa4N+mgNaZv6bDwrNqGCmgOu4iPq0C0Fp/pYtGhzZx6i3Cd zLJmn5odRB2MiQrY/HZDjHhFiOug5ZWZ8lo+osasPYAySvJ76qx+4r278nkWvWxYCXQZ M9ydcEauAfiXIsZvA9PF4FRYGVe4fQx1xfkbBCXosTw5Uk2EeSmuH3nSSqGhClgVNjbu bZ5LO2ZqKneRffXzsmxKe4hMLwyiZlMi51aemgJfV71AHvi/tF6oshTcAWifDXiZMu71 g8WofHUKKBR3WOFo385f/JHmHvXI2gnbtUlV4auPTvSWmC5D+lwWiLog6kDz26P196Nd rVRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iKJAz5rL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n188-20020a6327c5000000b003fdebe6e78dsi4923431pgn.572.2022.06.11.23.44.04; Sat, 11 Jun 2022 23:44:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iKJAz5rL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234335AbiFLFAm (ORCPT + 99 others); Sun, 12 Jun 2022 01:00:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229528AbiFLFAl (ORCPT ); Sun, 12 Jun 2022 01:00:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DB3C645B; Sat, 11 Jun 2022 22:00:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9DDAB60B42; Sun, 12 Jun 2022 05:00:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A4B6C34115; Sun, 12 Jun 2022 05:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655010039; bh=aZel3g0siRMs9hpkSzONyBNEL3/uXvkfsBx22Gz+SpY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iKJAz5rL98YIYN7Mo860AHcTlgAowtdfsN94Oa4K3Z10IBtqVOePW7FdngSDm/wKO A7fv7DEDgw0uBc4kLi+Yqqf5s0YrtzFhmFXikYoC0MrwNtSdYaqurEXoAbBGszAkpk vWlLtr35/nN1qppa33aWNMMBd3eXcyvWalR36a+Y= Date: Sun, 12 Jun 2022 07:00:36 +0200 From: Greg Kroah-Hartman To: Bjorn Helgaas Cc: "Rafael J . Wysocki" , Len Brown , Pavel Machek , linux-pm@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Helgaas Subject: Re: [PATCH] PM / wakeup: Unify device_init_wakeup() for PM_SLEEP and !PM_SLEEP Message-ID: References: <20220610150628.GA599243@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220610150628.GA599243@bhelgaas> X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 10, 2022 at 10:06:28AM -0500, Bjorn Helgaas wrote: > On Fri, Jun 10, 2022 at 04:42:16PM +0200, Greg Kroah-Hartman wrote: > > On Mon, Jun 06, 2022 at 10:51:58PM -0500, Bjorn Helgaas wrote: > > > From: Bjorn Helgaas > > > > > > Previously the CONFIG_PM_SLEEP and !CONFIG_PM_SLEEP device_init_wakeup() > > > implementations differed in confusing ways: > > > > > > - The PM_SLEEP version checked for a NULL device pointer and returned > > > -EINVAL, while the !PM_SLEEP version did not and would simply > > > dereference a NULL pointer. > > > > > > - When called with "false", the !PM_SLEEP version cleared "capable" and > > > "enable" in the opposite order of the PM_SLEEP version. That was > > > harmless because for !PM_SLEEP they're simple assignments, but it's > > > unnecessary confusion. > > > > > > Use a simplified version of the PM_SLEEP implementation for both cases. > > > > > > Signed-off-by: Bjorn Helgaas > > > --- > > > drivers/base/power/wakeup.c | 30 ------------------------------ > > > include/linux/pm_wakeup.h | 31 +++++++++++++++++++++++-------- > > > 2 files changed, 23 insertions(+), 38 deletions(-) > > > > > > diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c > > > index 11a4ffe91367..e3befa2c1b66 100644 > > > --- a/drivers/base/power/wakeup.c > > > +++ b/drivers/base/power/wakeup.c > > > @@ -500,36 +500,6 @@ void device_set_wakeup_capable(struct device *dev, bool capable) > > > } > > > EXPORT_SYMBOL_GPL(device_set_wakeup_capable); > > > > > > -/** > > > - * device_init_wakeup - Device wakeup initialization. > > > - * @dev: Device to handle. > > > - * @enable: Whether or not to enable @dev as a wakeup device. > > > - * > > > - * By default, most devices should leave wakeup disabled. The exceptions are > > > - * devices that everyone expects to be wakeup sources: keyboards, power buttons, > > > - * possibly network interfaces, etc. Also, devices that don't generate their > > > - * own wakeup requests but merely forward requests from one bus to another > > > - * (like PCI bridges) should have wakeup enabled by default. > > > - */ > > > -int device_init_wakeup(struct device *dev, bool enable) > > > -{ > > > - int ret = 0; > > > - > > > - if (!dev) > > > - return -EINVAL; > > > - > > > - if (enable) { > > > - device_set_wakeup_capable(dev, true); > > > - ret = device_wakeup_enable(dev); > > > - } else { > > > - device_wakeup_disable(dev); > > > - device_set_wakeup_capable(dev, false); > > > - } > > > - > > > - return ret; > > > -} > > > -EXPORT_SYMBOL_GPL(device_init_wakeup); > > > - > > > /** > > > * device_set_wakeup_enable - Enable or disable a device to wake up the system. > > > * @dev: Device to handle. > > > diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h > > > index 196a157456aa..77f4849e3418 100644 > > > --- a/include/linux/pm_wakeup.h > > > +++ b/include/linux/pm_wakeup.h > > > @@ -109,7 +109,6 @@ extern struct wakeup_source *wakeup_sources_walk_next(struct wakeup_source *ws); > > > extern int device_wakeup_enable(struct device *dev); > > > extern int device_wakeup_disable(struct device *dev); > > > extern void device_set_wakeup_capable(struct device *dev, bool capable); > > > -extern int device_init_wakeup(struct device *dev, bool val); > > > extern int device_set_wakeup_enable(struct device *dev, bool enable); > > > extern void __pm_stay_awake(struct wakeup_source *ws); > > > extern void pm_stay_awake(struct device *dev); > > > @@ -167,13 +166,6 @@ static inline int device_set_wakeup_enable(struct device *dev, bool enable) > > > return 0; > > > } > > > > > > -static inline int device_init_wakeup(struct device *dev, bool val) > > > -{ > > > - device_set_wakeup_capable(dev, val); > > > - device_set_wakeup_enable(dev, val); > > > - return 0; > > > -} > > > - > > > static inline bool device_may_wakeup(struct device *dev) > > > { > > > return dev->power.can_wakeup && dev->power.should_wakeup; > > > @@ -217,4 +209,27 @@ static inline void pm_wakeup_hard_event(struct device *dev) > > > return pm_wakeup_dev_event(dev, 0, true); > > > } > > > > > > +/** > > > + * device_init_wakeup - Device wakeup initialization. > > > + * @dev: Device to handle. > > > + * @enable: Whether or not to enable @dev as a wakeup device. > > > + * > > > + * By default, most devices should leave wakeup disabled. The exceptions are > > > + * devices that everyone expects to be wakeup sources: keyboards, power buttons, > > > + * possibly network interfaces, etc. Also, devices that don't generate their > > > + * own wakeup requests but merely forward requests from one bus to another > > > + * (like PCI bridges) should have wakeup enabled by default. > > > + */ > > > +static inline int device_init_wakeup(struct device *dev, bool enable) > > > +{ > > > + if (enable) { > > > + device_set_wakeup_capable(dev, true); > > > + return device_wakeup_enable(dev); > > > + } else { > > > + device_wakeup_disable(dev); > > > + device_set_wakeup_capable(dev, false); > > > + return 0; > > > + } > > > +} > > > + > > > > Why are you moving this to be inline? Why not just drop the "other" > > version and stick with the .c version? > > That would definitely be simpler but drivers/base/power/wakeup.c is > only built when CONFIG_PM_SLEEP=y, so a .c version there by itself > isn't sufficient. I should have mentioned that in the commit log. Ah, missed that, sorry, nevermind :)