Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] USB: shuttle_usbat: Hardcode detection of HP CDRW devices

Use USB vendor and product IDs to determine whether the attached
device is a CDROM or a Flash device. Daniel Drake says that the
*same* vendor and product IDs for non-HP vendor ID could be either
flash or cdrom, so try to probe for them.

Signed-off-by: Peter Chubb <peterc@gelato.unsw.edu.au>
Signed-off-by: Daniel Drake <dsd@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Peter Chubb and committed by
Greg Kroah-Hartman
bdcfd9e3 141804d4

+43 -20
+36 -15
drivers/usb/storage/shuttle_usbat.c
··· 893 893 * Set the transport function based on the device type 894 894 */ 895 895 static int usbat_set_transport(struct us_data *us, 896 - struct usbat_info *info) 896 + struct usbat_info *info, 897 + int devicetype) 897 898 { 898 - int rc; 899 899 900 - if (!info->devicetype) { 901 - rc = usbat_identify_device(us, info); 902 - if (rc != USB_STOR_TRANSPORT_GOOD) { 903 - US_DEBUGP("usbat_set_transport: Could not identify device\n"); 904 - return 1; 905 - } 906 - } 900 + if (!info->devicetype) 901 + info->devicetype = devicetype; 907 902 908 - if (usbat_get_device_type(us) == USBAT_DEV_HP8200) 903 + if (!info->devicetype) 904 + usbat_identify_device(us, info); 905 + 906 + switch (info->devicetype) { 907 + default: 908 + return USB_STOR_TRANSPORT_ERROR; 909 + 910 + case USBAT_DEV_HP8200: 909 911 us->transport = usbat_hp8200e_transport; 910 - else if (usbat_get_device_type(us) == USBAT_DEV_FLASH) 912 + break; 913 + 914 + case USBAT_DEV_FLASH: 911 915 us->transport = usbat_flash_transport; 916 + break; 917 + } 912 918 913 919 return 0; 914 920 } ··· 1322 1316 /* 1323 1317 * Initialize the USBAT processor and the storage device 1324 1318 */ 1325 - int init_usbat(struct us_data *us) 1319 + static int init_usbat(struct us_data *us, int devicetype) 1326 1320 { 1327 1321 int rc; 1328 1322 struct usbat_info *info; ··· 1404 1398 US_DEBUGP("INIT 9\n"); 1405 1399 1406 1400 /* At this point, we need to detect which device we are using */ 1407 - if (usbat_set_transport(us, info)) 1401 + if (usbat_set_transport(us, info, devicetype)) 1408 1402 return USB_STOR_TRANSPORT_ERROR; 1409 1403 1410 1404 US_DEBUGP("INIT 10\n"); ··· 1707 1701 return USB_STOR_TRANSPORT_FAILED; 1708 1702 } 1709 1703 1704 + int init_usbat_cd(struct us_data *us) 1705 + { 1706 + return init_usbat(us, USBAT_DEV_HP8200); 1707 + } 1708 + 1709 + 1710 + int init_usbat_flash(struct us_data *us) 1711 + { 1712 + return init_usbat(us, USBAT_DEV_FLASH); 1713 + } 1714 + 1715 + int init_usbat_probe(struct us_data *us) 1716 + { 1717 + return init_usbat(us, 0); 1718 + } 1719 + 1710 1720 /* 1711 1721 * Default transport function. Attempts to detect which transport function 1712 1722 * should be called, makes it the new default, and calls it. ··· 1736 1714 { 1737 1715 struct usbat_info *info = (struct usbat_info*) (us->extra); 1738 1716 1739 - if (usbat_set_transport(us, info)) 1717 + if (usbat_set_transport(us, info, 0)) 1740 1718 return USB_STOR_TRANSPORT_ERROR; 1741 1719 1742 1720 return us->transport(srb, us); 1743 1721 } 1744 -
+3 -1
drivers/usb/storage/shuttle_usbat.h
··· 106 106 #define USBAT_FEAT_ET2 0x01 107 107 108 108 extern int usbat_transport(struct scsi_cmnd *srb, struct us_data *us); 109 - extern int init_usbat(struct us_data *us); 109 + extern int init_usbat_cd(struct us_data *us); 110 + extern int init_usbat_flash(struct us_data *us); 111 + extern int init_usbat_probe(struct us_data *us); 110 112 111 113 struct usbat_info { 112 114 int devicetype;
+4 -4
drivers/usb/storage/unusual_devs.h
··· 78 78 UNUSUAL_DEV( 0x03f0, 0x0207, 0x0001, 0x0001, 79 79 "HP", 80 80 "CD-Writer+ 8200e", 81 - US_SC_8070, US_PR_USBAT, init_usbat, 0), 81 + US_SC_8070, US_PR_USBAT, init_usbat_cd, 0), 82 82 83 83 UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001, 84 84 "HP", 85 85 "CD-Writer+ CD-4e", 86 - US_SC_8070, US_PR_USBAT, init_usbat, 0), 86 + US_SC_8070, US_PR_USBAT, init_usbat_cd, 0), 87 87 #endif 88 88 89 89 /* Reported by Sebastian Kapfer <sebastian_kapfer@gmx.net> ··· 393 393 UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999, 394 394 "Shuttle/SCM", 395 395 "USBAT-02", 396 - US_SC_SCSI, US_PR_USBAT, init_usbat, 396 + US_SC_SCSI, US_PR_USBAT, init_usbat_probe, 397 397 US_FL_SINGLE_LUN), 398 398 #endif 399 399 ··· 797 797 UNUSUAL_DEV( 0x0781, 0x0005, 0x0005, 0x0005, 798 798 "Sandisk", 799 799 "ImageMate SDDR-05b", 800 - US_SC_SCSI, US_PR_USBAT, init_usbat, 800 + US_SC_SCSI, US_PR_USBAT, init_usbat_flash, 801 801 US_FL_SINGLE_LUN ), 802 802 #endif 803 803