soc.lore.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] bus: ts-nbus: Two improvements
@ 2024-01-24  8:12 Uwe Kleine-König
  2024-01-24  8:12 ` [PATCH v3 1/2] bus: ts-nbus: Convert to atomic pwm API Uwe Kleine-König
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2024-01-24  8:12 UTC (permalink / raw)
  To: Arnd Bergmann, soc; +Cc: linux-pwm, linux-kernel, kernel, Sebastien Bourdelin

Hello,

these patches were sent already before, the submission can be found at
https://lore.kernel.org/linux-kernel/cover.1703527372.git.u.kleine-koenig@pengutronix.de.

No relevant changes since v2, I just rebased to v6.8-rc1.

Arnd asked to resend the patches to soc@kernel.org after v6.8-rc1 for
merging via the soc tree. So here they come.

Best regards
Uwe

Uwe Kleine-König (2):
  bus: ts-nbus: Convert to atomic pwm API
  bus: ts-nbus: Improve error reporting

 drivers/bus/ts-nbus.c | 81 ++++++++++++++++++-------------------------
 1 file changed, 34 insertions(+), 47 deletions(-)

base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d
-- 
2.43.0


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

* [PATCH v3 1/2] bus: ts-nbus: Convert to atomic pwm API
  2024-01-24  8:12 [PATCH v3 0/2] bus: ts-nbus: Two improvements Uwe Kleine-König
@ 2024-01-24  8:12 ` Uwe Kleine-König
  2024-03-12 20:09   ` Arnd Bergmann
  2024-01-24  8:12 ` [PATCH v3 2/2] bus: ts-nbus: Improve error reporting Uwe Kleine-König
  2024-03-12 20:30 ` [PATCH v3 0/2] bus: ts-nbus: Two improvements patchwork-bot+linux-soc
  2 siblings, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2024-01-24  8:12 UTC (permalink / raw)
  To: Arnd Bergmann, soc; +Cc: linux-pwm, linux-kernel, kernel, Sebastien Bourdelin

With this change the PWM hardware is only configured once (instead of
three times).

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/bus/ts-nbus.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/bus/ts-nbus.c b/drivers/bus/ts-nbus.c
index 4fa932cb0915..19c5d1f4e4d7 100644
--- a/drivers/bus/ts-nbus.c
+++ b/drivers/bus/ts-nbus.c
@@ -273,7 +273,7 @@ EXPORT_SYMBOL_GPL(ts_nbus_write);
 static int ts_nbus_probe(struct platform_device *pdev)
 {
 	struct pwm_device *pwm;
-	struct pwm_args pargs;
+	struct pwm_state state;
 	struct device *dev = &pdev->dev;
 	struct ts_nbus *ts_nbus;
 	int ret;
@@ -296,25 +296,22 @@ static int ts_nbus_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	pwm_get_args(pwm, &pargs);
-	if (!pargs.period) {
+	pwm_init_state(pwm, &state);
+	if (!state.period) {
 		dev_err(&pdev->dev, "invalid PWM period\n");
 		return -EINVAL;
 	}
 
-	/*
-	 * FIXME: pwm_apply_args() should be removed when switching to
-	 * the atomic PWM API.
-	 */
-	pwm_apply_args(pwm);
-	ret = pwm_config(pwm, pargs.period, pargs.period);
+	state.duty_cycle = state.period;
+	state.enabled = true;
+
+	ret = pwm_apply_state(pwm, &state);
 	if (ret < 0)
 		return ret;
 
 	/*
 	 * we can now start the FPGA and populate the peripherals.
 	 */
-	pwm_enable(pwm);
 	ts_nbus->pwm = pwm;
 
 	/*
-- 
2.43.0


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

* [PATCH v3 2/2] bus: ts-nbus: Improve error reporting
  2024-01-24  8:12 [PATCH v3 0/2] bus: ts-nbus: Two improvements Uwe Kleine-König
  2024-01-24  8:12 ` [PATCH v3 1/2] bus: ts-nbus: Convert to atomic pwm API Uwe Kleine-König
@ 2024-01-24  8:12 ` Uwe Kleine-König
  2024-03-12 20:30 ` [PATCH v3 0/2] bus: ts-nbus: Two improvements patchwork-bot+linux-soc
  2 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2024-01-24  8:12 UTC (permalink / raw)
  To: Arnd Bergmann, soc; +Cc: linux-pwm, linux-kernel, kernel, Sebastien Bourdelin

Using dev_err_probe() brings several improvements:

 - emits the symbolic error code
 - properly handles EPROBE_DEFER
 - combines error message generation and return value handling

While at it add error messages to two error paths that were silent
before.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/bus/ts-nbus.c | 66 ++++++++++++++++++-------------------------
 1 file changed, 28 insertions(+), 38 deletions(-)

diff --git a/drivers/bus/ts-nbus.c b/drivers/bus/ts-nbus.c
index 19c5d1f4e4d7..baf22a82c47a 100644
--- a/drivers/bus/ts-nbus.c
+++ b/drivers/bus/ts-nbus.c
@@ -39,45 +39,39 @@ struct ts_nbus {
 /*
  * request all gpios required by the bus.
  */
-static int ts_nbus_init_pdata(struct platform_device *pdev, struct ts_nbus
-		*ts_nbus)
+static int ts_nbus_init_pdata(struct platform_device *pdev,
+			      struct ts_nbus *ts_nbus)
 {
 	ts_nbus->data = devm_gpiod_get_array(&pdev->dev, "ts,data",
 			GPIOD_OUT_HIGH);
-	if (IS_ERR(ts_nbus->data)) {
-		dev_err(&pdev->dev, "failed to retrieve ts,data-gpio from dts\n");
-		return PTR_ERR(ts_nbus->data);
-	}
+	if (IS_ERR(ts_nbus->data))
+		return dev_err_probe(&pdev->dev, PTR_ERR(ts_nbus->data),
+				     "failed to retrieve ts,data-gpio from dts\n");
 
 	ts_nbus->csn = devm_gpiod_get(&pdev->dev, "ts,csn", GPIOD_OUT_HIGH);
-	if (IS_ERR(ts_nbus->csn)) {
-		dev_err(&pdev->dev, "failed to retrieve ts,csn-gpio from dts\n");
-		return PTR_ERR(ts_nbus->csn);
-	}
+	if (IS_ERR(ts_nbus->csn))
+		return dev_err_probe(&pdev->dev, PTR_ERR(ts_nbus->csn),
+			      "failed to retrieve ts,csn-gpio from dts\n");
 
 	ts_nbus->txrx = devm_gpiod_get(&pdev->dev, "ts,txrx", GPIOD_OUT_HIGH);
-	if (IS_ERR(ts_nbus->txrx)) {
-		dev_err(&pdev->dev, "failed to retrieve ts,txrx-gpio from dts\n");
-		return PTR_ERR(ts_nbus->txrx);
-	}
+	if (IS_ERR(ts_nbus->txrx))
+		return dev_err_probe(&pdev->dev, PTR_ERR(ts_nbus->txrx),
+				     "failed to retrieve ts,txrx-gpio from dts\n");
 
 	ts_nbus->strobe = devm_gpiod_get(&pdev->dev, "ts,strobe", GPIOD_OUT_HIGH);
-	if (IS_ERR(ts_nbus->strobe)) {
-		dev_err(&pdev->dev, "failed to retrieve ts,strobe-gpio from dts\n");
-		return PTR_ERR(ts_nbus->strobe);
-	}
+	if (IS_ERR(ts_nbus->strobe))
+		return dev_err_probe(&pdev->dev, PTR_ERR(ts_nbus->strobe),
+				     "failed to retrieve ts,strobe-gpio from dts\n");
 
 	ts_nbus->ale = devm_gpiod_get(&pdev->dev, "ts,ale", GPIOD_OUT_HIGH);
-	if (IS_ERR(ts_nbus->ale)) {
-		dev_err(&pdev->dev, "failed to retrieve ts,ale-gpio from dts\n");
-		return PTR_ERR(ts_nbus->ale);
-	}
+	if (IS_ERR(ts_nbus->ale))
+		return dev_err_probe(&pdev->dev, PTR_ERR(ts_nbus->ale),
+				     "failed to retrieve ts,ale-gpio from dts\n");
 
 	ts_nbus->rdy = devm_gpiod_get(&pdev->dev, "ts,rdy", GPIOD_IN);
-	if (IS_ERR(ts_nbus->rdy)) {
-		dev_err(&pdev->dev, "failed to retrieve ts,rdy-gpio from dts\n");
-		return PTR_ERR(ts_nbus->rdy);
-	}
+	if (IS_ERR(ts_nbus->rdy))
+		return dev_err_probe(&pdev->dev, PTR_ERR(ts_nbus->rdy),
+				     "failed to retrieve ts,rdy-gpio from dts\n");
 
 	return 0;
 }
@@ -289,25 +283,20 @@ static int ts_nbus_probe(struct platform_device *pdev)
 		return ret;
 
 	pwm = devm_pwm_get(dev, NULL);
-	if (IS_ERR(pwm)) {
-		ret = PTR_ERR(pwm);
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "unable to request PWM\n");
-		return ret;
-	}
+	if (IS_ERR(pwm))
+		return dev_err_probe(dev, PTR_ERR(pwm),
+				     "unable to request PWM\n");
 
 	pwm_init_state(pwm, &state);
-	if (!state.period) {
-		dev_err(&pdev->dev, "invalid PWM period\n");
-		return -EINVAL;
-	}
+	if (!state.period)
+		return dev_err_probe(dev, -EINVAL, "invalid PWM period\n");
 
 	state.duty_cycle = state.period;
 	state.enabled = true;
 
 	ret = pwm_apply_state(pwm, &state);
 	if (ret < 0)
-		return ret;
+		return dev_err_probe(dev, ret, "failed to configure PWM\n");
 
 	/*
 	 * we can now start the FPGA and populate the peripherals.
@@ -321,7 +310,8 @@ static int ts_nbus_probe(struct platform_device *pdev)
 
 	ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
 	if (ret < 0)
-		return ret;
+		return dev_err_probe(dev, ret,
+				     "failed to populate platform devices on bus\n");
 
 	dev_info(dev, "initialized\n");
 
-- 
2.43.0


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

* Re: [PATCH v3 1/2] bus: ts-nbus: Convert to atomic pwm API
  2024-01-24  8:12 ` [PATCH v3 1/2] bus: ts-nbus: Convert to atomic pwm API Uwe Kleine-König
@ 2024-03-12 20:09   ` Arnd Bergmann
  0 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2024-03-12 20:09 UTC (permalink / raw)
  To: Uwe Kleine-König, soc
  Cc: linux-pwm, linux-kernel, Pengutronix Kernel Team, Sebastien Bourdelin

On Wed, Jan 24, 2024, at 09:12, Uwe Kleine-König wrote:
> With this change the PWM hardware is only configured once (instead of
> three times).
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

I'm not sure what happened here, but I just noticed that I missed
these in my pull requests. I still have a soc/late branch that
I was planning to send out in a couple of days, so I ended up
merging it into that now.

     Arnd

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

* Re: [PATCH v3 0/2] bus: ts-nbus: Two improvements
  2024-01-24  8:12 [PATCH v3 0/2] bus: ts-nbus: Two improvements Uwe Kleine-König
  2024-01-24  8:12 ` [PATCH v3 1/2] bus: ts-nbus: Convert to atomic pwm API Uwe Kleine-König
  2024-01-24  8:12 ` [PATCH v3 2/2] bus: ts-nbus: Improve error reporting Uwe Kleine-König
@ 2024-03-12 20:30 ` patchwork-bot+linux-soc
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+linux-soc @ 2024-03-12 20:30 UTC (permalink / raw)
  To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig_=3Cu=2Ekleine-koenig=40pengutronix=2Ede=3E?=
  Cc: soc

Hello:

This series was applied to soc/soc.git (for-next)
by Arnd Bergmann <arnd@arndb.de>:

On Wed, 24 Jan 2024 09:12:03 +0100 you wrote:
> Hello,
> 
> these patches were sent already before, the submission can be found at
> https://lore.kernel.org/linux-kernel/cover.1703527372.git.u.kleine-koenig@pengutronix.de.
> 
> No relevant changes since v2, I just rebased to v6.8-rc1.
> 
> [...]

Here is the summary with links:
  - [v3,1/2] bus: ts-nbus: Convert to atomic pwm API
    https://git.kernel.org/soc/soc/c/8129d25e32b7
  - [v3,2/2] bus: ts-nbus: Improve error reporting
    https://git.kernel.org/soc/soc/c/a04a7da3982e

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-03-12 20:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-24  8:12 [PATCH v3 0/2] bus: ts-nbus: Two improvements Uwe Kleine-König
2024-01-24  8:12 ` [PATCH v3 1/2] bus: ts-nbus: Convert to atomic pwm API Uwe Kleine-König
2024-03-12 20:09   ` Arnd Bergmann
2024-01-24  8:12 ` [PATCH v3 2/2] bus: ts-nbus: Improve error reporting Uwe Kleine-König
2024-03-12 20:30 ` [PATCH v3 0/2] bus: ts-nbus: Two improvements patchwork-bot+linux-soc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).