public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Shyti <andi.shyti@kernel.org>
To: linux-i2c <linux-i2c@vger.kernel.org>
Cc: Andi Shyti <andi.shyti@kernel.org>
Subject: [PATCH 02/10] i2c: iproc: Use dev_err_probe in probe
Date: Fri, 18 Apr 2025 23:16:27 +0200	[thread overview]
Message-ID: <20250418211635.2666234-3-andi.shyti@kernel.org> (raw)
In-Reply-To: <20250418211635.2666234-1-andi.shyti@kernel.org>

Use dev_err_probe() instead of dev_err() and then return.

Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
---
 drivers/i2c/busses/i2c-bcm-iproc.c | 31 ++++++++++++------------------
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c
index 5d846ab91e6f..2e24959bc9af 100644
--- a/drivers/i2c/busses/i2c-bcm-iproc.c
+++ b/drivers/i2c/busses/i2c-bcm-iproc.c
@@ -1014,17 +1014,14 @@ static int bcm_iproc_i2c_cfg_speed(struct bcm_iproc_i2c_dev *iproc_i2c)
 		bus_speed = I2C_MAX_STANDARD_MODE_FREQ;
 	}
 
-	if (bus_speed < I2C_MAX_STANDARD_MODE_FREQ) {
-		dev_err(iproc_i2c->device, "%d Hz bus speed not supported\n",
-			bus_speed);
-		dev_err(iproc_i2c->device,
-			"valid speeds are 100khz and 400khz\n");
-		return -EINVAL;
-	} else if (bus_speed < I2C_MAX_FAST_MODE_FREQ) {
+	if (bus_speed < I2C_MAX_STANDARD_MODE_FREQ)
+		return dev_err_probe(iproc_i2c->device, -EINVAL,
+				     "%d Hz not supported (out of 100-400 kHz range)\n",
+				     bus_speed);
+	else if (bus_speed < I2C_MAX_FAST_MODE_FREQ)
 		bus_speed = I2C_MAX_STANDARD_MODE_FREQ;
-	} else {
+	else
 		bus_speed = I2C_MAX_FAST_MODE_FREQ;
-	}
 
 	iproc_i2c->bus_speed = bus_speed;
 	val = iproc_i2c_rd_reg(iproc_i2c, TIM_CFG_OFFSET);
@@ -1066,11 +1063,9 @@ static int bcm_iproc_i2c_probe(struct platform_device *pdev)
 		ret = of_property_read_u32(iproc_i2c->device->of_node,
 					   "brcm,ape-hsls-addr-mask",
 					   &iproc_i2c->ape_addr_mask);
-		if (ret < 0) {
-			dev_err(iproc_i2c->device,
-				"'brcm,ape-hsls-addr-mask' missing\n");
-			return -EINVAL;
-		}
+		if (ret < 0)
+			return dev_err_probe(iproc_i2c->device, ret,
+					     "'brcm,ape-hsls-addr-mask' missing\n");
 
 		spin_lock_init(&iproc_i2c->idm_lock);
 
@@ -1090,11 +1085,9 @@ static int bcm_iproc_i2c_probe(struct platform_device *pdev)
 		ret = devm_request_irq(iproc_i2c->device, irq,
 				       bcm_iproc_i2c_isr, 0, pdev->name,
 				       iproc_i2c);
-		if (ret < 0) {
-			dev_err(iproc_i2c->device,
-				"unable to request irq %i\n", irq);
-			return ret;
-		}
+		if (ret < 0)
+			return dev_err_probe(iproc_i2c->device, ret,
+					     "unable to request irq %i\n", irq);
 
 		iproc_i2c->irq = irq;
 	} else {
-- 
2.49.0


  parent reply	other threads:[~2025-04-18 21:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-18 21:16 [PATCH 00/10] Few improvements on the Broadcom iProc Andi Shyti
2025-04-18 21:16 ` [PATCH 01/10] i2c: iproc: Drop unnecessary initialisation of 'ret' Andi Shyti
2025-04-18 21:16 ` Andi Shyti [this message]
2025-04-18 21:16 ` [PATCH 03/10] i2c: iproc: Use u32 instead of uint32_t Andi Shyti
2025-04-18 21:16 ` [PATCH 04/10] i2c: iproc: Fix alignment to match the open parenthesis Andi Shyti
2025-04-18 21:16 ` [PATCH 05/10] i2c: iproc: Remove stray blank line in slave ISR Andi Shyti
2025-04-18 21:16 ` [PATCH 06/10] i2c: iproc: Replace udelay() with usleep_range() Andi Shyti
2025-04-18 21:16 ` [PATCH 07/10] i2c: iproc: Fix indentation of bcm_iproc_i2c_slave_init() Andi Shyti
2025-04-18 21:16 ` [PATCH 08/10] i2c: iproc: Move function and avoid prototypes Andi Shyti
2025-04-19 19:46   ` Mukesh Kumar Savaliya
2025-04-26 20:19     ` [PATCH v2 " Andi Shyti
2025-04-18 21:16 ` [PATCH 09/10] i2c: iproc: When there's an error treat it as an error Andi Shyti
2025-04-18 21:16 ` [PATCH 10/10] i2c: iproc: Remove unnecessary double negation Andi Shyti
2025-04-28 19:30 ` [PATCH 00/10] Few improvements on the Broadcom iProc Andi Shyti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250418211635.2666234-3-andi.shyti@kernel.org \
    --to=andi.shyti@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox