diff mbox series

pata_octeon_cf: use of_property_read_{bool|u32}()

Message ID 20170827195613.904715064@cogentembedded.com
State Not Applicable
Delegated to: David Miller
Headers show
Series pata_octeon_cf: use of_property_read_{bool|u32}() | expand

Commit Message

Sergei Shtylyov Aug. 27, 2017, 7:55 p.m. UTC
The Octeon CF driver basically  open-codes of_property_read_{bool|u32}()
using  of_{find|get}_property() calls in its  probe() method.  Using the
modern DT APIs saves 2 LoCs and 16 bytes of object code (MIPS gcc 3.4.3).

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
 drivers/ata/pata_octeon_cf.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Tejun Heo Aug. 28, 2017, 5:45 p.m. UTC | #1
On Sun, Aug 27, 2017 at 10:55:09PM +0300, Sergei Shtylyov wrote:
> The Octeon CF driver basically  open-codes of_property_read_{bool|u32}()
> using  of_{find|get}_property() calls in its  probe() method.  Using the
> modern DT APIs saves 2 LoCs and 16 bytes of object code (MIPS gcc 3.4.3).
> 
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

Applied to libata/for-4.14.

Thanks.
David Daney Aug. 28, 2017, 9:52 p.m. UTC | #2
On 08/27/2017 12:55 PM, Sergei Shtylyov wrote:
> The Octeon CF driver basically  open-codes of_property_read_{bool|u32}()
> using  of_{find|get}_property() calls in its  probe() method.  Using the
> modern DT APIs saves 2 LoCs and 16 bytes of object code (MIPS gcc 3.4.3).
> 
> Signed-off-by: Sergei Shtylyov<sergei.shtylyov@cogentembedded.com>

It still works with this applied, so:

Acked-by: David Daney <david.daney@cavium.com>

> 
> ---
>   drivers/ata/pata_octeon_cf.c |   10 ++++------
>   1 file changed, 4 insertions(+), 6 deletions(-)
> 
> Index: libata/drivers/ata/pata_octeon_cf.c
> ===================================================================
> --- libata.orig/drivers/ata/pata_octeon_cf.c
> +++ libata/drivers/ata/pata_octeon_cf.c
> @@ -840,7 +840,6 @@ static int octeon_cf_probe(struct platfo
>   	struct property *reg_prop;
>   	int n_addr, n_size, reg_len;
>   	struct device_node *node;
> -	const void *prop;
>   	void __iomem *cs0;
>   	void __iomem *cs1 = NULL;
>   	struct ata_host *host;
> @@ -850,7 +849,7 @@ static int octeon_cf_probe(struct platfo
>   	void __iomem *base;
>   	struct octeon_cf_port *cf_port;
>   	int rv = -ENOMEM;
> -
> +	u32 bus_width;
>   
>   	node = pdev->dev.of_node;
>   	if (node == NULL)
> @@ -860,11 +859,10 @@ static int octeon_cf_probe(struct platfo
>   	if (!cf_port)
>   		return -ENOMEM;
>   
> -	cf_port->is_true_ide = (of_find_property(node, "cavium,true-ide", NULL) != NULL);
> +	cf_port->is_true_ide = of_property_read_bool(node, "cavium,true-ide");
>   
> -	prop = of_get_property(node, "cavium,bus-width", NULL);
> -	if (prop)
> -		is_16bit = (be32_to_cpup(prop) == 16);
> +	if (of_property_read_u32(node, "cavium,bus-width", &bus_width) == 0)
> +		is_16bit = (bus_width == 16);
>   	else
>   		is_16bit = false;
>   
> 
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

Index: libata/drivers/ata/pata_octeon_cf.c
===================================================================
--- libata.orig/drivers/ata/pata_octeon_cf.c
+++ libata/drivers/ata/pata_octeon_cf.c
@@ -840,7 +840,6 @@  static int octeon_cf_probe(struct platfo
 	struct property *reg_prop;
 	int n_addr, n_size, reg_len;
 	struct device_node *node;
-	const void *prop;
 	void __iomem *cs0;
 	void __iomem *cs1 = NULL;
 	struct ata_host *host;
@@ -850,7 +849,7 @@  static int octeon_cf_probe(struct platfo
 	void __iomem *base;
 	struct octeon_cf_port *cf_port;
 	int rv = -ENOMEM;
-
+	u32 bus_width;
 
 	node = pdev->dev.of_node;
 	if (node == NULL)
@@ -860,11 +859,10 @@  static int octeon_cf_probe(struct platfo
 	if (!cf_port)
 		return -ENOMEM;
 
-	cf_port->is_true_ide = (of_find_property(node, "cavium,true-ide", NULL) != NULL);
+	cf_port->is_true_ide = of_property_read_bool(node, "cavium,true-ide");
 
-	prop = of_get_property(node, "cavium,bus-width", NULL);
-	if (prop)
-		is_16bit = (be32_to_cpup(prop) == 16);
+	if (of_property_read_u32(node, "cavium,bus-width", &bus_width) == 0)
+		is_16bit = (bus_width == 16);
 	else
 		is_16bit = false;