linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] spi: stm32-qspi: Replace of_gpio_named_count() by gpiod_count()
@ 2022-08-30 18:28 Andy Shevchenko
  2022-08-30 18:28 ` [PATCH v1 2/2] spi: stm32-qspi: Refactor dual flash mode enable check in ->setup() Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-08-30 18:28 UTC (permalink / raw)
  To: Mark Brown, Patrice Chotard, linux-spi, linux-stm32,
	linux-arm-kernel, linux-kernel
  Cc: Maxime Coquelin, Alexandre Torgue, Andy Shevchenko

As a preparation to unexport of_gpio_named_count(), convert the
driver to use gpiod_count() instead.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-stm32-qspi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
index 227f450aa5f0..5858f5f9c758 100644
--- a/drivers/spi/spi-stm32-qspi.c
+++ b/drivers/spi/spi-stm32-qspi.c
@@ -656,7 +656,7 @@ static int stm32_qspi_setup(struct spi_device *spi)
 	mode = spi->mode & (SPI_TX_OCTAL | SPI_RX_OCTAL);
 	if ((mode == SPI_TX_OCTAL || mode == SPI_RX_OCTAL) ||
 	    ((mode == (SPI_TX_OCTAL | SPI_RX_OCTAL)) &&
-	    of_gpio_named_count(qspi->dev->of_node, "cs-gpios") == -ENOENT)) {
+	    gpiod_count(qspi->dev, "cs") == -ENOENT)) {
 		dev_err(qspi->dev, "spi-rx-bus-width\\/spi-tx-bus-width\\/cs-gpios\n");
 		dev_err(qspi->dev, "configuration not supported\n");
 
@@ -681,7 +681,7 @@ static int stm32_qspi_setup(struct spi_device *spi)
 	 * are both set in spi->mode and "cs-gpios" properties is found in DT
 	 */
 	if (((spi->mode & (SPI_TX_OCTAL | SPI_RX_OCTAL)) == (SPI_TX_OCTAL | SPI_RX_OCTAL)) &&
-	    of_gpio_named_count(qspi->dev->of_node, "cs-gpios")) {
+	    gpiod_count(qspi->dev, "cs")) {
 		qspi->cr_reg |= CR_DFM;
 		dev_dbg(qspi->dev, "Dual flash mode enable");
 	}
-- 
2.35.1


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

* [PATCH v1 2/2] spi: stm32-qspi: Refactor dual flash mode enable check in ->setup()
  2022-08-30 18:28 [PATCH v1 1/2] spi: stm32-qspi: Replace of_gpio_named_count() by gpiod_count() Andy Shevchenko
@ 2022-08-30 18:28 ` Andy Shevchenko
  2022-08-31  8:03   ` Patrice CHOTARD
  2022-08-31  7:22 ` [PATCH v1 1/2] spi: stm32-qspi: Replace of_gpio_named_count() by gpiod_count() Patrice CHOTARD
  2022-08-31 13:04 ` Mark Brown
  2 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2022-08-30 18:28 UTC (permalink / raw)
  To: Mark Brown, Patrice Chotard, linux-spi, linux-stm32,
	linux-arm-kernel, linux-kernel
  Cc: Maxime Coquelin, Alexandre Torgue, Andy Shevchenko

gpiod_count() either returns positive number of the CS or negative
error code. In the stm32_qspi_setup() we check that configuration
has enough CS for the dual flash mode and SPI mode is not changing
over the lines of the code. Taking all above into considertion,
refactor dual flash mode enable check by dropping unneeded CS check
and reusing local mode variable.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-stm32-qspi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
index 5858f5f9c758..9131660c1afb 100644
--- a/drivers/spi/spi-stm32-qspi.c
+++ b/drivers/spi/spi-stm32-qspi.c
@@ -680,8 +680,7 @@ static int stm32_qspi_setup(struct spi_device *spi)
 	 * Dual flash mode is only enable in case SPI_TX_OCTAL and SPI_TX_OCTAL
 	 * are both set in spi->mode and "cs-gpios" properties is found in DT
 	 */
-	if (((spi->mode & (SPI_TX_OCTAL | SPI_RX_OCTAL)) == (SPI_TX_OCTAL | SPI_RX_OCTAL)) &&
-	    gpiod_count(qspi->dev, "cs")) {
+	if (mode == (SPI_TX_OCTAL | SPI_RX_OCTAL)) {
 		qspi->cr_reg |= CR_DFM;
 		dev_dbg(qspi->dev, "Dual flash mode enable");
 	}
-- 
2.35.1


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

* Re: [PATCH v1 1/2] spi: stm32-qspi: Replace of_gpio_named_count() by gpiod_count()
  2022-08-30 18:28 [PATCH v1 1/2] spi: stm32-qspi: Replace of_gpio_named_count() by gpiod_count() Andy Shevchenko
  2022-08-30 18:28 ` [PATCH v1 2/2] spi: stm32-qspi: Refactor dual flash mode enable check in ->setup() Andy Shevchenko
@ 2022-08-31  7:22 ` Patrice CHOTARD
  2022-08-31 13:04 ` Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Patrice CHOTARD @ 2022-08-31  7:22 UTC (permalink / raw)
  To: Andy Shevchenko, Mark Brown, linux-spi, linux-stm32,
	linux-arm-kernel, linux-kernel
  Cc: Maxime Coquelin, Alexandre Torgue

Hi Andy

On 8/30/22 20:28, Andy Shevchenko wrote:
> As a preparation to unexport of_gpio_named_count(), convert the
> driver to use gpiod_count() instead.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/spi/spi-stm32-qspi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
> index 227f450aa5f0..5858f5f9c758 100644
> --- a/drivers/spi/spi-stm32-qspi.c
> +++ b/drivers/spi/spi-stm32-qspi.c
> @@ -656,7 +656,7 @@ static int stm32_qspi_setup(struct spi_device *spi)
>  	mode = spi->mode & (SPI_TX_OCTAL | SPI_RX_OCTAL);
>  	if ((mode == SPI_TX_OCTAL || mode == SPI_RX_OCTAL) ||
>  	    ((mode == (SPI_TX_OCTAL | SPI_RX_OCTAL)) &&
> -	    of_gpio_named_count(qspi->dev->of_node, "cs-gpios") == -ENOENT)) {
> +	    gpiod_count(qspi->dev, "cs") == -ENOENT)) {
>  		dev_err(qspi->dev, "spi-rx-bus-width\\/spi-tx-bus-width\\/cs-gpios\n");
>  		dev_err(qspi->dev, "configuration not supported\n");
>  
> @@ -681,7 +681,7 @@ static int stm32_qspi_setup(struct spi_device *spi)
>  	 * are both set in spi->mode and "cs-gpios" properties is found in DT
>  	 */
>  	if (((spi->mode & (SPI_TX_OCTAL | SPI_RX_OCTAL)) == (SPI_TX_OCTAL | SPI_RX_OCTAL)) &&
> -	    of_gpio_named_count(qspi->dev->of_node, "cs-gpios")) {
> +	    gpiod_count(qspi->dev, "cs")) {
>  		qspi->cr_reg |= CR_DFM;
>  		dev_dbg(qspi->dev, "Dual flash mode enable");
>  	}

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice

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

* Re: [PATCH v1 2/2] spi: stm32-qspi: Refactor dual flash mode enable check in ->setup()
  2022-08-30 18:28 ` [PATCH v1 2/2] spi: stm32-qspi: Refactor dual flash mode enable check in ->setup() Andy Shevchenko
@ 2022-08-31  8:03   ` Patrice CHOTARD
  0 siblings, 0 replies; 5+ messages in thread
From: Patrice CHOTARD @ 2022-08-31  8:03 UTC (permalink / raw)
  To: Andy Shevchenko, Mark Brown, linux-spi, linux-stm32,
	linux-arm-kernel, linux-kernel
  Cc: Maxime Coquelin, Alexandre Torgue

HI Andy

On 8/30/22 20:28, Andy Shevchenko wrote:
> gpiod_count() either returns positive number of the CS or negative
> error code. In the stm32_qspi_setup() we check that configuration
> has enough CS for the dual flash mode and SPI mode is not changing
> over the lines of the code. Taking all above into considertion,
> refactor dual flash mode enable check by dropping unneeded CS check
> and reusing local mode variable.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/spi/spi-stm32-qspi.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
> index 5858f5f9c758..9131660c1afb 100644
> --- a/drivers/spi/spi-stm32-qspi.c
> +++ b/drivers/spi/spi-stm32-qspi.c
> @@ -680,8 +680,7 @@ static int stm32_qspi_setup(struct spi_device *spi)
>  	 * Dual flash mode is only enable in case SPI_TX_OCTAL and SPI_TX_OCTAL
>  	 * are both set in spi->mode and "cs-gpios" properties is found in DT
>  	 */
> -	if (((spi->mode & (SPI_TX_OCTAL | SPI_RX_OCTAL)) == (SPI_TX_OCTAL | SPI_RX_OCTAL)) &&
> -	    gpiod_count(qspi->dev, "cs")) {
> +	if (mode == (SPI_TX_OCTAL | SPI_RX_OCTAL)) {
>  		qspi->cr_reg |= CR_DFM;
>  		dev_dbg(qspi->dev, "Dual flash mode enable");
>  	}

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice

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

* Re: [PATCH v1 1/2] spi: stm32-qspi: Replace of_gpio_named_count() by gpiod_count()
  2022-08-30 18:28 [PATCH v1 1/2] spi: stm32-qspi: Replace of_gpio_named_count() by gpiod_count() Andy Shevchenko
  2022-08-30 18:28 ` [PATCH v1 2/2] spi: stm32-qspi: Refactor dual flash mode enable check in ->setup() Andy Shevchenko
  2022-08-31  7:22 ` [PATCH v1 1/2] spi: stm32-qspi: Replace of_gpio_named_count() by gpiod_count() Patrice CHOTARD
@ 2022-08-31 13:04 ` Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2022-08-31 13:04 UTC (permalink / raw)
  To: Andy Shevchenko, Patrice Chotard, linux-kernel, linux-spi,
	linux-stm32, linux-arm-kernel
  Cc: Maxime Coquelin, Alexandre Torgue

On Tue, 30 Aug 2022 21:28:20 +0300, Andy Shevchenko wrote:
> As a preparation to unexport of_gpio_named_count(), convert the
> driver to use gpiod_count() instead.
> 
> 

Applied to

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

Thanks!

[1/2] spi: stm32-qspi: Replace of_gpio_named_count() by gpiod_count()
      commit: eea0e7d20d6dab38522ac0a3af61fd92c53c34f6
[2/2] spi: stm32-qspi: Refactor dual flash mode enable check in ->setup()
      commit: c9448aa41ac7dd223a6bef79e71d6c168593ebb7

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] 5+ messages in thread

end of thread, other threads:[~2022-08-31 13:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-30 18:28 [PATCH v1 1/2] spi: stm32-qspi: Replace of_gpio_named_count() by gpiod_count() Andy Shevchenko
2022-08-30 18:28 ` [PATCH v1 2/2] spi: stm32-qspi: Refactor dual flash mode enable check in ->setup() Andy Shevchenko
2022-08-31  8:03   ` Patrice CHOTARD
2022-08-31  7:22 ` [PATCH v1 1/2] spi: stm32-qspi: Replace of_gpio_named_count() by gpiod_count() Patrice CHOTARD
2022-08-31 13:04 ` Mark Brown

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