diff mbox series

[net-next,03/13] net: dsa: lantiq_gswip: Use dev_err_probe where appropriate

Message ID 20240606085234.565551-4-ms@dev.tdt.de (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: lantiq_gswip: code improvements | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 901 this patch: 901
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 905 this patch: 905
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 905 this patch: 905
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 115 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-06-07--09-00 (tests: 1041)

Commit Message

Martin Schiller June 6, 2024, 8:52 a.m. UTC
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

dev_err_probe() can be used to simplify the existing code. Also it means
we get rid of the following warning which is seen whenever the PMAC
(Ethernet controller which connects to GSWIP's CPU port) has not been
probed yet:
  gswip 1e108000.switch: dsa switch register failed: -517

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/net/dsa/lantiq_gswip.c | 53 ++++++++++++++++------------------
 1 file changed, 25 insertions(+), 28 deletions(-)

Comments

Vladimir Oltean June 7, 2024, 11:07 a.m. UTC | #1
On Thu, Jun 06, 2024 at 10:52:24AM +0200, Martin Schiller wrote:
> @@ -2050,8 +2048,9 @@ static int gswip_gphy_fw_list(struct gswip_priv *priv,
>  			priv->gphy_fw_name_cfg = &xrx200a2x_gphy_data;
>  			break;
>  		default:
> -			dev_err(dev, "unknown GSWIP version: 0x%x", version);
> -			return -ENOENT;
> +			return dev_err_probe(dev, -ENOENT,
> +					     "unknown GSWIP version: 0x%x",
> +					     version);
>  		}
>  	}
>  
> @@ -2059,10 +2058,9 @@ static int gswip_gphy_fw_list(struct gswip_priv *priv,
>  	if (match && match->data)
>  		priv->gphy_fw_name_cfg = match->data;
>  
> -	if (!priv->gphy_fw_name_cfg) {
> -		dev_err(dev, "GPHY compatible type not supported");
> -		return -ENOENT;
> -	}
> +	if (!priv->gphy_fw_name_cfg)
> +		return dev_err_probe(dev, -ENOENT,
> +				     "GPHY compatible type not supported");
>  
>  	priv->num_gphy_fw = of_get_available_child_count(gphy_fw_list_np);
>  	if (!priv->num_gphy_fw)
> @@ -2163,8 +2161,8 @@ static int gswip_probe(struct platform_device *pdev)
>  			return -EINVAL;
>  		break;
>  	default:
> -		dev_err(dev, "unknown GSWIP version: 0x%x", version);
> -		return -ENOENT;
> +		return dev_err_probe(dev, -ENOENT,
> +				     "unknown GSWIP version: 0x%x", version);
>  	}
>  
>  	/* bring up the mdio bus */
> @@ -2172,28 +2170,27 @@ static int gswip_probe(struct platform_device *pdev)
>  	if (!dsa_is_cpu_port(priv->ds, priv->hw_info->cpu_port)) {
> -		dev_err(dev, "wrong CPU port defined, HW only supports port: %i",
> -			priv->hw_info->cpu_port);
> -		err = -EINVAL;
> +		err = dev_err_probe(dev, -EINVAL,
> +				    "wrong CPU port defined, HW only supports port: %i",
> +				    priv->hw_info->cpu_port);
>  		goto disable_switch;
>  	}

Nitpick: there is no terminating \n here.
Martin Schiller June 7, 2024, 12:09 p.m. UTC | #2
On 2024-06-07 13:07, Vladimir Oltean wrote:
> On Thu, Jun 06, 2024 at 10:52:24AM +0200, Martin Schiller wrote:
>> @@ -2050,8 +2048,9 @@ static int gswip_gphy_fw_list(struct gswip_priv 
>> *priv,
>>  			priv->gphy_fw_name_cfg = &xrx200a2x_gphy_data;
>>  			break;
>>  		default:
>> -			dev_err(dev, "unknown GSWIP version: 0x%x", version);
>> -			return -ENOENT;
>> +			return dev_err_probe(dev, -ENOENT,
>> +					     "unknown GSWIP version: 0x%x",
>> +					     version);
>>  		}
>>  	}
>> 
>> @@ -2059,10 +2058,9 @@ static int gswip_gphy_fw_list(struct gswip_priv 
>> *priv,
>>  	if (match && match->data)
>>  		priv->gphy_fw_name_cfg = match->data;
>> 
>> -	if (!priv->gphy_fw_name_cfg) {
>> -		dev_err(dev, "GPHY compatible type not supported");
>> -		return -ENOENT;
>> -	}
>> +	if (!priv->gphy_fw_name_cfg)
>> +		return dev_err_probe(dev, -ENOENT,
>> +				     "GPHY compatible type not supported");
>> 
>>  	priv->num_gphy_fw = of_get_available_child_count(gphy_fw_list_np);
>>  	if (!priv->num_gphy_fw)
>> @@ -2163,8 +2161,8 @@ static int gswip_probe(struct platform_device 
>> *pdev)
>>  			return -EINVAL;
>>  		break;
>>  	default:
>> -		dev_err(dev, "unknown GSWIP version: 0x%x", version);
>> -		return -ENOENT;
>> +		return dev_err_probe(dev, -ENOENT,
>> +				     "unknown GSWIP version: 0x%x", version);
>>  	}
>> 
>>  	/* bring up the mdio bus */
>> @@ -2172,28 +2170,27 @@ static int gswip_probe(struct platform_device 
>> *pdev)
>>  	if (!dsa_is_cpu_port(priv->ds, priv->hw_info->cpu_port)) {
>> -		dev_err(dev, "wrong CPU port defined, HW only supports port: %i",
>> -			priv->hw_info->cpu_port);
>> -		err = -EINVAL;
>> +		err = dev_err_probe(dev, -EINVAL,
>> +				    "wrong CPU port defined, HW only supports port: %i",
>> +				    priv->hw_info->cpu_port);
>>  		goto disable_switch;
>>  	}
> 
> Nitpick: there is no terminating \n here.

Oh, thanks for the hint. I'll correct that (and also check the complete 
source
file for that kind of mistakes).
diff mbox series

Patch

diff --git a/drivers/net/dsa/lantiq_gswip.c b/drivers/net/dsa/lantiq_gswip.c
index b9c7076ce32f..fcb5929c9c88 100644
--- a/drivers/net/dsa/lantiq_gswip.c
+++ b/drivers/net/dsa/lantiq_gswip.c
@@ -1931,11 +1931,9 @@  static int gswip_gphy_fw_load(struct gswip_priv *priv, struct gswip_gphy_fw *gph
 	msleep(200);
 
 	ret = request_firmware(&fw, gphy_fw->fw_name, dev);
-	if (ret) {
-		dev_err(dev, "failed to load firmware: %s, error: %i\n",
-			gphy_fw->fw_name, ret);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to load firmware: %s\n",
+				     gphy_fw->fw_name);
 
 	/* GPHY cores need the firmware code in a persistent and contiguous
 	 * memory area with a 16 kB boundary aligned start address.
@@ -1948,9 +1946,9 @@  static int gswip_gphy_fw_load(struct gswip_priv *priv, struct gswip_gphy_fw *gph
 		dev_addr = ALIGN(dma_addr, XRX200_GPHY_FW_ALIGN);
 		memcpy(fw_addr, fw->data, fw->size);
 	} else {
-		dev_err(dev, "failed to alloc firmware memory\n");
 		release_firmware(fw);
-		return -ENOMEM;
+		return dev_err_probe(dev, -ENOMEM,
+				     "failed to alloc firmware memory\n");
 	}
 
 	release_firmware(fw);
@@ -1977,8 +1975,8 @@  static int gswip_gphy_fw_probe(struct gswip_priv *priv,
 
 	gphy_fw->clk_gate = devm_clk_get(dev, gphyname);
 	if (IS_ERR(gphy_fw->clk_gate)) {
-		dev_err(dev, "Failed to lookup gate clock\n");
-		return PTR_ERR(gphy_fw->clk_gate);
+		return dev_err_probe(dev, PTR_ERR(gphy_fw->clk_gate),
+				     "Failed to lookup gate clock\n");
 	}
 
 	ret = of_property_read_u32(gphy_fw_np, "reg", &gphy_fw->fw_addr_offset);
@@ -1998,8 +1996,8 @@  static int gswip_gphy_fw_probe(struct gswip_priv *priv,
 		gphy_fw->fw_name = priv->gphy_fw_name_cfg->ge_firmware_name;
 		break;
 	default:
-		dev_err(dev, "Unknown GPHY mode %d\n", gphy_mode);
-		return -EINVAL;
+		return dev_err_probe(dev, -EINVAL, "Unknown GPHY mode %d\n",
+				     gphy_mode);
 	}
 
 	gphy_fw->reset = of_reset_control_array_get_exclusive(gphy_fw_np);
@@ -2050,8 +2048,9 @@  static int gswip_gphy_fw_list(struct gswip_priv *priv,
 			priv->gphy_fw_name_cfg = &xrx200a2x_gphy_data;
 			break;
 		default:
-			dev_err(dev, "unknown GSWIP version: 0x%x", version);
-			return -ENOENT;
+			return dev_err_probe(dev, -ENOENT,
+					     "unknown GSWIP version: 0x%x",
+					     version);
 		}
 	}
 
@@ -2059,10 +2058,9 @@  static int gswip_gphy_fw_list(struct gswip_priv *priv,
 	if (match && match->data)
 		priv->gphy_fw_name_cfg = match->data;
 
-	if (!priv->gphy_fw_name_cfg) {
-		dev_err(dev, "GPHY compatible type not supported");
-		return -ENOENT;
-	}
+	if (!priv->gphy_fw_name_cfg)
+		return dev_err_probe(dev, -ENOENT,
+				     "GPHY compatible type not supported");
 
 	priv->num_gphy_fw = of_get_available_child_count(gphy_fw_list_np);
 	if (!priv->num_gphy_fw)
@@ -2163,8 +2161,8 @@  static int gswip_probe(struct platform_device *pdev)
 			return -EINVAL;
 		break;
 	default:
-		dev_err(dev, "unknown GSWIP version: 0x%x", version);
-		return -ENOENT;
+		return dev_err_probe(dev, -ENOENT,
+				     "unknown GSWIP version: 0x%x", version);
 	}
 
 	/* bring up the mdio bus */
@@ -2172,28 +2170,27 @@  static int gswip_probe(struct platform_device *pdev)
 	if (gphy_fw_np) {
 		err = gswip_gphy_fw_list(priv, gphy_fw_np, version);
 		of_node_put(gphy_fw_np);
-		if (err) {
-			dev_err(dev, "gphy fw probe failed\n");
-			return err;
-		}
+		if (err)
+			return dev_err_probe(dev, err,
+					     "gphy fw probe failed\n");
 	}
 
 	/* bring up the mdio bus */
 	err = gswip_mdio(priv);
 	if (err) {
-		dev_err(dev, "mdio probe failed\n");
+		dev_err_probe(dev, err, "mdio probe failed\n");
 		goto gphy_fw_remove;
 	}
 
 	err = dsa_register_switch(priv->ds);
 	if (err) {
-		dev_err(dev, "dsa switch register failed: %i\n", err);
+		dev_err_probe(dev, err, "dsa switch registration failed\n");
 		goto gphy_fw_remove;
 	}
 	if (!dsa_is_cpu_port(priv->ds, priv->hw_info->cpu_port)) {
-		dev_err(dev, "wrong CPU port defined, HW only supports port: %i",
-			priv->hw_info->cpu_port);
-		err = -EINVAL;
+		err = dev_err_probe(dev, -EINVAL,
+				    "wrong CPU port defined, HW only supports port: %i",
+				    priv->hw_info->cpu_port);
 		goto disable_switch;
 	}