* Re: [PATCH v10 1/9] can: peak_usb: use ARRAY_SIZE instead off NULL termination for peak_usb_adapters_list
@ 2015-01-27 21:02 Stéphane Grosjean
2015-01-27 21:02 ` Marc Kleine-Budde
0 siblings, 1 reply; 3+ messages in thread
From: Stéphane Grosjean @ 2015-01-27 21:02 UTC (permalink / raw)
To: Marc Kleine-Budde; +Cc: linux-can
[-- Attachment #1: Type: text/plain, Size: 1898 bytes --]
Hi Mark,
You've got my Ack for this patch.
Thanks,
Stéphane.Le 27 janv. 2015 17:41, Marc Kleine-Budde <mkl@pengutronix.de> a écrit :
>
> 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.
>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
> drivers/net/can/usb/peak_usb/pcan_usb_core.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> index c62f48a1161d..26c0cc3ce3b2 100644
> --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
> @@ -46,7 +46,6 @@ MODULE_DEVICE_TABLE(usb, peak_usb_table);
> static struct peak_usb_adapter *peak_usb_adapters_list[] = {
> &pcan_usb,
> &pcan_usb_pro,
> - NULL,
> };
>
> /*
> @@ -857,17 +856,18 @@ static int peak_usb_probe(struct usb_interface *intf,
> {
> struct usb_device *usb_dev = interface_to_usbdev(intf);
> 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;
>
> usb_dev = interface_to_usbdev(intf);
>
> /* get corresponding PCAN-USB adapter */
> - for (pp = peak_usb_adapters_list; *pp; pp++)
> - if ((*pp)->device_id == usb_id_product)
> + for (i = 0; i < ARRAY_SIZE(peak_usb_adapters_list); i++)
> + if (peak_usb_adapters_list[i]->device_id == usb_id_product) {
> + peak_usb_adapter = peak_usb_adapters_list[i];
> break;
> + }
>
> - peak_usb_adapter = *pp;
> if (!peak_usb_adapter) {
> /* 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",
> --
> 2.1.4
>
[-- Attachment #2: Signature.txt --]
[-- Type: text/plain, Size: 151 bytes --]
--
PEAK-System Technik GmbH
Sitz der Gesellschaft Darmstadt
Handelsregister Darmstadt HRB 9183
Geschaeftsfuehrung: Alexander Gach, Uwe Wilhelm
--
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH v10 1/9] can: peak_usb: updates and CANFD support
@ 2015-01-27 16:41 Marc Kleine-Budde
2015-01-27 16:41 ` [PATCH v10 1/9] can: peak_usb: use ARRAY_SIZE instead off NULL termination for peak_usb_adapters_list Marc Kleine-Budde
0 siblings, 1 reply; 3+ messages in thread
From: Marc Kleine-Budde @ 2015-01-27 16:41 UTC (permalink / raw)
To: s.grosjean; +Cc: linux-can
Hey,
picking up Stéphane's work.
Changes since v9
- 1/9: convert peak_usb_adapters_list from NULL termination to
ARRAY_SIZE usage
- 2/9: constify struct peak_usb_adapter
regards,
Marc
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH v10 1/9] can: peak_usb: use ARRAY_SIZE instead off NULL termination for peak_usb_adapters_list
2015-01-27 16:41 [PATCH v10 1/9] can: peak_usb: updates and CANFD support Marc Kleine-Budde
@ 2015-01-27 16:41 ` Marc Kleine-Budde
0 siblings, 0 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2015-01-27 16:41 UTC (permalink / raw)
To: s.grosjean; +Cc: linux-can, Marc Kleine-Budde
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.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/usb/peak_usb/pcan_usb_core.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
index c62f48a1161d..26c0cc3ce3b2 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
@@ -46,7 +46,6 @@ MODULE_DEVICE_TABLE(usb, peak_usb_table);
static struct peak_usb_adapter *peak_usb_adapters_list[] = {
&pcan_usb,
&pcan_usb_pro,
- NULL,
};
/*
@@ -857,17 +856,18 @@ static int peak_usb_probe(struct usb_interface *intf,
{
struct usb_device *usb_dev = interface_to_usbdev(intf);
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;
usb_dev = interface_to_usbdev(intf);
/* get corresponding PCAN-USB adapter */
- for (pp = peak_usb_adapters_list; *pp; pp++)
- if ((*pp)->device_id == usb_id_product)
+ for (i = 0; i < ARRAY_SIZE(peak_usb_adapters_list); i++)
+ if (peak_usb_adapters_list[i]->device_id == usb_id_product) {
+ peak_usb_adapter = peak_usb_adapters_list[i];
break;
+ }
- peak_usb_adapter = *pp;
if (!peak_usb_adapter) {
/* 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",
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-27 21:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-27 21:02 [PATCH v10 1/9] can: peak_usb: use ARRAY_SIZE instead off NULL termination for peak_usb_adapters_list Stéphane Grosjean
2015-01-27 21:02 ` Marc Kleine-Budde
-- strict thread matches above, loose matches on Subject: below --
2015-01-27 16:41 [PATCH v10 1/9] can: peak_usb: updates and CANFD support Marc Kleine-Budde
2015-01-27 16:41 ` [PATCH v10 1/9] can: peak_usb: use ARRAY_SIZE instead off NULL termination for peak_usb_adapters_list Marc Kleine-Budde
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.