Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3979537ybg; Mon, 21 Oct 2019 01:41:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqFl+xkiEKo8+2rmeUMHSdE2vfaIJvC7HLmNJ8lquTwPeioeuInernHBlQmTwwhr6h/irY X-Received: by 2002:a50:e606:: with SMTP id y6mr23594679edm.261.1571647291899; Mon, 21 Oct 2019 01:41:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571647291; cv=none; d=google.com; s=arc-20160816; b=XWJtlZSdY0SF7Gh9qfWa9c/z/5cRUbXMAeoIGvA9ODEYZIXHVb8tSAKpzwfobJd2X8 2BzqUvv2FJoIkEocJ/OgeHbMJJ+0b8QC79pKOKSCS6ToFPREkoUAarEhs0CAGJ4gdBqh PmiyAdCc4WkZigoaIro5p2M7cQzS72js+84+SKJQb+q5Ie5R3Gb2Asw7h2FgHE7UdnkS U//W5iwyOZ4TgsALr5QG50gd78meLZulCnxlRtXuDeHcMaG1P/2JwnXjLK/GbXIZFHFH fETvGkhT40EapXvzPqrgwqqNfR5B2RDrbgf4sKPw9sOJOvFHRFw8LcyNEndXY4ElSrLr 2vOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=Isdqq0Ubh24QJiFJ2l26RYaK1W86JQo/S0O5rntTFZ0=; b=eX2JWjo0xNYxioTsMJ5kn1h+eVHE1UYfaN2cZi1yG32gbyi8/uQoA2+JYdorior1CC pkwEUN49PPiMAQqCIp4FEe8XPm6X1fg5VVj6eDxJOeW5XkaSXOQSMnOhrtR/iM9U+aUt dsJ66KHLDN72PuBAmQH1JoRd5lvV0WjiseXWL9+3TBLVB5G8B1WUvmLwWYqJqBKgpm5u qURPUYyzg93zVi9BZQLCmOBjVRas5rM5MmBijOmJmWevp9s3PXcsZ7Pl4eYRXevslWUb qwoqsFFxyN9vqovShjg3Z4BDhlUoXrPu3R1ET1f8yODC32ppy3GUsSGytvb3FD8gRVCn bSCg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u12si11670317edi.326.2019.10.21.01.41.08; Mon, 21 Oct 2019 01:41:31 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727479AbfJUIiU (ORCPT + 99 others); Mon, 21 Oct 2019 04:38:20 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:37106 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726648AbfJUIiT (ORCPT ); Mon, 21 Oct 2019 04:38:19 -0400 Received: by mail-ot1-f68.google.com with SMTP id k32so10290143otc.4; Mon, 21 Oct 2019 01:38:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Isdqq0Ubh24QJiFJ2l26RYaK1W86JQo/S0O5rntTFZ0=; b=Z0TWIWcDFOQa1mesVbE2AV3RFGqL/hqwyU2Kg6KuPVvSfYXID05T9Lq8Gk3tE21XLz Lqxr/dIn1eN5vAla+SYfeNc1MDjotOOO9dk20OHs9aIxNv/OfA1FO2ZBvbM1oM7pgL4I cTF6PMvIVpVv9c7k/6WKB6NBlOvFj8N3gZ6bMN6q6ANZ9+nKeHWJoee807tQf5hMX6kB gAbAQkv3wB+0tIVNtoj4r3qKuC6VWincHXSZDV6fPSm5K0/GuqoapTxT/8bihEdXK4Hw ZPEcLyrz8SQ8uYjOKXYePjVABAWgi0gHnVupXEDuV5aXEtBYQzKxtVUMfOYwfOlDqCx1 jEjQ== X-Gm-Message-State: APjAAAVfWsfD2y5pccTvY3T37yyWHHJCppKbszvdbiwnsTNp0pd1eR44 WKOquBeAI+CmwqVRvhduRGmBoiM8S6NqdWGd5ZE= X-Received: by 2002:a05:6830:1e69:: with SMTP id m9mr17885485otr.262.1571647098420; Mon, 21 Oct 2019 01:38:18 -0700 (PDT) MIME-Version: 1.0 References: <20191021034927.19300-1-ran.wang_1@nxp.com> In-Reply-To: <20191021034927.19300-1-ran.wang_1@nxp.com> From: "Rafael J. Wysocki" Date: Mon, 21 Oct 2019 10:38:07 +0200 Message-ID: Subject: Re: [PATCH v7 1/3] PM: wakeup: Add routine to help fetch wakeup source object. To: Ran Wang Cc: "Rafael J . Wysocki" , Rob Herring , Li Yang , Mark Rutland , Pavel Machek , Li Biwen , Len Brown , Greg Kroah-Hartman , linuxppc-dev , Linux ARM , "devicetree@vger.kernel.org" , Linux Kernel Mailing List , Linux PM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 21, 2019 at 5:49 AM Ran Wang wrote: > > Some user might want to go through all registered wakeup sources > and doing things accordingly. For example, SoC PM driver might need to > do HW programming to prevent powering down specific IP which wakeup > source depending on. So add this API to help walk through all registered > wakeup source objects on that list and return them one by one. > > Signed-off-by: Ran Wang > Tested-by: Leonard Crestez > --- > Change in v7: > - Remove define of member *dev in wake_irq to fix conflict with commit > c8377adfa781 ("PM / wakeup: Show wakeup sources stats in sysfs"), user > will use ws->dev->parent instead. > - Remove '#include ' because it is not used. > > Change in v6: > - Add wakeup_source_get_star() and wakeup_source_get_stop() to aligned > with wakeup_sources_stats_seq_start/nex/stop. > > Change in v5: > - Update commit message, add decription of walk through all wakeup > source objects. > - Add SCU protection in function wakeup_source_get_next(). > - Rename wakeup_source member 'attached_dev' to 'dev' and move it up > (before wakeirq). > > Change in v4: > - None. > > Change in v3: > - Adjust indentation of *attached_dev;. > > Change in v2: > - None. > > drivers/base/power/wakeup.c | 37 +++++++++++++++++++++++++++++++++++++ > include/linux/pm_wakeup.h | 3 +++ > 2 files changed, 40 insertions(+) > > diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c > index 5817b51..dee1b09 100644 > --- a/drivers/base/power/wakeup.c > +++ b/drivers/base/power/wakeup.c > @@ -248,6 +248,43 @@ void wakeup_source_unregister(struct wakeup_source *ws) > EXPORT_SYMBOL_GPL(wakeup_source_unregister); > > /** > + * wakeup_source_get_star - Begin a walk on wakeup source list The "get" in the name suggests acquiring a reference of some kind which doesn't happen here. What about renaming it to wakeup_sources_walk_start()? > + * @srcuidx: Lock index allocated for this caller. > + */ > +struct wakeup_source *wakeup_source_get_start(int *srcuidx) I don't quite like the calling convention here with passing an int pointer to get the SRCU index back. What about splitting this into, say, wakeup_sources_read_lock() (that will return the SRCU index) and wakeup_sources_walk_start() (that will return the first list entry)? Then, you could do something like idx = wakeup_sources_read_lock(); ws = wakeup_sources_walk_start(); while (ws) { stuff ws = wakeup_sources_walk_next(); } wakeup_sources_read_unlock(idx); Or even define for_each_wakeup_source(ws) as for (ws = wakeup_sources_walk_start(); ws; ws = wakeup_sources_walk_next()) and use that under a _read_lock()/_read_unlock() pair?