diff options
Diffstat (limited to 'drivers/usb/storage')
-rw-r--r-- | drivers/usb/storage/Kconfig | 17 | ||||
-rw-r--r-- | drivers/usb/storage/Makefile | 1 | ||||
-rw-r--r-- | drivers/usb/storage/initializers.c | 73 | ||||
-rw-r--r-- | drivers/usb/storage/initializers.h | 1 | ||||
-rw-r--r-- | drivers/usb/storage/karma.c | 155 | ||||
-rw-r--r-- | drivers/usb/storage/karma.h | 7 | ||||
-rw-r--r-- | drivers/usb/storage/libusual.c | 10 | ||||
-rw-r--r-- | drivers/usb/storage/onetouch.c | 8 | ||||
-rw-r--r-- | drivers/usb/storage/scsiglue.c | 15 | ||||
-rw-r--r-- | drivers/usb/storage/transport.c | 5 | ||||
-rw-r--r-- | drivers/usb/storage/unusual_devs.h | 32 | ||||
-rw-r--r-- | drivers/usb/storage/usb.c | 11 |
12 files changed, 245 insertions, 90 deletions
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig index be9eec225743..422a4b288e34 100644 --- a/drivers/usb/storage/Kconfig +++ b/drivers/usb/storage/Kconfig @@ -8,8 +8,7 @@ comment "may also be needed; see USB_STORAGE Help for more information" config USB_STORAGE tristate "USB Mass Storage support" - depends on USB - select SCSI + depends on USB && SCSI ---help--- Say Y here if you want to connect USB mass storage devices to your computer's USB port. This is the driver you need for USB @@ -18,7 +17,7 @@ config USB_STORAGE similar devices. This driver may also be used for some cameras and card readers. - This option 'selects' (turns on, enables) 'SCSI', but you + This option depends on 'SCSI' support being enabled, but you probably also need 'SCSI device support: SCSI disk support' (BLK_DEV_SD) for most USB storage devices. @@ -135,6 +134,18 @@ config USB_STORAGE_ONETOUCH this input in any keybinding software. (e.g. gnome's keyboard short- cuts) +config USB_STORAGE_KARMA + bool "Support for Rio Karma music player" + depends on USB_STORAGE + help + Say Y here to include additional code to support the Rio Karma + USB interface. + + This code places the Rio Karma into mass storage mode, enabling + it to be mounted as an ordinary filesystem. Performing an eject + on the resulting scsi device node returns the Karma to normal + operation. + config USB_LIBUSUAL bool "The shared table of common (or usual) storage devices" depends on USB diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile index 8cbba22508a4..023969b4385b 100644 --- a/drivers/usb/storage/Makefile +++ b/drivers/usb/storage/Makefile @@ -20,6 +20,7 @@ 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 +usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ initializers.o $(usb-storage-obj-y) diff --git a/drivers/usb/storage/initializers.c b/drivers/usb/storage/initializers.c index ab173b30076e..5b06f9240d05 100644 --- a/drivers/usb/storage/initializers.c +++ b/drivers/usb/storage/initializers.c @@ -45,12 +45,6 @@ #include "debug.h" #include "transport.h" -#define RIO_MSC 0x08 -#define RIOP_INIT "RIOP\x00\x01\x08" -#define RIOP_INIT_LEN 7 -#define RIO_SEND_LEN 40 -#define RIO_RECV_LEN 0x200 - /* This places the Shuttle/SCM USB<->SCSI bridge devices in multi-target * mode */ int usb_stor_euscsi_init(struct us_data *us) @@ -97,70 +91,3 @@ int usb_stor_ucr61s2b_init(struct us_data *us) return (res ? -1 : 0); } - -/* Place the Rio Karma into mass storage mode. - * - * The initialization begins by sending 40 bytes starting - * RIOP\x00\x01\x08\x00, which the device will ack with a 512-byte - * packet with the high four bits set and everything else null. - * - * Next, we send RIOP\x80\x00\x08\x00. Each time, a 512 byte response - * must be read, but we must loop until byte 5 in the response is 0x08, - * indicating success. */ -int rio_karma_init(struct us_data *us) -{ - int result, partial; - char *recv; - unsigned long timeout; - - // us->iobuf is big enough to hold cmd but not receive - if (!(recv = kmalloc(RIO_RECV_LEN, GFP_KERNEL))) - goto die_nomem; - - US_DEBUGP("Initializing Karma...\n"); - - memset(us->iobuf, 0, RIO_SEND_LEN); - memcpy(us->iobuf, RIOP_INIT, RIOP_INIT_LEN); - - result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, - us->iobuf, RIO_SEND_LEN, &partial); - if (result != USB_STOR_XFER_GOOD) - goto die; - - result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, - recv, RIO_RECV_LEN, &partial); - if (result != USB_STOR_XFER_GOOD) - goto die; - - us->iobuf[4] = 0x80; - us->iobuf[5] = 0; - timeout = jiffies + msecs_to_jiffies(3000); - for (;;) { - US_DEBUGP("Sending init command\n"); - result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, - us->iobuf, RIO_SEND_LEN, &partial); - if (result != USB_STOR_XFER_GOOD) - goto die; - - result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, - recv, RIO_RECV_LEN, &partial); - if (result != USB_STOR_XFER_GOOD) - goto die; - - if (recv[5] == RIO_MSC) - break; - if (time_after(jiffies, timeout)) - goto die; - msleep(10); - } - US_DEBUGP("Karma initialized.\n"); - kfree(recv); - return 0; - -die: - kfree(recv); -die_nomem: - US_DEBUGP("Could not initialize karma.\n"); - return USB_STOR_TRANSPORT_FAILED; -} - diff --git a/drivers/usb/storage/initializers.h b/drivers/usb/storage/initializers.h index 927f7781080f..e2967a4d48a2 100644 --- a/drivers/usb/storage/initializers.h +++ b/drivers/usb/storage/initializers.h @@ -47,4 +47,3 @@ int usb_stor_euscsi_init(struct us_data *us); /* This function is required to activate all four slots on the UCR-61S2B * flash reader */ int usb_stor_ucr61s2b_init(struct us_data *us); -int rio_karma_init(struct us_data *us); diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c new file mode 100644 index 000000000000..0d79ae5683f7 --- /dev/null +++ b/drivers/usb/storage/karma.c @@ -0,0 +1,155 @@ +/* Driver for Rio Karma + * + * (c) 2006 Bob Copeland <me@bobcopeland.com> + * (c) 2006 Keith Bennett <keith@mcs.st-and.ac.uk> + * + * 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. + */ + +#include <scsi/scsi.h> +#include <scsi/scsi_cmnd.h> +#include <scsi/scsi_device.h> + +#include "usb.h" +#include "transport.h" +#include "debug.h" +#include "karma.h" + +#define RIO_PREFIX "RIOP\x00" +#define RIO_PREFIX_LEN 5 +#define RIO_SEND_LEN 40 +#define RIO_RECV_LEN 0x200 + +#define RIO_ENTER_STORAGE 0x1 +#define RIO_LEAVE_STORAGE 0x2 +#define RIO_RESET 0xC + +extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data *); + +struct karma_data { + int in_storage; + char *recv; +}; + +/* + * Send commands to Rio Karma. + * + * For each command we send 40 bytes starting 'RIOP\0' followed by + * the command number and a sequence number, which the device will ack + * with a 512-byte packet with the high four bits set and everything + * else null. Then we send 'RIOP\x80' followed by a zero and the + * sequence number, until byte 5 in the response repeats the sequence + * number. + */ +static int rio_karma_send_command(char cmd, struct us_data *us) +{ + int result, partial; + unsigned long timeout; + static unsigned char seq = 1; + struct karma_data *data = (struct karma_data *) us->extra; + + US_DEBUGP("karma: sending command %04x\n", cmd); + memset(us->iobuf, 0, RIO_SEND_LEN); + memcpy(us->iobuf, RIO_PREFIX, RIO_PREFIX_LEN); + us->iobuf[5] = cmd; + us->iobuf[6] = seq; + + timeout = jiffies + msecs_to_jiffies(6000); + for (;;) { + result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, + us->iobuf, RIO_SEND_LEN, &partial); + if (result != USB_STOR_XFER_GOOD) + goto err; + + result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, + data->recv, RIO_RECV_LEN, &partial); + if (result != USB_STOR_XFER_GOOD) + goto err; + + if (data->recv[5] == seq) + break; + + if (time_after(jiffies, timeout)) + goto err; + + us->iobuf[4] = 0x80; + us->iobuf[5] = 0; + msleep(50); + } + + seq++; + if (seq == 0) + seq = 1; + + US_DEBUGP("karma: sent command %04x\n", cmd); + return 0; +err: + US_DEBUGP("karma: command %04x failed\n", cmd); + return USB_STOR_TRANSPORT_FAILED; +} + +/* + * Trap START_STOP and READ_10 to leave/re-enter storage mode. + * Everything else is propagated to the normal bulk layer. + */ +int rio_karma_transport(struct scsi_cmnd *srb, struct us_data *us) +{ + int ret; + struct karma_data *data = (struct karma_data *) us->extra; + + if (srb->cmnd[0] == READ_10 && !data->in_storage) { + ret = rio_karma_send_command(RIO_ENTER_STORAGE, us); + if (ret) + return ret; + + data->in_storage = 1; + return usb_stor_Bulk_transport(srb, us); + } else if (srb->cmnd[0] == START_STOP) { + ret = rio_karma_send_command(RIO_LEAVE_STORAGE, us); + if (ret) + return ret; + + data->in_storage = 0; + return rio_karma_send_command(RIO_RESET, us); + } + return usb_stor_Bulk_transport(srb, us); +} + +static void rio_karma_destructor(void *extra) +{ + struct karma_data *data = (struct karma_data *) extra; + kfree(data->recv); +} + +int rio_karma_init(struct us_data *us) +{ + int ret = 0; + struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO); + if (!data) + goto out; + + data->recv = kmalloc(RIO_RECV_LEN, GFP_NOIO); + if (!data->recv) { + kfree(data); + goto out; + } + + us->extra = data; + us->extra_destructor = rio_karma_destructor; + ret = rio_karma_send_command(RIO_ENTER_STORAGE, us); + data->in_storage = (ret == 0); +out: + return ret; +} diff --git a/drivers/usb/storage/karma.h b/drivers/usb/storage/karma.h new file mode 100644 index 000000000000..8a60972af8c5 --- /dev/null +++ b/drivers/usb/storage/karma.h @@ -0,0 +1,7 @@ +#ifndef _KARMA_USB_H +#define _KARMA_USB_H + +extern int rio_karma_init(struct us_data *us); +extern int rio_karma_transport(struct scsi_cmnd *srb, struct us_data *us); + +#endif diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c index b1ec4a718547..599ad10a761b 100644 --- a/drivers/usb/storage/libusual.c +++ b/drivers/usb/storage/libusual.c @@ -8,6 +8,7 @@ #include <linux/usb.h> #include <linux/usb_usual.h> #include <linux/vmalloc.h> +#include <linux/kthread.h> /* */ @@ -117,7 +118,7 @@ static int usu_probe(struct usb_interface *intf, const struct usb_device_id *id) { unsigned long type; - int rc; + struct task_struct* task; unsigned long flags; type = USB_US_TYPE(id->driver_info); @@ -132,8 +133,9 @@ static int usu_probe(struct usb_interface *intf, stat[type].fls |= USU_MOD_FL_THREAD; spin_unlock_irqrestore(&usu_lock, flags); - rc = kernel_thread(usu_probe_thread, (void*)type, CLONE_VM); - if (rc < 0) { + task = kthread_run(usu_probe_thread, (void*)type, "libusual_%d", type); + if (IS_ERR(task)) { + int rc = PTR_ERR(task); printk(KERN_WARNING "libusual: " "Unable to start the thread for %s: %d\n", bias_names[type], rc); @@ -175,8 +177,6 @@ static int usu_probe_thread(void *arg) int rc; unsigned long flags; - daemonize("libusual_%d", type); /* "usb-storage" is kinda too long */ - /* A completion does not work here because it's counted. */ down(&usu_init_notify); up(&usu_init_notify); diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c index 313920d980c9..f843a0bcf107 100644 --- a/drivers/usb/storage/onetouch.c +++ b/drivers/usb/storage/onetouch.c @@ -135,6 +135,7 @@ int onetouch_connect_input(struct us_data *ss) struct usb_onetouch *onetouch; struct input_dev *input_dev; int pipe, maxp; + int error = -ENOMEM; interface = ss->pusb_intf->cur_altsetting; @@ -211,15 +212,18 @@ int onetouch_connect_input(struct us_data *ss) ss->suspend_resume_hook = usb_onetouch_pm_hook; #endif - input_register_device(onetouch->dev); + error = input_register_device(onetouch->dev); + if (error) + goto fail3; return 0; + fail3: usb_free_urb(onetouch->irq); fail2: usb_buffer_free(udev, ONETOUCH_PKT_LEN, onetouch->data, onetouch->data_dma); fail1: kfree(onetouch); input_free_device(input_dev); - return -ENOMEM; + return error; } void onetouch_release_input(void *onetouch_) diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index a4b7df9ff8c1..e1072d52d641 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -72,12 +72,27 @@ static const char* host_info(struct Scsi_Host *host) static int slave_alloc (struct scsi_device *sdev) { + struct us_data *us = host_to_us(sdev->host); + /* * Set the INQUIRY transfer length to 36. We don't use any of * the extra data and many devices choke if asked for more or * less than 36 bytes. */ sdev->inquiry_len = 36; + + /* + * The UFI spec treates the Peripheral Qualifier bits in an + * INQUIRY result as reserved and requires devices to set them + * to 0. However the SCSI spec requires these bits to be set + * to 3 to indicate when a LUN is not present. + * + * Let the scanning code know if this target merely sets + * Peripheral Device Type to 0x1f to indicate no LUN. + */ + if (us->subclass == US_SC_UFI) + sdev->sdev_target->pdt_1f_for_no_lun = 1; + return 0; } diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index d6acc92a4ae3..f23514c4e649 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c @@ -294,11 +294,6 @@ static int interpret_urb_result(struct us_data *us, unsigned int pipe, return USB_STOR_XFER_ERROR; return USB_STOR_XFER_STALLED; - /* timeout or excessively long NAK */ - case -ETIMEDOUT: - US_DEBUGP("-- timeout or NAK\n"); - return USB_STOR_XFER_ERROR; - /* babble - the device tried to send more than we wanted to read */ case -EOVERFLOW: US_DEBUGP("-- babble\n"); diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index b130e170b4a8..c9a8d50106d1 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -152,6 +152,13 @@ UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100, US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ), +/* Reported by Jon Hart <Jon.Hart@web.de> */ +UNUSUAL_DEV( 0x0421, 0x0434, 0x0100, 0x0100, + "Nokia", + "E60", + US_SC_DEVICE, US_PR_DEVICE, NULL, + US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ), + /* Reported by Sumedha Swamy <sumedhaswamy@gmail.com> and * Einar Th. Einarsson <einarthered@gmail.com> */ UNUSUAL_DEV( 0x0421, 0x0444, 0x0100, 0x0100, @@ -218,10 +225,12 @@ UNUSUAL_DEV( 0x0457, 0x0151, 0x0100, 0x0100, US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ), +#ifdef CONFIG_USB_STORAGE_KARMA UNUSUAL_DEV( 0x045a, 0x5210, 0x0101, 0x0101, "Rio", "Rio Karma", - US_SC_SCSI, US_PR_BULK, rio_karma_init, 0), + US_SC_SCSI, US_PR_KARMA, rio_karma_init, 0), +#endif /* Patch submitted by Philipp Friedrich <philipp@void.at> */ UNUSUAL_DEV( 0x0482, 0x0100, 0x0100, 0x0100, @@ -631,6 +640,13 @@ UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210, "Digital Camera EX-20 DSC", US_SC_8070, US_PR_DEVICE, NULL, 0 ), +/* Reported by <Hendryk.Pfeiffer@gmx.de> */ +UNUSUAL_DEV( 0x059f, 0x0643, 0x0000, 0x0000, + "LaCie", + "DVD+-RW", + US_SC_DEVICE, US_PR_DEVICE, NULL, + US_FL_GO_SLOW ), + /* Submitted by Joel Bourquard <numlock@freesurf.ch> * Some versions of this device need the SubClass and Protocol overrides * while others don't. @@ -1254,6 +1270,13 @@ UNUSUAL_DEV( 0x0fce, 0xd008, 0x0000, 0x0000, US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_NO_WP_DETECT ), +/* Reported by Jan Mate <mate@fiit.stuba.sk> */ +UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000, + "Sony Ericsson", + "P990i", + US_SC_DEVICE, US_PR_DEVICE, NULL, + US_FL_FIX_CAPACITY ), + /* Reported by Emmanuel Vasilakis <evas@forthnet.gr> */ UNUSUAL_DEV( 0x0fce, 0xe031, 0x0000, 0x0000, "Sony Ericsson", @@ -1261,6 +1284,13 @@ UNUSUAL_DEV( 0x0fce, 0xe031, 0x0000, 0x0000, US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_FIX_CAPACITY ), +/* Reported by Jan Mate <mate@fiit.stuba.sk> */ +UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000, + "Sony Ericsson", + "P990i", + US_SC_DEVICE, US_PR_DEVICE, NULL, + US_FL_FIX_CAPACITY ), + /* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu> * Tested on hardware version 1.10. * Entry is needed only for the initializer function override. diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 8d7bdcb5924d..b8d6031b0975 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -98,6 +98,9 @@ #ifdef CONFIG_USB_STORAGE_ALAUDA #include "alauda.h" #endif +#ifdef CONFIG_USB_STORAGE_KARMA +#include "karma.h" +#endif /* Some informational data */ MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>"); @@ -646,6 +649,14 @@ static int get_transport(struct us_data *us) break; #endif +#ifdef CONFIG_USB_STORAGE_KARMA + case US_PR_KARMA: + us->transport_name = "Rio Karma/Bulk"; + us->transport = rio_karma_transport; + us->transport_reset = usb_stor_Bulk_reset; + break; +#endif + default: return -EIO; } |