mirror of
https://github.com/genesi/linux-legacy.git
synced 2026-07-08 17:56:11 +00:00
gadget: add stmp uut support to file storage
This is gadget file storage changes needed for STMP universal updater tool (manufacturing flashing tool). Signed-off-by: Frank Li <Frank.Li@freescale.com>
This commit is contained in:
@@ -714,8 +714,16 @@ struct fsg_dev {
|
||||
unsigned int nluns;
|
||||
struct lun *luns;
|
||||
struct lun *curlun;
|
||||
|
||||
#ifdef CONFIG_STMP_UTP
|
||||
void *utp;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef CONFIG_STMP_UTP
|
||||
#include "stmp_updater.h"
|
||||
#endif
|
||||
|
||||
typedef void (*fsg_routine_t)(struct fsg_dev *);
|
||||
|
||||
static int exception_in_progress(struct fsg_dev *fsg)
|
||||
@@ -752,7 +760,7 @@ static void dump_msg(struct fsg_dev *fsg, const char *label,
|
||||
if (length < 512) {
|
||||
DBG(fsg, "%s, length %u:\n", label, length);
|
||||
print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET,
|
||||
16, 1, buf, length, 0);
|
||||
16, 1, buf, length, !0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -838,7 +846,11 @@ device_desc = {
|
||||
|
||||
.iManufacturer = STRING_MANUFACTURER,
|
||||
.iProduct = STRING_PRODUCT,
|
||||
#ifdef CONFIG_STMP_UTP
|
||||
.iSerialNumber = 0,
|
||||
#else
|
||||
.iSerialNumber = STRING_SERIAL,
|
||||
#endif
|
||||
.bNumConfigurations = 1,
|
||||
};
|
||||
|
||||
@@ -2068,6 +2080,13 @@ static int do_request_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STMP_UTP
|
||||
if (utp_get_sense(fsg) == 0) { /* got the sense from the UTP */
|
||||
sd = UTP_CTX(fsg)->sd;
|
||||
sdinfo = UTP_CTX(fsg)->sdinfo;
|
||||
valid = 0;
|
||||
} else
|
||||
#endif
|
||||
if (!curlun) { // Unsupported LUNs are okay
|
||||
fsg->bad_lun_okay = 1;
|
||||
sd = SS_LOGICAL_UNIT_NOT_SUPPORTED;
|
||||
@@ -2089,6 +2108,9 @@ static int do_request_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh)
|
||||
buf[7] = 18 - 8; // Additional sense length
|
||||
buf[12] = ASC(sd);
|
||||
buf[13] = ASCQ(sd);
|
||||
#ifdef CONFIG_STMP_UTP
|
||||
put_unaligned_be32(&buf[8], UTP_CTX(fsg)->sdinfo_h);
|
||||
#endif
|
||||
return 18;
|
||||
}
|
||||
|
||||
@@ -2849,6 +2871,13 @@ static int do_scsi_command(struct fsg_dev *fsg)
|
||||
fsg->phase_error = 0;
|
||||
fsg->short_packet_received = 0;
|
||||
|
||||
#ifdef CONFIG_STMP_UTP
|
||||
reply = utp_handle_message(fsg, fsg->cmnd, reply);
|
||||
|
||||
if (reply != -EINVAL)
|
||||
return reply;
|
||||
#endif
|
||||
|
||||
down_read(&fsg->filesem); // We're using the backing file
|
||||
switch (fsg->cmnd[0]) {
|
||||
|
||||
@@ -3537,10 +3566,12 @@ static int fsg_main_thread(void *fsg_)
|
||||
/* Allow the thread to be frozen */
|
||||
set_freezable();
|
||||
|
||||
#ifndef CONFIG_STMP_UTP
|
||||
/* Arrange for userspace references to be interpreted as kernel
|
||||
* pointers. That way we can pass a kernel pointer to a routine
|
||||
* that expects a __user pointer and it will work okay. */
|
||||
set_fs(get_ds());
|
||||
#endif
|
||||
|
||||
/* The main loop */
|
||||
while (fsg->state != FSG_STATE_TERMINATED) {
|
||||
@@ -3851,6 +3882,9 @@ static void /* __init_or_exit */ fsg_unbind(struct usb_gadget *gadget)
|
||||
}
|
||||
|
||||
set_gadget_data(gadget, NULL);
|
||||
#ifdef CONFIG_STMP_UTP
|
||||
utp_exit(fsg);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -3889,6 +3923,17 @@ static int __init check_parameters(struct fsg_dev *fsg)
|
||||
|
||||
prot = simple_strtol(mod_data.protocol_parm, NULL, 0);
|
||||
|
||||
#ifdef CONFIG_STMP_UTP
|
||||
mod_data.can_stall = 0;
|
||||
mod_data.removable = 1;
|
||||
mod_data.nluns = 1;
|
||||
mod_data.file[0] = NULL;
|
||||
mod_data.vendor = 0x066F;
|
||||
mod_data.product = 0x37FF;
|
||||
pr_info("%s:UTP settings are in place now, overriding defaults\n",
|
||||
__func__);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_FILE_STORAGE_TEST
|
||||
if (strnicmp(mod_data.transport_parm, "BBB", 10) == 0) {
|
||||
; // Use default setting
|
||||
@@ -3941,8 +3986,9 @@ static int __init check_parameters(struct fsg_dev *fsg)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_STMP_UTP
|
||||
#include "stmp_updater.c"
|
||||
#endif
|
||||
static int __init fsg_bind(struct usb_gadget *gadget)
|
||||
{
|
||||
struct fsg_dev *fsg = the_fsg;
|
||||
@@ -3970,6 +4016,10 @@ static int __init fsg_bind(struct usb_gadget *gadget)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_STMP_UTP
|
||||
utp_init(fsg);
|
||||
#endif
|
||||
|
||||
/* Find out how many LUNs there should be */
|
||||
i = mod_data.nluns;
|
||||
if (i == 0)
|
||||
|
||||
Reference in New Issue
Block a user