mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ata: ahci_ceva: return of_property_read_u8_array() error code
@ 2024-03-20 18:51 Radhey Shyam Pandey
  2024-03-21  9:22 ` Markus Elfring
  2024-03-21 23:58 ` Damien Le Moal
  0 siblings, 2 replies; 3+ messages in thread
From: Radhey Shyam Pandey @ 2024-03-20 18:51 UTC (permalink / raw)
  To: dlemoal, cassel, Markus.Elfring
  Cc: linux-ide, linux-kernel, git, Radhey Shyam Pandey

In the ahci_ceva_probe() error path instead of returning -EINVAL for all
of_property_read_u8_array() failure types return the actual error code.
It removes the redundant -EINVAL assignment at multiple places and
improves the error handling path.

Reported-by: Markus Elfring <Markus.Elfring@web.de>
Closes: https://lore.kernel.org/all/9427c0fd-f48a-4104-ac7e-2929be3562af@web.de/
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
---
 drivers/ata/ahci_ceva.c | 48 ++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/ata/ahci_ceva.c b/drivers/ata/ahci_ceva.c
index 11a2c199a7c2..b54ee80c068f 100644
--- a/drivers/ata/ahci_ceva.c
+++ b/drivers/ata/ahci_ceva.c
@@ -274,62 +274,62 @@ static int ceva_ahci_probe(struct platform_device *pdev)
 		cevapriv->flags = CEVA_FLAG_BROKEN_GEN2;
 
 	/* Read OOB timing value for COMINIT from device-tree */
-	if (of_property_read_u8_array(np, "ceva,p0-cominit-params",
-					(u8 *)&cevapriv->pp2c[0], 4) < 0) {
+	rc = of_property_read_u8_array(np, "ceva,p0-cominit-params",
+				       (u8 *)&cevapriv->pp2c[0], 4);
+	if (rc < 0) {
 		dev_warn(dev, "ceva,p0-cominit-params property not defined\n");
-		rc = -EINVAL;
 		goto disable_resources;
 	}
 
-	if (of_property_read_u8_array(np, "ceva,p1-cominit-params",
-					(u8 *)&cevapriv->pp2c[1], 4) < 0) {
+	rc = of_property_read_u8_array(np, "ceva,p1-cominit-params",
+				       (u8 *)&cevapriv->pp2c[1], 4);
+	if (rc < 0) {
 		dev_warn(dev, "ceva,p1-cominit-params property not defined\n");
-		rc = -EINVAL;
 		goto disable_resources;
 	}
 
 	/* Read OOB timing value for COMWAKE from device-tree*/
-	if (of_property_read_u8_array(np, "ceva,p0-comwake-params",
-					(u8 *)&cevapriv->pp3c[0], 4) < 0) {
+	rc = of_property_read_u8_array(np, "ceva,p0-comwake-params",
+				       (u8 *)&cevapriv->pp3c[0], 4);
+	if (rc < 0) {
 		dev_warn(dev, "ceva,p0-comwake-params property not defined\n");
-		rc = -EINVAL;
 		goto disable_resources;
 	}
 
-	if (of_property_read_u8_array(np, "ceva,p1-comwake-params",
-					(u8 *)&cevapriv->pp3c[1], 4) < 0) {
+	rc = of_property_read_u8_array(np, "ceva,p1-comwake-params",
+				       (u8 *)&cevapriv->pp3c[1], 4);
+	if (rc < 0) {
 		dev_warn(dev, "ceva,p1-comwake-params property not defined\n");
-		rc = -EINVAL;
 		goto disable_resources;
 	}
 
 	/* Read phy BURST timing value from device-tree */
-	if (of_property_read_u8_array(np, "ceva,p0-burst-params",
-					(u8 *)&cevapriv->pp4c[0], 4) < 0) {
+	rc = of_property_read_u8_array(np, "ceva,p0-burst-params",
+				       (u8 *)&cevapriv->pp4c[0], 4);
+	if (rc < 0) {
 		dev_warn(dev, "ceva,p0-burst-params property not defined\n");
-		rc = -EINVAL;
 		goto disable_resources;
 	}
 
-	if (of_property_read_u8_array(np, "ceva,p1-burst-params",
-					(u8 *)&cevapriv->pp4c[1], 4) < 0) {
+	rc = of_property_read_u8_array(np, "ceva,p1-burst-params",
+				       (u8 *)&cevapriv->pp4c[1], 4);
+	if (rc < 0) {
 		dev_warn(dev, "ceva,p1-burst-params property not defined\n");
-		rc = -EINVAL;
 		goto disable_resources;
 	}
 
 	/* Read phy RETRY interval timing value from device-tree */
-	if (of_property_read_u16_array(np, "ceva,p0-retry-params",
-					(u16 *)&cevapriv->pp5c[0], 2) < 0) {
+	rc = of_property_read_u16_array(np, "ceva,p0-retry-params",
+					(u16 *)&cevapriv->pp5c[0], 2);
+	if (rc < 0) {
 		dev_warn(dev, "ceva,p0-retry-params property not defined\n");
-		rc = -EINVAL;
 		goto disable_resources;
 	}
 
-	if (of_property_read_u16_array(np, "ceva,p1-retry-params",
-					(u16 *)&cevapriv->pp5c[1], 2) < 0) {
+	rc = of_property_read_u16_array(np, "ceva,p1-retry-params",
+					(u16 *)&cevapriv->pp5c[1], 2);
+	if (rc < 0) {
 		dev_warn(dev, "ceva,p1-retry-params property not defined\n");
-		rc = -EINVAL;
 		goto disable_resources;
 	}
 
-- 
2.34.1


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

* Re: [PATCH] ata: ahci_ceva: return of_property_read_u8_array() error code
  2024-03-20 18:51 [PATCH] ata: ahci_ceva: return of_property_read_u8_array() error code Radhey Shyam Pandey
@ 2024-03-21  9:22 ` Markus Elfring
  2024-03-21 23:58 ` Damien Le Moal
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2024-03-21  9:22 UTC (permalink / raw)
  To: Radhey Shyam Pandey, linux-ide, kernel-janitors, git,
	Damien Le Moal, Niklas Cassel
  Cc: LKML, Jens Axboe, Michal Simek, Peter Zijlstra, Philipp Zabel

> In the ahci_ceva_probe() error path instead of returning -EINVAL for all
> of_property_read_u8_array() failure types return the actual error code.
> It removes the redundant -EINVAL assignment at multiple places and
> improves the error handling path.

A) Would a change description be more desirable with a corresponding imperative wording?

   See also:
   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.8#n94


B) Can it be helpful to specify the hint “in ceva_ahci_probe()” at the end
   of the patch subject?


C) How do you think about to extend the application of scope-based resource management here?

   See also:
   Article by Jonathan Corbet
   2023-06-15
   https://lwn.net/Articles/934679/


Regards,
Markus

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

* Re: [PATCH] ata: ahci_ceva: return of_property_read_u8_array() error code
  2024-03-20 18:51 [PATCH] ata: ahci_ceva: return of_property_read_u8_array() error code Radhey Shyam Pandey
  2024-03-21  9:22 ` Markus Elfring
@ 2024-03-21 23:58 ` Damien Le Moal
  1 sibling, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2024-03-21 23:58 UTC (permalink / raw)
  To: Radhey Shyam Pandey, cassel; +Cc: linux-ide, linux-kernel, git

On 3/21/24 03:51, Radhey Shyam Pandey wrote:
> In the ahci_ceva_probe() error path instead of returning -EINVAL for all
> of_property_read_u8_array() failure types return the actual error code.
> It removes the redundant -EINVAL assignment at multiple places and
> improves the error handling path.
> 
> Reported-by: Markus Elfring <Markus.Elfring@web.de>
> Closes: https://lore.kernel.org/all/9427c0fd-f48a-4104-ac7e-2929be3562af@web.de/
> Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
> ---
>  drivers/ata/ahci_ceva.c | 48 ++++++++++++++++++++---------------------
>  1 file changed, 24 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/ata/ahci_ceva.c b/drivers/ata/ahci_ceva.c
> index 11a2c199a7c2..b54ee80c068f 100644
> --- a/drivers/ata/ahci_ceva.c
> +++ b/drivers/ata/ahci_ceva.c
> @@ -274,62 +274,62 @@ static int ceva_ahci_probe(struct platform_device *pdev)
>  		cevapriv->flags = CEVA_FLAG_BROKEN_GEN2;
>  
>  	/* Read OOB timing value for COMINIT from device-tree */
> -	if (of_property_read_u8_array(np, "ceva,p0-cominit-params",
> -					(u8 *)&cevapriv->pp2c[0], 4) < 0) {
> +	rc = of_property_read_u8_array(np, "ceva,p0-cominit-params",
> +				       (u8 *)&cevapriv->pp2c[0], 4);
> +	if (rc < 0) {
>  		dev_warn(dev, "ceva,p0-cominit-params property not defined\n");
> -		rc = -EINVAL;
>  		goto disable_resources;
>  	}
>  
> -	if (of_property_read_u8_array(np, "ceva,p1-cominit-params",
> -					(u8 *)&cevapriv->pp2c[1], 4) < 0) {
> +	rc = of_property_read_u8_array(np, "ceva,p1-cominit-params",
> +				       (u8 *)&cevapriv->pp2c[1], 4);
> +	if (rc < 0) {

This can be more simply "if (rc)"

>  		dev_warn(dev, "ceva,p1-cominit-params property not defined\n");
> -		rc = -EINVAL;

Here, it may be better to do:

		rc = dev_err_probe(dev, rc, "...");

and remove the dev_warn, as that really should be a dev_err() anyway.
Same pattern for all the other property reads below.

>  		goto disable_resources;
>  	}
>  
>  	/* Read OOB timing value for COMWAKE from device-tree*/
> -	if (of_property_read_u8_array(np, "ceva,p0-comwake-params",
> -					(u8 *)&cevapriv->pp3c[0], 4) < 0) {
> +	rc = of_property_read_u8_array(np, "ceva,p0-comwake-params",
> +				       (u8 *)&cevapriv->pp3c[0], 4);
> +	if (rc < 0) {
>  		dev_warn(dev, "ceva,p0-comwake-params property not defined\n");
> -		rc = -EINVAL;
>  		goto disable_resources;
>  	}
>  
> -	if (of_property_read_u8_array(np, "ceva,p1-comwake-params",
> -					(u8 *)&cevapriv->pp3c[1], 4) < 0) {
> +	rc = of_property_read_u8_array(np, "ceva,p1-comwake-params",
> +				       (u8 *)&cevapriv->pp3c[1], 4);
> +	if (rc < 0) {
>  		dev_warn(dev, "ceva,p1-comwake-params property not defined\n");
> -		rc = -EINVAL;
>  		goto disable_resources;
>  	}
>  
>  	/* Read phy BURST timing value from device-tree */
> -	if (of_property_read_u8_array(np, "ceva,p0-burst-params",
> -					(u8 *)&cevapriv->pp4c[0], 4) < 0) {
> +	rc = of_property_read_u8_array(np, "ceva,p0-burst-params",
> +				       (u8 *)&cevapriv->pp4c[0], 4);
> +	if (rc < 0) {
>  		dev_warn(dev, "ceva,p0-burst-params property not defined\n");
> -		rc = -EINVAL;
>  		goto disable_resources;
>  	}
>  
> -	if (of_property_read_u8_array(np, "ceva,p1-burst-params",
> -					(u8 *)&cevapriv->pp4c[1], 4) < 0) {
> +	rc = of_property_read_u8_array(np, "ceva,p1-burst-params",
> +				       (u8 *)&cevapriv->pp4c[1], 4);
> +	if (rc < 0) {
>  		dev_warn(dev, "ceva,p1-burst-params property not defined\n");
> -		rc = -EINVAL;
>  		goto disable_resources;
>  	}
>  
>  	/* Read phy RETRY interval timing value from device-tree */
> -	if (of_property_read_u16_array(np, "ceva,p0-retry-params",
> -					(u16 *)&cevapriv->pp5c[0], 2) < 0) {
> +	rc = of_property_read_u16_array(np, "ceva,p0-retry-params",
> +					(u16 *)&cevapriv->pp5c[0], 2);
> +	if (rc < 0) {
>  		dev_warn(dev, "ceva,p0-retry-params property not defined\n");
> -		rc = -EINVAL;
>  		goto disable_resources;
>  	}
>  
> -	if (of_property_read_u16_array(np, "ceva,p1-retry-params",
> -					(u16 *)&cevapriv->pp5c[1], 2) < 0) {
> +	rc = of_property_read_u16_array(np, "ceva,p1-retry-params",
> +					(u16 *)&cevapriv->pp5c[1], 2);
> +	if (rc < 0) {
>  		dev_warn(dev, "ceva,p1-retry-params property not defined\n");
> -		rc = -EINVAL;
>  		goto disable_resources;
>  	}
>  

-- 
Damien Le Moal
Western Digital Research


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

end of thread, other threads:[~2024-03-21 23:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-20 18:51 [PATCH] ata: ahci_ceva: return of_property_read_u8_array() error code Radhey Shyam Pandey
2024-03-21  9:22 ` Markus Elfring
2024-03-21 23:58 ` 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

all inboxes | Powered by JetHome®