linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] gpio: stp-xway: small cleanups and improvements
@ 2019-07-02 22:32 Martin Blumenstingl
  2019-07-02 22:32 ` [PATCH 1/4] gpio: stp-xway: simplify error handling in xway_stp_probe() Martin Blumenstingl
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Martin Blumenstingl @ 2019-07-02 22:32 UTC (permalink / raw)
  To: blogic, linus.walleij, bgolaszewski, linux-gpio
  Cc: dev, linux-kernel, Martin Blumenstingl

This series brings a few small cleanups and improvements to the stp-xway
driver:
- enable compile-testing
- preparation for whenever the lantiq target switches to the common clock
  framework
- easier to read (for me)

None of these fixes any known bugs so there's no Fixes tag anywhere.

It's probably too late for inclusion into Linux 5.3. No need to rush,
I'm happy with 5.4 as well.


Martin Blumenstingl (4):
  gpio: stp-xway: simplify error handling in xway_stp_probe()
  gpio: stp-xway: improve module clock error handling
  gpio: stp-xway: get rid of the #include <lantiq_soc.h> dependency
  gpio: stp-xway: allow compile-testing

 drivers/gpio/Kconfig         |  3 ++-
 drivers/gpio/gpio-stp-xway.c | 33 +++++++++++++++++----------------
 2 files changed, 19 insertions(+), 17 deletions(-)

-- 
2.22.0


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

* [PATCH 1/4] gpio: stp-xway: simplify error handling in xway_stp_probe()
  2019-07-02 22:32 [PATCH 0/4] gpio: stp-xway: small cleanups and improvements Martin Blumenstingl
@ 2019-07-02 22:32 ` Martin Blumenstingl
  2019-07-04  7:39   ` Linus Walleij
  2019-07-02 22:32 ` [PATCH 2/4] gpio: stp-xway: improve module clock error handling Martin Blumenstingl
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Martin Blumenstingl @ 2019-07-02 22:32 UTC (permalink / raw)
  To: blogic, linus.walleij, bgolaszewski, linux-gpio
  Cc: dev, linux-kernel, Martin Blumenstingl

Return early if devm_gpiochip_add_data() returns an error instead of
having two consecutive "if (!ret) ..." statements.

Also make xway_stp_hw_init() return void because it unconditionally
returns 0. While here also update the kerneldoc comment for
xway_stp_hw_init().

These changes makes the error handling within the driver consistent.
No functional changes intended.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/gpio/gpio-stp-xway.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/gpio-stp-xway.c b/drivers/gpio/gpio-stp-xway.c
index 24c478392394..a3326255ce3c 100644
--- a/drivers/gpio/gpio-stp-xway.c
+++ b/drivers/gpio/gpio-stp-xway.c
@@ -156,9 +156,9 @@ static int xway_stp_request(struct gpio_chip *gc, unsigned gpio)
 
 /**
  * xway_stp_hw_init() - Configure the STP unit and enable the clock gate
- * @virt: pointer to the remapped register range
+ * @chip: Pointer to the xway_stp chip structure
  */
-static int xway_stp_hw_init(struct xway_stp *chip)
+static void xway_stp_hw_init(struct xway_stp *chip)
 {
 	/* sane defaults */
 	xway_stp_w32(chip->virt, 0, XWAY_STP_AR);
@@ -201,8 +201,6 @@ static int xway_stp_hw_init(struct xway_stp *chip)
 	if (chip->reserved)
 		xway_stp_w32_mask(chip->virt, XWAY_STP_UPD_MASK,
 			XWAY_STP_UPD_FPI, XWAY_STP_CON1);
-
-	return 0;
 }
 
 static int xway_stp_probe(struct platform_device *pdev)
@@ -265,14 +263,15 @@ static int xway_stp_probe(struct platform_device *pdev)
 	}
 	clk_enable(clk);
 
-	ret = xway_stp_hw_init(chip);
-	if (!ret)
-		ret = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip);
+	xway_stp_hw_init(chip);
 
-	if (!ret)
-		dev_info(&pdev->dev, "Init done\n");
+	ret = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip);
+	if (ret)
+		return ret;
 
-	return ret;
+	dev_info(&pdev->dev, "Init done\n");
+
+	return 0;
 }
 
 static const struct of_device_id xway_stp_match[] = {
-- 
2.22.0


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

* [PATCH 2/4] gpio: stp-xway: improve module clock error handling
  2019-07-02 22:32 [PATCH 0/4] gpio: stp-xway: small cleanups and improvements Martin Blumenstingl
  2019-07-02 22:32 ` [PATCH 1/4] gpio: stp-xway: simplify error handling in xway_stp_probe() Martin Blumenstingl
@ 2019-07-02 22:32 ` Martin Blumenstingl
  2019-07-04  7:40   ` Linus Walleij
  2019-07-02 22:32 ` [PATCH 3/4] gpio: stp-xway: get rid of the #include <lantiq_soc.h> dependency Martin Blumenstingl
  2019-07-02 22:32 ` [PATCH 4/4] gpio: stp-xway: allow compile-testing Martin Blumenstingl
  3 siblings, 1 reply; 9+ messages in thread
From: Martin Blumenstingl @ 2019-07-02 22:32 UTC (permalink / raw)
  To: blogic, linus.walleij, bgolaszewski, linux-gpio
  Cc: dev, linux-kernel, Martin Blumenstingl

Three module clock error handling improvements:
- use devm_clk_get() so the clock instance can be freed if
  devm_gpiochip_add_data() fails later on
- switch to clk_prepare_enable() so the driver is ready whenever the
  lantiq target switches to the common clock framework
- disable the clock again (using clk_disable_unprepare()) if
  devm_gpiochip_add_data()

All of these are virtually no-ops with the current lantiq target.
However, these will be relevant if we switch to the common clock
framework.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/gpio/gpio-stp-xway.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-stp-xway.c b/drivers/gpio/gpio-stp-xway.c
index a3326255ce3c..b31e08f84681 100644
--- a/drivers/gpio/gpio-stp-xway.c
+++ b/drivers/gpio/gpio-stp-xway.c
@@ -256,18 +256,23 @@ static int xway_stp_probe(struct platform_device *pdev)
 	if (!of_find_property(pdev->dev.of_node, "lantiq,rising", NULL))
 		chip->edge = XWAY_STP_FALLING;
 
-	clk = clk_get(&pdev->dev, NULL);
+	clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(clk)) {
 		dev_err(&pdev->dev, "Failed to get clock\n");
 		return PTR_ERR(clk);
 	}
-	clk_enable(clk);
+
+	ret = clk_prepare_enable(clk);
+	if (ret)
+		return ret;
 
 	xway_stp_hw_init(chip);
 
 	ret = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip);
-	if (ret)
+	if (ret) {
+		clk_disable_unprepare(clk);
 		return ret;
+	}
 
 	dev_info(&pdev->dev, "Init done\n");
 
-- 
2.22.0


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

* [PATCH 3/4] gpio: stp-xway: get rid of the #include <lantiq_soc.h> dependency
  2019-07-02 22:32 [PATCH 0/4] gpio: stp-xway: small cleanups and improvements Martin Blumenstingl
  2019-07-02 22:32 ` [PATCH 1/4] gpio: stp-xway: simplify error handling in xway_stp_probe() Martin Blumenstingl
  2019-07-02 22:32 ` [PATCH 2/4] gpio: stp-xway: improve module clock error handling Martin Blumenstingl
@ 2019-07-02 22:32 ` Martin Blumenstingl
  2019-07-04  7:41   ` Linus Walleij
  2019-07-02 22:32 ` [PATCH 4/4] gpio: stp-xway: allow compile-testing Martin Blumenstingl
  3 siblings, 1 reply; 9+ messages in thread
From: Martin Blumenstingl @ 2019-07-02 22:32 UTC (permalink / raw)
  To: blogic, linus.walleij, bgolaszewski, linux-gpio
  Cc: dev, linux-kernel, Martin Blumenstingl

Use the xway_stp_{r,w}32 helpers in xway_stp_w32_mask instead of relying
on ltq_{r,w}32 from the architecture specific <lantiq_soc.h>.
This will allow the driver to be compile-tested on all architectures
that support MMIO.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/gpio/gpio-stp-xway.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-stp-xway.c b/drivers/gpio/gpio-stp-xway.c
index b31e08f84681..9e23a5ae8108 100644
--- a/drivers/gpio/gpio-stp-xway.c
+++ b/drivers/gpio/gpio-stp-xway.c
@@ -15,8 +15,6 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 
-#include <lantiq_soc.h>
-
 /*
  * The Serial To Parallel (STP) is found on MIPS based Lantiq socs. It is a
  * peripheral controller used to drive external shift register cascades. At most
@@ -71,8 +69,7 @@
 #define xway_stp_r32(m, reg)		__raw_readl(m + reg)
 #define xway_stp_w32(m, val, reg)	__raw_writel(val, m + reg)
 #define xway_stp_w32_mask(m, clear, set, reg) \
-		ltq_w32((ltq_r32(m + reg) & ~(clear)) | (set), \
-		m + reg)
+		xway_stp_w32(m, (xway_stp_r32(m, reg) & ~(clear)) | (set), reg)
 
 struct xway_stp {
 	struct gpio_chip gc;
-- 
2.22.0


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

* [PATCH 4/4] gpio: stp-xway: allow compile-testing
  2019-07-02 22:32 [PATCH 0/4] gpio: stp-xway: small cleanups and improvements Martin Blumenstingl
                   ` (2 preceding siblings ...)
  2019-07-02 22:32 ` [PATCH 3/4] gpio: stp-xway: get rid of the #include <lantiq_soc.h> dependency Martin Blumenstingl
@ 2019-07-02 22:32 ` Martin Blumenstingl
  2019-07-04  7:44   ` Linus Walleij
  3 siblings, 1 reply; 9+ messages in thread
From: Martin Blumenstingl @ 2019-07-02 22:32 UTC (permalink / raw)
  To: blogic, linus.walleij, bgolaszewski, linux-gpio
  Cc: dev, linux-kernel, Martin Blumenstingl

Enable compile-testing of the stp-xway GPIO driver now that it does not
depend on any architecture specific includes anymore.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/gpio/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index f1f02dac324e..43d7d6a9d9ab 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -489,7 +489,8 @@ config GPIO_STA2X11
 
 config GPIO_STP_XWAY
 	bool "XWAY STP GPIOs"
-	depends on SOC_XWAY
+	depends on SOC_XWAY || COMPILE_TEST
+	depends on OF_GPIO
 	help
 	  This enables support for the Serial To Parallel (STP) unit found on
 	  XWAY SoC. The STP allows the SoC to drive a shift registers cascade,
-- 
2.22.0


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

* Re: [PATCH 1/4] gpio: stp-xway: simplify error handling in xway_stp_probe()
  2019-07-02 22:32 ` [PATCH 1/4] gpio: stp-xway: simplify error handling in xway_stp_probe() Martin Blumenstingl
@ 2019-07-04  7:39   ` Linus Walleij
  0 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2019-07-04  7:39 UTC (permalink / raw)
  To: Martin Blumenstingl
  Cc: John Crispin, Bartosz Golaszewski, open list:GPIO SUBSYSTEM, dev,
	linux-kernel

On Wed, Jul 3, 2019 at 12:33 AM Martin Blumenstingl
<martin.blumenstingl@googlemail.com> wrote:

> Return early if devm_gpiochip_add_data() returns an error instead of
> having two consecutive "if (!ret) ..." statements.
>
> Also make xway_stp_hw_init() return void because it unconditionally
> returns 0. While here also update the kerneldoc comment for
> xway_stp_hw_init().
>
> These changes makes the error handling within the driver consistent.
> No functional changes intended.
>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 2/4] gpio: stp-xway: improve module clock error handling
  2019-07-02 22:32 ` [PATCH 2/4] gpio: stp-xway: improve module clock error handling Martin Blumenstingl
@ 2019-07-04  7:40   ` Linus Walleij
  0 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2019-07-04  7:40 UTC (permalink / raw)
  To: Martin Blumenstingl
  Cc: John Crispin, Bartosz Golaszewski, open list:GPIO SUBSYSTEM, dev,
	linux-kernel

On Wed, Jul 3, 2019 at 12:33 AM Martin Blumenstingl
<martin.blumenstingl@googlemail.com> wrote:

> Three module clock error handling improvements:
> - use devm_clk_get() so the clock instance can be freed if
>   devm_gpiochip_add_data() fails later on
> - switch to clk_prepare_enable() so the driver is ready whenever the
>   lantiq target switches to the common clock framework
> - disable the clock again (using clk_disable_unprepare()) if
>   devm_gpiochip_add_data()
>
> All of these are virtually no-ops with the current lantiq target.
> However, these will be relevant if we switch to the common clock
> framework.
>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 3/4] gpio: stp-xway: get rid of the #include <lantiq_soc.h> dependency
  2019-07-02 22:32 ` [PATCH 3/4] gpio: stp-xway: get rid of the #include <lantiq_soc.h> dependency Martin Blumenstingl
@ 2019-07-04  7:41   ` Linus Walleij
  0 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2019-07-04  7:41 UTC (permalink / raw)
  To: Martin Blumenstingl
  Cc: John Crispin, Bartosz Golaszewski, open list:GPIO SUBSYSTEM, dev,
	linux-kernel

On Wed, Jul 3, 2019 at 12:33 AM Martin Blumenstingl
<martin.blumenstingl@googlemail.com> wrote:

> Use the xway_stp_{r,w}32 helpers in xway_stp_w32_mask instead of relying
> on ltq_{r,w}32 from the architecture specific <lantiq_soc.h>.
> This will allow the driver to be compile-tested on all architectures
> that support MMIO.
>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH 4/4] gpio: stp-xway: allow compile-testing
  2019-07-02 22:32 ` [PATCH 4/4] gpio: stp-xway: allow compile-testing Martin Blumenstingl
@ 2019-07-04  7:44   ` Linus Walleij
  0 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2019-07-04  7:44 UTC (permalink / raw)
  To: Martin Blumenstingl
  Cc: John Crispin, Bartosz Golaszewski, open list:GPIO SUBSYSTEM, dev,
	linux-kernel

On Wed, Jul 3, 2019 at 12:33 AM Martin Blumenstingl
<martin.blumenstingl@googlemail.com> wrote:

> Enable compile-testing of the stp-xway GPIO driver now that it does not
> depend on any architecture specific includes anymore.
>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Patch applied.

Yours,
Linus Walleij

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

end of thread, other threads:[~2019-07-04  7:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-02 22:32 [PATCH 0/4] gpio: stp-xway: small cleanups and improvements Martin Blumenstingl
2019-07-02 22:32 ` [PATCH 1/4] gpio: stp-xway: simplify error handling in xway_stp_probe() Martin Blumenstingl
2019-07-04  7:39   ` Linus Walleij
2019-07-02 22:32 ` [PATCH 2/4] gpio: stp-xway: improve module clock error handling Martin Blumenstingl
2019-07-04  7:40   ` Linus Walleij
2019-07-02 22:32 ` [PATCH 3/4] gpio: stp-xway: get rid of the #include <lantiq_soc.h> dependency Martin Blumenstingl
2019-07-04  7:41   ` Linus Walleij
2019-07-02 22:32 ` [PATCH 4/4] gpio: stp-xway: allow compile-testing Martin Blumenstingl
2019-07-04  7:44   ` Linus Walleij

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).