Skip to content

Commit

Permalink
usb-storage: make cypress_atacb a separate module
Browse files Browse the repository at this point in the history
This patch (as1210) converts usb-storage's cypress_atacb 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 70fcc00 commit fcdb514
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 39 deletions.
4 changes: 3 additions & 1 deletion drivers/usb/storage/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ config USB_STORAGE_KARMA
operation.

config USB_STORAGE_CYPRESS_ATACB
bool "SAT emulation on Cypress USB/ATA Bridge with ATACB"
tristate "SAT emulation on Cypress USB/ATA Bridge with ATACB"
depends on USB_STORAGE
---help---
Say Y here if you want to use SAT (ata pass through) on devices based
Expand All @@ -156,6 +156,8 @@ config USB_STORAGE_CYPRESS_ATACB
If you say no here your device will still work with the standard usb
mass storage class.

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

config USB_LIBUSUAL
bool "The shared table of common (or usual) storage devices"
depends on USB
Expand Down
3 changes: 2 additions & 1 deletion drivers/usb/storage/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ 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
usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o
usb-storage-obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += cypress_atacb.o

usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \
initializers.o sierra_ms.o option_ms.o $(usb-storage-obj-y)
Expand All @@ -28,10 +27,12 @@ else
obj-$(CONFIG_USB) += libusual.o usual-tables.o
endif

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

ums-cypress-objs := cypress_atacb.o
ums-isd200-objs := isd200.o
ums-sddr09-objs := sddr09.o
ums-sddr55-objs := sddr55.o
88 changes: 87 additions & 1 deletion drivers/usb/storage/cypress_atacb.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <linux/module.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_eh.h>
Expand All @@ -29,14 +30,54 @@
#include "scsiglue.h"
#include "debug.h"


/*
* 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 cypress_usb_ids[] = {
# include "unusual_cypress.h"
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, cypress_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 cypress_unusual_dev_list[] = {
# include "unusual_cypress.h"
{ } /* Terminating entry */
};

#undef UNUSUAL_DEV


/*
* ATACB is a protocol used on cypress usb<->ata bridge to
* send raw ATA command over mass storage
* There is a ATACB2 protocol that support LBA48 on newer chip.
* More info that be found on cy7c68310_8.pdf and cy7c68300c_8.pdf
* datasheet from cypress.com.
*/
void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
{
unsigned char save_cmnd[MAX_COMMAND_SIZE];

Expand Down Expand Up @@ -197,3 +238,48 @@ void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
if (srb->cmnd[0] == ATA_12)
srb->cmd_len = 12;
}


static int cypress_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 - cypress_usb_ids) + cypress_unusual_dev_list);
if (result)
return result;

us->protocol_name = "Transparent SCSI with Cypress ATACB";
us->proto_handler = cypress_atacb_passthrough;

result = usb_stor_probe2(us);
return result;
}

static struct usb_driver cypress_driver = {
.name = "ums-cypress",
.probe = cypress_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 = cypress_usb_ids,
.soft_unbind = 1,
};

static int __init cypress_init(void)
{
return usb_register(&cypress_driver);
}

static void __exit cypress_exit(void)
{
usb_deregister(&cypress_driver);
}

module_init(cypress_init);
module_exit(cypress_exit);
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/*
* Support for emulating SAT (ata pass through) on devices based
* on the Cypress USB/ATA bridge supporting ATACB.
*
* Copyright (c) 2008 Matthieu Castet (castet.matthieu@free.fr)
/* Unusual Devices File for devices based on the Cypress USB/ATA bridge
* with support for ATACB
*
* 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
Expand All @@ -19,7 +16,19 @@
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef _CYPRESS_ATACB_H_
#define _CYPRESS_ATACB_H_
extern void cypress_atacb_passthrough(struct scsi_cmnd*, struct us_data*);
#endif
#if defined(CONFIG_USB_STORAGE_CYPRESS_ATACB) || \
defined(CONFIG_USB_STORAGE_CYPRESS_ATACB_MODULE)

/* CY7C68300 : support atacb */
UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999,
"Cypress",
"Cypress AT2LP",
US_SC_CYP_ATACB, US_PR_DEVICE, NULL, 0),

/* CY7C68310 : support atacb and atacb2 */
UNUSUAL_DEV( 0x04b4, 0x6831, 0x0000, 0x9999,
"Cypress",
"Cypress ISD-300LP",
US_SC_CYP_ATACB, US_PR_DEVICE, NULL, 0),

#endif /* defined(CONFIG_USB_STORAGE_CYPRESS_ATACB) || ... */
16 changes: 0 additions & 16 deletions drivers/usb/storage/unusual_devs.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,22 +375,6 @@ UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110,
US_SC_DEVICE, US_PR_CB, NULL,
US_FL_MAX_SECTORS_MIN),

#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
/* CY7C68300 : support atacb */
UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999,
"Cypress",
"Cypress AT2LP",
US_SC_CYP_ATACB, US_PR_DEVICE, NULL,
0),

/* CY7C68310 : support atacb and atacb2 */
UNUSUAL_DEV( 0x04b4, 0x6831, 0x0000, 0x9999,
"Cypress",
"Cypress ISD-300LP",
US_SC_CYP_ATACB, US_PR_DEVICE, NULL,
0),
#endif

/* Reported by Simon Levitt <simon@whattf.com>
* This entry needs Sub and Proto fields */
UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100,
Expand Down
11 changes: 0 additions & 11 deletions drivers/usb/storage/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@
#ifdef CONFIG_USB_STORAGE_KARMA
#include "karma.h"
#endif
#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
#include "cypress_atacb.h"
#endif
#include "sierra_ms.h"
#include "option_ms.h"

Expand Down Expand Up @@ -705,14 +702,6 @@ static void get_protocol(struct us_data *us)
us->protocol_name = "Uniform Floppy Interface (UFI)";
us->proto_handler = usb_stor_ufi_command;
break;

#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
case US_SC_CYP_ATACB:
us->protocol_name = "Transparent SCSI with Cypress ATACB";
us->proto_handler = cypress_atacb_passthrough;
break;
#endif

}
}

Expand Down
1 change: 1 addition & 0 deletions drivers/usb/storage/usual-tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ struct ignore_entry {
}

static struct ignore_entry ignore_ids[] = {
# include "unusual_cypress.h"
# include "unusual_isd200.h"
# include "unusual_sddr09.h"
# include "unusual_sddr55.h"
Expand Down

0 comments on commit fcdb514

Please sign in to comment.