Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] spi: aspeed: Fix __iomem annotation and VLA parameter
@ 2026-05-18  9:57 Chin-Ting Kuo
  2026-05-18  9:57 ` [PATCH 1/2] spi: aspeed: Fix missing __iomem annotation in output transfer path Chin-Ting Kuo
  2026-05-18  9:57 ` [PATCH] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper Chin-Ting Kuo
  0 siblings, 2 replies; 9+ messages in thread
From: Chin-Ting Kuo @ 2026-05-18  9:57 UTC (permalink / raw)
  To: clg, broonie, joel, andrew, linux-aspeed, openbmc, linux-spi,
	linux-arm-kernel, linux-kernel, BMC-SW

This series fixes two sparse warnings reported by the kernel test robot.
The first patch fixes missing __iomem annotation on an MMIO pointer
parameter, which also caused a redundant cast at the call site.
A VLA function parameter warning is also fixed in this patch series.

Chin-Ting Kuo (2):
  spi: aspeed: Fix missing __iomem annotation in output transfer path
  spi: aspeed: Fix sparse warnings for VLA parameter in calibration
    helper

 drivers/spi/spi-aspeed-smc.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

-- 
2.34.1



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

* [PATCH 1/2] spi: aspeed: Fix missing __iomem annotation in output transfer path
  2026-05-18  9:57 [PATCH 0/2] spi: aspeed: Fix __iomem annotation and VLA parameter Chin-Ting Kuo
@ 2026-05-18  9:57 ` Chin-Ting Kuo
  2026-05-19  5:15   ` Cédric Le Goater
  2026-05-18  9:57 ` [PATCH] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper Chin-Ting Kuo
  1 sibling, 1 reply; 9+ messages in thread
From: Chin-Ting Kuo @ 2026-05-18  9:57 UTC (permalink / raw)
  To: clg, broonie, joel, andrew, linux-aspeed, openbmc, linux-spi,
	linux-arm-kernel, linux-kernel, BMC-SW
  Cc: kernel test robot

The dst parameter of aspeed_spi_user_transfer_tx() is an MMIO address
obtained from chip->ahb_base, but it was typed as void * instead of
void __iomem *.  This caused a sparse warning report. Fix the
parameter type to void __iomem * and drop the now-unnecessary
cast at the call site.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605180441.uD3toFRJ-lkp@intel.com/
Signed-off-by: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
---
 drivers/spi/spi-aspeed-smc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
index c21323e07d3c..808659a1f460 100644
--- a/drivers/spi/spi-aspeed-smc.c
+++ b/drivers/spi/spi-aspeed-smc.c
@@ -891,7 +891,7 @@ static int aspeed_spi_user_unprepare_msg(struct spi_controller *ctlr,
 static void aspeed_spi_user_transfer_tx(struct aspeed_spi *aspi,
 					struct spi_device *spi,
 					const u8 *tx_buf, u8 *rx_buf,
-					void *dst, u32 len)
+					void __iomem *dst, u32 len)
 {
 	const struct aspeed_spi_data *data = aspi->data;
 	bool full_duplex_transfer = data->full_duplex && tx_buf == rx_buf;
@@ -936,7 +936,7 @@ static int aspeed_spi_user_transfer(struct spi_controller *ctlr,
 			aspeed_spi_set_io_mode(chip, CTRL_IO_QUAD_DATA);
 
 		aspeed_spi_user_transfer_tx(aspi, spi, tx_buf, rx_buf,
-					    (void *)ahb_base, xfer->len);
+					    ahb_base, xfer->len);
 	}
 
 	if (rx_buf && rx_buf != tx_buf) {
-- 
2.34.1



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

* [PATCH] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper
  2026-05-18  9:57 [PATCH 0/2] spi: aspeed: Fix __iomem annotation and VLA parameter Chin-Ting Kuo
  2026-05-18  9:57 ` [PATCH 1/2] spi: aspeed: Fix missing __iomem annotation in output transfer path Chin-Ting Kuo
@ 2026-05-18  9:57 ` Chin-Ting Kuo
  2026-05-19  5:24   ` Cédric Le Goater
  2026-05-19 11:03   ` Mark Brown
  1 sibling, 2 replies; 9+ messages in thread
From: Chin-Ting Kuo @ 2026-05-18  9:57 UTC (permalink / raw)
  To: clg, broonie, joel, andrew, linux-aspeed, openbmc, linux-spi,
	linux-arm-kernel, linux-kernel, BMC-SW
  Cc: kernel test robot

aspeed_spi_ast2600_optimized_timing() declared its buffer argument as a
variable-length array parameter (u8 buf[rows][cols]), which causes a
sparse warning. Replace the VLA parameter with a plain u8 * and compute
the 2-D index manually. The corresponding call site is also updated.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605180441.uD3toFRJ-lkp@intel.com/
Signed-off-by: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
---
 drivers/spi/spi-aspeed-smc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
index 808659a1f460..c5275700de3d 100644
--- a/drivers/spi/spi-aspeed-smc.c
+++ b/drivers/spi/spi-aspeed-smc.c
@@ -1467,8 +1467,7 @@ static int aspeed_spi_do_calibration(struct aspeed_spi_chip *chip)
  * must contains the highest number of consecutive "pass"
  * results and not span across multiple rows.
  */
-static u32 aspeed_spi_ast2600_optimized_timing(u32 rows, u32 cols,
-					       u8 buf[rows][cols])
+static u32 aspeed_spi_ast2600_optimized_timing(u32 rows, u32 cols, u8 *buf)
 {
 	int r = 0, c = 0;
 	int max = 0;
@@ -1478,7 +1477,7 @@ static u32 aspeed_spi_ast2600_optimized_timing(u32 rows, u32 cols,
 		for (j = 0; j < cols;) {
 			int k = j;
 
-			while (k < cols && buf[i][k])
+			while (k < cols && buf[i * cols + k])
 				k++;
 
 			if (k - j > max) {
@@ -1541,7 +1540,7 @@ static int aspeed_spi_ast2600_calibrate(struct aspeed_spi_chip *chip, u32 hdiv,
 		}
 	}
 
-	calib_point = aspeed_spi_ast2600_optimized_timing(6, 17, calib_res);
+	calib_point = aspeed_spi_ast2600_optimized_timing(6, 17, &calib_res[0][0]);
 	/* No good setting for this frequency */
 	if (calib_point == 0)
 		return -1;
-- 
2.34.1



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

* Re: [PATCH 1/2] spi: aspeed: Fix missing __iomem annotation in output transfer path
  2026-05-18  9:57 ` [PATCH 1/2] spi: aspeed: Fix missing __iomem annotation in output transfer path Chin-Ting Kuo
@ 2026-05-19  5:15   ` Cédric Le Goater
  0 siblings, 0 replies; 9+ messages in thread
From: Cédric Le Goater @ 2026-05-19  5:15 UTC (permalink / raw)
  To: Chin-Ting Kuo, broonie, joel, andrew, linux-aspeed, openbmc,
	linux-spi, linux-arm-kernel, linux-kernel, BMC-SW
  Cc: kernel test robot

On 5/18/26 11:57, Chin-Ting Kuo wrote:
> The dst parameter of aspeed_spi_user_transfer_tx() is an MMIO address
> obtained from chip->ahb_base, but it was typed as void * instead of
> void __iomem *.  This caused a sparse warning report. Fix the
> parameter type to void __iomem * and drop the now-unnecessary
> cast at the call site.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202605180441.uD3toFRJ-lkp@intel.com/
> Signed-off-by: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
> ---
>   drivers/spi/spi-aspeed-smc.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
> index c21323e07d3c..808659a1f460 100644
> --- a/drivers/spi/spi-aspeed-smc.c
> +++ b/drivers/spi/spi-aspeed-smc.c
> @@ -891,7 +891,7 @@ static int aspeed_spi_user_unprepare_msg(struct spi_controller *ctlr,
>   static void aspeed_spi_user_transfer_tx(struct aspeed_spi *aspi,
>   					struct spi_device *spi,
>   					const u8 *tx_buf, u8 *rx_buf,
> -					void *dst, u32 len)
> +					void __iomem *dst, u32 len)
>   {
>   	const struct aspeed_spi_data *data = aspi->data;
>   	bool full_duplex_transfer = data->full_duplex && tx_buf == rx_buf;
> @@ -936,7 +936,7 @@ static int aspeed_spi_user_transfer(struct spi_controller *ctlr,
>   			aspeed_spi_set_io_mode(chip, CTRL_IO_QUAD_DATA);
>   
>   		aspeed_spi_user_transfer_tx(aspi, spi, tx_buf, rx_buf,
> -					    (void *)ahb_base, xfer->len);
> +					    ahb_base, xfer->len);
>   	}
>   
>   	if (rx_buf && rx_buf != tx_buf) {

Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.



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

* Re: [PATCH] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper
  2026-05-18  9:57 ` [PATCH] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper Chin-Ting Kuo
@ 2026-05-19  5:24   ` Cédric Le Goater
  2026-05-19 11:03   ` Mark Brown
  1 sibling, 0 replies; 9+ messages in thread
From: Cédric Le Goater @ 2026-05-19  5:24 UTC (permalink / raw)
  To: Chin-Ting Kuo, broonie, joel, andrew, linux-aspeed, openbmc,
	linux-spi, linux-arm-kernel, linux-kernel, BMC-SW
  Cc: kernel test robot

On 5/18/26 11:57, Chin-Ting Kuo wrote:
> aspeed_spi_ast2600_optimized_timing() declared its buffer argument as a
> variable-length array parameter (u8 buf[rows][cols]), which causes a
> sparse warning. Replace the VLA parameter with a plain u8 * and compute
> the 2-D index manually. The corresponding call site is also updated.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202605180441.uD3toFRJ-lkp@intel.com/
> Signed-off-by: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
> ---
>   drivers/spi/spi-aspeed-smc.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
> index 808659a1f460..c5275700de3d 100644
> --- a/drivers/spi/spi-aspeed-smc.c
> +++ b/drivers/spi/spi-aspeed-smc.c
> @@ -1467,8 +1467,7 @@ static int aspeed_spi_do_calibration(struct aspeed_spi_chip *chip)
>    * must contains the highest number of consecutive "pass"
>    * results and not span across multiple rows.
>    */
> -static u32 aspeed_spi_ast2600_optimized_timing(u32 rows, u32 cols,
> -					       u8 buf[rows][cols])
> +static u32 aspeed_spi_ast2600_optimized_timing(u32 rows, u32 cols, u8 *buf)
>   {
>   	int r = 0, c = 0;
>   	int max = 0;
> @@ -1478,7 +1477,7 @@ static u32 aspeed_spi_ast2600_optimized_timing(u32 rows, u32 cols,
>   		for (j = 0; j < cols;) {
>   			int k = j;
>   
> -			while (k < cols && buf[i][k])
> +			while (k < cols && buf[i * cols + k])
>   				k++;
>   
>   			if (k - j > max) {
> @@ -1541,7 +1540,7 @@ static int aspeed_spi_ast2600_calibrate(struct aspeed_spi_chip *chip, u32 hdiv,
>   		}
>   	}
>   
> -	calib_point = aspeed_spi_ast2600_optimized_timing(6, 17, calib_res);
> +	calib_point = aspeed_spi_ast2600_optimized_timing(6, 17, &calib_res[0][0]);
>   	/* No good setting for this frequency */
>   	if (calib_point == 0)
>   		return -1;



Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.



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

* Re: [PATCH] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper
  2026-05-18  9:57 ` [PATCH] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper Chin-Ting Kuo
  2026-05-19  5:24   ` Cédric Le Goater
@ 2026-05-19 11:03   ` Mark Brown
  2026-05-19 12:43     ` Chin-Ting Kuo
  2026-05-19 17:13     ` David Laight
  1 sibling, 2 replies; 9+ messages in thread
From: Mark Brown @ 2026-05-19 11:03 UTC (permalink / raw)
  To: Chin-Ting Kuo
  Cc: clg, joel, andrew, linux-aspeed, openbmc, linux-spi,
	linux-arm-kernel, linux-kernel, BMC-SW, kernel test robot

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

On Mon, May 18, 2026 at 05:57:08PM +0800, Chin-Ting Kuo wrote:

> -			while (k < cols && buf[i][k])
> +			while (k < cols && buf[i * cols + k])

This really needs () to make it clear what's going on; the precedence is
well defined but not everyone is going to know that off the top of their
head.

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

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

* RE: [PATCH] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper
  2026-05-19 11:03   ` Mark Brown
@ 2026-05-19 12:43     ` Chin-Ting Kuo
  2026-05-19 13:10       ` Mark Brown
  2026-05-19 17:13     ` David Laight
  1 sibling, 1 reply; 9+ messages in thread
From: Chin-Ting Kuo @ 2026-05-19 12:43 UTC (permalink / raw)
  To: Mark Brown
  Cc: clg@kaod.org, joel@jms.id.au, andrew@codeconstruct.com.au,
	linux-aspeed@lists.ozlabs.org, openbmc@lists.ozlabs.org,
	linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, BMC-SW, kernel test robot

Hi Mark,

Thanks for the review.

> -----Original Message-----
> From: Mark Brown <broonie@kernel.org>
> Sent: Tuesday, May 19, 2026 7:04 PM
> Subject: Re: [PATCH] spi: aspeed: Replace VLA parameter with flat pointer in
> calibration helper
> 
> On Mon, May 18, 2026 at 05:57:08PM +0800, Chin-Ting Kuo wrote:
> 
> > -			while (k < cols && buf[i][k])
> > +			while (k < cols && buf[i * cols + k])
> 
> This really needs () to make it clear what's going on; the precedence is well
> defined but not everyone is going to know that off the top of their head.

Okay, below change will be added in the next patch version.
while (k < cols && buf[(i * cols) + k])


Chin-Ting


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

* Re: [PATCH] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper
  2026-05-19 12:43     ` Chin-Ting Kuo
@ 2026-05-19 13:10       ` Mark Brown
  0 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2026-05-19 13:10 UTC (permalink / raw)
  To: Chin-Ting Kuo
  Cc: clg@kaod.org, joel@jms.id.au, andrew@codeconstruct.com.au,
	linux-aspeed@lists.ozlabs.org, openbmc@lists.ozlabs.org,
	linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, BMC-SW, kernel test robot

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

On Tue, May 19, 2026 at 12:43:44PM +0000, Chin-Ting Kuo wrote:

> > This really needs () to make it clear what's going on; the precedence is well
> > defined but not everyone is going to know that off the top of their head.

> Okay, below change will be added in the next patch version.
> while (k < cols && buf[(i * cols) + k])

Sure, looks OK.

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

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

* Re: [PATCH] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper
  2026-05-19 11:03   ` Mark Brown
  2026-05-19 12:43     ` Chin-Ting Kuo
@ 2026-05-19 17:13     ` David Laight
  1 sibling, 0 replies; 9+ messages in thread
From: David Laight @ 2026-05-19 17:13 UTC (permalink / raw)
  To: Mark Brown
  Cc: Chin-Ting Kuo, clg, joel, andrew, linux-aspeed, openbmc,
	linux-spi, linux-arm-kernel, linux-kernel, BMC-SW,
	kernel test robot

On Tue, 19 May 2026 12:03:51 +0100
Mark Brown <broonie@kernel.org> wrote:

> On Mon, May 18, 2026 at 05:57:08PM +0800, Chin-Ting Kuo wrote:
> 
> > -			while (k < cols && buf[i][k])
> > +			while (k < cols && buf[i * cols + k])  
> 
> This really needs () to make it clear what's going on; the precedence is
> well defined but not everyone is going to know that off the top of their
> head.

Come on, it's multiply and add - everyone is going to get that right.

-- David


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

end of thread, other threads:[~2026-05-19 17:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-18  9:57 [PATCH 0/2] spi: aspeed: Fix __iomem annotation and VLA parameter Chin-Ting Kuo
2026-05-18  9:57 ` [PATCH 1/2] spi: aspeed: Fix missing __iomem annotation in output transfer path Chin-Ting Kuo
2026-05-19  5:15   ` Cédric Le Goater
2026-05-18  9:57 ` [PATCH] spi: aspeed: Replace VLA parameter with flat pointer in calibration helper Chin-Ting Kuo
2026-05-19  5:24   ` Cédric Le Goater
2026-05-19 11:03   ` Mark Brown
2026-05-19 12:43     ` Chin-Ting Kuo
2026-05-19 13:10       ` Mark Brown
2026-05-19 17:13     ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox