Skip to contentSkip to conversation

serial: make Open Firmware device id constant

PATCH In review Németh Márton 1 participant 1 message Jan 10, 2010 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 serial: make Open Firmware device id constant

From: Márton Németh <[email protected]>

The match_table field of the struct of_device_id is constant in <linux/of_platform.h> so it is worth to make the initialization data also constant.

The semantic match that finds this kind of pattern is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r@
disable decl_init,const_decl_init;
identifier I1, I2, x;
@@

	struct I1 {
	  ...
	  const struct I2 *x;
	  ...
	};

@s@
identifier r.I1, y;
identifier r.x, E;
@@

	struct I1 y = {
	  .x = E,
	};

@c@
identifier r.I2;
identifier s.E;
@@

	const struct I2 E[] = ... ;

@depends on !c@
identifier r.I2;
identifier s.E;
@@
+ const

	struct I2 E[] = ...;

// </smpl>

---

drivers/serial/of_serial.c 2010-01-08 18:42:19.000000000 +0100 renamed from drivers/serial/of_serial.c 2009-12-03 04:51:21.000000000 +0100 +1 -1
diff -u -p a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c
@@ -158,7 +158,7 @@ static int of_platform_serial_remove(str
 /*
  * A few common types, add more as needed.
  */
-static struct of_device_id __devinitdata of_platform_serial_table[] = {
+static const struct of_device_id of_platform_serial_table[] __devinitconst = {
 	{ .type = "serial", .compatible = "ns8250",   .data = (void *)PORT_8250, },
 	{ .type = "serial", .compatible = "ns16450",  .data = (void *)PORT_16450, },
 	{ .type = "serial", .compatible = "ns16550a", .data = (void *)PORT_16550A, },
drivers/serial/mpc52xx_uart.c 2010-01-08 18:45:41.000000000 +0100 renamed from drivers/serial/mpc52xx_uart.c 2009-12-03 04:51:21.000000000 +0100 +1 -1
diff -u -p a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
@@ -1088,7 +1088,7 @@ static struct uart_driver mpc52xx_uart_d
 /* OF Platform Driver                                                       */
 /* ======================================================================== */
 
-static struct of_device_id mpc52xx_uart_of_match[] = {
+static const struct of_device_id mpc52xx_uart_of_match[] = {
 #ifdef CONFIG_PPC_MPC52xx
 	{ .compatible = "fsl,mpc5200-psc-uart", .data = &mpc52xx_psc_ops, },
 	/* binding used by old lite5200 device trees: */
drivers/serial/uartlite.c 2010-01-08 18:47:33.000000000 +0100 renamed from drivers/serial/uartlite.c 2009-12-03 04:51:21.000000000 +0100 +1 -1
diff -u -p a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c
@@ -25,7 +25,7 @@
 #include <linux/of_platform.h>
 
 /* Match table for of_platform binding */
-static struct of_device_id ulite_of_match[] __devinitdata = {
+static const struct of_device_id ulite_of_match[] __devinitconst = {
 	{ .compatible = "xlnx,opb-uartlite-1.00.b", },
 	{ .compatible = "xlnx,xps-uartlite-1.00.a", },
 	{}
drivers/serial/cpm_uart/cpm_uart_core.c 2010-01-08 18:49:48.000000000 +0100 renamed from drivers/serial/cpm_uart/cpm_uart_core.c 2009-12-03 04:51:21.000000000 +0100 +1 -1
diff -u -p a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -1355,7 +1355,7 @@ static int __devexit cpm_uart_remove(str
 	return uart_remove_one_port(&cpm_reg, &pinfo->port);
 }
 
-static struct of_device_id cpm_uart_match[] = {
+static const struct of_device_id cpm_uart_match[] = {
 	{
 		.compatible = "fsl,cpm1-smc-uart",
 	},
drivers/serial/ucc_uart.c 2010-01-08 18:50:15.000000000 +0100 renamed from drivers/serial/ucc_uart.c 2010-01-07 19:08:45.000000000 +0100 +1 -1
diff -u -p a/drivers/serial/ucc_uart.c b/drivers/serial/ucc_uart.c
@@ -1475,7 +1475,7 @@ static int ucc_uart_remove(struct of_dev
 	return 0;
 }
 
-static struct of_device_id ucc_uart_match[] = {
+static const struct of_device_id ucc_uart_match[] = {
 	{
 		.type = "serial",
 		.compatible = "ucc_uart",
drivers/serial/apbuart.c 2010-01-08 18:51:23.000000000 +0100 renamed from drivers/serial/apbuart.c 2010-01-07 19:08:45.000000000 +0100 +1 -1
diff -u -p a/drivers/serial/apbuart.c b/drivers/serial/apbuart.c
@@ -576,7 +576,7 @@ static int __devinit apbuart_probe(struc
 
 }
 
-static struct of_device_id __initdata apbuart_match[] = {
+static const struct of_device_id apbuart_match[] __initconst = {
 	{
 	 .name = "GAISLER_APBUART",
 	 },

_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)