linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: stm32: update dev_dbg() print format for SPI params
@ 2021-01-04  8:59 Alexandru Ardelean
  2021-01-04 13:50 ` Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Alexandru Ardelean @ 2021-01-04  8:59 UTC (permalink / raw)
  To: linux-spi, linux-kernel; +Cc: andy.shevchenko, alexandru.ardelean, broonie, sfr

With the introduction of the 'include/uapi/linux/spi/spi.h' header, the
type of the macros are enforced to 'unsigned long int' via the _BITUL()
macro.

This causes some -Wformat warnings in the spi-stm32 driver.
This patch changes the printf() specifiers from '%d' to '%lu' to
accommodate for this change.

Fixes: f7005142dace ("spi: uapi: unify SPI modes into a single spi.h header")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/spi/spi-stm32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 6017209c6d2f..47fd35acb651 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -1027,7 +1027,7 @@ static int stm32_spi_prepare_msg(struct spi_master *master,
 	else
 		clrb |= spi->cfg->regs->lsb_first.mask;
 
-	dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
+	dev_dbg(spi->dev, "cpol=%lu cpha=%lu lsb_first=%lu cs_high=%lu\n",
 		spi_dev->mode & SPI_CPOL,
 		spi_dev->mode & SPI_CPHA,
 		spi_dev->mode & SPI_LSB_FIRST,
-- 
2.17.1


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

* Re: [PATCH] spi: stm32: update dev_dbg() print format for SPI params
  2021-01-04  8:59 [PATCH] spi: stm32: update dev_dbg() print format for SPI params Alexandru Ardelean
@ 2021-01-04 13:50 ` Andy Shevchenko
  2021-01-04 14:13   ` Ardelean, Alexandru
  2021-01-04 14:31 ` [PATCH v2] " Alexandru Ardelean
  2021-01-05 16:08 ` [PATCH] " Mark Brown
  2 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2021-01-04 13:50 UTC (permalink / raw)
  To: Alexandru Ardelean
  Cc: linux-spi, Linux Kernel Mailing List, Mark Brown, Stephen Rothwell

On Mon, Jan 4, 2021 at 10:55 AM Alexandru Ardelean
<alexandru.ardelean@analog.com> wrote:
>
> With the introduction of the 'include/uapi/linux/spi/spi.h' header, the
> type of the macros are enforced to 'unsigned long int' via the _BITUL()
> macro.
>
> This causes some -Wformat warnings in the spi-stm32 driver.
> This patch changes the printf() specifiers from '%d' to '%lu' to
> accommodate for this change.
>
> Fixes: f7005142dace ("spi: uapi: unify SPI modes into a single spi.h header")
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>

LKP also reported this before.

...

> -       dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
> +       dev_dbg(spi->dev, "cpol=%lu cpha=%lu lsb_first=%lu cs_high=%lu\n",
>                 spi_dev->mode & SPI_CPOL,
>                 spi_dev->mode & SPI_CPHA,
>                 spi_dev->mode & SPI_LSB_FIRST,

Wouldn't the output be a bit awful with all these?

I think the proper fix is to add !! to each bit mask.

-- 
With Best Regards,
Andy Shevchenko

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

* RE: [PATCH] spi: stm32: update dev_dbg() print format for SPI params
  2021-01-04 13:50 ` Andy Shevchenko
@ 2021-01-04 14:13   ` Ardelean, Alexandru
  0 siblings, 0 replies; 7+ messages in thread
From: Ardelean, Alexandru @ 2021-01-04 14:13 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-spi, Linux Kernel Mailing List, Mark Brown, Stephen Rothwell



> -----Original Message-----
> From: Andy Shevchenko <andy.shevchenko@gmail.com>
> Sent: Monday, January 4, 2021 3:51 PM
> To: Ardelean, Alexandru <alexandru.Ardelean@analog.com>
> Cc: linux-spi <linux-spi@vger.kernel.org>; Linux Kernel Mailing List <linux-
> kernel@vger.kernel.org>; Mark Brown <broonie@kernel.org>; Stephen Rothwell
> <sfr@canb.auug.org.au>
> Subject: Re: [PATCH] spi: stm32: update dev_dbg() print format for SPI params
> 
> [External]
> 
> On Mon, Jan 4, 2021 at 10:55 AM Alexandru Ardelean
> <alexandru.ardelean@analog.com> wrote:
> >
> > With the introduction of the 'include/uapi/linux/spi/spi.h' header,
> > the type of the macros are enforced to 'unsigned long int' via the
> > _BITUL() macro.
> >
> > This causes some -Wformat warnings in the spi-stm32 driver.
> > This patch changes the printf() specifiers from '%d' to '%lu' to
> > accommodate for this change.
> >
> > Fixes: f7005142dace ("spi: uapi: unify SPI modes into a single spi.h
> > header")
> > Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> 
> LKP also reported this before.
> 

Ack;
Will add it

> ...
> 
> > -       dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
> > +       dev_dbg(spi->dev, "cpol=%lu cpha=%lu lsb_first=%lu
> > + cs_high=%lu\n",
> >                 spi_dev->mode & SPI_CPOL,
> >                 spi_dev->mode & SPI_CPHA,
> >                 spi_dev->mode & SPI_LSB_FIRST,
> 
> Wouldn't the output be a bit awful with all these?
> 
> I think the proper fix is to add !! to each bit mask.

Fine by me

> 
> --
> With Best Regards,
> Andy Shevchenko

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

* [PATCH v2] spi: stm32: update dev_dbg() print format for SPI params
  2021-01-04  8:59 [PATCH] spi: stm32: update dev_dbg() print format for SPI params Alexandru Ardelean
  2021-01-04 13:50 ` Andy Shevchenko
@ 2021-01-04 14:31 ` Alexandru Ardelean
  2021-01-04 14:42   ` Andy Shevchenko
  2021-01-05 16:08   ` Mark Brown
  2021-01-05 16:08 ` [PATCH] " Mark Brown
  2 siblings, 2 replies; 7+ messages in thread
From: Alexandru Ardelean @ 2021-01-04 14:31 UTC (permalink / raw)
  To: linux-spi, linux-kernel; +Cc: andy.shevchenko, alexandru.ardelean, broonie, sfr

With the introduction of the 'include/uapi/linux/spi/spi.h' header, the
type of the macros are enforced to 'unsigned long int' via the _BITUL()
macro.

This causes some -Wformat warnings in the spi-stm32 driver.
This patch adds a double-negation operator to the bit-masks. Essentially,
the important values for debugging are 0 or 1, while masking them directly
would show 0 or BIT(x) values.
This way, the type of the arguments are automatically re-cast.

Fixes: f7005142dace ("spi: uapi: unify SPI modes into a single spi.h header")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---

Changelog v1 -> v2:
* revert to using '%d' specifiers
* add !! operatior to bit-masking; this way the types are automatically
  re-cast
* add 'Reported-by: kernel test robot <lkp@intel.com>'

 drivers/spi/spi-stm32.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 6017209c6d2f..be0fb169d7a7 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -1028,10 +1028,10 @@ static int stm32_spi_prepare_msg(struct spi_master *master,
 		clrb |= spi->cfg->regs->lsb_first.mask;
 
 	dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
-		spi_dev->mode & SPI_CPOL,
-		spi_dev->mode & SPI_CPHA,
-		spi_dev->mode & SPI_LSB_FIRST,
-		spi_dev->mode & SPI_CS_HIGH);
+		!!(spi_dev->mode & SPI_CPOL),
+		!!(spi_dev->mode & SPI_CPHA),
+		!!(spi_dev->mode & SPI_LSB_FIRST),
+		!!(spi_dev->mode & SPI_CS_HIGH));
 
 	spin_lock_irqsave(&spi->lock, flags);
 
-- 
2.17.1


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

* Re: [PATCH v2] spi: stm32: update dev_dbg() print format for SPI params
  2021-01-04 14:31 ` [PATCH v2] " Alexandru Ardelean
@ 2021-01-04 14:42   ` Andy Shevchenko
  2021-01-05 16:08   ` Mark Brown
  1 sibling, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2021-01-04 14:42 UTC (permalink / raw)
  To: Alexandru Ardelean
  Cc: linux-spi, Linux Kernel Mailing List, Mark Brown, Stephen Rothwell

On Mon, Jan 4, 2021 at 4:27 PM Alexandru Ardelean
<alexandru.ardelean@analog.com> wrote:
>
> With the introduction of the 'include/uapi/linux/spi/spi.h' header, the
> type of the macros are enforced to 'unsigned long int' via the _BITUL()
> macro.
>
> This causes some -Wformat warnings in the spi-stm32 driver.
> This patch adds a double-negation operator to the bit-masks. Essentially,
> the important values for debugging are 0 or 1, while masking them directly
> would show 0 or BIT(x) values.
> This way, the type of the arguments are automatically re-cast.

Thanks!
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Fixes: f7005142dace ("spi: uapi: unify SPI modes into a single spi.h header")
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> ---
>
> Changelog v1 -> v2:
> * revert to using '%d' specifiers
> * add !! operatior to bit-masking; this way the types are automatically
>   re-cast
> * add 'Reported-by: kernel test robot <lkp@intel.com>'
>
>  drivers/spi/spi-stm32.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
> index 6017209c6d2f..be0fb169d7a7 100644
> --- a/drivers/spi/spi-stm32.c
> +++ b/drivers/spi/spi-stm32.c
> @@ -1028,10 +1028,10 @@ static int stm32_spi_prepare_msg(struct spi_master *master,
>                 clrb |= spi->cfg->regs->lsb_first.mask;
>
>         dev_dbg(spi->dev, "cpol=%d cpha=%d lsb_first=%d cs_high=%d\n",
> -               spi_dev->mode & SPI_CPOL,
> -               spi_dev->mode & SPI_CPHA,
> -               spi_dev->mode & SPI_LSB_FIRST,
> -               spi_dev->mode & SPI_CS_HIGH);
> +               !!(spi_dev->mode & SPI_CPOL),
> +               !!(spi_dev->mode & SPI_CPHA),
> +               !!(spi_dev->mode & SPI_LSB_FIRST),
> +               !!(spi_dev->mode & SPI_CS_HIGH));
>
>         spin_lock_irqsave(&spi->lock, flags);
>
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] spi: stm32: update dev_dbg() print format for SPI params
  2021-01-04  8:59 [PATCH] spi: stm32: update dev_dbg() print format for SPI params Alexandru Ardelean
  2021-01-04 13:50 ` Andy Shevchenko
  2021-01-04 14:31 ` [PATCH v2] " Alexandru Ardelean
@ 2021-01-05 16:08 ` Mark Brown
  2 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2021-01-05 16:08 UTC (permalink / raw)
  To: linux-kernel, linux-spi, Alexandru Ardelean; +Cc: andy.shevchenko, sfr

On Mon, 4 Jan 2021 10:59:23 +0200, Alexandru Ardelean wrote:
> With the introduction of the 'include/uapi/linux/spi/spi.h' header, the
> type of the macros are enforced to 'unsigned long int' via the _BITUL()
> macro.
> 
> This causes some -Wformat warnings in the spi-stm32 driver.
> This patch changes the printf() specifiers from '%d' to '%lu' to
> accommodate for this change.

Applied to

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

Thanks!

[1/1] spi: stm32: update dev_dbg() print format for SPI params
      commit: 8b835da61774d4482864bc081dfb428104842ad3

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

* Re: [PATCH v2] spi: stm32: update dev_dbg() print format for SPI params
  2021-01-04 14:31 ` [PATCH v2] " Alexandru Ardelean
  2021-01-04 14:42   ` Andy Shevchenko
@ 2021-01-05 16:08   ` Mark Brown
  1 sibling, 0 replies; 7+ messages in thread
From: Mark Brown @ 2021-01-05 16:08 UTC (permalink / raw)
  To: linux-kernel, linux-spi, Alexandru Ardelean; +Cc: andy.shevchenko, sfr

On Mon, 4 Jan 2021 16:31:03 +0200, Alexandru Ardelean wrote:
> With the introduction of the 'include/uapi/linux/spi/spi.h' header, the
> type of the macros are enforced to 'unsigned long int' via the _BITUL()
> macro.
> 
> This causes some -Wformat warnings in the spi-stm32 driver.
> This patch adds a double-negation operator to the bit-masks. Essentially,
> the important values for debugging are 0 or 1, while masking them directly
> would show 0 or BIT(x) values.
> This way, the type of the arguments are automatically re-cast.

Applied to

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

Thanks!

[1/1] spi: stm32: update dev_dbg() print format for SPI params
      commit: 8b835da61774d4482864bc081dfb428104842ad3

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

end of thread, other threads:[~2021-01-05 16:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-04  8:59 [PATCH] spi: stm32: update dev_dbg() print format for SPI params Alexandru Ardelean
2021-01-04 13:50 ` Andy Shevchenko
2021-01-04 14:13   ` Ardelean, Alexandru
2021-01-04 14:31 ` [PATCH v2] " Alexandru Ardelean
2021-01-04 14:42   ` Andy Shevchenko
2021-01-05 16:08   ` Mark Brown
2021-01-05 16:08 ` [PATCH] " 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).