Commit 0adfd733 authored by Marc Kleine-Budde's avatar Marc Kleine-Budde

can: peak_usb: use ARRAY_SIZE instead of NULL termination for peak_usb_adapters_list

This patch converts the list "static struct peak_usb_adapter
*peak_usb_adapters_list[]" to be used with ARRAY_SIZE not with a NULL
termination, as the size is known during compile time.
Acked-by: default avatarStephane Grosjean <s.grosjean@peak-system.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent f5d4abea
...@@ -46,7 +46,6 @@ MODULE_DEVICE_TABLE(usb, peak_usb_table); ...@@ -46,7 +46,6 @@ MODULE_DEVICE_TABLE(usb, peak_usb_table);
static struct peak_usb_adapter *peak_usb_adapters_list[] = { static struct peak_usb_adapter *peak_usb_adapters_list[] = {
&pcan_usb, &pcan_usb,
&pcan_usb_pro, &pcan_usb_pro,
NULL,
}; };
/* /*
...@@ -857,17 +856,18 @@ static int peak_usb_probe(struct usb_interface *intf, ...@@ -857,17 +856,18 @@ static int peak_usb_probe(struct usb_interface *intf,
{ {
struct usb_device *usb_dev = interface_to_usbdev(intf); struct usb_device *usb_dev = interface_to_usbdev(intf);
const u16 usb_id_product = le16_to_cpu(usb_dev->descriptor.idProduct); const u16 usb_id_product = le16_to_cpu(usb_dev->descriptor.idProduct);
struct peak_usb_adapter *peak_usb_adapter, **pp; struct peak_usb_adapter *peak_usb_adapter = NULL;
int i, err = -ENOMEM; int i, err = -ENOMEM;
usb_dev = interface_to_usbdev(intf); usb_dev = interface_to_usbdev(intf);
/* get corresponding PCAN-USB adapter */ /* get corresponding PCAN-USB adapter */
for (pp = peak_usb_adapters_list; *pp; pp++) for (i = 0; i < ARRAY_SIZE(peak_usb_adapters_list); i++)
if ((*pp)->device_id == usb_id_product) if (peak_usb_adapters_list[i]->device_id == usb_id_product) {
peak_usb_adapter = peak_usb_adapters_list[i];
break; break;
}
peak_usb_adapter = *pp;
if (!peak_usb_adapter) { if (!peak_usb_adapter) {
/* should never come except device_id bad usage in this file */ /* should never come except device_id bad usage in this file */
pr_err("%s: didn't find device id. 0x%x in devices list\n", pr_err("%s: didn't find device id. 0x%x in devices list\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment