LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] fsi: Use of_property_read_reg() to parse "reg"
@ 2023-06-09 18:30 Rob Herring
  2023-06-30 21:02 ` Rob Herring
  0 siblings, 1 reply; 4+ messages in thread
From: Rob Herring @ 2023-06-09 18:30 UTC (permalink / raw)
  To: Jeremy Kerr, Joel Stanley, Alistar Popple, Eddie James
  Cc: linux-fsi, linux-kernel

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(-)

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] fsi: Use of_property_read_reg() to parse "reg"
  2023-06-09 18:30 [PATCH] fsi: Use of_property_read_reg() to parse "reg" Rob Herring
@ 2023-06-30 21:02 ` Rob Herring
  2023-07-18 19:03   ` Rob Herring
  0 siblings, 1 reply; 4+ messages in thread
From: Rob Herring @ 2023-06-30 21:02 UTC (permalink / raw)
  To: Jeremy Kerr, Joel Stanley, Alistar Popple, Eddie James
  Cc: linux-fsi, linux-kernel

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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fsi: Use of_property_read_reg() to parse "reg"
  2023-06-30 21:02 ` Rob Herring
@ 2023-07-18 19:03   ` Rob Herring
  2023-07-18 21:57     ` Eddie James
  0 siblings, 1 reply; 4+ messages in thread
From: Rob Herring @ 2023-07-18 19:03 UTC (permalink / raw)
  To: Jeremy Kerr, Joel Stanley, Alistar Popple, Eddie James
  Cc: linux-fsi, linux-kernel

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
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fsi: Use of_property_read_reg() to parse "reg"
  2023-07-18 19:03   ` Rob Herring
@ 2023-07-18 21:57     ` Eddie James
  0 siblings, 0 replies; 4+ messages in thread
From: Eddie James @ 2023-07-18 21:57 UTC (permalink / raw)
  To: Rob Herring, Jeremy Kerr, Joel Stanley, Alistar Popple
  Cc: linux-fsi, linux-kernel


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
>>>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-07-18 21:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-09 18:30 [PATCH] fsi: Use of_property_read_reg() to parse "reg" Rob Herring
2023-06-30 21:02 ` Rob Herring
2023-07-18 19:03   ` Rob Herring
2023-07-18 21:57     ` Eddie James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).