Message ID | 20230609183056.1765183-1-robh@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1110123vqr; Fri, 9 Jun 2023 11:40:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7wh5fE9Kz83nYZP8NPJXeNYYXSvawISa0FZZnaXgpkq1fx4rvwoCbbQLzzz8iTFlbSpvSs X-Received: by 2002:a05:6359:616:b0:129:c4f1:e7ca with SMTP id eh22-20020a056359061600b00129c4f1e7camr1998675rwb.27.1686336051305; Fri, 09 Jun 2023 11:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686336051; cv=none; d=google.com; s=arc-20160816; b=u96b9mNqwMxWQyN15lEMSzyL9Q6V1kWQZ7c2Dxzi75GcRnI6EZZIPDp3LWH3p+Wils vrusFslua1Lkbyug8PTXLAlbfX6XziRzPmxp/U3Z/OUUp9NQZbt1bZTAsU8ELQPZI2/L wjAKVmrQoVHGqxntCVRveUVm706KNRHHyCTZqjrstYipvUEfRba+RJdJF94TFJPcRVpo JKkyTRYdtwR0AuqIxAfuTtLukabD2LVH+g4cvIUyDQr/CCEx2+6SMdUj1380zmGg0dQb QYMXS2DtHIS2cO9Srws9RKHllsxAiF1/XjlFdE1wEzzTvQSKUbfEodhGvhssDoxoMHan L5kw== 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=XOkAktt4g0nx6LcgW7gCWAzTqQNaJuKZ2Hioy4cVgxI=; b=kZ2BnbwMJnYrfDyEY2n6KEeotQoWH1UtNV0EHFNhSj9x2syeZQEMk/c06BRgt6cPgH me1cYyC8HQ0wKlY4d7a1ObSAgWTIqFFV7v+61/TYSWA/t6UDeAUdBFjqRNbB+1TdaFv3 iKNC8Z2e/eeXSkTyvBE58hj6DuPsu2DFI7FcPwPeeYJr3k6UhYeGaq9jCvMEaPpzEKRT Ja94qI9vMFh87sMguTfvIGqCh9fKPsaa2XDZ/JGHlD7WgFreVhLy4St5AgHe8amnspfQ YKtP6dOYzFEjS6tU1gP/F4rdvXcmJ8QWGCkRaq5+Fzj19SvuaawMK8LYIzYB4DuSGX5I N08Q== 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 h71-20020a63834a000000b0054b51fd23b0si43546pge.844.2023.06.09.11.40.38; Fri, 09 Jun 2023 11:40:51 -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 S230076AbjFISbK (ORCPT <rfc822;liningstudo@gmail.com> + 99 others); Fri, 9 Jun 2023 14:31:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229536AbjFISbH (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 9 Jun 2023 14:31:07 -0400 Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8133435B7 for <linux-kernel@vger.kernel.org>; Fri, 9 Jun 2023 11:31:05 -0700 (PDT) Received: by mail-io1-f53.google.com with SMTP id ca18e2360f4ac-77acb944bdfso92160039f.0 for <linux-kernel@vger.kernel.org>; Fri, 09 Jun 2023 11:31:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686335465; x=1688927465; 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=XOkAktt4g0nx6LcgW7gCWAzTqQNaJuKZ2Hioy4cVgxI=; b=K5soMjKJqC7j+Qh8Hg22hmQRFyROcrQ6kwFOlqfgKFIGK0a3tay5vChR3mTzgINafv abefyvXFd0LudToK7acJJmbCJVfpLTBYgulU0S1b/pQfD1dyIzSd/5362ammvUhURO46 MVFu7w1iiHn9ZAZV7td5CwjW9qofpJgjQRtK5fUG1nFlO6NycD5+kOIi1Tdt0sfa9NKM kiaLJVCsS647bUJBGxVjfUQXYDgFLjjDEvTJ8yVpfIw5E3E24UXnOnRj0XYIHMbNoakn gICJNpx3HuxHVwDO+veJeT69JDcTXXDcSdwb63mPFqGbEEO2qREvHxXFcwHrs8qr9tKr 63Mw== X-Gm-Message-State: AC+VfDxOMur5Aa/vMzJEWI19bcm+I3mWj6owoqUzGj0DCGejMRIEPRLR aHyt1L+fkRQmIfMDlcsyR6S83fr0GA== X-Received: by 2002:a5e:dc45:0:b0:778:65fb:5e25 with SMTP id s5-20020a5edc45000000b0077865fb5e25mr2134840iop.4.1686335464768; Fri, 09 Jun 2023 11:31:04 -0700 (PDT) Received: from robh_at_kernel.org ([64.188.179.250]) by smtp.gmail.com with ESMTPSA id x6-20020a5e8306000000b0077a1b6f73b9sm1221722iom.41.2023.06.09.11.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 11:31:04 -0700 (PDT) Received: (nullmailer pid 1765318 invoked by uid 1000); Fri, 09 Jun 2023 18:31:02 -0000 From: Rob Herring <robh@kernel.org> To: Jeremy Kerr <jk@ozlabs.org>, Joel Stanley <joel@jms.id.au>, Alistar Popple <alistair@popple.id.au>, Eddie James <eajames@linux.ibm.com> Cc: linux-fsi@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] fsi: Use of_property_read_reg() to parse "reg" Date: Fri, 9 Jun 2023 12:30:56 -0600 Message-Id: <20230609183056.1765183-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_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: <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?1768251511644890171?= X-GMAIL-MSGID: =?utf-8?q?1768251511644890171?= |
Series |
fsi: Use of_property_read_reg() to parse "reg"
|
|
Commit Message
Rob Herring
June 9, 2023, 6:30 p.m. UTC
Use the recently added of_property_read_reg() helper to get the
untranslated "reg" address value.
Signed-off-by: Rob Herring <robh@kernel.org>
---
drivers/fsi/fsi-core.c | 39 +++++++++------------------------------
1 file changed, 9 insertions(+), 30 deletions(-)
Comments
On Fri, Jun 9, 2023 at 12:31 PM Rob Herring <robh@kernel.org> wrote: > > Use the recently added of_property_read_reg() helper to get the > untranslated "reg" address value. > > Signed-off-by: Rob Herring <robh@kernel.org> > --- > drivers/fsi/fsi-core.c | 39 +++++++++------------------------------ > 1 file changed, 9 insertions(+), 30 deletions(-) Ping! > > diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c > index 0b927c9f4267..19c4d5b3bde9 100644 > --- a/drivers/fsi/fsi-core.c > +++ b/drivers/fsi/fsi-core.c > @@ -16,6 +16,7 @@ > #include <linux/idr.h> > #include <linux/module.h> > #include <linux/of.h> > +#include <linux/of_address.h> > #include <linux/slab.h> > #include <linux/bitops.h> > #include <linux/cdev.h> > @@ -415,28 +416,18 @@ EXPORT_SYMBOL_GPL(fsi_slave_release_range); > static bool fsi_device_node_matches(struct device *dev, struct device_node *np, > uint32_t addr, uint32_t size) > { > - unsigned int len, na, ns; > - const __be32 *prop; > - uint32_t psize; > + u64 paddr, psize; > > - na = of_n_addr_cells(np); > - ns = of_n_size_cells(np); > - > - if (na != 1 || ns != 1) > - return false; > - > - prop = of_get_property(np, "reg", &len); > - if (!prop || len != 8) > + if (of_property_read_reg(np, 0, &paddr, &psize)) > return false; > > - if (of_read_number(prop, 1) != addr) > + if (paddr != addr) > return false; > > - psize = of_read_number(prop + 1, 1); > if (psize != size) { > dev_warn(dev, > - "node %s matches probed address, but not size (got 0x%x, expected 0x%x)", > - of_node_full_name(np), psize, size); > + "node %pOF matches probed address, but not size (got 0x%llx, expected 0x%x)", > + np, psize, size); > } > > return true; > @@ -653,24 +644,12 @@ static void fsi_slave_release(struct device *dev) > static bool fsi_slave_node_matches(struct device_node *np, > int link, uint8_t id) > { > - unsigned int len, na, ns; > - const __be32 *prop; > - > - na = of_n_addr_cells(np); > - ns = of_n_size_cells(np); > - > - /* Ensure we have the correct format for addresses and sizes in > - * reg properties > - */ > - if (na != 2 || ns != 0) > - return false; > + u64 addr; > > - prop = of_get_property(np, "reg", &len); > - if (!prop || len != 8) > + if (of_property_read_reg(np, 0, &addr, NULL)) > return false; > > - return (of_read_number(prop, 1) == link) && > - (of_read_number(prop + 1, 1) == id); > + return addr == (((u64)link << 32) | id); > } > > /* Find a matching node for the slave at (link, id). Returns NULL if none > -- > 2.39.2 >
On Fri, Jun 30, 2023 at 3:02 PM Rob Herring <robh@kernel.org> wrote: > > On Fri, Jun 9, 2023 at 12:31 PM Rob Herring <robh@kernel.org> wrote: > > > > Use the recently added of_property_read_reg() helper to get the > > untranslated "reg" address value. > > > > Signed-off-by: Rob Herring <robh@kernel.org> > > --- > > drivers/fsi/fsi-core.c | 39 +++++++++------------------------------ > > 1 file changed, 9 insertions(+), 30 deletions(-) > > Ping! Is FSI still maintained or should we just remove it? > > > > > diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c > > index 0b927c9f4267..19c4d5b3bde9 100644 > > --- a/drivers/fsi/fsi-core.c > > +++ b/drivers/fsi/fsi-core.c > > @@ -16,6 +16,7 @@ > > #include <linux/idr.h> > > #include <linux/module.h> > > #include <linux/of.h> > > +#include <linux/of_address.h> > > #include <linux/slab.h> > > #include <linux/bitops.h> > > #include <linux/cdev.h> > > @@ -415,28 +416,18 @@ EXPORT_SYMBOL_GPL(fsi_slave_release_range); > > static bool fsi_device_node_matches(struct device *dev, struct device_node *np, > > uint32_t addr, uint32_t size) > > { > > - unsigned int len, na, ns; > > - const __be32 *prop; > > - uint32_t psize; > > + u64 paddr, psize; > > > > - na = of_n_addr_cells(np); > > - ns = of_n_size_cells(np); > > - > > - if (na != 1 || ns != 1) > > - return false; > > - > > - prop = of_get_property(np, "reg", &len); > > - if (!prop || len != 8) > > + if (of_property_read_reg(np, 0, &paddr, &psize)) > > return false; > > > > - if (of_read_number(prop, 1) != addr) > > + if (paddr != addr) > > return false; > > > > - psize = of_read_number(prop + 1, 1); > > if (psize != size) { > > dev_warn(dev, > > - "node %s matches probed address, but not size (got 0x%x, expected 0x%x)", > > - of_node_full_name(np), psize, size); > > + "node %pOF matches probed address, but not size (got 0x%llx, expected 0x%x)", > > + np, psize, size); > > } > > > > return true; > > @@ -653,24 +644,12 @@ static void fsi_slave_release(struct device *dev) > > static bool fsi_slave_node_matches(struct device_node *np, > > int link, uint8_t id) > > { > > - unsigned int len, na, ns; > > - const __be32 *prop; > > - > > - na = of_n_addr_cells(np); > > - ns = of_n_size_cells(np); > > - > > - /* Ensure we have the correct format for addresses and sizes in > > - * reg properties > > - */ > > - if (na != 2 || ns != 0) > > - return false; > > + u64 addr; > > > > - prop = of_get_property(np, "reg", &len); > > - if (!prop || len != 8) > > + if (of_property_read_reg(np, 0, &addr, NULL)) > > return false; > > > > - return (of_read_number(prop, 1) == link) && > > - (of_read_number(prop + 1, 1) == id); > > + return addr == (((u64)link << 32) | id); > > } > > > > /* Find a matching node for the slave at (link, id). Returns NULL if none > > -- > > 2.39.2 > >
On 7/18/23 14:03, Rob Herring wrote: > On Fri, Jun 30, 2023 at 3:02 PM Rob Herring <robh@kernel.org> wrote: >> On Fri, Jun 9, 2023 at 12:31 PM Rob Herring <robh@kernel.org> wrote: >>> Use the recently added of_property_read_reg() helper to get the >>> untranslated "reg" address value. >>> >>> Signed-off-by: Rob Herring <robh@kernel.org> >>> --- >>> drivers/fsi/fsi-core.c | 39 +++++++++------------------------------ >>> 1 file changed, 9 insertions(+), 30 deletions(-) >> Ping! > Is FSI still maintained or should we just remove it? Yes, it is. Reviewed-by: Eddie James <eajames@linux.ibm.com> > >>> diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c >>> index 0b927c9f4267..19c4d5b3bde9 100644 >>> --- a/drivers/fsi/fsi-core.c >>> +++ b/drivers/fsi/fsi-core.c >>> @@ -16,6 +16,7 @@ >>> #include <linux/idr.h> >>> #include <linux/module.h> >>> #include <linux/of.h> >>> +#include <linux/of_address.h> >>> #include <linux/slab.h> >>> #include <linux/bitops.h> >>> #include <linux/cdev.h> >>> @@ -415,28 +416,18 @@ EXPORT_SYMBOL_GPL(fsi_slave_release_range); >>> static bool fsi_device_node_matches(struct device *dev, struct device_node *np, >>> uint32_t addr, uint32_t size) >>> { >>> - unsigned int len, na, ns; >>> - const __be32 *prop; >>> - uint32_t psize; >>> + u64 paddr, psize; >>> >>> - na = of_n_addr_cells(np); >>> - ns = of_n_size_cells(np); >>> - >>> - if (na != 1 || ns != 1) >>> - return false; >>> - >>> - prop = of_get_property(np, "reg", &len); >>> - if (!prop || len != 8) >>> + if (of_property_read_reg(np, 0, &paddr, &psize)) >>> return false; >>> >>> - if (of_read_number(prop, 1) != addr) >>> + if (paddr != addr) >>> return false; >>> >>> - psize = of_read_number(prop + 1, 1); >>> if (psize != size) { >>> dev_warn(dev, >>> - "node %s matches probed address, but not size (got 0x%x, expected 0x%x)", >>> - of_node_full_name(np), psize, size); >>> + "node %pOF matches probed address, but not size (got 0x%llx, expected 0x%x)", >>> + np, psize, size); >>> } >>> >>> return true; >>> @@ -653,24 +644,12 @@ static void fsi_slave_release(struct device *dev) >>> static bool fsi_slave_node_matches(struct device_node *np, >>> int link, uint8_t id) >>> { >>> - unsigned int len, na, ns; >>> - const __be32 *prop; >>> - >>> - na = of_n_addr_cells(np); >>> - ns = of_n_size_cells(np); >>> - >>> - /* Ensure we have the correct format for addresses and sizes in >>> - * reg properties >>> - */ >>> - if (na != 2 || ns != 0) >>> - return false; >>> + u64 addr; >>> >>> - prop = of_get_property(np, "reg", &len); >>> - if (!prop || len != 8) >>> + if (of_property_read_reg(np, 0, &addr, NULL)) >>> return false; >>> >>> - return (of_read_number(prop, 1) == link) && >>> - (of_read_number(prop + 1, 1) == id); >>> + return addr == (((u64)link << 32) | id); >>> } >>> >>> /* Find a matching node for the slave at (link, id). Returns NULL if none >>> -- >>> 2.39.2 >>>
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 0b927c9f4267..19c4d5b3bde9 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -16,6 +16,7 @@ #include <linux/idr.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_address.h> #include <linux/slab.h> #include <linux/bitops.h> #include <linux/cdev.h> @@ -415,28 +416,18 @@ EXPORT_SYMBOL_GPL(fsi_slave_release_range); static bool fsi_device_node_matches(struct device *dev, struct device_node *np, uint32_t addr, uint32_t size) { - unsigned int len, na, ns; - const __be32 *prop; - uint32_t psize; + u64 paddr, psize; - na = of_n_addr_cells(np); - ns = of_n_size_cells(np); - - if (na != 1 || ns != 1) - return false; - - prop = of_get_property(np, "reg", &len); - if (!prop || len != 8) + if (of_property_read_reg(np, 0, &paddr, &psize)) return false; - if (of_read_number(prop, 1) != addr) + if (paddr != addr) return false; - psize = of_read_number(prop + 1, 1); if (psize != size) { dev_warn(dev, - "node %s matches probed address, but not size (got 0x%x, expected 0x%x)", - of_node_full_name(np), psize, size); + "node %pOF matches probed address, but not size (got 0x%llx, expected 0x%x)", + np, psize, size); } return true; @@ -653,24 +644,12 @@ static void fsi_slave_release(struct device *dev) static bool fsi_slave_node_matches(struct device_node *np, int link, uint8_t id) { - unsigned int len, na, ns; - const __be32 *prop; - - na = of_n_addr_cells(np); - ns = of_n_size_cells(np); - - /* Ensure we have the correct format for addresses and sizes in - * reg properties - */ - if (na != 2 || ns != 0) - return false; + u64 addr; - prop = of_get_property(np, "reg", &len); - if (!prop || len != 8) + if (of_property_read_reg(np, 0, &addr, NULL)) return false; - return (of_read_number(prop, 1) == link) && - (of_read_number(prop + 1, 1) == id); + return addr == (((u64)link << 32) | id); } /* Find a matching node for the slave at (link, id). Returns NULL if none