All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi: st-ssc4: Covert to use GPIO descriptors
@ 2022-01-25  1:10 Linus Walleij
  2022-01-31 15:16 ` Mark Brown
  2022-02-01 17:18 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Linus Walleij @ 2022-01-25  1:10 UTC (permalink / raw)
  To: Mark Brown, linux-spi; +Cc: Linus Walleij, Lee Jones

This switches the ST SSC SPI controller to use GPIO
descriptors from the core instead of GPIO numbers.
It is already using the core parsing of GPIO numbers
so the switch is pretty straight-forward.

Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/spi/spi-st-ssc4.c | 30 ++++--------------------------
 1 file changed, 4 insertions(+), 26 deletions(-)

diff --git a/drivers/spi/spi-st-ssc4.c b/drivers/spi/spi-st-ssc4.c
index 6c44dda9ee8c..76478a53b9d8 100644
--- a/drivers/spi/spi-st-ssc4.c
+++ b/drivers/spi/spi-st-ssc4.c
@@ -17,7 +17,6 @@
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
 #include <linux/of_irq.h>
 #include <linux/pm_runtime.h>
 #include <linux/spi/spi.h>
@@ -171,11 +170,6 @@ static int spi_st_transfer_one(struct spi_master *master,
 	return t->len;
 }
 
-static void spi_st_cleanup(struct spi_device *spi)
-{
-	gpio_free(spi->cs_gpio);
-}
-
 /* the spi->mode bits understood by this driver: */
 #define MODEBITS  (SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST | SPI_LOOP | SPI_CS_HIGH)
 static int spi_st_setup(struct spi_device *spi)
@@ -183,7 +177,6 @@ static int spi_st_setup(struct spi_device *spi)
 	struct spi_st *spi_st = spi_master_get_devdata(spi->master);
 	u32 spi_st_clk, sscbrg, var;
 	u32 hz = spi->max_speed_hz;
-	int cs = spi->cs_gpio;
 	int ret;
 
 	if (!hz)  {
@@ -191,21 +184,11 @@ static int spi_st_setup(struct spi_device *spi)
 		return -EINVAL;
 	}
 
-	if (!gpio_is_valid(cs)) {
-		dev_err(&spi->dev, "%d is not a valid gpio\n", cs);
+	if (!spi->cs_gpiod) {
+		dev_err(&spi->dev, "no valid gpio assigned\n");
 		return -EINVAL;
 	}
 
-	ret = gpio_request(cs, dev_name(&spi->dev));
-	if (ret) {
-		dev_err(&spi->dev, "could not request gpio:%d\n", cs);
-		return ret;
-	}
-
-	ret = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
-	if (ret)
-		goto out_free_gpio;
-
 	spi_st_clk = clk_get_rate(spi_st->clk);
 
 	/* Set SSC_BRF */
@@ -213,8 +196,7 @@ static int spi_st_setup(struct spi_device *spi)
 	if (sscbrg < 0x07 || sscbrg > BIT(16)) {
 		dev_err(&spi->dev,
 			"baudrate %d outside valid range %d\n", sscbrg, hz);
-		ret = -EINVAL;
-		goto out_free_gpio;
+		return -EINVAL;
 	}
 
 	spi_st->baud = spi_st_clk / (2 * sscbrg);
@@ -263,10 +245,6 @@ static int spi_st_setup(struct spi_device *spi)
 	readl_relaxed(spi_st->base + SSC_RBUF);
 
 	return 0;
-
-out_free_gpio:
-	gpio_free(cs);
-	return ret;
 }
 
 /* Interrupt fired when TX shift register becomes empty */
@@ -309,11 +287,11 @@ static int spi_st_probe(struct platform_device *pdev)
 	master->dev.of_node		= np;
 	master->mode_bits		= MODEBITS;
 	master->setup			= spi_st_setup;
-	master->cleanup			= spi_st_cleanup;
 	master->transfer_one		= spi_st_transfer_one;
 	master->bits_per_word_mask	= SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
 	master->auto_runtime_pm		= true;
 	master->bus_num			= pdev->id;
+	master->use_gpio_descriptors	= true;
 	spi_st				= spi_master_get_devdata(master);
 
 	spi_st->clk = devm_clk_get(&pdev->dev, "ssc");
-- 
2.34.1


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

* Re: [PATCH] spi: st-ssc4: Covert to use GPIO descriptors
  2022-01-25  1:10 [PATCH] spi: st-ssc4: Covert to use GPIO descriptors Linus Walleij
@ 2022-01-31 15:16 ` Mark Brown
  2022-02-01 17:18 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-01-31 15:16 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-spi, Lee Jones

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

On Tue, Jan 25, 2022 at 02:10:47AM +0100, Linus Walleij wrote:
> This switches the ST SSC SPI controller to use GPIO
> descriptors from the core instead of GPIO numbers.
> It is already using the core parsing of GPIO numbers
> so the switch is pretty straight-forward.

This breaks an x86 allmodconfig build:

/mnt/kernel/drivers/spi/spi-st-ssc4.c: In function 'spi_st_setup':
/mnt/kernel/drivers/spi/spi-st-ssc4.c:180:6: error: unused variable 'ret' [-Werror=unused-variable]
  180 |  int ret;
      |      ^~~

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

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

* Re: [PATCH] spi: st-ssc4: Covert to use GPIO descriptors
  2022-01-25  1:10 [PATCH] spi: st-ssc4: Covert to use GPIO descriptors Linus Walleij
  2022-01-31 15:16 ` Mark Brown
@ 2022-02-01 17:18 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-02-01 17:18 UTC (permalink / raw)
  To: linux-spi, Linus Walleij; +Cc: Lee Jones

On Tue, 25 Jan 2022 02:10:47 +0100, Linus Walleij wrote:
> This switches the ST SSC SPI controller to use GPIO
> descriptors from the core instead of GPIO numbers.
> It is already using the core parsing of GPIO numbers
> so the switch is pretty straight-forward.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: st-ssc4: Covert to use GPIO descriptors
      commit: 321599693213c81b2ce8530abb27e39528e969f9

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

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

end of thread, other threads:[~2022-02-01 17:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-25  1:10 [PATCH] spi: st-ssc4: Covert to use GPIO descriptors Linus Walleij
2022-01-31 15:16 ` Mark Brown
2022-02-01 17:18 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.