Message ID | 20230310144703.1541888-1-robh@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp951670wrd; Fri, 10 Mar 2023 08:00:54 -0800 (PST) X-Google-Smtp-Source: AK7set+PLfANBwXkH05K5elVM1pGoUEmXlShDm/z8o8qcALKI8sRSPtFFI88+uyl3Df4HIN2+Hcd X-Received: by 2002:aa7:8bd6:0:b0:5dc:107f:2e19 with SMTP id s22-20020aa78bd6000000b005dc107f2e19mr24068159pfd.9.1678464054307; Fri, 10 Mar 2023 08:00:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678464054; cv=none; d=google.com; s=arc-20160816; b=xnFpXKYw9iDDzmhY2gFu549Oj3lkxdlBksHJ+8cz4N0zS/eSvdjgv13ZdJ5y3wAGG2 NeSw9sio2buFREP2jl+oA8S/z8JZeQM/949aJmq9PW47N3Rioaja5qfcd+rTQzaIToon 9/bZ1x5ZaE1L4k05MS6u7+u10D7+B6gY096/FARza8pXJrB4wCVMiD22fjCjYDuSd3VB Ee1bK1NOpEykuJavtWDe7Pn1aqxYvXZWA6f4qlBVdjWEG1T9fme4XcO6bg3GrgfTX008 cFUiKePS9fOKzpxQFKh9BqqTj/i+WsJ2y834mdgtIlgxu6jIju9aW4G4Bg1RXCpjy+Hn Bzpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=2woDhUU8segjfXUK8bCKWWkxeooki4Tiioxihb29omI=; b=sfsiFXqRGu9uQjSvLG8kOu6eVRHjAXzIq4Hk6XXaeIaiVd+KXi8EezYLBoGbYXZf5j wkyhxTwl+ajRcDptqXwtBR4je929WEEK6paxGDcAkrO2le2ZMV3G5Os9eisHmXezoN8H ZmnmS1hOU8PEkdqdad33NXy5n5lBmBs3uso1dElEZ8lzRUJyKpyf5xd8eqnHAvWW0En2 lsuu1aIoCZ6AqeVpBGJZMjpBYEZBp7eNkhL8XlQAwFmUa25/Ty8yiwSpi+u4c5HYIg+v JR9vHe+2ZLuuZlh4VqgS8sz3GQhJ48ju/SkUJIZsWG3nQfsck3tiljHq7CdVWZgcCmUM 3aXA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 3-20020a621803000000b005e341e4b7bdsi3379pfy.214.2023.03.10.08.00.38; Fri, 10 Mar 2023 08:00:54 -0800 (PST) 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 S233242AbjCJOu0 (ORCPT <rfc822;carlos.wei.hk@gmail.com> + 99 others); Fri, 10 Mar 2023 09:50:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233085AbjCJOtE (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 10 Mar 2023 09:49:04 -0500 Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A3D51223B9; Fri, 10 Mar 2023 06:47:42 -0800 (PST) Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-176261d7f45so6035547fac.11; Fri, 10 Mar 2023 06:47:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678459662; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2woDhUU8segjfXUK8bCKWWkxeooki4Tiioxihb29omI=; b=77sr8Yd32bNJG5E5gvSB/QAYw7sH6uZZYnzRb9vwSvrRpBhHesYo36o5pwes2RUSC3 d3Bss/p+T5OVt/GFznda7n9ni/f7zW1R20nFfJ6sukfuDbhSwtKgzieznkFi4TCgzxJi U6N6ppGWXSgkt/8EzRMCYbWQwmDnlBqufIxfgF2eExzan5c6B0IG6GC2rYWC0Mt89EYU laQlBc+iqytku2koO8/VAcrYkt/oEXr2VX+X8TklMaygap09EJMAFwXJ8bO3Zv+aKV0R hp+v6SjrzBf30bor5skzvMQA4yb/IKS5rif/2+iIA9XVGOd8f73GvYfyCP5b0t10auar 1lBg== X-Gm-Message-State: AO0yUKW8TIAL8Ny+J9gmKvnrH79XLA++G6W2cCO7qYCnyp1a6JwTAmYO wF0E/cU6udmuBOX7MtEL0A== X-Received: by 2002:a05:6870:b14d:b0:172:80f9:a545 with SMTP id a13-20020a056870b14d00b0017280f9a545mr4220778oal.25.1678459662131; Fri, 10 Mar 2023 06:47:42 -0800 (PST) Received: from robh_at_kernel.org (66-90-144-107.dyn.grandenetworks.net. [66.90.144.107]) by smtp.gmail.com with ESMTPSA id y20-20020a056870429400b00172428894e0sm95296oah.28.2023.03.10.06.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 06:47:41 -0800 (PST) Received: (nullmailer pid 1541915 invoked by uid 1000); Fri, 10 Mar 2023 14:47:03 -0000 From: Rob Herring <robh@kernel.org> To: Ulf Hansson <ulf.hansson@linaro.org>, "Rafael J. Wysocki" <rafael@kernel.org>, Daniel Lezcano <daniel.lezcano@linaro.org>, Anup Patel <anup@brainfault.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu> Cc: devicetree@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH] cpuidle: Use of_property_present() for testing DT property presence Date: Fri, 10 Mar 2023 08:47:03 -0600 Message-Id: <20230310144703.1541888-1-robh@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759997124318684782?= X-GMAIL-MSGID: =?utf-8?q?1759997124318684782?= |
Series |
cpuidle: Use of_property_present() for testing DT property presence
|
|
Commit Message
Rob Herring
March 10, 2023, 2:47 p.m. UTC
It is preferred to use typed property access functions (i.e.
of_property_read_<type> functions) rather than low-level
of_get_property/of_find_property functions for reading properties. As
part of this, convert of_get_property/of_find_property calls to the
recently added of_property_present() helper when we just want to test
for presence of a property and nothing more.
Signed-off-by: Rob Herring <robh@kernel.org>
---
drivers/cpuidle/cpuidle-psci-domain.c | 2 +-
drivers/cpuidle/cpuidle-riscv-sbi.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
Comments
On Fri, 10 Mar 2023 at 15:47, Rob Herring <robh@kernel.org> wrote: > > It is preferred to use typed property access functions (i.e. > of_property_read_<type> functions) rather than low-level > of_get_property/of_find_property functions for reading properties. As > part of this, convert of_get_property/of_find_property calls to the > recently added of_property_present() helper when we just want to test > for presence of a property and nothing more. > > Signed-off-by: Rob Herring <robh@kernel.org> Acked-by: Ulf Hansson <ulf.hansson@linaro.org> Rafael, can you please pick this via your tree. Kind regards Uffe > --- > drivers/cpuidle/cpuidle-psci-domain.c | 2 +- > drivers/cpuidle/cpuidle-riscv-sbi.c | 6 +++--- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c > index 6ad2954948a5..e875ddadc51b 100644 > --- a/drivers/cpuidle/cpuidle-psci-domain.c > +++ b/drivers/cpuidle/cpuidle-psci-domain.c > @@ -165,7 +165,7 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) > * initialize a genpd/genpd-of-provider pair when it's found. > */ > for_each_child_of_node(np, node) { > - if (!of_find_property(node, "#power-domain-cells", NULL)) > + if (!of_property_present(node, "#power-domain-cells")) > continue; > > ret = psci_pd_init(node, use_osi); > diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c > index be383f4b6855..1fab1abc6eb6 100644 > --- a/drivers/cpuidle/cpuidle-riscv-sbi.c > +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c > @@ -497,7 +497,7 @@ static int sbi_genpd_probe(struct device_node *np) > * initialize a genpd/genpd-of-provider pair when it's found. > */ > for_each_child_of_node(np, node) { > - if (!of_find_property(node, "#power-domain-cells", NULL)) > + if (!of_property_present(node, "#power-domain-cells")) > continue; > > ret = sbi_pd_init(node); > @@ -548,8 +548,8 @@ static int sbi_cpuidle_probe(struct platform_device *pdev) > for_each_possible_cpu(cpu) { > np = of_cpu_device_node_get(cpu); > if (np && > - of_find_property(np, "power-domains", NULL) && > - of_find_property(np, "power-domain-names", NULL)) { > + of_property_present(np, "power-domains") && > + of_property_present(np, "power-domain-names")) { > continue; > } else { > sbi_cpuidle_use_osi = false; > -- > 2.39.2 >
On Fri, Mar 10, 2023 at 8:17 PM Rob Herring <robh@kernel.org> wrote: > > It is preferred to use typed property access functions (i.e. > of_property_read_<type> functions) rather than low-level > of_get_property/of_find_property functions for reading properties. As > part of this, convert of_get_property/of_find_property calls to the > recently added of_property_present() helper when we just want to test > for presence of a property and nothing more. > > Signed-off-by: Rob Herring <robh@kernel.org> For cpuidle-riscv-sbi: Acked-by: Anup Patel <anup@brainfault.org> Thanks, Anup > --- > drivers/cpuidle/cpuidle-psci-domain.c | 2 +- > drivers/cpuidle/cpuidle-riscv-sbi.c | 6 +++--- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c > index 6ad2954948a5..e875ddadc51b 100644 > --- a/drivers/cpuidle/cpuidle-psci-domain.c > +++ b/drivers/cpuidle/cpuidle-psci-domain.c > @@ -165,7 +165,7 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) > * initialize a genpd/genpd-of-provider pair when it's found. > */ > for_each_child_of_node(np, node) { > - if (!of_find_property(node, "#power-domain-cells", NULL)) > + if (!of_property_present(node, "#power-domain-cells")) > continue; > > ret = psci_pd_init(node, use_osi); > diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c > index be383f4b6855..1fab1abc6eb6 100644 > --- a/drivers/cpuidle/cpuidle-riscv-sbi.c > +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c > @@ -497,7 +497,7 @@ static int sbi_genpd_probe(struct device_node *np) > * initialize a genpd/genpd-of-provider pair when it's found. > */ > for_each_child_of_node(np, node) { > - if (!of_find_property(node, "#power-domain-cells", NULL)) > + if (!of_property_present(node, "#power-domain-cells")) > continue; > > ret = sbi_pd_init(node); > @@ -548,8 +548,8 @@ static int sbi_cpuidle_probe(struct platform_device *pdev) > for_each_possible_cpu(cpu) { > np = of_cpu_device_node_get(cpu); > if (np && > - of_find_property(np, "power-domains", NULL) && > - of_find_property(np, "power-domain-names", NULL)) { > + of_property_present(np, "power-domains") && > + of_property_present(np, "power-domain-names")) { > continue; > } else { > sbi_cpuidle_use_osi = false; > -- > 2.39.2 >
On Fri, Mar 10, 2023 at 6:47 PM Ulf Hansson <ulf.hansson@linaro.org> wrote: > > On Fri, 10 Mar 2023 at 15:47, Rob Herring <robh@kernel.org> wrote: > > > > It is preferred to use typed property access functions (i.e. > > of_property_read_<type> functions) rather than low-level > > of_get_property/of_find_property functions for reading properties. As > > part of this, convert of_get_property/of_find_property calls to the > > recently added of_property_present() helper when we just want to test > > for presence of a property and nothing more. > > > > Signed-off-by: Rob Herring <robh@kernel.org> > > Acked-by: Ulf Hansson <ulf.hansson@linaro.org> > > Rafael, can you please pick this via your tree. Done (queued up for 6.4), thanks! > > --- > > drivers/cpuidle/cpuidle-psci-domain.c | 2 +- > > drivers/cpuidle/cpuidle-riscv-sbi.c | 6 +++--- > > 2 files changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c > > index 6ad2954948a5..e875ddadc51b 100644 > > --- a/drivers/cpuidle/cpuidle-psci-domain.c > > +++ b/drivers/cpuidle/cpuidle-psci-domain.c > > @@ -165,7 +165,7 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) > > * initialize a genpd/genpd-of-provider pair when it's found. > > */ > > for_each_child_of_node(np, node) { > > - if (!of_find_property(node, "#power-domain-cells", NULL)) > > + if (!of_property_present(node, "#power-domain-cells")) > > continue; > > > > ret = psci_pd_init(node, use_osi); > > diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c > > index be383f4b6855..1fab1abc6eb6 100644 > > --- a/drivers/cpuidle/cpuidle-riscv-sbi.c > > +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c > > @@ -497,7 +497,7 @@ static int sbi_genpd_probe(struct device_node *np) > > * initialize a genpd/genpd-of-provider pair when it's found. > > */ > > for_each_child_of_node(np, node) { > > - if (!of_find_property(node, "#power-domain-cells", NULL)) > > + if (!of_property_present(node, "#power-domain-cells")) > > continue; > > > > ret = sbi_pd_init(node); > > @@ -548,8 +548,8 @@ static int sbi_cpuidle_probe(struct platform_device *pdev) > > for_each_possible_cpu(cpu) { > > np = of_cpu_device_node_get(cpu); > > if (np && > > - of_find_property(np, "power-domains", NULL) && > > - of_find_property(np, "power-domain-names", NULL)) { > > + of_property_present(np, "power-domains") && > > + of_property_present(np, "power-domain-names")) { > > continue; > > } else { > > sbi_cpuidle_use_osi = false; > > -- > > 2.39.2 > >
Hello: This patch was applied to riscv/linux.git (fixes) by Rafael J. Wysocki <rafael.j.wysocki@intel.com>: On Fri, 10 Mar 2023 08:47:03 -0600 you wrote: > It is preferred to use typed property access functions (i.e. > of_property_read_<type> functions) rather than low-level > of_get_property/of_find_property functions for reading properties. As > part of this, convert of_get_property/of_find_property calls to the > recently added of_property_present() helper when we just want to test > for presence of a property and nothing more. > > [...] Here is the summary with links: - cpuidle: Use of_property_present() for testing DT property presence https://git.kernel.org/riscv/c/f914bfdd7f84 You are awesome, thank you!
diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index 6ad2954948a5..e875ddadc51b 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -165,7 +165,7 @@ static int psci_cpuidle_domain_probe(struct platform_device *pdev) * initialize a genpd/genpd-of-provider pair when it's found. */ for_each_child_of_node(np, node) { - if (!of_find_property(node, "#power-domain-cells", NULL)) + if (!of_property_present(node, "#power-domain-cells")) continue; ret = psci_pd_init(node, use_osi); diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c index be383f4b6855..1fab1abc6eb6 100644 --- a/drivers/cpuidle/cpuidle-riscv-sbi.c +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c @@ -497,7 +497,7 @@ static int sbi_genpd_probe(struct device_node *np) * initialize a genpd/genpd-of-provider pair when it's found. */ for_each_child_of_node(np, node) { - if (!of_find_property(node, "#power-domain-cells", NULL)) + if (!of_property_present(node, "#power-domain-cells")) continue; ret = sbi_pd_init(node); @@ -548,8 +548,8 @@ static int sbi_cpuidle_probe(struct platform_device *pdev) for_each_possible_cpu(cpu) { np = of_cpu_device_node_get(cpu); if (np && - of_find_property(np, "power-domains", NULL) && - of_find_property(np, "power-domain-names", NULL)) { + of_property_present(np, "power-domains") && + of_property_present(np, "power-domain-names")) { continue; } else { sbi_cpuidle_use_osi = false;