aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/sddr09.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2009-02-12 14:47:49 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-03-24 19:20:34 -0400
commit0ff71883b2d60136430458413c135d545c69b0c4 (patch)
treec8828d2881acc8d4c063ee5336f5a282f766e7c8 /drivers/usb/storage/sddr09.c
parente6e244b6cb1f70e7109381626293cd40a8334ed3 (diff)
usb-storage: make sddr09 a separate module
This patch (as1207) converts usb-storage's sddr09 subdriver into a separate module. An unexpected complication arises because of DPCM devices, in which one LUN uses the sddr09 transport and one uses the standard CB transport. Since these devices can be used even when USB_STORAGE_SDDR09 isn't configured, their entries in unusual_devs.h require special treatment. If SDDR09 isn't configured then the entries remain in unusual_devs.h; if it is then the entries are present in unusual_sddr09.h instead. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/storage/sddr09.c')
-rw-r--r--drivers/usb/storage/sddr09.c107
1 files changed, 102 insertions, 5 deletions
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
index b667c7d2b837..170ad86b2d3e 100644
--- a/drivers/usb/storage/sddr09.c
+++ b/drivers/usb/storage/sddr09.c
@@ -41,6 +41,7 @@
41 */ 41 */
42 42
43#include <linux/errno.h> 43#include <linux/errno.h>
44#include <linux/module.h>
44#include <linux/slab.h> 45#include <linux/slab.h>
45 46
46#include <scsi/scsi.h> 47#include <scsi/scsi.h>
@@ -51,7 +52,50 @@
51#include "transport.h" 52#include "transport.h"
52#include "protocol.h" 53#include "protocol.h"
53#include "debug.h" 54#include "debug.h"
54#include "sddr09.h" 55
56
57static int usb_stor_sddr09_dpcm_init(struct us_data *us);
58static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us);
59static int usb_stor_sddr09_init(struct us_data *us);
60
61
62/*
63 * The table of devices
64 */
65#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
66 vendorName, productName, useProtocol, useTransport, \
67 initFunction, flags) \
68{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
69 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
70
71struct usb_device_id sddr09_usb_ids[] = {
72# include "unusual_sddr09.h"
73 { } /* Terminating entry */
74};
75MODULE_DEVICE_TABLE(usb, sddr09_usb_ids);
76
77#undef UNUSUAL_DEV
78
79/*
80 * The flags table
81 */
82#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
83 vendor_name, product_name, use_protocol, use_transport, \
84 init_function, Flags) \
85{ \
86 .vendorName = vendor_name, \
87 .productName = product_name, \
88 .useProtocol = use_protocol, \
89 .useTransport = use_transport, \
90 .initFunction = init_function, \
91}
92
93static struct us_unusual_dev sddr09_unusual_dev_list[] = {
94# include "unusual_sddr09.h"
95 { } /* Terminating entry */
96};
97
98#undef UNUSUAL_DEV
55 99
56 100
57#define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) ) 101#define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) )
@@ -1406,7 +1450,7 @@ sddr09_common_init(struct us_data *us) {
1406 * unusual devices list but called from here then LUN 0 of the combo reader 1450 * unusual devices list but called from here then LUN 0 of the combo reader
1407 * is not recognized. But I do not know what precisely these calls do. 1451 * is not recognized. But I do not know what precisely these calls do.
1408 */ 1452 */
1409int 1453static int
1410usb_stor_sddr09_dpcm_init(struct us_data *us) { 1454usb_stor_sddr09_dpcm_init(struct us_data *us) {
1411 int result; 1455 int result;
1412 unsigned char *data = us->iobuf; 1456 unsigned char *data = us->iobuf;
@@ -1456,7 +1500,7 @@ usb_stor_sddr09_dpcm_init(struct us_data *us) {
1456/* 1500/*
1457 * Transport for the Microtech DPCM-USB 1501 * Transport for the Microtech DPCM-USB
1458 */ 1502 */
1459int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us) 1503static int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us)
1460{ 1504{
1461 int ret; 1505 int ret;
1462 1506
@@ -1498,7 +1542,7 @@ int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us)
1498/* 1542/*
1499 * Transport for the Sandisk SDDR-09 1543 * Transport for the Sandisk SDDR-09
1500 */ 1544 */
1501int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) 1545static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
1502{ 1546{
1503 static unsigned char sensekey = 0, sensecode = 0; 1547 static unsigned char sensekey = 0, sensecode = 0;
1504 static unsigned char havefakesense = 0; 1548 static unsigned char havefakesense = 0;
@@ -1697,7 +1741,60 @@ int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
1697/* 1741/*
1698 * Initialization routine for the sddr09 subdriver 1742 * Initialization routine for the sddr09 subdriver
1699 */ 1743 */
1700int 1744static int
1701usb_stor_sddr09_init(struct us_data *us) { 1745usb_stor_sddr09_init(struct us_data *us) {
1702 return sddr09_common_init(us); 1746 return sddr09_common_init(us);
1703} 1747}
1748
1749static int sddr09_probe(struct usb_interface *intf,
1750 const struct usb_device_id *id)
1751{
1752 struct us_data *us;
1753 int result;
1754
1755 result = usb_stor_probe1(&us, intf, id,
1756 (id - sddr09_usb_ids) + sddr09_unusual_dev_list);
1757 if (result)
1758 return result;
1759
1760 if (us->protocol == US_PR_DPCM_USB) {
1761 us->transport_name = "Control/Bulk-EUSB/SDDR09";
1762 us->transport = dpcm_transport;
1763 us->transport_reset = usb_stor_CB_reset;
1764 us->max_lun = 1;
1765 } else {
1766 us->transport_name = "EUSB/SDDR09";
1767 us->transport = sddr09_transport;
1768 us->transport_reset = usb_stor_CB_reset;
1769 us->max_lun = 0;
1770 }
1771
1772 result = usb_stor_probe2(us);
1773 return result;
1774}
1775
1776static struct usb_driver sddr09_driver = {
1777 .name = "ums-sddr09",
1778 .probe = sddr09_probe,
1779 .disconnect = usb_stor_disconnect,
1780 .suspend = usb_stor_suspend,
1781 .resume = usb_stor_resume,
1782 .reset_resume = usb_stor_reset_resume,
1783 .pre_reset = usb_stor_pre_reset,
1784 .post_reset = usb_stor_post_reset,
1785 .id_table = sddr09_usb_ids,
1786 .soft_unbind = 1,
1787};
1788
1789static int __init sddr09_init(void)
1790{
1791 return usb_register(&sddr09_driver);
1792}
1793
1794static void __exit sddr09_exit(void)
1795{
1796 usb_deregister(&sddr09_driver);
1797}
1798
1799module_init(sddr09_init);
1800module_exit(sddr09_exit);