Skip to content

Commit 7d40d7e

Browse files
nmarci1gregkh
authored andcommitted
USB serial: make USB device id constant
The id_table field of the struct usb_device_id is constant in <linux/usb.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> Signed-off-by: Németh Márton <nm127@freemail.hu> Cc: Julia Lawall <julia@diku.dk> Cc: cocci@diku.dk Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 6ef4852 commit 7d40d7e

39 files changed

Lines changed: 60 additions & 60 deletions

‎drivers/usb/serial/aircable.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static int debug;
7878
#define DRIVER_DESC "AIRcable USB Driver"
7979

8080
/* ID table that will be registered with USB core */
81-
static struct usb_device_id id_table [] = {
81+
static const struct usb_device_id id_table[] = {
8282
{ USB_DEVICE(AIRCABLE_VID, AIRCABLE_USB_PID) },
8383
{ },
8484
};

‎drivers/usb/serial/ark3116.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static int debug;
5050
/* usb timeout of 1 second */
5151
#define ARK_TIMEOUT (1*HZ)
5252

53-
static struct usb_device_id id_table [] = {
53+
static const struct usb_device_id id_table[] = {
5454
{ USB_DEVICE(0x6547, 0x0232) },
5555
{ USB_DEVICE(0x18ec, 0x3118) }, /* USB to IrDA adapter */
5656
{ },

‎drivers/usb/serial/belkin_sa.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static int belkin_sa_tiocmset(struct tty_struct *tty, struct file *file,
103103
unsigned int set, unsigned int clear);
104104

105105

106-
static struct usb_device_id id_table_combined [] = {
106+
static const struct usb_device_id id_table_combined[] = {
107107
{ USB_DEVICE(BELKIN_SA_VID, BELKIN_SA_PID) },
108108
{ USB_DEVICE(BELKIN_OLD_VID, BELKIN_OLD_PID) },
109109
{ USB_DEVICE(PERACOM_VID, PERACOM_PID) },

‎drivers/usb/serial/ch341.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272
static int debug;
7373

74-
static struct usb_device_id id_table [] = {
74+
static const struct usb_device_id id_table[] = {
7575
{ USB_DEVICE(0x4348, 0x5523) },
7676
{ USB_DEVICE(0x1a86, 0x7523) },
7777
{ },

‎drivers/usb/serial/cp210x.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static int cp210x_carrier_raised(struct usb_serial_port *p);
5555

5656
static int debug;
5757

58-
static struct usb_device_id id_table [] = {
58+
static const struct usb_device_id id_table[] = {
5959
{ USB_DEVICE(0x0471, 0x066A) }, /* AKTAKOM ACE-1001 cable */
6060
{ USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */
6161
{ USB_DEVICE(0x0745, 0x1000) }, /* CipherLab USB CCD Barcode Scanner 1000 */

‎drivers/usb/serial/cyberjack.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static void cyberjack_read_int_callback(struct urb *urb);
7070
static void cyberjack_read_bulk_callback(struct urb *urb);
7171
static void cyberjack_write_bulk_callback(struct urb *urb);
7272

73-
static struct usb_device_id id_table [] = {
73+
static const struct usb_device_id id_table[] = {
7474
{ USB_DEVICE(CYBERJACK_VENDOR_ID, CYBERJACK_PRODUCT_ID) },
7575
{ } /* Terminating entry */
7676
};

‎drivers/usb/serial/cypress_m8.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,24 +87,24 @@ static int unstable_bauds;
8787
#define CYPRESS_BUF_SIZE 1024
8888
#define CYPRESS_CLOSING_WAIT (30*HZ)
8989

90-
static struct usb_device_id id_table_earthmate [] = {
90+
static const struct usb_device_id id_table_earthmate[] = {
9191
{ USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) },
9292
{ USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) },
9393
{ } /* Terminating entry */
9494
};
9595

96-
static struct usb_device_id id_table_cyphidcomrs232 [] = {
96+
static const struct usb_device_id id_table_cyphidcomrs232[] = {
9797
{ USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },
9898
{ USB_DEVICE(VENDOR_ID_POWERCOM, PRODUCT_ID_UPS) },
9999
{ } /* Terminating entry */
100100
};
101101

102-
static struct usb_device_id id_table_nokiaca42v2 [] = {
102+
static const struct usb_device_id id_table_nokiaca42v2[] = {
103103
{ USB_DEVICE(VENDOR_ID_DAZZLE, PRODUCT_ID_CA42) },
104104
{ } /* Terminating entry */
105105
};
106106

107-
static struct usb_device_id id_table_combined [] = {
107+
static const struct usb_device_id id_table_combined[] = {
108108
{ USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB) },
109109
{ USB_DEVICE(VENDOR_ID_DELORME, PRODUCT_ID_EARTHMATEUSB_LT20) },
110110
{ USB_DEVICE(VENDOR_ID_CYPRESS, PRODUCT_ID_CYPHIDCOM) },

‎drivers/usb/serial/digi_acceleport.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,18 +470,18 @@ static int digi_read_oob_callback(struct urb *urb);
470470

471471
static int debug;
472472

473-
static struct usb_device_id id_table_combined [] = {
473+
static const struct usb_device_id id_table_combined[] = {
474474
{ USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) },
475475
{ USB_DEVICE(DIGI_VENDOR_ID, DIGI_4_ID) },
476476
{ } /* Terminating entry */
477477
};
478478

479-
static struct usb_device_id id_table_2 [] = {
479+
static const struct usb_device_id id_table_2[] = {
480480
{ USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) },
481481
{ } /* Terminating entry */
482482
};
483483

484-
static struct usb_device_id id_table_4 [] = {
484+
static const struct usb_device_id id_table_4[] = {
485485
{ USB_DEVICE(DIGI_VENDOR_ID, DIGI_4_ID) },
486486
{ } /* Terminating entry */
487487
};

‎drivers/usb/serial/empeg.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static void empeg_init_termios(struct tty_struct *tty);
9393
static void empeg_write_bulk_callback(struct urb *urb);
9494
static void empeg_read_bulk_callback(struct urb *urb);
9595

96-
static struct usb_device_id id_table [] = {
96+
static const struct usb_device_id id_table[] = {
9797
{ USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
9898
{ } /* Terminating entry */
9999
};

‎drivers/usb/serial/funsoft.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
static int debug;
2020

21-
static struct usb_device_id id_table [] = {
21+
static const struct usb_device_id id_table[] = {
2222
{ USB_DEVICE(0x1404, 0xcddc) },
2323
{ },
2424
};

0 commit comments

Comments
 (0)