All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: s.grosjean@peak-system.com
Cc: linux-can@vger.kernel.org, Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH v11 02/10] can: peak_usb: use ARRAY_SIZE instead of NULL termination for peak_usb_adapters_list
Date: Tue, 27 Jan 2015 19:30:30 +0100	[thread overview]
Message-ID: <1422383438-7432-3-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1422383438-7432-1-git-send-email-mkl@pengutronix.de>

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


  parent reply	other threads:[~2015-01-27 18:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-27 18:30 [PATCH v11 01/10] can: peak_usb: updates and CANFD support Marc Kleine-Budde
2015-01-27 18:30 ` [PATCH v11 01/10] can: m_can: tag current CAN FD controllers as non-ISO Marc Kleine-Budde
2015-01-27 18:30 ` Marc Kleine-Budde [this message]
2015-01-27 18:30 ` [PATCH v11 03/10] can: peak_usb: constify struct peak_usb_adapter Marc Kleine-Budde
2015-01-27 18:30 ` [PATCH v11 04/10] can: peak_usb: export ctrlmode_supported to adapter specific Marc Kleine-Budde
2015-01-27 18:30 ` [PATCH v11 05/10] can: peak_usb: add adapter BEC callback definition Marc Kleine-Budde
2015-01-27 18:30 ` [PATCH v11 06/10] can: peak_usb: upgrade core to data bittiming specs Marc Kleine-Budde
2015-01-27 18:30 ` [PATCH v11 07/10] can: peak_usb: upgrade core to new struct canfd_frame Marc Kleine-Budde
2015-01-27 18:30 ` [PATCH v11 08/10] can: peak_usb: export pcan_usb_pro functions Marc Kleine-Budde
2015-01-27 18:30 ` [PATCH v11 09/10] can: peak_usb: add peak_usb_netif_rx() new function Marc Kleine-Budde
2015-01-27 18:30 ` [PATCH v11 10/10] can: peak_usb: add support for PEAK new CANFD USB adapters Marc Kleine-Budde

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=1422383438-7432-3-git-send-email-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=s.grosjean@peak-system.com \
    /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 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.