Skip to content

Commit

Permalink
usb-storage: make datafab a separate module
Browse files Browse the repository at this point in the history
This patch (as1213) converts usb-storage's datafab subdriver into a
separate module.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Mar 24, 2009
1 parent 0d62939 commit 2cbbf35
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 142 deletions.
4 changes: 3 additions & 1 deletion drivers/usb/storage/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ config USB_STORAGE_DEBUG
verbose debugging messages.

config USB_STORAGE_DATAFAB
bool "Datafab Compact Flash Reader support"
tristate "Datafab Compact Flash Reader support"
depends on USB_STORAGE
help
Support for certain Datafab CompactFlash readers.
Datafab has a web page at <http://www.datafabusa.com/>.

If this driver is compiled as a module, it will be named ums-datafab.

config USB_STORAGE_FREECOM
tristate "Freecom USB/ATAPI Bridge support"
depends on USB_STORAGE
Expand Down
3 changes: 2 additions & 1 deletion drivers/usb/storage/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ EXTRA_CFLAGS := -Idrivers/scsi
obj-$(CONFIG_USB_STORAGE) += usb-storage.o

usb-storage-obj-$(CONFIG_USB_STORAGE_DEBUG) += debug.o
usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB) += datafab.o
usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o
usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o
usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o
Expand All @@ -26,13 +25,15 @@ else
endif

obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += ums-cypress.o
obj-$(CONFIG_USB_STORAGE_DATAFAB) += ums-datafab.o
obj-$(CONFIG_USB_STORAGE_FREECOM) += ums-freecom.o
obj-$(CONFIG_USB_STORAGE_ISD200) += ums-isd200.o
obj-$(CONFIG_USB_STORAGE_SDDR09) += ums-sddr09.o
obj-$(CONFIG_USB_STORAGE_SDDR55) += ums-sddr55.o
obj-$(CONFIG_USB_STORAGE_USBAT) += ums-usbat.o

ums-cypress-objs := cypress_atacb.o
ums-datafab-objs := datafab.o
ums-freecom-objs := freecom.o
ums-isd200-objs := isd200.o
ums-sddr09-objs := sddr09.o
Expand Down
100 changes: 98 additions & 2 deletions drivers/usb/storage/datafab.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
*/

#include <linux/errno.h>
#include <linux/module.h>
#include <linux/slab.h>

#include <scsi/scsi.h>
Expand All @@ -58,12 +59,61 @@
#include "transport.h"
#include "protocol.h"
#include "debug.h"
#include "datafab.h"

struct datafab_info {
unsigned long sectors; /* total sector count */
unsigned long ssize; /* sector size in bytes */
signed char lun; /* used for dual-slot readers */

/* the following aren't used yet */
unsigned char sense_key;
unsigned long sense_asc; /* additional sense code */
unsigned long sense_ascq; /* additional sense code qualifier */
};

static int datafab_determine_lun(struct us_data *us,
struct datafab_info *info);


/*
* The table of devices
*/
#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
vendorName, productName, useProtocol, useTransport, \
initFunction, flags) \
{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
.driver_info = (flags)|(USB_US_TYPE_STOR<<24) }

struct usb_device_id datafab_usb_ids[] = {
# include "unusual_datafab.h"
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, datafab_usb_ids);

#undef UNUSUAL_DEV

/*
* The flags table
*/
#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
vendor_name, product_name, use_protocol, use_transport, \
init_function, Flags) \
{ \
.vendorName = vendor_name, \
.productName = product_name, \
.useProtocol = use_protocol, \
.useTransport = use_transport, \
.initFunction = init_function, \
}

static struct us_unusual_dev datafab_unusual_dev_list[] = {
# include "unusual_datafab.h"
{ } /* Terminating entry */
};

#undef UNUSUAL_DEV


static inline int
datafab_bulk_read(struct us_data *us, unsigned char *data, unsigned int len) {
if (len == 0)
Expand Down Expand Up @@ -500,7 +550,7 @@ static void datafab_info_destructor(void *extra)

// Transport for the Datafab MDCFE-B
//
int datafab_transport(struct scsi_cmnd * srb, struct us_data *us)
static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us)
{
struct datafab_info *info;
int rc;
Expand Down Expand Up @@ -665,3 +715,49 @@ int datafab_transport(struct scsi_cmnd * srb, struct us_data *us)
info->sense_ascq = 0x00;
return USB_STOR_TRANSPORT_FAILED;
}

static int datafab_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct us_data *us;
int result;

result = usb_stor_probe1(&us, intf, id,
(id - datafab_usb_ids) + datafab_unusual_dev_list);
if (result)
return result;

us->transport_name = "Datafab Bulk-Only";
us->transport = datafab_transport;
us->transport_reset = usb_stor_Bulk_reset;
us->max_lun = 1;

result = usb_stor_probe2(us);
return result;
}

static struct usb_driver datafab_driver = {
.name = "ums-datafab",
.probe = datafab_probe,
.disconnect = usb_stor_disconnect,
.suspend = usb_stor_suspend,
.resume = usb_stor_resume,
.reset_resume = usb_stor_reset_resume,
.pre_reset = usb_stor_pre_reset,
.post_reset = usb_stor_post_reset,
.id_table = datafab_usb_ids,
.soft_unbind = 1,
};

static int __init datafab_init(void)
{
return usb_register(&datafab_driver);
}

static void __exit datafab_exit(void)
{
usb_deregister(&datafab_driver);
}

module_init(datafab_init);
module_exit(datafab_exit);
40 changes: 0 additions & 40 deletions drivers/usb/storage/datafab.h

This file was deleted.

98 changes: 98 additions & 0 deletions drivers/usb/storage/unusual_datafab.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/* Unusual Devices File for the Datafab USB Compact Flash reader
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#if defined(CONFIG_USB_STORAGE_DATAFAB) || \
defined(CONFIG_USB_STORAGE_DATAFAB_MODULE)

UNUSUAL_DEV( 0x07c4, 0xa000, 0x0000, 0x0015,
"Datafab",
"MDCFE-B USB CF Reader",
US_SC_SCSI, US_PR_DATAFAB, NULL,
0),

/*
* The following Datafab-based devices may or may not work
* using the current driver...the 0xffff is arbitrary since I
* don't know what device versions exist for these guys.
*
* The 0xa003 and 0xa004 devices in particular I'm curious about.
* I'm told they exist but so far nobody has come forward to say that
* they work with this driver. Given the success we've had getting
* other Datafab-based cards operational with this driver, I've decided
* to leave these two devices in the list.
*/
UNUSUAL_DEV( 0x07c4, 0xa001, 0x0000, 0xffff,
"SIIG/Datafab",
"SIIG/Datafab Memory Stick+CF Reader/Writer",
US_SC_SCSI, US_PR_DATAFAB, NULL,
0),

/* Reported by Josef Reisinger <josef.reisinger@netcologne.de> */
UNUSUAL_DEV( 0x07c4, 0xa002, 0x0000, 0xffff,
"Datafab/Unknown",
"MD2/MD3 Disk enclosure",
US_SC_SCSI, US_PR_DATAFAB, NULL,
US_FL_SINGLE_LUN),

UNUSUAL_DEV( 0x07c4, 0xa003, 0x0000, 0xffff,
"Datafab/Unknown",
"Datafab-based Reader",
US_SC_SCSI, US_PR_DATAFAB, NULL,
0),

UNUSUAL_DEV( 0x07c4, 0xa004, 0x0000, 0xffff,
"Datafab/Unknown",
"Datafab-based Reader",
US_SC_SCSI, US_PR_DATAFAB, NULL,
0),

UNUSUAL_DEV( 0x07c4, 0xa005, 0x0000, 0xffff,
"PNY/Datafab",
"PNY/Datafab CF+SM Reader",
US_SC_SCSI, US_PR_DATAFAB, NULL,
0),

UNUSUAL_DEV( 0x07c4, 0xa006, 0x0000, 0xffff,
"Simple Tech/Datafab",
"Simple Tech/Datafab CF+SM Reader",
US_SC_SCSI, US_PR_DATAFAB, NULL,
0),

/* Submitted by Olaf Hering <olh@suse.de> */
UNUSUAL_DEV( 0x07c4, 0xa109, 0x0000, 0xffff,
"Datafab Systems, Inc.",
"USB to CF + SM Combo (LC1)",
US_SC_SCSI, US_PR_DATAFAB, NULL,
0),

/* Reported by Felix Moeller <felix@derklecks.de>
* in Germany this is sold by Hama with the productnumber 46952
* as "DualSlot CompactFlash(TM) & MStick Drive USB"
*/
UNUSUAL_DEV( 0x07c4, 0xa10b, 0x0000, 0xffff,
"DataFab Systems Inc.",
"USB CF+MS",
US_SC_SCSI, US_PR_DATAFAB, NULL,
0),

UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
"Acomdata",
"CF",
US_SC_SCSI, US_PR_DATAFAB, NULL,
US_FL_SINGLE_LUN),

#endif /* defined(CONFIG_USB_STORAGE_DATAFAB) || ... */
Loading

0 comments on commit 2cbbf35

Please sign in to comment.