Commit bdcfd9e349eff9398a1d85eaa517294f493bb3c8
Committed by
Greg Kroah-Hartman
1 parent
141804d401
Exists in
master
and in
7 other branches
[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>
Showing 3 changed files with 43 additions and 20 deletions Side-by-side Diff
drivers/usb/storage/shuttle_usbat.c
... | ... | @@ -893,22 +893,28 @@ |
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 | } |
... | ... | @@ -1316,7 +1322,7 @@ |
1316 | 1322 | /* |
1317 | 1323 | * Initialize the USBAT processor and the storage device |
1318 | 1324 | */ |
1319 | -int init_usbat(struct us_data *us) | |
1325 | +static int init_usbat(struct us_data *us, int devicetype) | |
1320 | 1326 | { |
1321 | 1327 | int rc; |
1322 | 1328 | struct usbat_info *info; |
... | ... | @@ -1398,7 +1404,7 @@ |
1398 | 1404 | US_DEBUGP("INIT 9\n"); |
1399 | 1405 | |
1400 | 1406 | /* At this point, we need to detect which device we are using */ |
1401 | - if (usbat_set_transport(us, info)) | |
1407 | + if (usbat_set_transport(us, info, devicetype)) | |
1402 | 1408 | return USB_STOR_TRANSPORT_ERROR; |
1403 | 1409 | |
1404 | 1410 | US_DEBUGP("INIT 10\n"); |
... | ... | @@ -1701,6 +1707,22 @@ |
1701 | 1707 | return USB_STOR_TRANSPORT_FAILED; |
1702 | 1708 | } |
1703 | 1709 | |
1710 | +int init_usbat_cd(struct us_data *us) | |
1711 | +{ | |
1712 | + return init_usbat(us, USBAT_DEV_HP8200); | |
1713 | +} | |
1714 | + | |
1715 | + | |
1716 | +int init_usbat_flash(struct us_data *us) | |
1717 | +{ | |
1718 | + return init_usbat(us, USBAT_DEV_FLASH); | |
1719 | +} | |
1720 | + | |
1721 | +int init_usbat_probe(struct us_data *us) | |
1722 | +{ | |
1723 | + return init_usbat(us, 0); | |
1724 | +} | |
1725 | + | |
1704 | 1726 | /* |
1705 | 1727 | * Default transport function. Attempts to detect which transport function |
1706 | 1728 | * should be called, makes it the new default, and calls it. |
... | ... | @@ -1714,7 +1736,7 @@ |
1714 | 1736 | { |
1715 | 1737 | struct usbat_info *info = (struct usbat_info*) (us->extra); |
1716 | 1738 | |
1717 | - if (usbat_set_transport(us, info)) | |
1739 | + if (usbat_set_transport(us, info, 0)) | |
1718 | 1740 | return USB_STOR_TRANSPORT_ERROR; |
1719 | 1741 | |
1720 | 1742 | return us->transport(srb, us); |
drivers/usb/storage/shuttle_usbat.h
... | ... | @@ -106,7 +106,9 @@ |
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; |
drivers/usb/storage/unusual_devs.h
... | ... | @@ -78,12 +78,12 @@ |
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,7 +393,7 @@ |
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,7 +797,7 @@ |
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 |