[PATCH v2 1/2] m68k: coldfire: Mark platform device resource arrays as const

Jean-Michel Hautbois posted 2 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH v2 1/2] m68k: coldfire: Mark platform device resource arrays as const
Posted by Jean-Michel Hautbois 1 month, 1 week ago
Add 'const' qualifier to all static resource arrays in device.c.
These arrays are never modified at runtime, they are only read by
platform device registration functions.

Suggested-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
---
 arch/m68k/coldfire/device.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/m68k/coldfire/device.c b/arch/m68k/coldfire/device.c
index b6958ec2a220cf91a78a14fc7fa18749451412f7..20adba27a687029ef53249bad71b342d563d612b 100644
--- a/arch/m68k/coldfire/device.c
+++ b/arch/m68k/coldfire/device.c
@@ -111,7 +111,7 @@ static struct fec_platform_data fec_pdata = {
  *	block. It is Freescale's own hardware block. Some ColdFires
  *	have 2 of these.
  */
-static struct resource mcf_fec0_resources[] = {
+static const struct resource mcf_fec0_resources[] = {
 	{
 		.start		= MCFFEC_BASE0,
 		.end		= MCFFEC_BASE0 + MCFFEC_SIZE0 - 1,
@@ -148,7 +148,7 @@ static struct platform_device mcf_fec0 = {
 #endif /* MCFFEC_BASE0 */
 
 #ifdef MCFFEC_BASE1
-static struct resource mcf_fec1_resources[] = {
+static const struct resource mcf_fec1_resources[] = {
 	{
 		.start		= MCFFEC_BASE1,
 		.end		= MCFFEC_BASE1 + MCFFEC_SIZE1 - 1,
@@ -189,7 +189,7 @@ static struct platform_device mcf_fec1 = {
  *	The ColdFire QSPI module is an SPI protocol hardware block used
  *	on a number of different ColdFire CPUs.
  */
-static struct resource mcf_qspi_resources[] = {
+static const struct resource mcf_qspi_resources[] = {
 	{
 		.start		= MCFQSPI_BASE,
 		.end		= MCFQSPI_BASE + MCFQSPI_SIZE - 1,
@@ -340,7 +340,7 @@ static struct platform_device mcf_qspi = {
 #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
 
 #if IS_ENABLED(CONFIG_I2C_IMX)
-static struct resource mcf_i2c0_resources[] = {
+static const struct resource mcf_i2c0_resources[] = {
 	{
 		.start          = MCFI2C_BASE0,
 		.end            = MCFI2C_BASE0 + MCFI2C_SIZE0 - 1,
@@ -361,7 +361,7 @@ static struct platform_device mcf_i2c0 = {
 };
 #ifdef MCFI2C_BASE1
 
-static struct resource mcf_i2c1_resources[] = {
+static const struct resource mcf_i2c1_resources[] = {
 	{
 		.start          = MCFI2C_BASE1,
 		.end            = MCFI2C_BASE1 + MCFI2C_SIZE1 - 1,
@@ -385,7 +385,7 @@ static struct platform_device mcf_i2c1 = {
 
 #ifdef MCFI2C_BASE2
 
-static struct resource mcf_i2c2_resources[] = {
+static const struct resource mcf_i2c2_resources[] = {
 	{
 		.start          = MCFI2C_BASE2,
 		.end            = MCFI2C_BASE2 + MCFI2C_SIZE2 - 1,
@@ -409,7 +409,7 @@ static struct platform_device mcf_i2c2 = {
 
 #ifdef MCFI2C_BASE3
 
-static struct resource mcf_i2c3_resources[] = {
+static const struct resource mcf_i2c3_resources[] = {
 	{
 		.start          = MCFI2C_BASE3,
 		.end            = MCFI2C_BASE3 + MCFI2C_SIZE3 - 1,
@@ -433,7 +433,7 @@ static struct platform_device mcf_i2c3 = {
 
 #ifdef MCFI2C_BASE4
 
-static struct resource mcf_i2c4_resources[] = {
+static const struct resource mcf_i2c4_resources[] = {
 	{
 		.start          = MCFI2C_BASE4,
 		.end            = MCFI2C_BASE4 + MCFI2C_SIZE4 - 1,
@@ -457,7 +457,7 @@ static struct platform_device mcf_i2c4 = {
 
 #ifdef MCFI2C_BASE5
 
-static struct resource mcf_i2c5_resources[] = {
+static const struct resource mcf_i2c5_resources[] = {
 	{
 		.start          = MCFI2C_BASE5,
 		.end            = MCFI2C_BASE5 + MCFI2C_SIZE5 - 1,
@@ -507,7 +507,7 @@ static struct mcf_edma_platform_data mcf_edma_data = {
 	.slavecnt		= ARRAY_SIZE(mcf_edma_map),
 };
 
-static struct resource mcf_edma_resources[] = {
+static const struct resource mcf_edma_resources[] = {
 	{
 		.start		= MCFEDMA_BASE,
 		.end		= MCFEDMA_BASE + MCFEDMA_SIZE - 1,
@@ -560,7 +560,7 @@ static struct mcf_esdhc_platform_data mcf_esdhc_data = {
 	.cd_type = ESDHC_CD_NONE,
 };
 
-static struct resource mcf_esdhc_resources[] = {
+static const struct resource mcf_esdhc_resources[] = {
 	{
 		.start = MCFSDHC_BASE,
 		.end = MCFSDHC_BASE + MCFSDHC_SIZE - 1,
@@ -590,7 +590,7 @@ static struct flexcan_platform_data mcf5441x_flexcan_info = {
 	.clock_frequency = 120000000,
 };
 
-static struct resource mcf5441x_flexcan0_resource[] = {
+static const struct resource mcf5441x_flexcan0_resource[] = {
 	{
 		.start = MCFFLEXCAN_BASE0,
 		.end = MCFFLEXCAN_BASE0 + MCFFLEXCAN_SIZE,

-- 
2.39.5
Re: [PATCH v2 1/2] m68k: coldfire: Mark platform device resource arrays as const
Posted by Frank Li 1 month, 1 week ago
On Fri, Nov 07, 2025 at 11:29:43AM +0100, Jean-Michel Hautbois wrote:
> Add 'const' qualifier to all static resource arrays in device.c.
> These arrays are never modified at runtime, they are only read by
> platform device registration functions.
>
> Suggested-by: Frank Li <Frank.Li@nxp.com>
> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>

Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
>  arch/m68k/coldfire/device.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/arch/m68k/coldfire/device.c b/arch/m68k/coldfire/device.c
> index b6958ec2a220cf91a78a14fc7fa18749451412f7..20adba27a687029ef53249bad71b342d563d612b 100644
> --- a/arch/m68k/coldfire/device.c
> +++ b/arch/m68k/coldfire/device.c
> @@ -111,7 +111,7 @@ static struct fec_platform_data fec_pdata = {
>   *	block. It is Freescale's own hardware block. Some ColdFires
>   *	have 2 of these.
>   */
> -static struct resource mcf_fec0_resources[] = {
> +static const struct resource mcf_fec0_resources[] = {
>  	{
>  		.start		= MCFFEC_BASE0,
>  		.end		= MCFFEC_BASE0 + MCFFEC_SIZE0 - 1,
> @@ -148,7 +148,7 @@ static struct platform_device mcf_fec0 = {
>  #endif /* MCFFEC_BASE0 */
>
>  #ifdef MCFFEC_BASE1
> -static struct resource mcf_fec1_resources[] = {
> +static const struct resource mcf_fec1_resources[] = {
>  	{
>  		.start		= MCFFEC_BASE1,
>  		.end		= MCFFEC_BASE1 + MCFFEC_SIZE1 - 1,
> @@ -189,7 +189,7 @@ static struct platform_device mcf_fec1 = {
>   *	The ColdFire QSPI module is an SPI protocol hardware block used
>   *	on a number of different ColdFire CPUs.
>   */
> -static struct resource mcf_qspi_resources[] = {
> +static const struct resource mcf_qspi_resources[] = {
>  	{
>  		.start		= MCFQSPI_BASE,
>  		.end		= MCFQSPI_BASE + MCFQSPI_SIZE - 1,
> @@ -340,7 +340,7 @@ static struct platform_device mcf_qspi = {
>  #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
>
>  #if IS_ENABLED(CONFIG_I2C_IMX)
> -static struct resource mcf_i2c0_resources[] = {
> +static const struct resource mcf_i2c0_resources[] = {
>  	{
>  		.start          = MCFI2C_BASE0,
>  		.end            = MCFI2C_BASE0 + MCFI2C_SIZE0 - 1,
> @@ -361,7 +361,7 @@ static struct platform_device mcf_i2c0 = {
>  };
>  #ifdef MCFI2C_BASE1
>
> -static struct resource mcf_i2c1_resources[] = {
> +static const struct resource mcf_i2c1_resources[] = {
>  	{
>  		.start          = MCFI2C_BASE1,
>  		.end            = MCFI2C_BASE1 + MCFI2C_SIZE1 - 1,
> @@ -385,7 +385,7 @@ static struct platform_device mcf_i2c1 = {
>
>  #ifdef MCFI2C_BASE2
>
> -static struct resource mcf_i2c2_resources[] = {
> +static const struct resource mcf_i2c2_resources[] = {
>  	{
>  		.start          = MCFI2C_BASE2,
>  		.end            = MCFI2C_BASE2 + MCFI2C_SIZE2 - 1,
> @@ -409,7 +409,7 @@ static struct platform_device mcf_i2c2 = {
>
>  #ifdef MCFI2C_BASE3
>
> -static struct resource mcf_i2c3_resources[] = {
> +static const struct resource mcf_i2c3_resources[] = {
>  	{
>  		.start          = MCFI2C_BASE3,
>  		.end            = MCFI2C_BASE3 + MCFI2C_SIZE3 - 1,
> @@ -433,7 +433,7 @@ static struct platform_device mcf_i2c3 = {
>
>  #ifdef MCFI2C_BASE4
>
> -static struct resource mcf_i2c4_resources[] = {
> +static const struct resource mcf_i2c4_resources[] = {
>  	{
>  		.start          = MCFI2C_BASE4,
>  		.end            = MCFI2C_BASE4 + MCFI2C_SIZE4 - 1,
> @@ -457,7 +457,7 @@ static struct platform_device mcf_i2c4 = {
>
>  #ifdef MCFI2C_BASE5
>
> -static struct resource mcf_i2c5_resources[] = {
> +static const struct resource mcf_i2c5_resources[] = {
>  	{
>  		.start          = MCFI2C_BASE5,
>  		.end            = MCFI2C_BASE5 + MCFI2C_SIZE5 - 1,
> @@ -507,7 +507,7 @@ static struct mcf_edma_platform_data mcf_edma_data = {
>  	.slavecnt		= ARRAY_SIZE(mcf_edma_map),
>  };
>
> -static struct resource mcf_edma_resources[] = {
> +static const struct resource mcf_edma_resources[] = {
>  	{
>  		.start		= MCFEDMA_BASE,
>  		.end		= MCFEDMA_BASE + MCFEDMA_SIZE - 1,
> @@ -560,7 +560,7 @@ static struct mcf_esdhc_platform_data mcf_esdhc_data = {
>  	.cd_type = ESDHC_CD_NONE,
>  };
>
> -static struct resource mcf_esdhc_resources[] = {
> +static const struct resource mcf_esdhc_resources[] = {
>  	{
>  		.start = MCFSDHC_BASE,
>  		.end = MCFSDHC_BASE + MCFSDHC_SIZE - 1,
> @@ -590,7 +590,7 @@ static struct flexcan_platform_data mcf5441x_flexcan_info = {
>  	.clock_frequency = 120000000,
>  };
>
> -static struct resource mcf5441x_flexcan0_resource[] = {
> +static const struct resource mcf5441x_flexcan0_resource[] = {
>  	{
>  		.start = MCFFLEXCAN_BASE0,
>  		.end = MCFFLEXCAN_BASE0 + MCFFLEXCAN_SIZE,
>
> --
> 2.39.5
>
Re: [PATCH v2 1/2] m68k: coldfire: Mark platform device resource arrays as const
Posted by Jean-Michel Hautbois 1 month, 1 week ago
Hi Frank,

Le vendredi 7 novembre 2025, 17:02:24 heure normale d’Europe centrale Frank Li 
a écrit :
> On Fri, Nov 07, 2025 at 11:29:43AM +0100, Jean-Michel Hautbois wrote:
> > Add 'const' qualifier to all static resource arrays in device.c.
> > These arrays are never modified at runtime, they are only read by
> > platform device registration functions.
> > 
> > Suggested-by: Frank Li <Frank.Li@nxp.com>
> > Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
> 
> Reviewed-by: Frank Li <Frank.Li@nxp.com>

Thanks. It must be noted though that it generates warnings when building:

  CC      arch/m68k/coldfire/device.o
arch/m68k/coldfire/device.c:141:35: warning: initialization discards ‘const’ 
qualifier from pointer target type [-Wdiscarded-qualifiers]
  141 |         .resource               = mcf_fec0_resources,
      |                                   ^~~~~~~~~~~~~~~~~~
arch/m68k/coldfire/device.c:178:35: warning: initialization discards ‘const’ 
qualifier from pointer target type [-Wdiscarded-qualifiers]
  178 |         .resource               = mcf_fec1_resources,
      |                                   ^~~~~~~~~~~~~~~~~~
arch/m68k/coldfire/device.c:360:35: warning: initialization discards ‘const’ 
qualifier from pointer target type [-Wdiscarded-qualifiers]
  360 |         .resource               = mcf_i2c0_resources,
      |                                   ^~~~~~~~~~~~~~~~~~
arch/m68k/coldfire/device.c:381:35: warning: initialization discards ‘const’ 
qualifier from pointer target type [-Wdiscarded-qualifiers]
  381 |         .resource               = mcf_i2c1_resources,
      |                                   ^~~~~~~~~~~~~~~~~~
arch/m68k/coldfire/device.c:405:35: warning: initialization discards ‘const’ 
qualifier from pointer target type [-Wdiscarded-qualifiers]
  405 |         .resource               = mcf_i2c2_resources,
      |                                   ^~~~~~~~~~~~~~~~~~
arch/m68k/coldfire/device.c:429:35: warning: initialization discards ‘const’ 
qualifier from pointer target type [-Wdiscarded-qualifiers]
  429 |         .resource               = mcf_i2c3_resources,
      |                                   ^~~~~~~~~~~~~~~~~~
arch/m68k/coldfire/device.c:453:35: warning: initialization discards ‘const’ 
qualifier from pointer target type [-Wdiscarded-qualifiers]
  453 |         .resource               = mcf_i2c4_resources,
      |                                   ^~~~~~~~~~~~~~~~~~
arch/m68k/coldfire/device.c:477:35: warning: initialization discards ‘const’ 
qualifier from pointer target type [-Wdiscarded-qualifiers]
  477 |         .resource               = mcf_i2c5_resources,
      |                                   ^~~~~~~~~~~~~~~~~~
arch/m68k/coldfire/device.c:548:35: warning: initialization discards ‘const’ 
qualifier from pointer target type [-Wdiscarded-qualifiers]
  548 |         .resource               = mcf_edma_resources,
      |                                   ^~~~~~~~~~~~~~~~~~
arch/m68k/coldfire/device.c:579:35: warning: initialization discards ‘const’ 
qualifier from pointer target type [-Wdiscarded-qualifiers]
  579 |         .resource               = mcf_esdhc_resources,
      |                                   ^~~~~~~~~~~~~~~~~~~
arch/m68k/coldfire/device.c:620:21: warning: initialization discards ‘const’ 
qualifier from pointer target type [-Wdiscarded-qualifiers]
  620 |         .resource = mcf5441x_flexcan0_resource,
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~

JM

> 
> > ---
> > 
> >  arch/m68k/coldfire/device.c | 24 ++++++++++++------------
> >  1 file changed, 12 insertions(+), 12 deletions(-)
> > 
> > diff --git a/arch/m68k/coldfire/device.c b/arch/m68k/coldfire/device.c
> > index
> > b6958ec2a220cf91a78a14fc7fa18749451412f7..20adba27a687029ef53249bad71b342
> > d563d612b 100644 --- a/arch/m68k/coldfire/device.c
> > +++ b/arch/m68k/coldfire/device.c
> > @@ -111,7 +111,7 @@ static struct fec_platform_data fec_pdata = {
> > 
> >   *	block. It is Freescale's own hardware block. Some ColdFires
> >   *	have 2 of these.
> >   */
> > 
> > -static struct resource mcf_fec0_resources[] = {
> > +static const struct resource mcf_fec0_resources[] = {
> > 
> >  	{
> >  	
> >  		.start		= MCFFEC_BASE0,
> >  		.end		= MCFFEC_BASE0 + MCFFEC_SIZE0 - 
1,
> > 
> > @@ -148,7 +148,7 @@ static struct platform_device mcf_fec0 = {
> > 
> >  #endif /* MCFFEC_BASE0 */
> >  
> >  #ifdef MCFFEC_BASE1
> > 
> > -static struct resource mcf_fec1_resources[] = {
> > +static const struct resource mcf_fec1_resources[] = {
> > 
> >  	{
> >  	
> >  		.start		= MCFFEC_BASE1,
> >  		.end		= MCFFEC_BASE1 + MCFFEC_SIZE1 - 
1,
> > 
> > @@ -189,7 +189,7 @@ static struct platform_device mcf_fec1 = {
> > 
> >   *	The ColdFire QSPI module is an SPI protocol hardware block used
> >   *	on a number of different ColdFire CPUs.
> >   */
> > 
> > -static struct resource mcf_qspi_resources[] = {
> > +static const struct resource mcf_qspi_resources[] = {
> > 
> >  	{
> >  	
> >  		.start		= MCFQSPI_BASE,
> >  		.end		= MCFQSPI_BASE + MCFQSPI_SIZE - 
1,
> > 
> > @@ -340,7 +340,7 @@ static struct platform_device mcf_qspi = {
> > 
> >  #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
> >  
> >  #if IS_ENABLED(CONFIG_I2C_IMX)
> > 
> > -static struct resource mcf_i2c0_resources[] = {
> > +static const struct resource mcf_i2c0_resources[] = {
> > 
> >  	{
> >  	
> >  		.start          = MCFI2C_BASE0,
> >  		.end            = MCFI2C_BASE0 + MCFI2C_SIZE0 - 1,
> > 
> > @@ -361,7 +361,7 @@ static struct platform_device mcf_i2c0 = {
> > 
> >  };
> >  #ifdef MCFI2C_BASE1
> > 
> > -static struct resource mcf_i2c1_resources[] = {
> > +static const struct resource mcf_i2c1_resources[] = {
> > 
> >  	{
> >  	
> >  		.start          = MCFI2C_BASE1,
> >  		.end            = MCFI2C_BASE1 + MCFI2C_SIZE1 - 1,
> > 
> > @@ -385,7 +385,7 @@ static struct platform_device mcf_i2c1 = {
> > 
> >  #ifdef MCFI2C_BASE2
> > 
> > -static struct resource mcf_i2c2_resources[] = {
> > +static const struct resource mcf_i2c2_resources[] = {
> > 
> >  	{
> >  	
> >  		.start          = MCFI2C_BASE2,
> >  		.end            = MCFI2C_BASE2 + MCFI2C_SIZE2 - 1,
> > 
> > @@ -409,7 +409,7 @@ static struct platform_device mcf_i2c2 = {
> > 
> >  #ifdef MCFI2C_BASE3
> > 
> > -static struct resource mcf_i2c3_resources[] = {
> > +static const struct resource mcf_i2c3_resources[] = {
> > 
> >  	{
> >  	
> >  		.start          = MCFI2C_BASE3,
> >  		.end            = MCFI2C_BASE3 + MCFI2C_SIZE3 - 1,
> > 
> > @@ -433,7 +433,7 @@ static struct platform_device mcf_i2c3 = {
> > 
> >  #ifdef MCFI2C_BASE4
> > 
> > -static struct resource mcf_i2c4_resources[] = {
> > +static const struct resource mcf_i2c4_resources[] = {
> > 
> >  	{
> >  	
> >  		.start          = MCFI2C_BASE4,
> >  		.end            = MCFI2C_BASE4 + MCFI2C_SIZE4 - 1,
> > 
> > @@ -457,7 +457,7 @@ static struct platform_device mcf_i2c4 = {
> > 
> >  #ifdef MCFI2C_BASE5
> > 
> > -static struct resource mcf_i2c5_resources[] = {
> > +static const struct resource mcf_i2c5_resources[] = {
> > 
> >  	{
> >  	
> >  		.start          = MCFI2C_BASE5,
> >  		.end            = MCFI2C_BASE5 + MCFI2C_SIZE5 - 1,
> > 
> > @@ -507,7 +507,7 @@ static struct mcf_edma_platform_data mcf_edma_data = {
> > 
> >  	.slavecnt		= ARRAY_SIZE(mcf_edma_map),
> >  
> >  };
> > 
> > -static struct resource mcf_edma_resources[] = {
> > +static const struct resource mcf_edma_resources[] = {
> > 
> >  	{
> >  	
> >  		.start		= MCFEDMA_BASE,
> >  		.end		= MCFEDMA_BASE + MCFEDMA_SIZE - 
1,
> > 
> > @@ -560,7 +560,7 @@ static struct mcf_esdhc_platform_data mcf_esdhc_data =
> > {> 
> >  	.cd_type = ESDHC_CD_NONE,
> >  
> >  };
> > 
> > -static struct resource mcf_esdhc_resources[] = {
> > +static const struct resource mcf_esdhc_resources[] = {
> > 
> >  	{
> >  	
> >  		.start = MCFSDHC_BASE,
> >  		.end = MCFSDHC_BASE + MCFSDHC_SIZE - 1,
> > 
> > @@ -590,7 +590,7 @@ static struct flexcan_platform_data
> > mcf5441x_flexcan_info = {> 
> >  	.clock_frequency = 120000000,
> >  
> >  };
> > 
> > -static struct resource mcf5441x_flexcan0_resource[] = {
> > +static const struct resource mcf5441x_flexcan0_resource[] = {
> > 
> >  	{
> >  	
> >  		.start = MCFFLEXCAN_BASE0,
> >  		.end = MCFFLEXCAN_BASE0 + MCFFLEXCAN_SIZE,
> > 
> > --
> > 2.39.5