Commit for backup purpose

This commit is contained in:
mlt
2010-06-28 17:51:53 +00:00
committed by Godzil
parent 71062896b6
commit e3c7c1b8b5
17 changed files with 1809 additions and 261 deletions

View File

@@ -350,8 +350,10 @@ MODULE_LICENSE("Dual BSD/GPL");
static struct {
char *file[MAX_LUNS];
int ro[MAX_LUNS];
int status[MAX_LUNS];
int num_filenames;
int num_ros;
int num_status;
unsigned int nluns;
int removable;
@@ -362,7 +364,8 @@ static struct {
unsigned short vendor;
unsigned short product;
unsigned short release;
unsigned int buflen;
char serial[12];
unsigned int buflen;
int transport_type;
char *transport_name;
@@ -378,6 +381,7 @@ static struct {
.product = DRIVER_PRODUCT_ID,
.release = 0xffff, // Use controller chip type
.buflen = 16384,
.serial = "CYBOR10",
};
@@ -388,6 +392,9 @@ MODULE_PARM_DESC(file, "names of backing files or devices");
module_param_array_named(ro, mod_data.ro, bool, &mod_data.num_ros, S_IRUGO);
MODULE_PARM_DESC(ro, "true to force read-only");
module_param_array_named(status, mod_data.status, int, &mod_data.num_status, S_IRUGO);
MODULE_PARM_DESC(status, "get lun(s) status");
module_param_named(luns, mod_data.nluns, uint, S_IRUGO);
MODULE_PARM_DESC(luns, "number of LUNs");
@@ -421,6 +428,9 @@ 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 */
@@ -560,6 +570,8 @@ struct interrupt_data {
struct lun {
u8 id;
struct file *filp;
loff_t file_length;
loff_t num_sectors;
@@ -569,6 +581,8 @@ struct lun {
unsigned int registered : 1;
unsigned int info_valid : 1;
unsigned int status : 1;
u32 sense_data;
u32 sense_data_info;
u32 unit_attention_data;
@@ -2061,8 +2075,8 @@ static int do_inquiry(struct fsg_dev *fsg, struct fsg_buffhd *bh)
/* 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[] = "e-Book ";
static char product_id[] = "Reader";
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;
@@ -2078,7 +2092,7 @@ static int do_inquiry(struct fsg_dev *fsg, struct fsg_buffhd *bh)
buf[3] = 2; // SCSI-2 INQUIRY data format
buf[4] = 31; // Additional length
// No special options
sprintf(buf + 8, "%-8s%-16s%04x", vendor_id, product_id,
sprintf(buf + 8, "%-8s%-13s-%-2s%04x", vendor_id, product_id, (fsg->curlun->id==1)?"FD":"SD",
mod_data.release);
return 36;
}
@@ -3625,6 +3639,12 @@ static ssize_t show_file(struct device *dev, struct device_attribute *attr, char
return rc;
}
static ssize_t show_status(struct device *dev, struct device_attribute *attr, char *buf)
{
struct lun *curlun = dev_to_lun(dev);
return sprintf(buf, "%d\n", curlun->status);
}
static ssize_t store_ro(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
@@ -3650,6 +3670,12 @@ static ssize_t store_ro(struct device *dev, struct device_attribute *attr, const
return rc;
}
static ssize_t store_status(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
return 0;
}
static ssize_t store_file(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct lun *curlun = dev_to_lun(dev);
@@ -3687,6 +3713,7 @@ static ssize_t store_file(struct device *dev, struct device_attribute *attr, con
/* The write permissions and store_xxx pointers are set in fsg_bind() */
static DEVICE_ATTR(ro, 0444, show_ro, NULL);
static DEVICE_ATTR(file, 0444, show_file, NULL);
static DEVICE_ATTR(status, 0444, show_status, NULL);
/*-------------------------------------------------------------------------*/
@@ -3722,6 +3749,7 @@ static void /* __init_or_exit */ fsg_unbind(struct usb_gadget *gadget)
if (curlun->registered) {
device_remove_file(&curlun->dev, &dev_attr_ro);
device_remove_file(&curlun->dev, &dev_attr_file);
device_remove_file(&curlun->dev, &dev_attr_status);
device_unregister(&curlun->dev);
curlun->registered = 0;
}
@@ -3862,8 +3890,10 @@ static int __init fsg_bind(struct usb_gadget *gadget)
if (mod_data.removable) { // Enable the store_xxx attributes
dev_attr_ro.attr.mode = dev_attr_file.attr.mode = 0644;
dev_attr_status.attr.mode = 0444;
dev_attr_ro.store = store_ro;
dev_attr_file.store = store_file;
dev_attr_status.store = store_status;
}
/* Find out how many LUNs there should be */
@@ -3902,10 +3932,13 @@ static int __init fsg_bind(struct usb_gadget *gadget)
if ((rc = device_create_file(&curlun->dev,
&dev_attr_ro)) != 0 ||
(rc = device_create_file(&curlun->dev,
&dev_attr_file)) != 0) {
&dev_attr_file)) != 0 ||
(rc = device_create_file(&curlun->dev,
&dev_attr_status)) != 0) {
device_unregister(&curlun->dev);
goto out;
}
curlun->id = i;
curlun->registered = 1;
kref_get(&fsg->ref);
@@ -4001,15 +4034,21 @@ static int __init fsg_bind(struct usb_gadget *gadget)
/* This should reflect the actual gadget power source */
usb_gadget_set_selfpowered(gadget);
#if 0
snprintf(manufacturer, sizeof manufacturer, "%s %s with %s",
init_utsname()->sysname, init_utsname()->release,
gadget->name);
#else
snprintf(manufacturer, sizeof manufacturer, "Bookeen");
#endif
/* On a real device, serial[] would be loaded from permanent
* storage. We just encode it from the driver version string. */
for (i = 0; i < sizeof(serial) - 2; i += 2) {
#if 0
unsigned char c = DRIVER_VERSION[i / 2];
#else
unsigned char c = mod_data.serial[i / 2];
#endif
if (!c)
break;
sprintf(&serial[i], "%02X", c);