From: Anders Hammarquist <iko@iko.pp.se>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
Anders Hammarquist <iko@iko.pp.se>
Subject: [PATCH 2/2] Remove static sizing of usb_device_id arrays
Date: Sat, 22 Jun 2013 20:55:59 +0200 [thread overview]
Message-ID: <1371927359-13977-2-git-send-email-iko@iko.pp.se> (raw)
In-Reply-To: <1371927359-13977-1-git-send-email-iko@iko.pp.se>
Signed-off-by: Anders Hammarquist <iko@iko.pp.se>
---
drivers/usb/serial/ti_usb_3410_5052.c | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 26c1161..441c788 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -60,7 +60,20 @@
#define TI_READ_URB_STOPPED 2
#define TI_EXTRA_VID_PID_COUNT 5
-
+#define TI_EXTRA_VID_PID_INITALIZER {0}, {0}, {0}, {0}, {0}
+
+/* Check that TI_EXTRA_VID_PID_COUNT and TI_EXTRA_VID_PID_INITALIZER match.
+ On x86, this wastes one byte of __init space to provide a compile-time
+ error if you do not match up the definitions of TI_EXTRA_VID_PID_COUNT and
+ TI_EXTRA_VID_PID_INITIALIZER. Expect space waste up to sizeof(void *) for
+ other architectures. */
+__init void __ti_extra_vid_pid_test(void)
+{
+ struct { char a; } ti_extra_vid_pid_initializer[] =
+ { TI_EXTRA_VID_PID_INITALIZER };
+ BUILD_BUG_ON(ARRAY_SIZE(ti_extra_vid_pid_initializer) !=
+ TI_EXTRA_VID_PID_COUNT);
+}
/* Structures */
@@ -158,7 +171,7 @@ static unsigned int product_5052_count;
/* the array dimension is the number of default entries plus */
/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */
/* null entry */
-static struct usb_device_id ti_id_table_3410[16+TI_EXTRA_VID_PID_COUNT+1] = {
+static struct usb_device_id ti_id_table_3410[] = {
{ USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
{ USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -175,16 +188,20 @@ static struct usb_device_id ti_id_table_3410[16+TI_EXTRA_VID_PID_COUNT+1] = {
{ USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_STEREO_PLUG_PRODUCT_ID) },
{ USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_STRIP_PORT_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) },
+ TI_EXTRA_VID_PID_INITALIZER, /* space for run-time VID-PID pairs */
+ {0} /* End of array maker */
};
-static struct usb_device_id ti_id_table_5052[5+TI_EXTRA_VID_PID_COUNT+1] = {
+static struct usb_device_id ti_id_table_5052[] = {
{ USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
+ TI_EXTRA_VID_PID_INITALIZER, /* space for run-time VID-PID pairs */
+ {0} /* End of array maker */
};
-static struct usb_device_id ti_id_table_combined[20+2*TI_EXTRA_VID_PID_COUNT+1] = {
+static struct usb_device_id ti_id_table_combined[] = {
{ USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
{ USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -205,7 +222,9 @@ static struct usb_device_id ti_id_table_combined[20+2*TI_EXTRA_VID_PID_COUNT+1]
{ USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_STEREO_PLUG_PRODUCT_ID) },
{ USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_STRIP_PORT_PRODUCT_ID) },
{ USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) },
- { }
+ TI_EXTRA_VID_PID_INITALIZER, /* space for run-time VID-PID pairs */
+ TI_EXTRA_VID_PID_INITALIZER, /* Two needed, combined 3410 and 5052 */
+ {0} /* End of array maker */
};
static struct usb_serial_driver ti_1port_device = {
--
1.7.10.4
next prev parent reply other threads:[~2013-06-22 18:56 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-19 0:05 [PATCH 0/2] *** SUBJECT HERE *** Anders Hammarquist
2013-06-19 22:53 ` Greg KH
2013-06-21 23:08 ` Anders Hammarquist
2013-06-21 23:56 ` Greg KH
2013-06-22 18:54 ` Anders Hammarquist
2013-06-25 23:39 ` Greg KH
2013-06-26 8:29 ` Anders Hammarquist
2013-06-26 10:39 ` Johan Hovold
2013-06-27 21:50 ` Anders Hammarquist
2013-06-28 10:23 ` Johan Hovold
2013-06-28 10:24 ` [PATCH] USB: ti_usb_3410_5052: fix dynamic-id matching Johan Hovold
2013-07-01 23:22 ` [PATCH 0/2] *** SUBJECT HERE *** Anders Hammarquist
2013-07-02 9:46 ` Johan Hovold
2013-06-22 18:55 ` [PATCH 1/2] * Remove unused and overly generic ABBOTT_PRODUCT_ID * Fix sizes of statically sized usb_debvice_id tables Anders Hammarquist
2013-06-22 18:55 ` Anders Hammarquist [this message]
2013-07-24 22:52 ` [PATCH 2/2] Remove static sizing of usb_device_id arrays Greg KH
2013-07-25 14:15 ` Anders Hammarquist
2013-07-25 14:37 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371927359-13977-2-git-send-email-iko@iko.pp.se \
--to=iko@iko.pp.se \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®