LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] ata: Use of_property_read_reg() to parse "reg"
@ 2023-06-09 18:31 Rob Herring
  2023-06-10 20:39 ` Sergey Shtylyov
  2023-06-13  6:43 ` Damien Le Moal
  0 siblings, 2 replies; 3+ messages in thread
From: Rob Herring @ 2023-06-09 18:31 UTC (permalink / raw)
  To: Sergey Shtylyov, Damien Le Moal; +Cc: linux-ide, 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/ata/pata_octeon_cf.c | 26 +++++++++-----------------
 drivers/ata/sata_svw.c       |  7 ++++---
 2 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c
index b1ce9f1761af..57b2166a6d5d 100644
--- a/drivers/ata/pata_octeon_cf.c
+++ b/drivers/ata/pata_octeon_cf.c
@@ -804,9 +804,7 @@ static int octeon_cf_probe(struct platform_device *pdev)
 	struct resource *res_cs0, *res_cs1;
 
 	bool is_16bit;
-	const __be32 *cs_num;
-	struct property *reg_prop;
-	int n_addr, n_size, reg_len;
+	u64 reg;
 	struct device_node *node;
 	void __iomem *cs0;
 	void __iomem *cs1 = NULL;
@@ -834,15 +832,10 @@ static int octeon_cf_probe(struct platform_device *pdev)
 	else
 		is_16bit = false;
 
-	n_addr = of_n_addr_cells(node);
-	n_size = of_n_size_cells(node);
-
-	reg_prop = of_find_property(node, "reg", &reg_len);
-	if (!reg_prop || reg_len < sizeof(__be32))
-		return -EINVAL;
-
-	cs_num = reg_prop->value;
-	cf_port->cs0 = be32_to_cpup(cs_num);
+	rv = of_property_read_reg(node, 0, &reg, NULL);
+	if (rv < 0)
+		return rv;
+	cf_port->cs0 = upper_32_bits(reg);
 
 	if (cf_port->is_true_ide) {
 		struct device_node *dma_node;
@@ -884,13 +877,12 @@ static int octeon_cf_probe(struct platform_device *pdev)
 		cs1 = devm_ioremap(&pdev->dev, res_cs1->start,
 					   resource_size(res_cs1));
 		if (!cs1)
-			return rv;
-
-		if (reg_len < (n_addr + n_size + 1) * sizeof(__be32))
 			return -EINVAL;
 
-		cs_num += n_addr + n_size;
-		cf_port->cs1 = be32_to_cpup(cs_num);
+		rv = of_property_read_reg(node, 1, &reg, NULL);
+		if (rv < 0)
+			return rv;
+		cf_port->cs1 = upper_32_bits(reg);
 	}
 
 	res_cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index c47c3fb434d5..b3cc23d891d5 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -32,6 +32,7 @@
 #include <scsi/scsi.h>
 #include <linux/libata.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 
 #define DRV_NAME	"sata_svw"
 #define DRV_VERSION	"2.3"
@@ -319,10 +320,10 @@ static int k2_sata_show_info(struct seq_file *m, struct Scsi_Host *shost)
 	/* Match it to a port node */
 	index = (ap == ap->host->ports[0]) ? 0 : 1;
 	for (np = np->child; np != NULL; np = np->sibling) {
-		const u32 *reg = of_get_property(np, "reg", NULL);
-		if (!reg)
+		u64 reg;
+		if (of_property_read_reg(np, 0, &reg, NULL))
 			continue;
-		if (index == *reg) {
+		if (index == reg) {
 			seq_printf(m, "devspec: %pOF\n", np);
 			break;
 		}
-- 
2.39.2


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

* Re: [PATCH] ata: Use of_property_read_reg() to parse "reg"
  2023-06-09 18:31 [PATCH] ata: Use of_property_read_reg() to parse "reg" Rob Herring
@ 2023-06-10 20:39 ` Sergey Shtylyov
  2023-06-13  6:43 ` Damien Le Moal
  1 sibling, 0 replies; 3+ messages in thread
From: Sergey Shtylyov @ 2023-06-10 20:39 UTC (permalink / raw)
  To: Rob Herring, Damien Le Moal; +Cc: linux-ide, linux-kernel

Hello!

On 6/9/23 9:31 PM, Rob Herring 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>
[...]


Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>

> diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
> index c47c3fb434d5..b3cc23d891d5 100644
> --- a/drivers/ata/sata_svw.c
[...]
> @@ -319,10 +320,10 @@ static int k2_sata_show_info(struct seq_file *m, struct Scsi_Host *shost)
>  	/* Match it to a port node */
>  	index = (ap == ap->host->ports[0]) ? 0 : 1;
>  	for (np = np->child; np != NULL; np = np->sibling) {
> -		const u32 *reg = of_get_property(np, "reg", NULL);
> -		if (!reg)
> +		u64 reg;

   An empty line wouldn't hurt here... :-)

> +		if (of_property_read_reg(np, 0, &reg, NULL))
>  			continue;
> -		if (index == *reg) {
> +		if (index == reg) {
>  			seq_printf(m, "devspec: %pOF\n", np);
>  			break;
>  		}

MBR, Sergey

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

* Re: [PATCH] ata: Use of_property_read_reg() to parse "reg"
  2023-06-09 18:31 [PATCH] ata: Use of_property_read_reg() to parse "reg" Rob Herring
  2023-06-10 20:39 ` Sergey Shtylyov
@ 2023-06-13  6:43 ` Damien Le Moal
  1 sibling, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2023-06-13  6:43 UTC (permalink / raw)
  To: Rob Herring, Sergey Shtylyov; +Cc: linux-ide, linux-kernel

On 6/10/23 03:31, Rob Herring 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>

Applied to for-6.5 with the blan line after the declaration added as Sergey
suggested. Thanks !

-- 
Damien Le Moal
Western Digital Research


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

end of thread, other threads:[~2023-06-13  6:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-09 18:31 [PATCH] ata: Use of_property_read_reg() to parse "reg" Rob Herring
2023-06-10 20:39 ` Sergey Shtylyov
2023-06-13  6:43 ` Damien Le Moal

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