1 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
3 #include <linux/slab.h>
4 #include <linux/module.h>
24 return "SCSI emulation for USB Mass Storage devices";
48 static int slave_configure(
struct scsi_device *sdev)
53 if (us->
fflags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN)) {
54 unsigned int max_sectors = 64;
56 if (us->
fflags & US_FL_MAX_SECTORS_MIN)
68 if (us->
fflags & US_FL_NO_WP_DETECT)
71 if (us->
fflags & US_FL_FIX_CAPACITY)
73 if (us->
fflags & US_FL_CAPACITY_HEURISTICS)
88 if (us->
fflags & US_FL_NOT_LOCKABLE)
114 pr_info(
"Fail command during disconnect\n");
140 struct us_data *us = host_to_us(srb->device->host);
145 if (us->
srb != srb) {
147 printk(
"-- nothing to abort\n");
169 static int device_reset(
struct scsi_cmnd *srb)
187 static int bus_reset(
struct scsi_cmnd *srb)
207 if (us->
fflags & US_FL_SCM_MULT_TARG) {
208 for (i = 1; i < host->
max_id; ++
i)
232 #define SPRINTF(args...) \
234 if (pos < buffer+length) \
235 pos += sprintf(pos, ## args); \
244 struct us_data *us = host_to_us(host);
257 string = us->
pusb_dev->manufacturer;
262 SPRINTF(
" Vendor: %s\n",
string);
269 SPRINTF(
" Product: %s\n",
string);
274 SPRINTF(
"Serial Number: %s\n",
string);
281 if (pos < buffer + length) {
282 pos +=
sprintf(pos,
" Quirks:");
284 #define US_FLAG(name, value) \
286 if (us->fflags & value) \
287 pos += sprintf(pos, " " #name); \
298 if ((pos - buffer) <
offset)
300 else if ((pos - buffer - offset) <
length)
301 return pos - buffer - offset;
329 const char *buf,
size_t count)
352 .name =
"eucr-storage",
353 .proc_name =
"eucr-storage",
362 .eh_device_reset_handler = device_reset,
363 .eh_bus_reset_handler = bus_reset,
391 .skip_settle_delay = 1,
394 .sdev_attrs = sysfs_device_attr_list,
425 sg = scsi_sglist(srb);
428 while (cnt < buflen && sg) {
434 if (sglen > buflen - cnt) {
436 sglen = buflen -
cnt;
447 unsigned char *
ptr =
kmap(page);
450 memcpy(ptr + poff, buffer + cnt, plen);
452 memcpy(buffer + cnt, ptr + poff, plen);
483 buflen =
min(buflen, scsi_bufflen(srb));
486 if (buflen < scsi_bufflen(srb))
487 scsi_set_resid(srb, scsi_bufflen(srb) - buflen);