usb-storage: make shuttle_usbat a separate module

This patch (as1211) converts usb-storage's shuttle_usbat subdriver
into a separate module.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Alan Stern 2009-02-12 14:48:08 -05:00 committed by Greg Kroah-Hartman
parent fcdb51401f
commit 26d6818f19
8 changed files with 228 additions and 187 deletions

View File

@ -64,7 +64,7 @@ config USB_STORAGE_ISD200
If this driver is compiled as a module, it will be named ums-isd200.
config USB_STORAGE_USBAT
bool "USBAT/USBAT02-based storage support"
tristate "USBAT/USBAT02-based storage support"
depends on USB_STORAGE
help
Say Y here to include additional code to support storage devices
@ -84,6 +84,8 @@ config USB_STORAGE_USBAT
- RCA LYRA MP3 portable
- Sandisk ImageMate SDDR-05b
If this driver is compiled as a module, it will be named ums-usbat.
config USB_STORAGE_SDDR09
tristate "SanDisk SDDR-09 (and other SmartMedia, including DPCM) support"
depends on USB_STORAGE

View File

@ -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_USBAT) += shuttle_usbat.o
usb-storage-obj-$(CONFIG_USB_STORAGE_FREECOM) += freecom.o
usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB) += datafab.o
usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o
@ -31,8 +30,10 @@ obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += ums-cypress.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-isd200-objs := isd200.o
ums-sddr09-objs := sddr09.o
ums-sddr55-objs := sddr55.o
ums-usbat-objs := shuttle_usbat.o

View File

@ -42,6 +42,7 @@
*/
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/cdrom.h>
@ -52,7 +53,97 @@
#include "transport.h"
#include "protocol.h"
#include "debug.h"
#include "shuttle_usbat.h"
/* Supported device types */
#define USBAT_DEV_HP8200 0x01
#define USBAT_DEV_FLASH 0x02
#define USBAT_EPP_PORT 0x10
#define USBAT_EPP_REGISTER 0x30
#define USBAT_ATA 0x40
#define USBAT_ISA 0x50
/* Commands (need to be logically OR'd with an access type */
#define USBAT_CMD_READ_REG 0x00
#define USBAT_CMD_WRITE_REG 0x01
#define USBAT_CMD_READ_BLOCK 0x02
#define USBAT_CMD_WRITE_BLOCK 0x03
#define USBAT_CMD_COND_READ_BLOCK 0x04
#define USBAT_CMD_COND_WRITE_BLOCK 0x05
#define USBAT_CMD_WRITE_REGS 0x07
/* Commands (these don't need an access type) */
#define USBAT_CMD_EXEC_CMD 0x80
#define USBAT_CMD_SET_FEAT 0x81
#define USBAT_CMD_UIO 0x82
/* Methods of accessing UIO register */
#define USBAT_UIO_READ 1
#define USBAT_UIO_WRITE 0
/* Qualifier bits */
#define USBAT_QUAL_FCQ 0x20 /* full compare */
#define USBAT_QUAL_ALQ 0x10 /* auto load subcount */
/* USBAT Flash Media status types */
#define USBAT_FLASH_MEDIA_NONE 0
#define USBAT_FLASH_MEDIA_CF 1
/* USBAT Flash Media change types */
#define USBAT_FLASH_MEDIA_SAME 0
#define USBAT_FLASH_MEDIA_CHANGED 1
/* USBAT ATA registers */
#define USBAT_ATA_DATA 0x10 /* read/write data (R/W) */
#define USBAT_ATA_FEATURES 0x11 /* set features (W) */
#define USBAT_ATA_ERROR 0x11 /* error (R) */
#define USBAT_ATA_SECCNT 0x12 /* sector count (R/W) */
#define USBAT_ATA_SECNUM 0x13 /* sector number (R/W) */
#define USBAT_ATA_LBA_ME 0x14 /* cylinder low (R/W) */
#define USBAT_ATA_LBA_HI 0x15 /* cylinder high (R/W) */
#define USBAT_ATA_DEVICE 0x16 /* head/device selection (R/W) */
#define USBAT_ATA_STATUS 0x17 /* device status (R) */
#define USBAT_ATA_CMD 0x17 /* device command (W) */
#define USBAT_ATA_ALTSTATUS 0x0E /* status (no clear IRQ) (R) */
/* USBAT User I/O Data registers */
#define USBAT_UIO_EPAD 0x80 /* Enable Peripheral Control Signals */
#define USBAT_UIO_CDT 0x40 /* Card Detect (Read Only) */
/* CDT = ACKD & !UI1 & !UI0 */
#define USBAT_UIO_1 0x20 /* I/O 1 */
#define USBAT_UIO_0 0x10 /* I/O 0 */
#define USBAT_UIO_EPP_ATA 0x08 /* 1=EPP mode, 0=ATA mode */
#define USBAT_UIO_UI1 0x04 /* Input 1 */
#define USBAT_UIO_UI0 0x02 /* Input 0 */
#define USBAT_UIO_INTR_ACK 0x01 /* Interrupt (ATA/ISA)/Acknowledge (EPP) */
/* USBAT User I/O Enable registers */
#define USBAT_UIO_DRVRST 0x80 /* Reset Peripheral */
#define USBAT_UIO_ACKD 0x40 /* Enable Card Detect */
#define USBAT_UIO_OE1 0x20 /* I/O 1 set=output/clr=input */
/* If ACKD=1, set OE1 to 1 also. */
#define USBAT_UIO_OE0 0x10 /* I/O 0 set=output/clr=input */
#define USBAT_UIO_ADPRST 0x01 /* Reset SCM chip */
/* USBAT Features */
#define USBAT_FEAT_ETEN 0x80 /* External trigger enable */
#define USBAT_FEAT_U1 0x08
#define USBAT_FEAT_U0 0x04
#define USBAT_FEAT_ET1 0x02
#define USBAT_FEAT_ET2 0x01
struct usbat_info {
int devicetype;
/* Used for Flash readers only */
unsigned long sectors; /* total sector count */
unsigned long ssize; /* sector size in bytes */
unsigned char sense_key;
unsigned long sense_asc; /* additional sense code */
unsigned long sense_ascq; /* additional sense code qualifier */
};
#define short_pack(LSB,MSB) ( ((u16)(LSB)) | ( ((u16)(MSB))<<8 ) )
#define LSB_of(s) ((s)&0xFF)
@ -63,6 +154,48 @@ static int transferred = 0;
static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us);
static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us);
static int init_usbat_cd(struct us_data *us);
static int init_usbat_flash(struct us_data *us);
/*
* 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 usbat_usb_ids[] = {
# include "unusual_usbat.h"
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, usbat_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 usbat_unusual_dev_list[] = {
# include "unusual_usbat.h"
{ } /* Terminating entry */
};
#undef UNUSUAL_DEV
/*
* Convenience function to produce an ATA read/write sectors command
* Use cmd=0x20 for read, cmd=0x30 for write
@ -1684,37 +1817,61 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us)
return USB_STOR_TRANSPORT_FAILED;
}
int init_usbat_cd(struct us_data *us)
static int init_usbat_cd(struct us_data *us)
{
return init_usbat(us, USBAT_DEV_HP8200);
}
int init_usbat_flash(struct us_data *us)
static int init_usbat_flash(struct us_data *us)
{
return init_usbat(us, USBAT_DEV_FLASH);
}
int init_usbat_probe(struct us_data *us)
static int usbat_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
return init_usbat(us, 0);
struct us_data *us;
int result;
result = usb_stor_probe1(&us, intf, id,
(id - usbat_usb_ids) + usbat_unusual_dev_list);
if (result)
return result;
/* The actual transport will be determined later by the
* initialization routine; this is just a placeholder.
*/
us->transport_name = "Shuttle USBAT";
us->transport = usbat_flash_transport;
us->transport_reset = usb_stor_CB_reset;
us->max_lun = 1;
result = usb_stor_probe2(us);
return result;
}
/*
* Default transport function. Attempts to detect which transport function
* should be called, makes it the new default, and calls it.
*
* This function should never be called. Our usbat_init() function detects the
* device type and changes the us->transport ptr to the transport function
* relevant to the device.
* However, we'll support this impossible(?) case anyway.
*/
int usbat_transport(struct scsi_cmnd *srb, struct us_data *us)
static struct usb_driver usbat_driver = {
.name = "ums-usbat",
.probe = usbat_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 = usbat_usb_ids,
.soft_unbind = 1,
};
static int __init usbat_init(void)
{
struct usbat_info *info = (struct usbat_info*) (us->extra);
if (usbat_set_transport(us, info, 0))
return USB_STOR_TRANSPORT_ERROR;
return us->transport(srb, us);
return usb_register(&usbat_driver);
}
static void __exit usbat_exit(void)
{
usb_deregister(&usbat_driver);
}
module_init(usbat_init);
module_exit(usbat_exit);

View File

@ -1,123 +0,0 @@
/* Driver for SCM Microsystems USB-ATAPI cable
* Header File
*
* Current development and maintenance by:
* (c) 2000 Robert Baruch (autophile@dol.net)
* (c) 2004, 2005 Daniel Drake <dsd@gentoo.org>
*
* See shuttle_usbat.c for more explanation
*
* 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.
*/
#ifndef _USB_SHUTTLE_USBAT_H
#define _USB_SHUTTLE_USBAT_H
/* Supported device types */
#define USBAT_DEV_HP8200 0x01
#define USBAT_DEV_FLASH 0x02
#define USBAT_EPP_PORT 0x10
#define USBAT_EPP_REGISTER 0x30
#define USBAT_ATA 0x40
#define USBAT_ISA 0x50
/* Commands (need to be logically OR'd with an access type */
#define USBAT_CMD_READ_REG 0x00
#define USBAT_CMD_WRITE_REG 0x01
#define USBAT_CMD_READ_BLOCK 0x02
#define USBAT_CMD_WRITE_BLOCK 0x03
#define USBAT_CMD_COND_READ_BLOCK 0x04
#define USBAT_CMD_COND_WRITE_BLOCK 0x05
#define USBAT_CMD_WRITE_REGS 0x07
/* Commands (these don't need an access type) */
#define USBAT_CMD_EXEC_CMD 0x80
#define USBAT_CMD_SET_FEAT 0x81
#define USBAT_CMD_UIO 0x82
/* Methods of accessing UIO register */
#define USBAT_UIO_READ 1
#define USBAT_UIO_WRITE 0
/* Qualifier bits */
#define USBAT_QUAL_FCQ 0x20 /* full compare */
#define USBAT_QUAL_ALQ 0x10 /* auto load subcount */
/* USBAT Flash Media status types */
#define USBAT_FLASH_MEDIA_NONE 0
#define USBAT_FLASH_MEDIA_CF 1
/* USBAT Flash Media change types */
#define USBAT_FLASH_MEDIA_SAME 0
#define USBAT_FLASH_MEDIA_CHANGED 1
/* USBAT ATA registers */
#define USBAT_ATA_DATA 0x10 /* read/write data (R/W) */
#define USBAT_ATA_FEATURES 0x11 /* set features (W) */
#define USBAT_ATA_ERROR 0x11 /* error (R) */
#define USBAT_ATA_SECCNT 0x12 /* sector count (R/W) */
#define USBAT_ATA_SECNUM 0x13 /* sector number (R/W) */
#define USBAT_ATA_LBA_ME 0x14 /* cylinder low (R/W) */
#define USBAT_ATA_LBA_HI 0x15 /* cylinder high (R/W) */
#define USBAT_ATA_DEVICE 0x16 /* head/device selection (R/W) */
#define USBAT_ATA_STATUS 0x17 /* device status (R) */
#define USBAT_ATA_CMD 0x17 /* device command (W) */
#define USBAT_ATA_ALTSTATUS 0x0E /* status (no clear IRQ) (R) */
/* USBAT User I/O Data registers */
#define USBAT_UIO_EPAD 0x80 /* Enable Peripheral Control Signals */
#define USBAT_UIO_CDT 0x40 /* Card Detect (Read Only) */
/* CDT = ACKD & !UI1 & !UI0 */
#define USBAT_UIO_1 0x20 /* I/O 1 */
#define USBAT_UIO_0 0x10 /* I/O 0 */
#define USBAT_UIO_EPP_ATA 0x08 /* 1=EPP mode, 0=ATA mode */
#define USBAT_UIO_UI1 0x04 /* Input 1 */
#define USBAT_UIO_UI0 0x02 /* Input 0 */
#define USBAT_UIO_INTR_ACK 0x01 /* Interrupt (ATA/ISA)/Acknowledge (EPP) */
/* USBAT User I/O Enable registers */
#define USBAT_UIO_DRVRST 0x80 /* Reset Peripheral */
#define USBAT_UIO_ACKD 0x40 /* Enable Card Detect */
#define USBAT_UIO_OE1 0x20 /* I/O 1 set=output/clr=input */
/* If ACKD=1, set OE1 to 1 also. */
#define USBAT_UIO_OE0 0x10 /* I/O 0 set=output/clr=input */
#define USBAT_UIO_ADPRST 0x01 /* Reset SCM chip */
/* USBAT Features */
#define USBAT_FEAT_ETEN 0x80 /* External trigger enable */
#define USBAT_FEAT_U1 0x08
#define USBAT_FEAT_U0 0x04
#define USBAT_FEAT_ET1 0x02
#define USBAT_FEAT_ET2 0x01
extern int usbat_transport(struct scsi_cmnd *srb, struct us_data *us);
extern int init_usbat_cd(struct us_data *us);
extern int init_usbat_flash(struct us_data *us);
extern int init_usbat_probe(struct us_data *us);
struct usbat_info {
int devicetype;
/* Used for Flash readers only */
unsigned long sectors; /* total sector count */
unsigned long ssize; /* sector size in bytes */
unsigned char sense_key;
unsigned long sense_asc; /* additional sense code */
unsigned long sense_ascq; /* additional sense code qualifier */
};
#endif

View File

@ -85,18 +85,6 @@ UNUSUAL_DEV( 0x03f0, 0x0107, 0x0200, 0x0200,
"CD-Writer+",
US_SC_8070, US_PR_CB, NULL, 0),
#ifdef CONFIG_USB_STORAGE_USBAT
UNUSUAL_DEV( 0x03f0, 0x0207, 0x0001, 0x0001,
"HP",
"CD-Writer+ 8200e",
US_SC_8070, US_PR_USBAT, init_usbat_cd, 0),
UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001,
"HP",
"CD-Writer+ CD-4e",
US_SC_8070, US_PR_USBAT, init_usbat_cd, 0),
#endif
/* Reported by Ben Efros <ben@pc-doctor.com> */
UNUSUAL_DEV( 0x03f0, 0x070c, 0x0000, 0x0000,
"HP",
@ -506,14 +494,6 @@ UNUSUAL_DEV( 0x04e6, 0x0101, 0x0200, 0x0200,
"CD-RW Device",
US_SC_8020, US_PR_CB, NULL, 0),
#ifdef CONFIG_USB_STORAGE_USBAT
UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999,
"Shuttle/SCM",
"USBAT-02",
US_SC_SCSI, US_PR_USBAT, init_usbat_flash,
US_FL_SINGLE_LUN),
#endif
/* Reported by Dmitry Khlystov <adminimus@gmail.com> */
UNUSUAL_DEV( 0x04e8, 0x507c, 0x0220, 0x0220,
"Samsung",
@ -972,14 +952,6 @@ UNUSUAL_DEV( 0x0781, 0x0002, 0x0009, 0x0009,
US_SC_DEVICE, US_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY ),
#ifdef CONFIG_USB_STORAGE_USBAT
UNUSUAL_DEV( 0x0781, 0x0005, 0x0005, 0x0005,
"Sandisk",
"ImageMate SDDR-05b",
US_SC_SCSI, US_PR_USBAT, init_usbat_flash,
US_FL_SINGLE_LUN ),
#endif
UNUSUAL_DEV( 0x0781, 0x0100, 0x0100, 0x0100,
"Sandisk",
"ImageMate SDDR-12",

View File

@ -0,0 +1,43 @@
/* Unusual Devices File for SCM Microsystems (a.k.a. Shuttle) USB-ATAPI cable
*
* 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_USBAT) || \
defined(CONFIG_USB_STORAGE_USBAT_MODULE)
UNUSUAL_DEV( 0x03f0, 0x0207, 0x0001, 0x0001,
"HP",
"CD-Writer+ 8200e",
US_SC_8070, US_PR_USBAT, init_usbat_cd, 0),
UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001,
"HP",
"CD-Writer+ CD-4e",
US_SC_8070, US_PR_USBAT, init_usbat_cd, 0),
UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999,
"Shuttle/SCM",
"USBAT-02",
US_SC_SCSI, US_PR_USBAT, init_usbat_flash,
US_FL_SINGLE_LUN),
UNUSUAL_DEV( 0x0781, 0x0005, 0x0005, 0x0005,
"Sandisk",
"ImageMate SDDR-05b",
US_SC_SCSI, US_PR_USBAT, init_usbat_flash,
US_FL_SINGLE_LUN),
#endif /* defined(CONFIG_USB_STORAGE_USBAT) || ... */

View File

@ -66,9 +66,6 @@
#include "debug.h"
#include "initializers.h"
#ifdef CONFIG_USB_STORAGE_USBAT
#include "shuttle_usbat.h"
#endif
#ifdef CONFIG_USB_STORAGE_FREECOM
#include "freecom.h"
#endif
@ -610,15 +607,6 @@ static void get_transport(struct us_data *us)
us->transport_reset = usb_stor_Bulk_reset;
break;
#ifdef CONFIG_USB_STORAGE_USBAT
case US_PR_USBAT:
us->transport_name = "Shuttle USBAT";
us->transport = usbat_transport;
us->transport_reset = usb_stor_CB_reset;
us->max_lun = 1;
break;
#endif
#ifdef CONFIG_USB_STORAGE_FREECOM
case US_PR_FREECOM:
us->transport_name = "Freecom";

View File

@ -81,6 +81,7 @@ static struct ignore_entry ignore_ids[] = {
# include "unusual_isd200.h"
# include "unusual_sddr09.h"
# include "unusual_sddr55.h"
# include "unusual_usbat.h"
{ } /* Terminating entry */
};