Skip to contentSkip to conversation

of: add const to struct of_device_id.data

PATCH In review Uwe Kleine-König 3 participants 10 messages Apr 23, 2012 – Jun 24, 2012 2 messages not in the archive

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 of: add const to struct of_device_id.data

Drivers should never need to modify the data of a device id. So it can be const which in turn allows more consts in the driver.

---
Hello,

this might introduce warnings in drivers that access the data member without using const, so this is definitly merge window material if it is considered at all.

Best regards
Uwe

 include/linux/mod_devicetable.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mod_devicetable.h +1 -1
index 501da4c..183f411 100644
@@ -222,7 +222,7 @@ struct of_device_id
 	char	type[32];
 	char	compatible[128];
 #ifdef __KERNEL__
-	void	*data;
+	const void *data;
 #else
 	kernel_ulong_t data;
 #endif
Signature · 6 lines
1.7.10

_______________________________________________
devicetree-discuss mailing list
[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

A message that is not in the archive (sent off-list or not yet received): 1335171381-24869-1-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org

#2 lore raw

Hello,

Quoted 17 lines · Uwe Kleine-König

Drivers should never need to modify the data of a device id. So it can be const which in turn allows more consts in the driver.

---
this might introduce warnings in drivers that access the data member without using const, so this is definitly merge window material if it is considered at all.

 include/linux/mod_devicetable.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mod_devicetable.h +0 -0
index 501da4c..183f411 100644

include/linux/mod_devicetable.h struct of_device_id · line 228

Quoted 8 lines
include/linux/mod_devicetable.h +1 -1
@@ -222,7 +222,7 @@ struct of_device_id
 	char	type[32];
 	char	compatible[128];
 #ifdef __KERNEL__
-	void	*data;
+	const void *data;
 #else
 	kernel_ulong_t data;
 #endif

any thoughts on this one? I got no feed back and it doesn't appear in next-20120518.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#3 lore raw

PATCH 1/1 spi/imx: make devtype_data member point to const data

In reply to a message not in the archive

This is only cosmetic for now. In case that

	http://mid.gmane.org/[email protected]

will be applied, it fixes a warning

drivers/spi/spi-imx.c: In function spi_imx_probe:
drivers/spi/spi-imx.c:814:24: warning: assignment discards const qualifier from pointer target type [enabled by default]

though.

---
 drivers/spi/spi-imx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-imx.c +1 -1
index 570f220..37b3a26 100644
@@ -95,7 +95,7 @@ struct spi_imx_data {
 	const void *tx_buf;
 	unsigned int txfifo; /* number of words pushed in tx FIFO */
 
-	struct spi_imx_devtype_data *devtype_data;
+	const struct spi_imx_devtype_data *devtype_data;
 	int chipselect[0];
 };
 
Signature · 13 lines
1.7.10


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
spi-devel-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spi-devel-general

A message that is not in the archive (sent off-list or not yet received): 1337629775-9166-1-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org

#5 lore raw

Re: [PATCH] spi/imx: make devtype_data member point to const data

Hi Grant,

Quoted 4 lines · Uwe Kleine-König

This is only cosmetic for now. In case that

	http://mid.gmane.org/[email protected]
Quoted 8 lines

will be applied, it fixes a warning

drivers/spi/spi-imx.c: In function spi_imx_probe:
drivers/spi/spi-imx.c:814:24: warning: assignment discards const qualifier from pointer target type [enabled by default]

though.

ping

Best regards
Uwe

Quoted 21 lines
---
 drivers/spi/spi-imx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-imx.c +1 -1
index 570f220..37b3a26 100644
@@ -95,7 +95,7 @@ struct spi_imx_data {
 	const void *tx_buf;
 	unsigned int txfifo; /* number of words pushed in tx FIFO */
 
-	struct spi_imx_devtype_data *devtype_data;
+	const struct spi_imx_devtype_data *devtype_data;
 	int chipselect[0];
 };
 
Signature · 1 line
1.7.10
Signature · 9 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
#6 lore raw

PATCH 1/1 ARM: cache-l2x0: add a const qualifier

In reply to Uwe Kleine-König

This is only cosmetic for now. In case that

	http://mid.gmane.org/1335171381-24869-1-git-send-email-u.kleine-koenig at pengutronix.de

will be applied, it fixes a warning

	arch/arm/mm/cache-l2x0.c: In function 'l2x0_of_init':
	arch/arm/mm/cache-l2x0.c:573:7: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]

though.

---
 arch/arm/mm/cache-l2x0.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mm/cache-l2x0.c +1 -1
index 2a8e380..577baf7 100644
@@ -554,7 +554,7 @@ static const struct of_device_id l2x0_ids[] __initconst = {
 int __init l2x0_of_init(u32 aux_val, u32 aux_mask)
 {
 	struct device_node *np;
-	struct l2x0_of_data *data;
+	const struct l2x0_of_data *data;
 	struct resource res;
 
 	np = of_find_matching_node(NULL, l2x0_ids);
Signature · 1 line
1.7.10
#7 lore raw

PATCH 1/1 serial/imx: make devdata member point to const data

In reply to Uwe Kleine-König

This is only cosmetic for now. In case that

	http://mid.gmane.org/[email protected]

will be applied, it fixes a warning

drivers/tty/serial/imx.c: In function 'serial_imx_probe_dt':
drivers/tty/serial/imx.c:1430:17: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]

though.

---
 drivers/tty/serial/imx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/imx.c +1 -1
index e7fecee..d409bbb 100644
@@ -205,7 +205,7 @@ struct imx_port {
 	unsigned int		irda_inv_tx:1;
 	unsigned short		trcv_delay; /* transceiver delay */
 	struct clk		*clk;
-	struct imx_uart_data	*devdata;
+	const struct imx_uart_data *devdata;
 };
 
 struct imx_port_ucrs {
Signature · 6 lines
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw

PATCH RESEND 1/1 of: add const to struct of_device_id.data

In reply to Uwe Kleine-König

Drivers should never need to modify the data of a device id. So it can be const which in turn allows more consts in the driver.

---
(Cc += lkml + Grant)

Hello,

this might introduce warnings in drivers that access the data member without using const, so this is definitly merge window material if it is considered at all.

Best regards
Uwe

 include/linux/mod_devicetable.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mod_devicetable.h +1 -1
index 501da4c..183f411 100644
@@ -222,7 +222,7 @@ struct of_device_id
 	char	type[32];
 	char	compatible[128];
 #ifdef __KERNEL__
-	void	*data;
+	const void *data;
 #else
 	kernel_ulong_t data;
 #endif
Signature · 7 lines
1.7.10



-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#9 lore raw
Quoted 4 lines · Uwe Kleine-König

Drivers should never need to modify the data of a device id. So it can be const which in turn allows more consts in the driver.

Quoted 8 lines

---
(Cc += lkml + Grant)

Hello,

this might introduce warnings in drivers that access the data member without using const, so this is definitly merge window material if it is considered at all.

ping

Best regards
Uwe

Quoted 25 lines
 include/linux/mod_devicetable.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mod_devicetable.h +1 -1
index 501da4c..183f411 100644
@@ -222,7 +222,7 @@ struct of_device_id
 	char	type[32];
 	char	compatible[128];
 #ifdef __KERNEL__
-	void	*data;
+	const void *data;
 #else
 	kernel_ulong_t data;
 #endif
Signature · 7 lines
1.7.10



-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#10 lore raw
Quoted 8 lines · Uwe Kleine-König
Quoted 7 lines · Uwe Kleine-König

Drivers should never need to modify the data of a device id. So it can be const which in turn allows more consts in the driver.

---
(Cc += lkml + Grant)

Quoted 7 lines
Quoted 5 lines

Hello,

this might introduce warnings in drivers that access the data member without using const, so this is definitly merge window material if it is considered at all.

ping

Sorry for the delayed response. I think the approach is right, but I am a bit worried about adding warnings for legit code.

A quick test with the defconfigs gave me this error for prima2_defconfig and kzm9g_defconfig:

/home/arnd/linux-arm/arch/arm/mm/cache-l2x0.c: In function 'l2x0_of_init':
/home/arnd/linux-arm/arch/arm/mm/cache-l2x0.c:573:7: error: assignment discards 'const' qualifier from pointer target type [-Werror]

and this one with at91sam9263_defconfig:
/home/arnd/linux-arm/drivers/misc/atmel_tclib.c: In function 'tc_probe':
/home/arnd/linux-arm/drivers/misc/atmel_tclib.c:170:19: error: assignment discards 'const' qualifier from pointer target type [-Werror]

I haven't checked all the defconfigs yet, but I think we should at least make sure they build fine before applying your patch.

Arnd

8<---

arch/arm/mm/cache-l2x0.c +1 -1
index 2a8e380..577baf7 100644
@@ -554,7 +554,7 @@ static const struct of_device_id l2x0_ids[] __initconst = {
 int __init l2x0_of_init(u32 aux_val, u32 aux_mask)
 {
 	struct device_node *np;
-	struct l2x0_of_data *data;
+	const struct l2x0_of_data *data;
 	struct resource res;
 
 	np = of_find_matching_node(NULL, l2x0_ids);
include/linux/atmel_tc.h +1 -1
index 1d14b1dc..89a931b 100644
@@ -63,7 +63,7 @@ struct atmel_tc {
 	struct platform_device	*pdev;
 	struct resource		*iomem;
 	void __iomem		*regs;
-	struct atmel_tcb_config	*tcb_config;
+	const struct atmel_tcb_config *tcb_config;
 	int			irq[3];
 	struct clk		*clk[3];
 	struct list_head	node;
#11 lore raw

Hello Arnd,

Quoted 17 lines · Arnd Bergmann
Quoted 8 lines · Uwe Kleine-König
Quoted 7 lines · Uwe Kleine-König

Drivers should never need to modify the data of a device id. So it can be const which in turn allows more consts in the driver.

---
(Cc += lkml + Grant)

Quoted 7 lines
Quoted 5 lines

Hello,

this might introduce warnings in drivers that access the data member without using const, so this is definitly merge window material if it is considered at all.

ping

Quoted 8 lines

Sorry for the delayed response. I think the approach is right, but I am a bit worried about adding warnings for legit code.

A quick test with the defconfigs gave me this error for prima2_defconfig and kzm9g_defconfig:

/home/arnd/linux-arm/arch/arm/mm/cache-l2x0.c: In function 'l2x0_of_init':
/home/arnd/linux-arm/arch/arm/mm/cache-l2x0.c:573:7: error: assignment discards 'const' qualifier from pointer target type [-Werror]

I already sent a patch for that to rmk's patch system:

	http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=7429/1

Russell commented:
Sigh, a gmane.org URL. Which is difficult to dig the thread out of. Eventually you can. And I see nothing which suggests that the series will be applied or, more importantly when it is going to be applied. Punting this patch until there's better communication.

Russell, I didn't completely get your problem about gmane here. If you follow the link in the Subject: line, you get a thread view. Does this address your concerns?

And even without the of: add const to struct of_device_id.data patch patch using more consts is IMHO nice.

Quoted 6 lines

and this one with at91sam9263_defconfig:
/home/arnd/linux-arm/drivers/misc/atmel_tclib.c: In function 'tc_probe':
/home/arnd/linux-arm/drivers/misc/atmel_tclib.c:170:19: error: assignment discards 'const' qualifier from pointer target type [-Werror]

I haven't checked all the defconfigs yet, but I think we should at least make sure they build fine before applying your patch.

Fine for me, I will come up with a series next week.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |