diff options
author | Peter Chubb <peterc@gelato.unsw.edu.au> | 2006-05-02 13:29:34 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-06-21 18:04:10 -0400 |
commit | bdcfd9e349eff9398a1d85eaa517294f493bb3c8 (patch) | |
tree | 62a8804e6ff6559a0de1f09021c9f8cccaf11cf5 | |
parent | 141804d401631f0384feabfa5fc3e2ce1321c0f0 (diff) |
[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>
-rw-r--r-- | drivers/usb/storage/shuttle_usbat.c | 51 | ||||
-rw-r--r-- | drivers/usb/storage/shuttle_usbat.h | 4 | ||||
-rw-r--r-- | drivers/usb/storage/unusual_devs.h | 8 |
3 files changed, 43 insertions, 20 deletions
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index 92095b858eb7..8fcec01dc622 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c | |||
@@ -893,22 +893,28 @@ static int usbat_identify_device(struct us_data *us, | |||
893 | * Set the transport function based on the device type | 893 | * Set the transport function based on the device type |
894 | */ | 894 | */ |
895 | static int usbat_set_transport(struct us_data *us, | 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) { | 900 | if (!info->devicetype) |
901 | rc = usbat_identify_device(us, info); | 901 | info->devicetype = devicetype; |
902 | if (rc != USB_STOR_TRANSPORT_GOOD) { | ||
903 | US_DEBUGP("usbat_set_transport: Could not identify device\n"); | ||
904 | return 1; | ||
905 | } | ||
906 | } | ||
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 | us->transport = usbat_hp8200e_transport; | 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 | us->transport = usbat_flash_transport; | 915 | us->transport = usbat_flash_transport; |
916 | break; | ||
917 | } | ||
912 | 918 | ||
913 | return 0; | 919 | return 0; |
914 | } | 920 | } |
@@ -1316,7 +1322,7 @@ static int usbat_select_and_test_registers(struct us_data *us) | |||
1316 | /* | 1322 | /* |
1317 | * Initialize the USBAT processor and the storage device | 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 | int rc; | 1327 | int rc; |
1322 | struct usbat_info *info; | 1328 | struct usbat_info *info; |
@@ -1398,7 +1404,7 @@ int init_usbat(struct us_data *us) | |||
1398 | US_DEBUGP("INIT 9\n"); | 1404 | US_DEBUGP("INIT 9\n"); |
1399 | 1405 | ||
1400 | /* At this point, we need to detect which device we are using */ | 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 | return USB_STOR_TRANSPORT_ERROR; | 1408 | return USB_STOR_TRANSPORT_ERROR; |
1403 | 1409 | ||
1404 | US_DEBUGP("INIT 10\n"); | 1410 | US_DEBUGP("INIT 10\n"); |
@@ -1701,6 +1707,22 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us) | |||
1701 | return USB_STOR_TRANSPORT_FAILED; | 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 | * Default transport function. Attempts to detect which transport function | 1727 | * Default transport function. Attempts to detect which transport function |
1706 | * should be called, makes it the new default, and calls it. | 1728 | * should be called, makes it the new default, and calls it. |
@@ -1714,9 +1736,8 @@ int usbat_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1714 | { | 1736 | { |
1715 | struct usbat_info *info = (struct usbat_info*) (us->extra); | 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 | return USB_STOR_TRANSPORT_ERROR; | 1740 | return USB_STOR_TRANSPORT_ERROR; |
1719 | 1741 | ||
1720 | return us->transport(srb, us); | 1742 | return us->transport(srb, us); |
1721 | } | 1743 | } |
1722 | |||
diff --git a/drivers/usb/storage/shuttle_usbat.h b/drivers/usb/storage/shuttle_usbat.h index 25e7d8b340b8..3ddf143a1dec 100644 --- a/drivers/usb/storage/shuttle_usbat.h +++ b/drivers/usb/storage/shuttle_usbat.h | |||
@@ -106,7 +106,9 @@ | |||
106 | #define USBAT_FEAT_ET2 0x01 | 106 | #define USBAT_FEAT_ET2 0x01 |
107 | 107 | ||
108 | extern int usbat_transport(struct scsi_cmnd *srb, struct us_data *us); | 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 | struct usbat_info { | 113 | struct usbat_info { |
112 | int devicetype; | 114 | int devicetype; |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index aec5ea8682d5..f24fa12eaedf 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -78,12 +78,12 @@ UNUSUAL_DEV( 0x03f0, 0x0107, 0x0200, 0x0200, | |||
78 | UNUSUAL_DEV( 0x03f0, 0x0207, 0x0001, 0x0001, | 78 | UNUSUAL_DEV( 0x03f0, 0x0207, 0x0001, 0x0001, |
79 | "HP", | 79 | "HP", |
80 | "CD-Writer+ 8200e", | 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 | UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001, | 83 | UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001, |
84 | "HP", | 84 | "HP", |
85 | "CD-Writer+ CD-4e", | 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 | #endif | 87 | #endif |
88 | 88 | ||
89 | /* Reported by Sebastian Kapfer <sebastian_kapfer@gmx.net> | 89 | /* Reported by Sebastian Kapfer <sebastian_kapfer@gmx.net> |
@@ -393,7 +393,7 @@ UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100, | |||
393 | UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999, | 393 | UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999, |
394 | "Shuttle/SCM", | 394 | "Shuttle/SCM", |
395 | "USBAT-02", | 395 | "USBAT-02", |
396 | US_SC_SCSI, US_PR_USBAT, init_usbat, | 396 | US_SC_SCSI, US_PR_USBAT, init_usbat_probe, |
397 | US_FL_SINGLE_LUN), | 397 | US_FL_SINGLE_LUN), |
398 | #endif | 398 | #endif |
399 | 399 | ||
@@ -797,7 +797,7 @@ UNUSUAL_DEV( 0x0781, 0x0002, 0x0009, 0x0009, | |||
797 | UNUSUAL_DEV( 0x0781, 0x0005, 0x0005, 0x0005, | 797 | UNUSUAL_DEV( 0x0781, 0x0005, 0x0005, 0x0005, |
798 | "Sandisk", | 798 | "Sandisk", |
799 | "ImageMate SDDR-05b", | 799 | "ImageMate SDDR-05b", |
800 | US_SC_SCSI, US_PR_USBAT, init_usbat, | 800 | US_SC_SCSI, US_PR_USBAT, init_usbat_flash, |
801 | US_FL_SINGLE_LUN ), | 801 | US_FL_SINGLE_LUN ), |
802 | #endif | 802 | #endif |
803 | 803 | ||