public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] i2c: busses: nomadik cleanups
@ 2023-06-11  1:36 Andi Shyti
  2023-06-11  1:36 ` [PATCH 1/3] i2c: busses: i2c-nomadik: Remove unnecessary goto label Andi Shyti
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Andi Shyti @ 2023-06-11  1:36 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-arm-kernel, linux-i2c, Andi Shyti

Hi,

while browing the i2c code I spotted the unused goto. The other
two patches come naturally.

Andi

Andi Shyti (3):
  i2c: busses: i2c-nomadik: Remove unnecessary goto label
  i2c: busses: nomadik: Use devm_clk_get_enabled()
  i2c: busses: nomadik: Use dev_err_probe() whenever possible

 drivers/i2c/busses/i2c-nomadik.c | 45 +++++++++-----------------------
 1 file changed, 13 insertions(+), 32 deletions(-)

-- 
2.40.1


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

* [PATCH 1/3] i2c: busses: i2c-nomadik: Remove unnecessary goto label
  2023-06-11  1:36 [PATCH 0/3] i2c: busses: nomadik cleanups Andi Shyti
@ 2023-06-11  1:36 ` Andi Shyti
  2023-06-11  1:37 ` [PATCH 2/3] i2c: busses: nomadik: Use devm_clk_get_enabled() Andi Shyti
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andi Shyti @ 2023-06-11  1:36 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-arm-kernel, linux-i2c, Andi Shyti

The err_no_mem goto label doesn't do anything. Remove it.

Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
---
 drivers/i2c/busses/i2c-nomadik.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 5004b9dd98563..8b9577318388e 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -971,10 +971,9 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
 	u32 max_fifo_threshold = (vendor->fifodepth / 2) - 1;
 
 	dev = devm_kzalloc(&adev->dev, sizeof(*dev), GFP_KERNEL);
-	if (!dev) {
-		ret = -ENOMEM;
-		goto err_no_mem;
-	}
+	if (!dev)
+		return -ENOMEM;
+
 	dev->vendor = vendor;
 	dev->adev = adev;
 	nmk_i2c_of_probe(np, dev);
@@ -995,30 +994,27 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
 
 	dev->virtbase = devm_ioremap(&adev->dev, adev->res.start,
 				resource_size(&adev->res));
-	if (!dev->virtbase) {
-		ret = -ENOMEM;
-		goto err_no_mem;
-	}
+	if (!dev->virtbase)
+		return -ENOMEM;
 
 	dev->irq = adev->irq[0];
 	ret = devm_request_irq(&adev->dev, dev->irq, i2c_irq_handler, 0,
 				DRIVER_NAME, dev);
 	if (ret) {
 		dev_err(&adev->dev, "cannot claim the irq %d\n", dev->irq);
-		goto err_no_mem;
+		return ret;
 	}
 
 	dev->clk = devm_clk_get(&adev->dev, NULL);
 	if (IS_ERR(dev->clk)) {
 		dev_err(&adev->dev, "could not get i2c clock\n");
-		ret = PTR_ERR(dev->clk);
-		goto err_no_mem;
+		return PTR_ERR(dev->clk);
 	}
 
 	ret = clk_prepare_enable(dev->clk);
 	if (ret) {
 		dev_err(&adev->dev, "can't prepare_enable clock\n");
-		goto err_no_mem;
+		return ret;
 	}
 
 	init_hw(dev);
@@ -1049,7 +1045,6 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
 
  err_no_adap:
 	clk_disable_unprepare(dev->clk);
- err_no_mem:
 
 	return ret;
 }
-- 
2.40.1


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

* [PATCH 2/3] i2c: busses: nomadik: Use devm_clk_get_enabled()
  2023-06-11  1:36 [PATCH 0/3] i2c: busses: nomadik cleanups Andi Shyti
  2023-06-11  1:36 ` [PATCH 1/3] i2c: busses: i2c-nomadik: Remove unnecessary goto label Andi Shyti
@ 2023-06-11  1:37 ` Andi Shyti
  2023-06-11  1:37 ` [PATCH 3/3] i2c: busses: nomadik: Use dev_err_probe() whenever possible Andi Shyti
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andi Shyti @ 2023-06-11  1:37 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-arm-kernel, linux-i2c, Andi Shyti

Replace the pair of functions, devm_clk_get() and
clk_prepare_enable(), with a single function
devm_clk_get_enabled().

Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
---
 drivers/i2c/busses/i2c-nomadik.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 8b9577318388e..2141ba05dfece 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -1005,18 +1005,12 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
 		return ret;
 	}
 
-	dev->clk = devm_clk_get(&adev->dev, NULL);
+	dev->clk = devm_clk_get_enabled(&adev->dev, NULL);
 	if (IS_ERR(dev->clk)) {
-		dev_err(&adev->dev, "could not get i2c clock\n");
+		dev_err(&adev->dev, "could enable i2c clock\n");
 		return PTR_ERR(dev->clk);
 	}
 
-	ret = clk_prepare_enable(dev->clk);
-	if (ret) {
-		dev_err(&adev->dev, "can't prepare_enable clock\n");
-		return ret;
-	}
-
 	init_hw(dev);
 
 	adap = &dev->adap;
@@ -1037,16 +1031,11 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
 
 	ret = i2c_add_adapter(adap);
 	if (ret)
-		goto err_no_adap;
+		return ret;
 
 	pm_runtime_put(&adev->dev);
 
 	return 0;
-
- err_no_adap:
-	clk_disable_unprepare(dev->clk);
-
-	return ret;
 }
 
 static void nmk_i2c_remove(struct amba_device *adev)
@@ -1060,7 +1049,6 @@ static void nmk_i2c_remove(struct amba_device *adev)
 	clear_all_interrupts(dev);
 	/* disable the controller */
 	i2c_clr_bit(dev->virtbase + I2C_CR, I2C_CR_PE);
-	clk_disable_unprepare(dev->clk);
 	release_mem_region(res->start, resource_size(res));
 }
 
-- 
2.40.1


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

* [PATCH 3/3] i2c: busses: nomadik: Use dev_err_probe() whenever possible
  2023-06-11  1:36 [PATCH 0/3] i2c: busses: nomadik cleanups Andi Shyti
  2023-06-11  1:36 ` [PATCH 1/3] i2c: busses: i2c-nomadik: Remove unnecessary goto label Andi Shyti
  2023-06-11  1:37 ` [PATCH 2/3] i2c: busses: nomadik: Use devm_clk_get_enabled() Andi Shyti
@ 2023-06-11  1:37 ` Andi Shyti
  2023-06-11 19:22 ` [PATCH 0/3] i2c: busses: nomadik cleanups Linus Walleij
  2023-06-14  9:08 ` Wolfram Sang
  4 siblings, 0 replies; 6+ messages in thread
From: Andi Shyti @ 2023-06-11  1:37 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-arm-kernel, linux-i2c, Andi Shyti

Make use of dev_err_probe() in order to simplify the code and
avoid printing when returning EPROBE_DEFER.

Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
---
 drivers/i2c/busses/i2c-nomadik.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 2141ba05dfece..1e5fd23ef45c3 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -1000,16 +1000,14 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
 	dev->irq = adev->irq[0];
 	ret = devm_request_irq(&adev->dev, dev->irq, i2c_irq_handler, 0,
 				DRIVER_NAME, dev);
-	if (ret) {
-		dev_err(&adev->dev, "cannot claim the irq %d\n", dev->irq);
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(&adev->dev, ret,
+				     "cannot claim the irq %d\n", dev->irq);
 
 	dev->clk = devm_clk_get_enabled(&adev->dev, NULL);
-	if (IS_ERR(dev->clk)) {
-		dev_err(&adev->dev, "could enable i2c clock\n");
-		return PTR_ERR(dev->clk);
-	}
+	if (IS_ERR(dev->clk))
+		return dev_err_probe(&adev->dev, PTR_ERR(dev->clk),
+				     "could enable i2c clock\n");
 
 	init_hw(dev);
 
-- 
2.40.1


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

* Re: [PATCH 0/3] i2c: busses: nomadik cleanups
  2023-06-11  1:36 [PATCH 0/3] i2c: busses: nomadik cleanups Andi Shyti
                   ` (2 preceding siblings ...)
  2023-06-11  1:37 ` [PATCH 3/3] i2c: busses: nomadik: Use dev_err_probe() whenever possible Andi Shyti
@ 2023-06-11 19:22 ` Linus Walleij
  2023-06-14  9:08 ` Wolfram Sang
  4 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2023-06-11 19:22 UTC (permalink / raw)
  To: Andi Shyti; +Cc: linux-arm-kernel, linux-i2c

On Sun, Jun 11, 2023 at 3:37 AM Andi Shyti <andi.shyti@kernel.org> wrote:

> while browing the i2c code I spotted the unused goto. The other
> two patches come naturally.

Excellent patches Andi!

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 0/3] i2c: busses: nomadik cleanups
  2023-06-11  1:36 [PATCH 0/3] i2c: busses: nomadik cleanups Andi Shyti
                   ` (3 preceding siblings ...)
  2023-06-11 19:22 ` [PATCH 0/3] i2c: busses: nomadik cleanups Linus Walleij
@ 2023-06-14  9:08 ` Wolfram Sang
  4 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2023-06-14  9:08 UTC (permalink / raw)
  To: Andi Shyti; +Cc: Linus Walleij, linux-arm-kernel, linux-i2c

[-- Attachment #1: Type: text/plain, Size: 423 bytes --]

On Sun, Jun 11, 2023 at 03:36:58AM +0200, Andi Shyti wrote:
> Hi,
> 
> while browing the i2c code I spotted the unused goto. The other
> two patches come naturally.
> 
> Andi
> 
> Andi Shyti (3):
>   i2c: busses: i2c-nomadik: Remove unnecessary goto label
>   i2c: busses: nomadik: Use devm_clk_get_enabled()
>   i2c: busses: nomadik: Use dev_err_probe() whenever possible
> 

Applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2023-06-14  9:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-11  1:36 [PATCH 0/3] i2c: busses: nomadik cleanups Andi Shyti
2023-06-11  1:36 ` [PATCH 1/3] i2c: busses: i2c-nomadik: Remove unnecessary goto label Andi Shyti
2023-06-11  1:37 ` [PATCH 2/3] i2c: busses: nomadik: Use devm_clk_get_enabled() Andi Shyti
2023-06-11  1:37 ` [PATCH 3/3] i2c: busses: nomadik: Use dev_err_probe() whenever possible Andi Shyti
2023-06-11 19:22 ` [PATCH 0/3] i2c: busses: nomadik cleanups Linus Walleij
2023-06-14  9:08 ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox