11da177e4SLinus Torvalds /* Driver for Datafab USB Compact Flash reader 21da177e4SLinus Torvalds * 31da177e4SLinus Torvalds * datafab driver v0.1: 41da177e4SLinus Torvalds * 51da177e4SLinus Torvalds * First release 61da177e4SLinus Torvalds * 71da177e4SLinus Torvalds * Current development and maintenance by: 81da177e4SLinus Torvalds * (c) 2000 Jimmie Mayfield (mayfield+datafab@sackheads.org) 91da177e4SLinus Torvalds * 101da177e4SLinus Torvalds * Many thanks to Robert Baruch for the SanDisk SmartMedia reader driver 111da177e4SLinus Torvalds * which I used as a template for this driver. 121da177e4SLinus Torvalds * 131da177e4SLinus Torvalds * Some bugfixes and scatter-gather code by Gregory P. Smith 141da177e4SLinus Torvalds * (greg-usb@electricrain.com) 151da177e4SLinus Torvalds * 161da177e4SLinus Torvalds * Fix for media change by Joerg Schneider (js@joergschneider.com) 171da177e4SLinus Torvalds * 181da177e4SLinus Torvalds * Other contributors: 191da177e4SLinus Torvalds * (c) 2002 Alan Stern <stern@rowland.org> 201da177e4SLinus Torvalds * 211da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify it 221da177e4SLinus Torvalds * under the terms of the GNU General Public License as published by the 231da177e4SLinus Torvalds * Free Software Foundation; either version 2, or (at your option) any 241da177e4SLinus Torvalds * later version. 251da177e4SLinus Torvalds * 261da177e4SLinus Torvalds * This program is distributed in the hope that it will be useful, but 271da177e4SLinus Torvalds * WITHOUT ANY WARRANTY; without even the implied warranty of 281da177e4SLinus Torvalds * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 291da177e4SLinus Torvalds * General Public License for more details. 301da177e4SLinus Torvalds * 311da177e4SLinus Torvalds * You should have received a copy of the GNU General Public License along 321da177e4SLinus Torvalds * with this program; if not, write to the Free Software Foundation, Inc., 331da177e4SLinus Torvalds * 675 Mass Ave, Cambridge, MA 02139, USA. 341da177e4SLinus Torvalds */ 351da177e4SLinus Torvalds 361da177e4SLinus Torvalds /* 371da177e4SLinus Torvalds * This driver attempts to support USB CompactFlash reader/writer devices 381da177e4SLinus Torvalds * based on Datafab USB-to-ATA chips. It was specifically developed for the 391da177e4SLinus Torvalds * Datafab MDCFE-B USB CompactFlash reader but has since been found to work 401da177e4SLinus Torvalds * with a variety of Datafab-based devices from a number of manufacturers. 411da177e4SLinus Torvalds * I've received a report of this driver working with a Datafab-based 421da177e4SLinus Torvalds * SmartMedia device though please be aware that I'm personally unable to 431da177e4SLinus Torvalds * test SmartMedia support. 441da177e4SLinus Torvalds * 451da177e4SLinus Torvalds * This driver supports reading and writing. If you're truly paranoid, 461da177e4SLinus Torvalds * however, you can force the driver into a write-protected state by setting 471da177e4SLinus Torvalds * the WP enable bits in datafab_handle_mode_sense(). See the comments 481da177e4SLinus Torvalds * in that routine. 491da177e4SLinus Torvalds */ 501da177e4SLinus Torvalds 511da177e4SLinus Torvalds #include <linux/errno.h> 522cbbf357SAlan Stern #include <linux/module.h> 531da177e4SLinus Torvalds #include <linux/slab.h> 541da177e4SLinus Torvalds 551da177e4SLinus Torvalds #include <scsi/scsi.h> 561da177e4SLinus Torvalds #include <scsi/scsi_cmnd.h> 571da177e4SLinus Torvalds 581da177e4SLinus Torvalds #include "usb.h" 591da177e4SLinus Torvalds #include "transport.h" 601da177e4SLinus Torvalds #include "protocol.h" 611da177e4SLinus Torvalds #include "debug.h" 622cbbf357SAlan Stern 634246b06aSMaciej Grela MODULE_DESCRIPTION("Driver for Datafab USB Compact Flash reader"); 644246b06aSMaciej Grela MODULE_AUTHOR("Jimmie Mayfield <mayfield+datafab@sackheads.org>"); 654246b06aSMaciej Grela MODULE_LICENSE("GPL"); 664246b06aSMaciej Grela 672cbbf357SAlan Stern struct datafab_info { 682cbbf357SAlan Stern unsigned long sectors; /* total sector count */ 692cbbf357SAlan Stern unsigned long ssize; /* sector size in bytes */ 702cbbf357SAlan Stern signed char lun; /* used for dual-slot readers */ 712cbbf357SAlan Stern 722cbbf357SAlan Stern /* the following aren't used yet */ 732cbbf357SAlan Stern unsigned char sense_key; 742cbbf357SAlan Stern unsigned long sense_asc; /* additional sense code */ 752cbbf357SAlan Stern unsigned long sense_ascq; /* additional sense code qualifier */ 762cbbf357SAlan Stern }; 771da177e4SLinus Torvalds 781da177e4SLinus Torvalds static int datafab_determine_lun(struct us_data *us, 791da177e4SLinus Torvalds struct datafab_info *info); 801da177e4SLinus Torvalds 811da177e4SLinus Torvalds 822cbbf357SAlan Stern /* 832cbbf357SAlan Stern * The table of devices 842cbbf357SAlan Stern */ 852cbbf357SAlan Stern #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ 862cbbf357SAlan Stern vendorName, productName, useProtocol, useTransport, \ 872cbbf357SAlan Stern initFunction, flags) \ 882cbbf357SAlan Stern { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ 892cbbf357SAlan Stern .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } 902cbbf357SAlan Stern 91b03379f7SFelipe Balbi static struct usb_device_id datafab_usb_ids[] = { 922cbbf357SAlan Stern # include "unusual_datafab.h" 932cbbf357SAlan Stern { } /* Terminating entry */ 942cbbf357SAlan Stern }; 952cbbf357SAlan Stern MODULE_DEVICE_TABLE(usb, datafab_usb_ids); 962cbbf357SAlan Stern 972cbbf357SAlan Stern #undef UNUSUAL_DEV 982cbbf357SAlan Stern 992cbbf357SAlan Stern /* 1002cbbf357SAlan Stern * The flags table 1012cbbf357SAlan Stern */ 1022cbbf357SAlan Stern #define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \ 1032cbbf357SAlan Stern vendor_name, product_name, use_protocol, use_transport, \ 1042cbbf357SAlan Stern init_function, Flags) \ 1052cbbf357SAlan Stern { \ 1062cbbf357SAlan Stern .vendorName = vendor_name, \ 1072cbbf357SAlan Stern .productName = product_name, \ 1082cbbf357SAlan Stern .useProtocol = use_protocol, \ 1092cbbf357SAlan Stern .useTransport = use_transport, \ 1102cbbf357SAlan Stern .initFunction = init_function, \ 1112cbbf357SAlan Stern } 1122cbbf357SAlan Stern 1132cbbf357SAlan Stern static struct us_unusual_dev datafab_unusual_dev_list[] = { 1142cbbf357SAlan Stern # include "unusual_datafab.h" 1152cbbf357SAlan Stern { } /* Terminating entry */ 1162cbbf357SAlan Stern }; 1172cbbf357SAlan Stern 1182cbbf357SAlan Stern #undef UNUSUAL_DEV 1192cbbf357SAlan Stern 1202cbbf357SAlan Stern 1211da177e4SLinus Torvalds static inline int 1221da177e4SLinus Torvalds datafab_bulk_read(struct us_data *us, unsigned char *data, unsigned int len) { 1231da177e4SLinus Torvalds if (len == 0) 1241da177e4SLinus Torvalds return USB_STOR_XFER_GOOD; 1251da177e4SLinus Torvalds 1261da177e4SLinus Torvalds US_DEBUGP("datafab_bulk_read: len = %d\n", len); 1271da177e4SLinus Torvalds return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, 1281da177e4SLinus Torvalds data, len, NULL); 1291da177e4SLinus Torvalds } 1301da177e4SLinus Torvalds 1311da177e4SLinus Torvalds 1321da177e4SLinus Torvalds static inline int 1331da177e4SLinus Torvalds datafab_bulk_write(struct us_data *us, unsigned char *data, unsigned int len) { 1341da177e4SLinus Torvalds if (len == 0) 1351da177e4SLinus Torvalds return USB_STOR_XFER_GOOD; 1361da177e4SLinus Torvalds 1371da177e4SLinus Torvalds US_DEBUGP("datafab_bulk_write: len = %d\n", len); 1381da177e4SLinus Torvalds return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, 1391da177e4SLinus Torvalds data, len, NULL); 1401da177e4SLinus Torvalds } 1411da177e4SLinus Torvalds 1421da177e4SLinus Torvalds 1431da177e4SLinus Torvalds static int datafab_read_data(struct us_data *us, 1441da177e4SLinus Torvalds struct datafab_info *info, 1451da177e4SLinus Torvalds u32 sector, 1461da177e4SLinus Torvalds u32 sectors) 1471da177e4SLinus Torvalds { 1481da177e4SLinus Torvalds unsigned char *command = us->iobuf; 1491da177e4SLinus Torvalds unsigned char *buffer; 1501da177e4SLinus Torvalds unsigned char thistime; 1511da177e4SLinus Torvalds unsigned int totallen, alloclen; 1521da177e4SLinus Torvalds int len, result; 1531f6f31a0SJens Axboe unsigned int sg_offset = 0; 1541f6f31a0SJens Axboe struct scatterlist *sg = NULL; 1551da177e4SLinus Torvalds 1561da177e4SLinus Torvalds // we're working in LBA mode. according to the ATA spec, 1571da177e4SLinus Torvalds // we can support up to 28-bit addressing. I don't know if Datafab 1581da177e4SLinus Torvalds // supports beyond 24-bit addressing. It's kind of hard to test 1591da177e4SLinus Torvalds // since it requires > 8GB CF card. 1601da177e4SLinus Torvalds // 1611da177e4SLinus Torvalds if (sectors > 0x0FFFFFFF) 1621da177e4SLinus Torvalds return USB_STOR_TRANSPORT_ERROR; 1631da177e4SLinus Torvalds 1641da177e4SLinus Torvalds if (info->lun == -1) { 1651da177e4SLinus Torvalds result = datafab_determine_lun(us, info); 1661da177e4SLinus Torvalds if (result != USB_STOR_TRANSPORT_GOOD) 1671da177e4SLinus Torvalds return result; 1681da177e4SLinus Torvalds } 1691da177e4SLinus Torvalds 1701da177e4SLinus Torvalds totallen = sectors * info->ssize; 1711da177e4SLinus Torvalds 1721da177e4SLinus Torvalds // Since we don't read more than 64 KB at a time, we have to create 1731da177e4SLinus Torvalds // a bounce buffer and move the data a piece at a time between the 1741da177e4SLinus Torvalds // bounce buffer and the actual transfer buffer. 1751da177e4SLinus Torvalds 1761da177e4SLinus Torvalds alloclen = min(totallen, 65536u); 1771da177e4SLinus Torvalds buffer = kmalloc(alloclen, GFP_NOIO); 1781da177e4SLinus Torvalds if (buffer == NULL) 1791da177e4SLinus Torvalds return USB_STOR_TRANSPORT_ERROR; 1801da177e4SLinus Torvalds 1811da177e4SLinus Torvalds do { 1821da177e4SLinus Torvalds // loop, never allocate or transfer more than 64k at once 1831da177e4SLinus Torvalds // (min(128k, 255*info->ssize) is the real limit) 1841da177e4SLinus Torvalds 1851da177e4SLinus Torvalds len = min(totallen, alloclen); 1861da177e4SLinus Torvalds thistime = (len / info->ssize) & 0xff; 1871da177e4SLinus Torvalds 1881da177e4SLinus Torvalds command[0] = 0; 1891da177e4SLinus Torvalds command[1] = thistime; 1901da177e4SLinus Torvalds command[2] = sector & 0xFF; 1911da177e4SLinus Torvalds command[3] = (sector >> 8) & 0xFF; 1921da177e4SLinus Torvalds command[4] = (sector >> 16) & 0xFF; 1931da177e4SLinus Torvalds 1941da177e4SLinus Torvalds command[5] = 0xE0 + (info->lun << 4); 1951da177e4SLinus Torvalds command[5] |= (sector >> 24) & 0x0F; 1961da177e4SLinus Torvalds command[6] = 0x20; 1971da177e4SLinus Torvalds command[7] = 0x01; 1981da177e4SLinus Torvalds 1991da177e4SLinus Torvalds // send the read command 2001da177e4SLinus Torvalds result = datafab_bulk_write(us, command, 8); 2011da177e4SLinus Torvalds if (result != USB_STOR_XFER_GOOD) 2021da177e4SLinus Torvalds goto leave; 2031da177e4SLinus Torvalds 2041da177e4SLinus Torvalds // read the result 2051da177e4SLinus Torvalds result = datafab_bulk_read(us, buffer, len); 2061da177e4SLinus Torvalds if (result != USB_STOR_XFER_GOOD) 2071da177e4SLinus Torvalds goto leave; 2081da177e4SLinus Torvalds 2091da177e4SLinus Torvalds // Store the data in the transfer buffer 2101da177e4SLinus Torvalds usb_stor_access_xfer_buf(buffer, len, us->srb, 2111f6f31a0SJens Axboe &sg, &sg_offset, TO_XFER_BUF); 2121da177e4SLinus Torvalds 2131da177e4SLinus Torvalds sector += thistime; 2141da177e4SLinus Torvalds totallen -= len; 2151da177e4SLinus Torvalds } while (totallen > 0); 2161da177e4SLinus Torvalds 2171da177e4SLinus Torvalds kfree(buffer); 2181da177e4SLinus Torvalds return USB_STOR_TRANSPORT_GOOD; 2191da177e4SLinus Torvalds 2201da177e4SLinus Torvalds leave: 2211da177e4SLinus Torvalds kfree(buffer); 2221da177e4SLinus Torvalds return USB_STOR_TRANSPORT_ERROR; 2231da177e4SLinus Torvalds } 2241da177e4SLinus Torvalds 2251da177e4SLinus Torvalds 2261da177e4SLinus Torvalds static int datafab_write_data(struct us_data *us, 2271da177e4SLinus Torvalds struct datafab_info *info, 2281da177e4SLinus Torvalds u32 sector, 2291da177e4SLinus Torvalds u32 sectors) 2301da177e4SLinus Torvalds { 2311da177e4SLinus Torvalds unsigned char *command = us->iobuf; 2321da177e4SLinus Torvalds unsigned char *reply = us->iobuf; 2331da177e4SLinus Torvalds unsigned char *buffer; 2341da177e4SLinus Torvalds unsigned char thistime; 2351da177e4SLinus Torvalds unsigned int totallen, alloclen; 2361da177e4SLinus Torvalds int len, result; 2371f6f31a0SJens Axboe unsigned int sg_offset = 0; 2381f6f31a0SJens Axboe struct scatterlist *sg = NULL; 2391da177e4SLinus Torvalds 2401da177e4SLinus Torvalds // we're working in LBA mode. according to the ATA spec, 2411da177e4SLinus Torvalds // we can support up to 28-bit addressing. I don't know if Datafab 2421da177e4SLinus Torvalds // supports beyond 24-bit addressing. It's kind of hard to test 2431da177e4SLinus Torvalds // since it requires > 8GB CF card. 2441da177e4SLinus Torvalds // 2451da177e4SLinus Torvalds if (sectors > 0x0FFFFFFF) 2461da177e4SLinus Torvalds return USB_STOR_TRANSPORT_ERROR; 2471da177e4SLinus Torvalds 2481da177e4SLinus Torvalds if (info->lun == -1) { 2491da177e4SLinus Torvalds result = datafab_determine_lun(us, info); 2501da177e4SLinus Torvalds if (result != USB_STOR_TRANSPORT_GOOD) 2511da177e4SLinus Torvalds return result; 2521da177e4SLinus Torvalds } 2531da177e4SLinus Torvalds 2541da177e4SLinus Torvalds totallen = sectors * info->ssize; 2551da177e4SLinus Torvalds 2561da177e4SLinus Torvalds // Since we don't write more than 64 KB at a time, we have to create 2571da177e4SLinus Torvalds // a bounce buffer and move the data a piece at a time between the 2581da177e4SLinus Torvalds // bounce buffer and the actual transfer buffer. 2591da177e4SLinus Torvalds 2601da177e4SLinus Torvalds alloclen = min(totallen, 65536u); 2611da177e4SLinus Torvalds buffer = kmalloc(alloclen, GFP_NOIO); 2621da177e4SLinus Torvalds if (buffer == NULL) 2631da177e4SLinus Torvalds return USB_STOR_TRANSPORT_ERROR; 2641da177e4SLinus Torvalds 2651da177e4SLinus Torvalds do { 2661da177e4SLinus Torvalds // loop, never allocate or transfer more than 64k at once 2671da177e4SLinus Torvalds // (min(128k, 255*info->ssize) is the real limit) 2681da177e4SLinus Torvalds 2691da177e4SLinus Torvalds len = min(totallen, alloclen); 2701da177e4SLinus Torvalds thistime = (len / info->ssize) & 0xff; 2711da177e4SLinus Torvalds 2721da177e4SLinus Torvalds // Get the data from the transfer buffer 2731da177e4SLinus Torvalds usb_stor_access_xfer_buf(buffer, len, us->srb, 2741f6f31a0SJens Axboe &sg, &sg_offset, FROM_XFER_BUF); 2751da177e4SLinus Torvalds 2761da177e4SLinus Torvalds command[0] = 0; 2771da177e4SLinus Torvalds command[1] = thistime; 2781da177e4SLinus Torvalds command[2] = sector & 0xFF; 2791da177e4SLinus Torvalds command[3] = (sector >> 8) & 0xFF; 2801da177e4SLinus Torvalds command[4] = (sector >> 16) & 0xFF; 2811da177e4SLinus Torvalds 2821da177e4SLinus Torvalds command[5] = 0xE0 + (info->lun << 4); 2831da177e4SLinus Torvalds command[5] |= (sector >> 24) & 0x0F; 2841da177e4SLinus Torvalds command[6] = 0x30; 2851da177e4SLinus Torvalds command[7] = 0x02; 2861da177e4SLinus Torvalds 2871da177e4SLinus Torvalds // send the command 2881da177e4SLinus Torvalds result = datafab_bulk_write(us, command, 8); 2891da177e4SLinus Torvalds if (result != USB_STOR_XFER_GOOD) 2901da177e4SLinus Torvalds goto leave; 2911da177e4SLinus Torvalds 2921da177e4SLinus Torvalds // send the data 2931da177e4SLinus Torvalds result = datafab_bulk_write(us, buffer, len); 2941da177e4SLinus Torvalds if (result != USB_STOR_XFER_GOOD) 2951da177e4SLinus Torvalds goto leave; 2961da177e4SLinus Torvalds 2971da177e4SLinus Torvalds // read the result 2981da177e4SLinus Torvalds result = datafab_bulk_read(us, reply, 2); 2991da177e4SLinus Torvalds if (result != USB_STOR_XFER_GOOD) 3001da177e4SLinus Torvalds goto leave; 3011da177e4SLinus Torvalds 3021da177e4SLinus Torvalds if (reply[0] != 0x50 && reply[1] != 0) { 3031da177e4SLinus Torvalds US_DEBUGP("datafab_write_data: Gah! " 3041da177e4SLinus Torvalds "write return code: %02x %02x\n", 3051da177e4SLinus Torvalds reply[0], reply[1]); 3061da177e4SLinus Torvalds result = USB_STOR_TRANSPORT_ERROR; 3071da177e4SLinus Torvalds goto leave; 3081da177e4SLinus Torvalds } 3091da177e4SLinus Torvalds 3101da177e4SLinus Torvalds sector += thistime; 3111da177e4SLinus Torvalds totallen -= len; 3121da177e4SLinus Torvalds } while (totallen > 0); 3131da177e4SLinus Torvalds 3141da177e4SLinus Torvalds kfree(buffer); 3151da177e4SLinus Torvalds return USB_STOR_TRANSPORT_GOOD; 3161da177e4SLinus Torvalds 3171da177e4SLinus Torvalds leave: 3181da177e4SLinus Torvalds kfree(buffer); 3191da177e4SLinus Torvalds return USB_STOR_TRANSPORT_ERROR; 3201da177e4SLinus Torvalds } 3211da177e4SLinus Torvalds 3221da177e4SLinus Torvalds 3231da177e4SLinus Torvalds static int datafab_determine_lun(struct us_data *us, 3241da177e4SLinus Torvalds struct datafab_info *info) 3251da177e4SLinus Torvalds { 3261da177e4SLinus Torvalds // Dual-slot readers can be thought of as dual-LUN devices. 3271da177e4SLinus Torvalds // We need to determine which card slot is being used. 3281da177e4SLinus Torvalds // We'll send an IDENTIFY DEVICE command and see which LUN responds... 3291da177e4SLinus Torvalds // 3301da177e4SLinus Torvalds // There might be a better way of doing this? 3311da177e4SLinus Torvalds 3321da177e4SLinus Torvalds static unsigned char scommand[8] = { 0, 1, 0, 0, 0, 0xa0, 0xec, 1 }; 3331da177e4SLinus Torvalds unsigned char *command = us->iobuf; 3341da177e4SLinus Torvalds unsigned char *buf; 3351da177e4SLinus Torvalds int count = 0, rc; 3361da177e4SLinus Torvalds 33764aebe73SJulia Lawall if (!info) 3381da177e4SLinus Torvalds return USB_STOR_TRANSPORT_ERROR; 3391da177e4SLinus Torvalds 3401da177e4SLinus Torvalds memcpy(command, scommand, 8); 3411da177e4SLinus Torvalds buf = kmalloc(512, GFP_NOIO); 3421da177e4SLinus Torvalds if (!buf) 3431da177e4SLinus Torvalds return USB_STOR_TRANSPORT_ERROR; 3441da177e4SLinus Torvalds 3451da177e4SLinus Torvalds US_DEBUGP("datafab_determine_lun: locating...\n"); 3461da177e4SLinus Torvalds 3471da177e4SLinus Torvalds // we'll try 3 times before giving up... 3481da177e4SLinus Torvalds // 3491da177e4SLinus Torvalds while (count++ < 3) { 3501da177e4SLinus Torvalds command[5] = 0xa0; 3511da177e4SLinus Torvalds 3521da177e4SLinus Torvalds rc = datafab_bulk_write(us, command, 8); 3531da177e4SLinus Torvalds if (rc != USB_STOR_XFER_GOOD) { 3541da177e4SLinus Torvalds rc = USB_STOR_TRANSPORT_ERROR; 3551da177e4SLinus Torvalds goto leave; 3561da177e4SLinus Torvalds } 3571da177e4SLinus Torvalds 3581da177e4SLinus Torvalds rc = datafab_bulk_read(us, buf, 512); 3591da177e4SLinus Torvalds if (rc == USB_STOR_XFER_GOOD) { 3601da177e4SLinus Torvalds info->lun = 0; 3611da177e4SLinus Torvalds rc = USB_STOR_TRANSPORT_GOOD; 3621da177e4SLinus Torvalds goto leave; 3631da177e4SLinus Torvalds } 3641da177e4SLinus Torvalds 3651da177e4SLinus Torvalds command[5] = 0xb0; 3661da177e4SLinus Torvalds 3671da177e4SLinus Torvalds rc = datafab_bulk_write(us, command, 8); 3681da177e4SLinus Torvalds if (rc != USB_STOR_XFER_GOOD) { 3691da177e4SLinus Torvalds rc = USB_STOR_TRANSPORT_ERROR; 3701da177e4SLinus Torvalds goto leave; 3711da177e4SLinus Torvalds } 3721da177e4SLinus Torvalds 3731da177e4SLinus Torvalds rc = datafab_bulk_read(us, buf, 512); 3741da177e4SLinus Torvalds if (rc == USB_STOR_XFER_GOOD) { 3751da177e4SLinus Torvalds info->lun = 1; 3761da177e4SLinus Torvalds rc = USB_STOR_TRANSPORT_GOOD; 3771da177e4SLinus Torvalds goto leave; 3781da177e4SLinus Torvalds } 3791da177e4SLinus Torvalds 3801da177e4SLinus Torvalds msleep(20); 3811da177e4SLinus Torvalds } 3821da177e4SLinus Torvalds 3831da177e4SLinus Torvalds rc = USB_STOR_TRANSPORT_ERROR; 3841da177e4SLinus Torvalds 3851da177e4SLinus Torvalds leave: 3861da177e4SLinus Torvalds kfree(buf); 3871da177e4SLinus Torvalds return rc; 3881da177e4SLinus Torvalds } 3891da177e4SLinus Torvalds 3901da177e4SLinus Torvalds static int datafab_id_device(struct us_data *us, 3911da177e4SLinus Torvalds struct datafab_info *info) 3921da177e4SLinus Torvalds { 3931da177e4SLinus Torvalds // this is a variation of the ATA "IDENTIFY DEVICE" command...according 3941da177e4SLinus Torvalds // to the ATA spec, 'Sector Count' isn't used but the Windows driver 3951da177e4SLinus Torvalds // sets this bit so we do too... 3961da177e4SLinus Torvalds // 3971da177e4SLinus Torvalds static unsigned char scommand[8] = { 0, 1, 0, 0, 0, 0xa0, 0xec, 1 }; 3981da177e4SLinus Torvalds unsigned char *command = us->iobuf; 3991da177e4SLinus Torvalds unsigned char *reply; 4001da177e4SLinus Torvalds int rc; 4011da177e4SLinus Torvalds 40264aebe73SJulia Lawall if (!info) 4031da177e4SLinus Torvalds return USB_STOR_TRANSPORT_ERROR; 4041da177e4SLinus Torvalds 4051da177e4SLinus Torvalds if (info->lun == -1) { 4061da177e4SLinus Torvalds rc = datafab_determine_lun(us, info); 4071da177e4SLinus Torvalds if (rc != USB_STOR_TRANSPORT_GOOD) 4081da177e4SLinus Torvalds return rc; 4091da177e4SLinus Torvalds } 4101da177e4SLinus Torvalds 4111da177e4SLinus Torvalds memcpy(command, scommand, 8); 4121da177e4SLinus Torvalds reply = kmalloc(512, GFP_NOIO); 4131da177e4SLinus Torvalds if (!reply) 4141da177e4SLinus Torvalds return USB_STOR_TRANSPORT_ERROR; 4151da177e4SLinus Torvalds 4161da177e4SLinus Torvalds command[5] += (info->lun << 4); 4171da177e4SLinus Torvalds 4181da177e4SLinus Torvalds rc = datafab_bulk_write(us, command, 8); 4191da177e4SLinus Torvalds if (rc != USB_STOR_XFER_GOOD) { 4201da177e4SLinus Torvalds rc = USB_STOR_TRANSPORT_ERROR; 4211da177e4SLinus Torvalds goto leave; 4221da177e4SLinus Torvalds } 4231da177e4SLinus Torvalds 4241da177e4SLinus Torvalds // we'll go ahead and extract the media capacity while we're here... 4251da177e4SLinus Torvalds // 4261da177e4SLinus Torvalds rc = datafab_bulk_read(us, reply, 512); 4271da177e4SLinus Torvalds if (rc == USB_STOR_XFER_GOOD) { 4281da177e4SLinus Torvalds // capacity is at word offset 57-58 4291da177e4SLinus Torvalds // 4301da177e4SLinus Torvalds info->sectors = ((u32)(reply[117]) << 24) | 4311da177e4SLinus Torvalds ((u32)(reply[116]) << 16) | 4321da177e4SLinus Torvalds ((u32)(reply[115]) << 8) | 4331da177e4SLinus Torvalds ((u32)(reply[114]) ); 4341da177e4SLinus Torvalds rc = USB_STOR_TRANSPORT_GOOD; 4351da177e4SLinus Torvalds goto leave; 4361da177e4SLinus Torvalds } 4371da177e4SLinus Torvalds 4381da177e4SLinus Torvalds rc = USB_STOR_TRANSPORT_ERROR; 4391da177e4SLinus Torvalds 4401da177e4SLinus Torvalds leave: 4411da177e4SLinus Torvalds kfree(reply); 4421da177e4SLinus Torvalds return rc; 4431da177e4SLinus Torvalds } 4441da177e4SLinus Torvalds 4451da177e4SLinus Torvalds 4461da177e4SLinus Torvalds static int datafab_handle_mode_sense(struct us_data *us, 4471da177e4SLinus Torvalds struct scsi_cmnd * srb, 4481da177e4SLinus Torvalds int sense_6) 4491da177e4SLinus Torvalds { 4501da177e4SLinus Torvalds static unsigned char rw_err_page[12] = { 4511da177e4SLinus Torvalds 0x1, 0xA, 0x21, 1, 0, 0, 0, 0, 1, 0, 0, 0 4521da177e4SLinus Torvalds }; 4531da177e4SLinus Torvalds static unsigned char cache_page[12] = { 4541da177e4SLinus Torvalds 0x8, 0xA, 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0 4551da177e4SLinus Torvalds }; 4561da177e4SLinus Torvalds static unsigned char rbac_page[12] = { 4571da177e4SLinus Torvalds 0x1B, 0xA, 0, 0x81, 0, 0, 0, 0, 0, 0, 0, 0 4581da177e4SLinus Torvalds }; 4591da177e4SLinus Torvalds static unsigned char timer_page[8] = { 4601da177e4SLinus Torvalds 0x1C, 0x6, 0, 0, 0, 0 4611da177e4SLinus Torvalds }; 4621da177e4SLinus Torvalds unsigned char pc, page_code; 4631da177e4SLinus Torvalds unsigned int i = 0; 4641da177e4SLinus Torvalds struct datafab_info *info = (struct datafab_info *) (us->extra); 4651da177e4SLinus Torvalds unsigned char *ptr = us->iobuf; 4661da177e4SLinus Torvalds 4671da177e4SLinus Torvalds // most of this stuff is just a hack to get things working. the 4681da177e4SLinus Torvalds // datafab reader doesn't present a SCSI interface so we 4691da177e4SLinus Torvalds // fudge the SCSI commands... 4701da177e4SLinus Torvalds // 4711da177e4SLinus Torvalds 4721da177e4SLinus Torvalds pc = srb->cmnd[2] >> 6; 4731da177e4SLinus Torvalds page_code = srb->cmnd[2] & 0x3F; 4741da177e4SLinus Torvalds 4751da177e4SLinus Torvalds switch (pc) { 4761da177e4SLinus Torvalds case 0x0: 4771da177e4SLinus Torvalds US_DEBUGP("datafab_handle_mode_sense: Current values\n"); 4781da177e4SLinus Torvalds break; 4791da177e4SLinus Torvalds case 0x1: 4801da177e4SLinus Torvalds US_DEBUGP("datafab_handle_mode_sense: Changeable values\n"); 4811da177e4SLinus Torvalds break; 4821da177e4SLinus Torvalds case 0x2: 4831da177e4SLinus Torvalds US_DEBUGP("datafab_handle_mode_sense: Default values\n"); 4841da177e4SLinus Torvalds break; 4851da177e4SLinus Torvalds case 0x3: 4861da177e4SLinus Torvalds US_DEBUGP("datafab_handle_mode_sense: Saves values\n"); 4871da177e4SLinus Torvalds break; 4881da177e4SLinus Torvalds } 4891da177e4SLinus Torvalds 4901da177e4SLinus Torvalds memset(ptr, 0, 8); 4911da177e4SLinus Torvalds if (sense_6) { 4921da177e4SLinus Torvalds ptr[2] = 0x00; // WP enable: 0x80 4931da177e4SLinus Torvalds i = 4; 4941da177e4SLinus Torvalds } else { 4951da177e4SLinus Torvalds ptr[3] = 0x00; // WP enable: 0x80 4961da177e4SLinus Torvalds i = 8; 4971da177e4SLinus Torvalds } 4981da177e4SLinus Torvalds 4991da177e4SLinus Torvalds switch (page_code) { 5001da177e4SLinus Torvalds default: 5011da177e4SLinus Torvalds // vendor-specific mode 5021da177e4SLinus Torvalds info->sense_key = 0x05; 5031da177e4SLinus Torvalds info->sense_asc = 0x24; 5041da177e4SLinus Torvalds info->sense_ascq = 0x00; 5051da177e4SLinus Torvalds return USB_STOR_TRANSPORT_FAILED; 5061da177e4SLinus Torvalds 5071da177e4SLinus Torvalds case 0x1: 5081da177e4SLinus Torvalds memcpy(ptr + i, rw_err_page, sizeof(rw_err_page)); 5091da177e4SLinus Torvalds i += sizeof(rw_err_page); 5101da177e4SLinus Torvalds break; 5111da177e4SLinus Torvalds 5121da177e4SLinus Torvalds case 0x8: 5131da177e4SLinus Torvalds memcpy(ptr + i, cache_page, sizeof(cache_page)); 5141da177e4SLinus Torvalds i += sizeof(cache_page); 5151da177e4SLinus Torvalds break; 5161da177e4SLinus Torvalds 5171da177e4SLinus Torvalds case 0x1B: 5181da177e4SLinus Torvalds memcpy(ptr + i, rbac_page, sizeof(rbac_page)); 5191da177e4SLinus Torvalds i += sizeof(rbac_page); 5201da177e4SLinus Torvalds break; 5211da177e4SLinus Torvalds 5221da177e4SLinus Torvalds case 0x1C: 5231da177e4SLinus Torvalds memcpy(ptr + i, timer_page, sizeof(timer_page)); 5241da177e4SLinus Torvalds i += sizeof(timer_page); 5251da177e4SLinus Torvalds break; 5261da177e4SLinus Torvalds 5271da177e4SLinus Torvalds case 0x3F: // retrieve all pages 5281da177e4SLinus Torvalds memcpy(ptr + i, timer_page, sizeof(timer_page)); 5291da177e4SLinus Torvalds i += sizeof(timer_page); 5301da177e4SLinus Torvalds memcpy(ptr + i, rbac_page, sizeof(rbac_page)); 5311da177e4SLinus Torvalds i += sizeof(rbac_page); 5321da177e4SLinus Torvalds memcpy(ptr + i, cache_page, sizeof(cache_page)); 5331da177e4SLinus Torvalds i += sizeof(cache_page); 5341da177e4SLinus Torvalds memcpy(ptr + i, rw_err_page, sizeof(rw_err_page)); 5351da177e4SLinus Torvalds i += sizeof(rw_err_page); 5361da177e4SLinus Torvalds break; 5371da177e4SLinus Torvalds } 5381da177e4SLinus Torvalds 5391da177e4SLinus Torvalds if (sense_6) 5401da177e4SLinus Torvalds ptr[0] = i - 1; 5411da177e4SLinus Torvalds else 5421da177e4SLinus Torvalds ((__be16 *) ptr)[0] = cpu_to_be16(i - 2); 5431da177e4SLinus Torvalds usb_stor_set_xfer_buf(ptr, i, srb); 5441da177e4SLinus Torvalds 5451da177e4SLinus Torvalds return USB_STOR_TRANSPORT_GOOD; 5461da177e4SLinus Torvalds } 5471da177e4SLinus Torvalds 5481da177e4SLinus Torvalds static void datafab_info_destructor(void *extra) 5491da177e4SLinus Torvalds { 5501da177e4SLinus Torvalds // this routine is a placeholder... 5511da177e4SLinus Torvalds // currently, we don't allocate any extra memory so we're okay 5521da177e4SLinus Torvalds } 5531da177e4SLinus Torvalds 5541da177e4SLinus Torvalds 5551da177e4SLinus Torvalds // Transport for the Datafab MDCFE-B 5561da177e4SLinus Torvalds // 5572cbbf357SAlan Stern static int datafab_transport(struct scsi_cmnd *srb, struct us_data *us) 5581da177e4SLinus Torvalds { 5591da177e4SLinus Torvalds struct datafab_info *info; 5601da177e4SLinus Torvalds int rc; 5611da177e4SLinus Torvalds unsigned long block, blocks; 5621da177e4SLinus Torvalds unsigned char *ptr = us->iobuf; 5631da177e4SLinus Torvalds static unsigned char inquiry_reply[8] = { 5641da177e4SLinus Torvalds 0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00 5651da177e4SLinus Torvalds }; 5661da177e4SLinus Torvalds 5671da177e4SLinus Torvalds if (!us->extra) { 568887c2560SOliver Neukum us->extra = kzalloc(sizeof(struct datafab_info), GFP_NOIO); 5691da177e4SLinus Torvalds if (!us->extra) { 5701da177e4SLinus Torvalds US_DEBUGP("datafab_transport: Gah! " 5711da177e4SLinus Torvalds "Can't allocate storage for Datafab info struct!\n"); 5721da177e4SLinus Torvalds return USB_STOR_TRANSPORT_ERROR; 5731da177e4SLinus Torvalds } 5741da177e4SLinus Torvalds us->extra_destructor = datafab_info_destructor; 5751da177e4SLinus Torvalds ((struct datafab_info *)us->extra)->lun = -1; 5761da177e4SLinus Torvalds } 5771da177e4SLinus Torvalds 5781da177e4SLinus Torvalds info = (struct datafab_info *) (us->extra); 5791da177e4SLinus Torvalds 5801da177e4SLinus Torvalds if (srb->cmnd[0] == INQUIRY) { 5811da177e4SLinus Torvalds US_DEBUGP("datafab_transport: INQUIRY. Returning bogus response"); 5821da177e4SLinus Torvalds memcpy(ptr, inquiry_reply, sizeof(inquiry_reply)); 5831da177e4SLinus Torvalds fill_inquiry_response(us, ptr, 36); 5841da177e4SLinus Torvalds return USB_STOR_TRANSPORT_GOOD; 5851da177e4SLinus Torvalds } 5861da177e4SLinus Torvalds 5871da177e4SLinus Torvalds if (srb->cmnd[0] == READ_CAPACITY) { 5881da177e4SLinus Torvalds info->ssize = 0x200; // hard coded 512 byte sectors as per ATA spec 5891da177e4SLinus Torvalds rc = datafab_id_device(us, info); 5901da177e4SLinus Torvalds if (rc != USB_STOR_TRANSPORT_GOOD) 5911da177e4SLinus Torvalds return rc; 5921da177e4SLinus Torvalds 5931da177e4SLinus Torvalds US_DEBUGP("datafab_transport: READ_CAPACITY: %ld sectors, %ld bytes per sector\n", 5941da177e4SLinus Torvalds info->sectors, info->ssize); 5951da177e4SLinus Torvalds 5961da177e4SLinus Torvalds // build the reply 5971da177e4SLinus Torvalds // we need the last sector, not the number of sectors 5981da177e4SLinus Torvalds ((__be32 *) ptr)[0] = cpu_to_be32(info->sectors - 1); 5991da177e4SLinus Torvalds ((__be32 *) ptr)[1] = cpu_to_be32(info->ssize); 6001da177e4SLinus Torvalds usb_stor_set_xfer_buf(ptr, 8, srb); 6011da177e4SLinus Torvalds 6021da177e4SLinus Torvalds return USB_STOR_TRANSPORT_GOOD; 6031da177e4SLinus Torvalds } 6041da177e4SLinus Torvalds 6051da177e4SLinus Torvalds if (srb->cmnd[0] == MODE_SELECT_10) { 6061da177e4SLinus Torvalds US_DEBUGP("datafab_transport: Gah! MODE_SELECT_10.\n"); 6071da177e4SLinus Torvalds return USB_STOR_TRANSPORT_ERROR; 6081da177e4SLinus Torvalds } 6091da177e4SLinus Torvalds 6101da177e4SLinus Torvalds // don't bother implementing READ_6 or WRITE_6. 6111da177e4SLinus Torvalds // 6121da177e4SLinus Torvalds if (srb->cmnd[0] == READ_10) { 6131da177e4SLinus Torvalds block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) | 6141da177e4SLinus Torvalds ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); 6151da177e4SLinus Torvalds 6161da177e4SLinus Torvalds blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8])); 6171da177e4SLinus Torvalds 6181da177e4SLinus Torvalds US_DEBUGP("datafab_transport: READ_10: read block 0x%04lx count %ld\n", block, blocks); 6191da177e4SLinus Torvalds return datafab_read_data(us, info, block, blocks); 6201da177e4SLinus Torvalds } 6211da177e4SLinus Torvalds 6221da177e4SLinus Torvalds if (srb->cmnd[0] == READ_12) { 6231da177e4SLinus Torvalds // we'll probably never see a READ_12 but we'll do it anyway... 6241da177e4SLinus Torvalds // 6251da177e4SLinus Torvalds block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) | 6261da177e4SLinus Torvalds ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); 6271da177e4SLinus Torvalds 6281da177e4SLinus Torvalds blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) | 6291da177e4SLinus Torvalds ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); 6301da177e4SLinus Torvalds 6311da177e4SLinus Torvalds US_DEBUGP("datafab_transport: READ_12: read block 0x%04lx count %ld\n", block, blocks); 6321da177e4SLinus Torvalds return datafab_read_data(us, info, block, blocks); 6331da177e4SLinus Torvalds } 6341da177e4SLinus Torvalds 6351da177e4SLinus Torvalds if (srb->cmnd[0] == WRITE_10) { 6361da177e4SLinus Torvalds block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) | 6371da177e4SLinus Torvalds ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); 6381da177e4SLinus Torvalds 6391da177e4SLinus Torvalds blocks = ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8])); 6401da177e4SLinus Torvalds 6411da177e4SLinus Torvalds US_DEBUGP("datafab_transport: WRITE_10: write block 0x%04lx count %ld\n", block, blocks); 6421da177e4SLinus Torvalds return datafab_write_data(us, info, block, blocks); 6431da177e4SLinus Torvalds } 6441da177e4SLinus Torvalds 6451da177e4SLinus Torvalds if (srb->cmnd[0] == WRITE_12) { 6461da177e4SLinus Torvalds // we'll probably never see a WRITE_12 but we'll do it anyway... 6471da177e4SLinus Torvalds // 6481da177e4SLinus Torvalds block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) | 6491da177e4SLinus Torvalds ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); 6501da177e4SLinus Torvalds 6511da177e4SLinus Torvalds blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) | 6521da177e4SLinus Torvalds ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); 6531da177e4SLinus Torvalds 6541da177e4SLinus Torvalds US_DEBUGP("datafab_transport: WRITE_12: write block 0x%04lx count %ld\n", block, blocks); 6551da177e4SLinus Torvalds return datafab_write_data(us, info, block, blocks); 6561da177e4SLinus Torvalds } 6571da177e4SLinus Torvalds 6581da177e4SLinus Torvalds if (srb->cmnd[0] == TEST_UNIT_READY) { 6591da177e4SLinus Torvalds US_DEBUGP("datafab_transport: TEST_UNIT_READY.\n"); 6601da177e4SLinus Torvalds return datafab_id_device(us, info); 6611da177e4SLinus Torvalds } 6621da177e4SLinus Torvalds 6631da177e4SLinus Torvalds if (srb->cmnd[0] == REQUEST_SENSE) { 6641da177e4SLinus Torvalds US_DEBUGP("datafab_transport: REQUEST_SENSE. Returning faked response\n"); 6651da177e4SLinus Torvalds 6661da177e4SLinus Torvalds // this response is pretty bogus right now. eventually if necessary 6671da177e4SLinus Torvalds // we can set the correct sense data. so far though it hasn't been 6681da177e4SLinus Torvalds // necessary 6691da177e4SLinus Torvalds // 6701da177e4SLinus Torvalds memset(ptr, 0, 18); 6711da177e4SLinus Torvalds ptr[0] = 0xF0; 6721da177e4SLinus Torvalds ptr[2] = info->sense_key; 6731da177e4SLinus Torvalds ptr[7] = 11; 6741da177e4SLinus Torvalds ptr[12] = info->sense_asc; 6751da177e4SLinus Torvalds ptr[13] = info->sense_ascq; 6761da177e4SLinus Torvalds usb_stor_set_xfer_buf(ptr, 18, srb); 6771da177e4SLinus Torvalds 6781da177e4SLinus Torvalds return USB_STOR_TRANSPORT_GOOD; 6791da177e4SLinus Torvalds } 6801da177e4SLinus Torvalds 6811da177e4SLinus Torvalds if (srb->cmnd[0] == MODE_SENSE) { 6821da177e4SLinus Torvalds US_DEBUGP("datafab_transport: MODE_SENSE_6 detected\n"); 6831da177e4SLinus Torvalds return datafab_handle_mode_sense(us, srb, 1); 6841da177e4SLinus Torvalds } 6851da177e4SLinus Torvalds 6861da177e4SLinus Torvalds if (srb->cmnd[0] == MODE_SENSE_10) { 6871da177e4SLinus Torvalds US_DEBUGP("datafab_transport: MODE_SENSE_10 detected\n"); 6881da177e4SLinus Torvalds return datafab_handle_mode_sense(us, srb, 0); 6891da177e4SLinus Torvalds } 6901da177e4SLinus Torvalds 6911da177e4SLinus Torvalds if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { 6921da177e4SLinus Torvalds // sure. whatever. not like we can stop the user from 6931da177e4SLinus Torvalds // popping the media out of the device (no locking doors, etc) 6941da177e4SLinus Torvalds // 6951da177e4SLinus Torvalds return USB_STOR_TRANSPORT_GOOD; 6961da177e4SLinus Torvalds } 6971da177e4SLinus Torvalds 6981da177e4SLinus Torvalds if (srb->cmnd[0] == START_STOP) { 6991da177e4SLinus Torvalds /* this is used by sd.c'check_scsidisk_media_change to detect 7001da177e4SLinus Torvalds media change */ 7011da177e4SLinus Torvalds US_DEBUGP("datafab_transport: START_STOP.\n"); 7021da177e4SLinus Torvalds /* the first datafab_id_device after a media change returns 7031da177e4SLinus Torvalds an error (determined experimentally) */ 7041da177e4SLinus Torvalds rc = datafab_id_device(us, info); 7051da177e4SLinus Torvalds if (rc == USB_STOR_TRANSPORT_GOOD) { 7061da177e4SLinus Torvalds info->sense_key = NO_SENSE; 7071da177e4SLinus Torvalds srb->result = SUCCESS; 7081da177e4SLinus Torvalds } else { 7091da177e4SLinus Torvalds info->sense_key = UNIT_ATTENTION; 7101da177e4SLinus Torvalds srb->result = SAM_STAT_CHECK_CONDITION; 7111da177e4SLinus Torvalds } 7121da177e4SLinus Torvalds return rc; 7131da177e4SLinus Torvalds } 7141da177e4SLinus Torvalds 7151da177e4SLinus Torvalds US_DEBUGP("datafab_transport: Gah! Unknown command: %d (0x%x)\n", 7161da177e4SLinus Torvalds srb->cmnd[0], srb->cmnd[0]); 7171da177e4SLinus Torvalds info->sense_key = 0x05; 7181da177e4SLinus Torvalds info->sense_asc = 0x20; 7191da177e4SLinus Torvalds info->sense_ascq = 0x00; 7201da177e4SLinus Torvalds return USB_STOR_TRANSPORT_FAILED; 7211da177e4SLinus Torvalds } 7222cbbf357SAlan Stern 7232cbbf357SAlan Stern static int datafab_probe(struct usb_interface *intf, 7242cbbf357SAlan Stern const struct usb_device_id *id) 7252cbbf357SAlan Stern { 7262cbbf357SAlan Stern struct us_data *us; 7272cbbf357SAlan Stern int result; 7282cbbf357SAlan Stern 7292cbbf357SAlan Stern result = usb_stor_probe1(&us, intf, id, 7302cbbf357SAlan Stern (id - datafab_usb_ids) + datafab_unusual_dev_list); 7312cbbf357SAlan Stern if (result) 7322cbbf357SAlan Stern return result; 7332cbbf357SAlan Stern 7342cbbf357SAlan Stern us->transport_name = "Datafab Bulk-Only"; 7352cbbf357SAlan Stern us->transport = datafab_transport; 7362cbbf357SAlan Stern us->transport_reset = usb_stor_Bulk_reset; 7372cbbf357SAlan Stern us->max_lun = 1; 7382cbbf357SAlan Stern 7392cbbf357SAlan Stern result = usb_stor_probe2(us); 7402cbbf357SAlan Stern return result; 7412cbbf357SAlan Stern } 7422cbbf357SAlan Stern 7432cbbf357SAlan Stern static struct usb_driver datafab_driver = { 7442cbbf357SAlan Stern .name = "ums-datafab", 7452cbbf357SAlan Stern .probe = datafab_probe, 7462cbbf357SAlan Stern .disconnect = usb_stor_disconnect, 7472cbbf357SAlan Stern .suspend = usb_stor_suspend, 7482cbbf357SAlan Stern .resume = usb_stor_resume, 7492cbbf357SAlan Stern .reset_resume = usb_stor_reset_resume, 7502cbbf357SAlan Stern .pre_reset = usb_stor_pre_reset, 7512cbbf357SAlan Stern .post_reset = usb_stor_post_reset, 7522cbbf357SAlan Stern .id_table = datafab_usb_ids, 7532cbbf357SAlan Stern .soft_unbind = 1, 754*e73b2db6SHuajun Li .no_dynamic_id = 1, 7552cbbf357SAlan Stern }; 7562cbbf357SAlan Stern 75765db4305SGreg Kroah-Hartman module_usb_driver(datafab_driver); 758