Latest changes
This commit is contained in:
@@ -276,8 +276,8 @@ MODULE_LICENSE("Dual BSD/GPL");
|
||||
*
|
||||
* DO NOT REUSE THESE IDs with any other driver!! Ever!!
|
||||
* Instead: allocate your own, using normal USB-IF procedures. */
|
||||
#define DRIVER_VENDOR_ID 0x0525 // NetChip
|
||||
#define DRIVER_PRODUCT_ID 0xa4a5 // Linux-USB File-backed Storage Gadget
|
||||
#define DRIVER_VENDOR_ID 0x0525 // NetChip
|
||||
#define DRIVER_PRODUCT_ID 0xa4a5 // Linux-USB File-backed Storage Gadget
|
||||
|
||||
|
||||
/*
|
||||
@@ -286,9 +286,17 @@ MODULE_LICENSE("Dual BSD/GPL");
|
||||
* and endpoint addresses.
|
||||
*/
|
||||
|
||||
//#define DEBUG
|
||||
//#define VERBOSE
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
#if 0
|
||||
#undef dev_printk
|
||||
#define dev_printk(level, l, fmt, args...) \
|
||||
printk(KERN_DEBUG DRIVER_NAME ": " fmt, ## args)
|
||||
#endif
|
||||
|
||||
#define xprintk(f,level,fmt,args...) \
|
||||
dev_printk(level , &(f)->gadget->dev , fmt , ## args)
|
||||
#define yprintk(l,level,fmt,args...) \
|
||||
@@ -358,7 +366,8 @@ static struct {
|
||||
|
||||
int removable;
|
||||
int can_stall;
|
||||
|
||||
int hw_disk_status;
|
||||
|
||||
char *transport_parm;
|
||||
char *protocol_parm;
|
||||
unsigned short vendor;
|
||||
@@ -373,18 +382,19 @@ static struct {
|
||||
char *protocol_name;
|
||||
|
||||
} mod_data = { // Default values
|
||||
.transport_parm = "BBB",
|
||||
.transport_parm = "BBB",
|
||||
.protocol_parm = "SCSI",
|
||||
.removable = 0,
|
||||
.can_stall = 1,
|
||||
.vendor = DRIVER_VENDOR_ID,
|
||||
.product = DRIVER_PRODUCT_ID,
|
||||
.release = 0xffff, // Use controller chip type
|
||||
.product = DRIVER_PRODUCT_ID,
|
||||
.release = 0xffff, // Use controller chip type
|
||||
.buflen = 16384,
|
||||
.serial = "CYBOR10",
|
||||
};
|
||||
|
||||
|
||||
#undef S_IRUGO
|
||||
#define S_IRUGO (0644)
|
||||
module_param_array_named(file, mod_data.file, charp, &mod_data.num_filenames,
|
||||
S_IRUGO);
|
||||
MODULE_PARM_DESC(file, "names of backing files or devices");
|
||||
@@ -404,6 +414,14 @@ MODULE_PARM_DESC(removable, "true to simulate removable media");
|
||||
module_param_named(stall, mod_data.can_stall, bool, S_IRUGO);
|
||||
MODULE_PARM_DESC(stall, "false to prevent bulk stalls");
|
||||
|
||||
module_param_named(vendor, mod_data.vendor, ushort, S_IRUGO);
|
||||
MODULE_PARM_DESC(vendor, "USB Vendor ID");
|
||||
|
||||
module_param_named(product, mod_data.product, ushort, S_IRUGO);
|
||||
MODULE_PARM_DESC(product, "USB Product ID");
|
||||
|
||||
module_param_named(serial, mod_data.serial, charp, S_IRUGO);
|
||||
MODULE_PARM_DESC(serial, "Device serial number");
|
||||
|
||||
/* In the non-TEST version, only the module parameters listed above
|
||||
* are available. */
|
||||
@@ -416,21 +434,12 @@ module_param_named(protocol, mod_data.protocol_parm, charp, S_IRUGO);
|
||||
MODULE_PARM_DESC(protocol, "type of protocol (RBC, 8020, QIC, UFI, "
|
||||
"8070, or SCSI)");
|
||||
|
||||
module_param_named(vendor, mod_data.vendor, ushort, S_IRUGO);
|
||||
MODULE_PARM_DESC(vendor, "USB Vendor ID");
|
||||
|
||||
module_param_named(product, mod_data.product, ushort, S_IRUGO);
|
||||
MODULE_PARM_DESC(product, "USB Product ID");
|
||||
|
||||
module_param_named(release, mod_data.release, ushort, S_IRUGO);
|
||||
MODULE_PARM_DESC(release, "USB release number");
|
||||
|
||||
module_param_named(buflen, mod_data.buflen, uint, S_IRUGO);
|
||||
MODULE_PARM_DESC(buflen, "I/O buffer size");
|
||||
|
||||
module_param_named(serial, mod_data.serial, charp, S_IRUGO);
|
||||
MODULE_PARM_DESC(serial, "Device serial number");
|
||||
|
||||
#endif /* CONFIG_USB_FILE_STORAGE_TEST */
|
||||
|
||||
|
||||
@@ -2072,12 +2081,9 @@ static int do_verify(struct fsg_dev *fsg)
|
||||
static int do_inquiry(struct fsg_dev *fsg, struct fsg_buffhd *bh)
|
||||
{
|
||||
u8 *buf = (u8 *) bh->buf;
|
||||
/* Qisda, howard.hsu, 2010/01/26, change usb device name { */
|
||||
//static char vendor_id[] = "Linux ";
|
||||
//static char product_id[] = "File-Stor Gadget";
|
||||
static char vendor_id[] = "Bookeen ";
|
||||
static char product_id[] = "Cybook Orizon";
|
||||
/* } Qisda, howard.hsu, 2010/01/26, change usb device name */
|
||||
|
||||
if (!fsg->curlun) { // Unsupported LUNs are okay
|
||||
fsg->bad_lun_okay = 1;
|
||||
memset(buf, 0, 36);
|
||||
@@ -2263,7 +2269,6 @@ static int do_start_stop(struct fsg_dev *fsg)
|
||||
loej = fsg->cmnd[4] & 0x02;
|
||||
start = fsg->cmnd[4] & 0x01;
|
||||
|
||||
#ifdef CONFIG_USB_FILE_STORAGE_TEST
|
||||
if ((fsg->cmnd[1] & ~0x01) != 0 || // Mask away Immed
|
||||
(fsg->cmnd[4] & ~0x03) != 0) { // Mask LoEj, Start
|
||||
curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
|
||||
@@ -2273,11 +2278,13 @@ static int do_start_stop(struct fsg_dev *fsg)
|
||||
if (!start) {
|
||||
|
||||
/* Are we allowed to unload the media? */
|
||||
if (curlun->prevent_medium_removal) {
|
||||
#if 0 /* We can't prevent hardware removal */
|
||||
if (curlun->prevent_medium_removal) {
|
||||
LDBG(curlun, "unload attempt prevented\n");
|
||||
curlun->sense_data = SS_MEDIUM_REMOVAL_PREVENTED;
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
if (loej) { // Simulate an unload/eject
|
||||
up_read(&fsg->filesem);
|
||||
down_write(&fsg->filesem);
|
||||
@@ -2294,11 +2301,10 @@ static int do_start_stop(struct fsg_dev *fsg)
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int do_prevent_allow(struct fsg_dev *fsg)
|
||||
{
|
||||
struct lun *curlun = fsg->curlun;
|
||||
@@ -3682,11 +3688,13 @@ static ssize_t store_file(struct device *dev, struct device_attribute *attr, con
|
||||
struct fsg_dev *fsg = dev_get_drvdata(dev);
|
||||
int rc = 0;
|
||||
|
||||
if (curlun->prevent_medium_removal && backing_file_is_open(curlun)) {
|
||||
LDBG(curlun, "eject attempt prevented\n");
|
||||
return -EBUSY; // "Door is locked"
|
||||
}
|
||||
|
||||
#if 0 /* Current hardware can't prevent remove */
|
||||
if (curlun->prevent_medium_removal && backing_file_is_open(curlun)) {
|
||||
LDBG(curlun, "eject attempt prevented\n");
|
||||
return -EBUSY; // "Door is locked"
|
||||
} /* If file[] is NULL, then the media has been physically removed, we can't allow access to it */
|
||||
#endif
|
||||
LDBG(curlun, "Will try to mount floppy [%p] '%s'\n", buf, buf);
|
||||
/* Remove a trailing newline */
|
||||
if (count > 0 && buf[count-1] == '\n')
|
||||
((char *) buf)[count-1] = 0; // Ugh!
|
||||
@@ -3694,12 +3702,14 @@ static ssize_t store_file(struct device *dev, struct device_attribute *attr, con
|
||||
/* Eject current medium */
|
||||
down_write(&fsg->filesem);
|
||||
if (backing_file_is_open(curlun)) {
|
||||
LDBG(curlun, "There is currently a floppy.. Eject it before...\n");
|
||||
close_backing_file(curlun);
|
||||
curlun->unit_attention_data = SS_MEDIUM_NOT_PRESENT;
|
||||
}
|
||||
|
||||
/* Load new medium */
|
||||
if (count > 0 && buf[0]) {
|
||||
LDBG(curlun, "File name is valide, now insert floppy...\n");
|
||||
rc = open_backing_file(curlun, buf);
|
||||
if (rc == 0)
|
||||
curlun->unit_attention_data =
|
||||
@@ -3889,7 +3899,7 @@ static int __init fsg_bind(struct usb_gadget *gadget)
|
||||
goto out;
|
||||
|
||||
if (mod_data.removable) { // Enable the store_xxx attributes
|
||||
dev_attr_ro.attr.mode = dev_attr_file.attr.mode = 0644;
|
||||
dev_attr_ro.attr.mode = dev_attr_file.attr.mode = 0664;
|
||||
dev_attr_status.attr.mode = 0444;
|
||||
dev_attr_ro.store = store_ro;
|
||||
dev_attr_file.store = store_file;
|
||||
|
||||
Reference in New Issue
Block a user