From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754442AbbAJFgs (ORCPT ); Sat, 10 Jan 2015 00:36:48 -0500 Received: from mail-ig0-f169.google.com ([209.85.213.169]:36953 "EHLO mail-ig0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753161AbbAJFgh (ORCPT ); Sat, 10 Jan 2015 00:36:37 -0500 From: Chris Rorvick To: Greg Kroah-Hartman Cc: Chris Rorvick , Alexey Khoroshilov , Davide Berardi , devel@driverdev.osuosl.org, Fabian Mewes , Gulsah Kose , Himangi Saraogi , Jerry Snitselaar , =?UTF-8?q?L=2E=20Alberto=20Gim=C3=A9nez?= , linux-kernel@vger.kernel.org, Mikhail Boiko , Monam Agarwal , Peter P Waskiewicz Jr , Stefan Hajnoczi , Takashi Iwai Subject: [PATCH 06/25] staging: line6: Index properties array with device type Date: Fri, 9 Jan 2015 23:35:52 -0600 Message-Id: <1420868171-2031-7-git-send-email-chris@rorvick.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1420868171-2031-1-git-send-email-chris@rorvick.com> References: <1420868171-2031-1-git-send-email-chris@rorvick.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current logic uses the index of the matched entry from the device table as an offset to the corresponding properties entry. The values of the new `line6_device_type' enum are ordered such that they can be used as an index into either of these arrays. Drop the device entry lookup logic and use the device type (via the .driver_info member) instead. Signed-off-by: Chris Rorvick --- drivers/staging/line6/driver.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/staging/line6/driver.c b/drivers/staging/line6/driver.c index 2797e41..c090b2b 100644 --- a/drivers/staging/line6/driver.c +++ b/drivers/staging/line6/driver.c @@ -624,7 +624,7 @@ static void line6_destruct(struct usb_interface *interface) static int line6_probe(struct usb_interface *interface, const struct usb_device_id *id) { - int devtype; + enum line6_device_type devtype; struct usb_device *usbdev; struct usb_line6 *line6; const struct line6_properties *properties; @@ -646,20 +646,7 @@ static int line6_probe(struct usb_interface *interface, goto err_put; } - /* check vendor and product id */ - for (devtype = ARRAY_SIZE(line6_id_table) - 1; devtype--;) { - u16 idVendor = le16_to_cpu(usbdev->descriptor.idVendor); - u16 idProduct = le16_to_cpu(usbdev->descriptor.idProduct); - - if (idVendor == line6_id_table[devtype].idVendor && - idProduct == line6_id_table[devtype].idProduct) - break; - } - - if (devtype < 0) { - ret = -ENODEV; - goto err_put; - } + devtype = id->driver_info; /* initialize device info: */ properties = &line6_properties_table[devtype]; -- 2.1.0