Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1621920imw; Tue, 5 Jul 2022 12:31:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sL1KOPjYhH58X0/iDpGk1I21pjt3GNkK/MLkWZAhfIm2RflUDEmoZdn1VUQfayVhxF8XLT X-Received: by 2002:a63:210f:0:b0:40d:dd27:8361 with SMTP id h15-20020a63210f000000b0040ddd278361mr31423084pgh.306.1657049496714; Tue, 05 Jul 2022 12:31:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657049496; cv=none; d=google.com; s=arc-20160816; b=ztshIcfuPsjT59Gl9dTzDRW3357KH7cnEKcUYwA74k+FP9fFP04QEdQLhu4FvOGaD3 L8yVh73aHz3sIDEI3RMJI5s8zCcfez465fKFGTFAlJXdqyHg5XovGPAV08XaThqP9Cpd hHhbWQ0orIoGqIVEuy7i9rrt1StmpsNMfNaG6XYeNucLXQXY67JGRZG/dp+d7U7J5Il7 SfEPzLECeOuXAXNbJEHQ8892C4kJSxdOPZEvd2AUxunjsBl/OkHGCjsBd8jXZZ1yVJfS aJTMCy4bLvdPEKUKxK0AB+dOYXfkhlYpoN5TLvcPd6QvTrE2LTyjAL3HYF5W0zewjLcR z/cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=rEEp1avjtVpzd2rsIuvCf8awzg9kogoo/eZ9Po79gdw=; b=xMu4KoU6JlZyT3FLRe6kS9pwDHLw+7/3YDRR49N5bfwdgasC1HeCikwCm/1oguGjxT uph8dhaoypUBZZCzfMAWBzycsVGwD7Yng7LeN3h5Jo31AG04fL6lKFFBJJyFMTP3JSYV /ReCLKsl5HynXVkEhhgwoWMREdwVbY4hFGUI1Q1rmjDFkz1r4Bt6fu6Orzx8I6pkPMFi HfWFiMZFdMT3ZYimaLpUwlQ0CTEnTY2/yhRmLGPYJGnXEe7kS0wChPYPPT0rerXnsPGt vuozFKtyLgHU4nUGIQ29vdPSamB7y7KNeIcW75PE0O/S4Aq+5+miQ0r4wf09Bsv/aGlc o8zQ== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l1-20020a654c41000000b0041216889b79si13097409pgr.700.2022.07.05.12.31.24; Tue, 05 Jul 2022 12:31:36 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232381AbiGESu5 (ORCPT + 99 others); Tue, 5 Jul 2022 14:50:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230300AbiGESuz (ORCPT ); Tue, 5 Jul 2022 14:50:55 -0400 Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB5AC18370; Tue, 5 Jul 2022 11:50:54 -0700 (PDT) Received: by mail-yb1-f180.google.com with SMTP id 76so7842800ybd.0; Tue, 05 Jul 2022 11:50:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rEEp1avjtVpzd2rsIuvCf8awzg9kogoo/eZ9Po79gdw=; b=7nJf6Nr24WQCYtyhTuUjddA2GsQqaAuNQJ0Dt+xvFDy7Th7ZuHAP6NqsbLnGfXe1uz zGdg1XdDC3eL1xHXCNu+coKL9TjtzpEIgMsyMnSuG53mReozZyqAk0oximOWg4Y4oSnM tmrhl9uyIGTb7xb4HHx+Hnpu7+F+PehbNY73f6SRowfnt5etTjSXHLNBax5ad79APcm2 rOPVT7vMPRCLVe/sgSn4aotCwJP02gx9OtmVIKNDVDD+HAtK7d3m6TSbSzRnfTM2WCi2 ijYl1kd7b02CekxddsVkFP2gZNYOR55UeEOW3iSDnfIfJiu+aY3TMm22A22VQReAlIeX EygQ== X-Gm-Message-State: AJIora+27yAA4WGbIf/UQ/XP3Np4pJefReiKP92fd+cDM1aMERoZEihS Ve5oJwDlSglWsXtk5hsW2niM9NUNIcGTZTqLJlg= X-Received: by 2002:a25:ab81:0:b0:66e:3dc5:898c with SMTP id v1-20020a25ab81000000b0066e3dc5898cmr15271965ybi.81.1657047054027; Tue, 05 Jul 2022 11:50:54 -0700 (PDT) MIME-Version: 1.0 References: <20220607035158.308111-1-helgaas@kernel.org> In-Reply-To: <20220607035158.308111-1-helgaas@kernel.org> From: "Rafael J. Wysocki" Date: Tue, 5 Jul 2022 20:50:43 +0200 Message-ID: Subject: Re: [PATCH] PM / wakeup: Unify device_init_wakeup() for PM_SLEEP and !PM_SLEEP To: Bjorn Helgaas Cc: "Rafael J . Wysocki" , Len Brown , Pavel Machek , Greg Kroah-Hartman , Linux PM , Linux PCI , Linux Kernel Mailing List , Bjorn Helgaas Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 Tue, Jun 7, 2022 at 5:52 AM 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; > + } > +} > + > #endif /* _LINUX_PM_WAKEUP_H */ > -- Applied as 5.20 material, sorry for the delay. Thanks!