Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 1 | #include <linux/sched.h> |
| 2 | #include <linux/errno.h> |
| 3 | #include <linux/freezer.h> |
| 4 | #include <linux/module.h> |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 5 | #include <linux/slab.h> |
| 6 | #include <linux/kthread.h> |
| 7 | #include <linux/mutex.h> |
| 8 | #include <linux/utsname.h> |
| 9 | |
| 10 | #include <scsi/scsi.h> |
| 11 | #include <scsi/scsi_cmnd.h> |
| 12 | #include <scsi/scsi_device.h> |
| 13 | |
| 14 | #include "usb.h" |
| 15 | #include "scsiglue.h" |
Randy Dunlap | d8aba9d | 2011-05-09 10:46:24 -0700 | [diff] [blame] | 16 | #include "smil.h" |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 17 | #include "transport.h" |
| 18 | |
| 19 | /* Some informational data */ |
| 20 | MODULE_AUTHOR("Domao"); |
| 21 | MODULE_DESCRIPTION("ENE USB Mass Storage driver for Linux"); |
| 22 | MODULE_LICENSE("GPL"); |
| 23 | |
Al Cho | a871869 | 2010-09-16 11:51:48 +0800 | [diff] [blame] | 24 | static unsigned int delay_use = 1; |
| 25 | |
Amarjargal Gundjalam | a353959 | 2013-05-17 01:05:04 -0700 | [diff] [blame] | 26 | static struct usb_device_id eucr_usb_ids[] = { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 27 | { USB_DEVICE(0x058f, 0x6366) }, |
| 28 | { USB_DEVICE(0x0cf2, 0x6230) }, |
| 29 | { USB_DEVICE(0x0cf2, 0x6250) }, |
| 30 | { } /* Terminating entry */ |
| 31 | }; |
Amarjargal Gundjalam | 96dfb4b | 2013-05-17 01:04:49 -0700 | [diff] [blame] | 32 | MODULE_DEVICE_TABLE(usb, eucr_usb_ids); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 33 | |
| 34 | |
Randy Dunlap | e23f773 | 2010-09-14 15:41:41 -0700 | [diff] [blame] | 35 | #ifdef CONFIG_PM |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 36 | |
Randy Dunlap | d8aba9d | 2011-05-09 10:46:24 -0700 | [diff] [blame] | 37 | static int eucr_suspend(struct usb_interface *iface, pm_message_t message) |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 38 | { |
| 39 | struct us_data *us = usb_get_intfdata(iface); |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 40 | pr_info("--- eucr_suspend ---\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 41 | /* Wait until no command is running */ |
| 42 | mutex_lock(&us->dev_mutex); |
| 43 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 44 | if (us->suspend_resume_hook) |
| 45 | (us->suspend_resume_hook)(us, US_SUSPEND); |
| 46 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 47 | mutex_unlock(&us->dev_mutex); |
| 48 | return 0; |
| 49 | } |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 50 | |
Randy Dunlap | d8aba9d | 2011-05-09 10:46:24 -0700 | [diff] [blame] | 51 | static int eucr_resume(struct usb_interface *iface) |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 52 | { |
| 53 | BYTE tmp = 0; |
| 54 | |
| 55 | struct us_data *us = usb_get_intfdata(iface); |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 56 | pr_info("--- eucr_resume---\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 57 | mutex_lock(&us->dev_mutex); |
| 58 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 59 | if (us->suspend_resume_hook) |
| 60 | (us->suspend_resume_hook)(us, US_RESUME); |
| 61 | |
| 62 | |
| 63 | mutex_unlock(&us->dev_mutex); |
| 64 | |
Kurt Kanzenbach | 531c336 | 2012-11-30 12:18:17 +0100 | [diff] [blame] | 65 | us->Power_IsResum = true; |
| 66 | |
Johannes Schilling | 8be8804 | 2013-06-06 18:10:45 +0200 | [diff] [blame] | 67 | us->SM_Status = *(struct keucr_sm_status *)&tmp; |
Kurt Kanzenbach | 2c392da | 2012-11-30 12:18:18 +0100 | [diff] [blame] | 68 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 69 | return 0; |
| 70 | } |
Kurt Kanzenbach | 531c336 | 2012-11-30 12:18:17 +0100 | [diff] [blame] | 71 | |
Randy Dunlap | d8aba9d | 2011-05-09 10:46:24 -0700 | [diff] [blame] | 72 | static int eucr_reset_resume(struct usb_interface *iface) |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 73 | { |
| 74 | BYTE tmp = 0; |
| 75 | struct us_data *us = usb_get_intfdata(iface); |
| 76 | |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 77 | pr_info("--- eucr_reset_resume---\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 78 | |
| 79 | /* Report the reset to the SCSI core */ |
| 80 | usb_stor_report_bus_reset(us); |
| 81 | |
Kurt Kanzenbach | 531c336 | 2012-11-30 12:18:17 +0100 | [diff] [blame] | 82 | /* |
| 83 | * FIXME: Notify the subdrivers that they need to reinitialize |
| 84 | * the device |
| 85 | */ |
| 86 | |
Amarjargal Gundjalam | 5a5097a | 2013-05-17 01:06:19 -0700 | [diff] [blame] | 87 | us->Power_IsResum = true; |
Kurt Kanzenbach | 531c336 | 2012-11-30 12:18:17 +0100 | [diff] [blame] | 88 | |
Johannes Schilling | 8be8804 | 2013-06-06 18:10:45 +0200 | [diff] [blame] | 89 | us->SM_Status = *(struct keucr_sm_status *)&tmp; |
Kurt Kanzenbach | 531c336 | 2012-11-30 12:18:17 +0100 | [diff] [blame] | 90 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 91 | return 0; |
| 92 | } |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 93 | |
Randy Dunlap | e23f773 | 2010-09-14 15:41:41 -0700 | [diff] [blame] | 94 | #else |
| 95 | |
| 96 | #define eucr_suspend NULL |
| 97 | #define eucr_resume NULL |
| 98 | #define eucr_reset_resume NULL |
| 99 | |
| 100 | #endif |
| 101 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 102 | static int eucr_pre_reset(struct usb_interface *iface) |
| 103 | { |
| 104 | struct us_data *us = usb_get_intfdata(iface); |
| 105 | |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 106 | pr_info("usb --- eucr_pre_reset\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 107 | |
| 108 | /* Make sure no command runs during the reset */ |
| 109 | mutex_lock(&us->dev_mutex); |
| 110 | return 0; |
| 111 | } |
| 112 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 113 | static int eucr_post_reset(struct usb_interface *iface) |
| 114 | { |
| 115 | struct us_data *us = usb_get_intfdata(iface); |
| 116 | |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 117 | pr_info("usb --- eucr_post_reset\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 118 | |
| 119 | /* Report the reset to the SCSI core */ |
| 120 | usb_stor_report_bus_reset(us); |
| 121 | |
| 122 | mutex_unlock(&us->dev_mutex); |
| 123 | return 0; |
| 124 | } |
| 125 | |
Amarjargal Gundjalam | b9594b8 | 2013-05-17 01:06:49 -0700 | [diff] [blame] | 126 | void fill_inquiry_response(struct us_data *us, unsigned char *data, |
| 127 | unsigned int data_len) |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 128 | { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 129 | pr_info("usb --- fill_inquiry_response\n"); |
Kurt Kanzenbach | 531c336 | 2012-11-30 12:18:17 +0100 | [diff] [blame] | 130 | if (data_len < 36) /* You lose. */ |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 131 | return; |
| 132 | |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 133 | if (data[0]&0x20) { |
Amarjargal Gundjalam | 99b4974 | 2013-05-17 01:04:02 -0700 | [diff] [blame] | 134 | memset(data+8, 0, 28); |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 135 | } else { |
Amarjargal Gundjalam | b9594b8 | 2013-05-17 01:06:49 -0700 | [diff] [blame] | 136 | u16 bcdDevice = |
| 137 | le16_to_cpu(us->pusb_dev->descriptor.bcdDevice); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 138 | memcpy(data+8, us->unusual_dev->vendorName, |
| 139 | strlen(us->unusual_dev->vendorName) > 8 ? 8 : |
| 140 | strlen(us->unusual_dev->vendorName)); |
| 141 | memcpy(data+16, us->unusual_dev->productName, |
| 142 | strlen(us->unusual_dev->productName) > 16 ? 16 : |
| 143 | strlen(us->unusual_dev->productName)); |
| 144 | data[32] = 0x30 + ((bcdDevice>>12) & 0x0F); |
| 145 | data[33] = 0x30 + ((bcdDevice>>8) & 0x0F); |
| 146 | data[34] = 0x30 + ((bcdDevice>>4) & 0x0F); |
| 147 | data[35] = 0x30 + ((bcdDevice) & 0x0F); |
| 148 | } |
| 149 | usb_stor_set_xfer_buf(us, data, data_len, us->srb, TO_XFER_BUF); |
| 150 | } |
| 151 | |
Johannes Schilling | 0ea8a16 | 2013-06-06 18:10:50 +0200 | [diff] [blame] | 152 | static int usb_stor_control_thread(void *__us) |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 153 | { |
| 154 | struct us_data *us = (struct us_data *)__us; |
| 155 | struct Scsi_Host *host = us_to_host(us); |
| 156 | |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 157 | pr_info("usb --- usb_stor_control_thread\n"); |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 158 | for (;;) { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 159 | if (wait_for_completion_interruptible(&us->cmnd_ready)) |
| 160 | break; |
Kurt Kanzenbach | 531c336 | 2012-11-30 12:18:17 +0100 | [diff] [blame] | 161 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 162 | /* lock the device pointers */ |
| 163 | mutex_lock(&(us->dev_mutex)); |
| 164 | |
| 165 | /* if the device has disconnected, we are free to exit */ |
Al Cho | a871869 | 2010-09-16 11:51:48 +0800 | [diff] [blame] | 166 | if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 167 | mutex_unlock(&us->dev_mutex); |
| 168 | break; |
Al Cho | a871869 | 2010-09-16 11:51:48 +0800 | [diff] [blame] | 169 | } |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 170 | |
| 171 | /* lock access to the state */ |
| 172 | scsi_lock(host); |
| 173 | |
| 174 | /* When we are called with no command pending, we're done */ |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 175 | if (us->srb == NULL) { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 176 | scsi_unlock(host); |
| 177 | mutex_unlock(&us->dev_mutex); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 178 | break; |
| 179 | } |
| 180 | |
| 181 | /* has the command timed out *already* ? */ |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 182 | if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 183 | us->srb->result = DID_ABORT << 16; |
| 184 | goto SkipForAbort; |
| 185 | } |
| 186 | |
| 187 | scsi_unlock(host); |
| 188 | |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 189 | if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 190 | us->srb->result = DID_ERROR << 16; |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 191 | } else if (us->srb->device->id |
| 192 | && !(us->fflags & US_FL_SCM_MULT_TARG)) { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 193 | us->srb->result = DID_BAD_TARGET << 16; |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 194 | } else if (us->srb->device->lun > us->max_lun) { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 195 | us->srb->result = DID_BAD_TARGET << 16; |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 196 | } else if ((us->srb->cmnd[0] == INQUIRY) |
| 197 | && (us->fflags & US_FL_FIX_INQUIRY)) { |
Amarjargal Gundjalam | b9594b8 | 2013-05-17 01:06:49 -0700 | [diff] [blame] | 198 | unsigned char data_ptr[36] = {0x00, 0x80, 0x02, 0x02, |
| 199 | 0x1F, 0x00, 0x00, 0x00}; |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 200 | |
| 201 | fill_inquiry_response(us, data_ptr, 36); |
| 202 | us->srb->result = SAM_STAT_GOOD; |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 203 | } else { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 204 | us->proto_handler(us->srb, us); |
| 205 | } |
| 206 | |
| 207 | /* lock access to the state */ |
| 208 | scsi_lock(host); |
| 209 | |
| 210 | /* indicate that the command is done */ |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 211 | if (us->srb->result != DID_ABORT << 16) { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 212 | us->srb->scsi_done(us->srb); |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 213 | } else { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 214 | SkipForAbort: |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 215 | pr_info("scsi command aborted\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 218 | if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 219 | complete(&(us->notify)); |
| 220 | |
| 221 | /* Allow USB transfers to resume */ |
| 222 | clear_bit(US_FLIDX_ABORTING, &us->dflags); |
| 223 | clear_bit(US_FLIDX_TIMED_OUT, &us->dflags); |
| 224 | } |
| 225 | |
| 226 | /* finished working on this command */ |
| 227 | us->srb = NULL; |
| 228 | scsi_unlock(host); |
| 229 | |
| 230 | /* unlock the device pointers */ |
| 231 | mutex_unlock(&us->dev_mutex); |
| 232 | } /* for (;;) */ |
| 233 | |
| 234 | /* Wait until we are told to stop */ |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 235 | for (;;) { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 236 | set_current_state(TASK_INTERRUPTIBLE); |
| 237 | if (kthread_should_stop()) |
| 238 | break; |
| 239 | schedule(); |
| 240 | } |
| 241 | __set_current_state(TASK_RUNNING); |
| 242 | return 0; |
Kurt Kanzenbach | 2c392da | 2012-11-30 12:18:18 +0100 | [diff] [blame] | 243 | } |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 244 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 245 | static int associate_dev(struct us_data *us, struct usb_interface *intf) |
| 246 | { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 247 | pr_info("usb --- associate_dev\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 248 | |
| 249 | /* Fill in the device-related fields */ |
| 250 | us->pusb_dev = interface_to_usbdev(intf); |
| 251 | us->pusb_intf = intf; |
| 252 | us->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; |
| 253 | |
| 254 | /* Store our private data in the interface */ |
| 255 | usb_set_intfdata(intf, us); |
| 256 | |
| 257 | /* Allocate the device-related DMA-mapped buffers */ |
Amarjargal Gundjalam | b9594b8 | 2013-05-17 01:06:49 -0700 | [diff] [blame] | 258 | us->cr = usb_alloc_coherent(us->pusb_dev, sizeof(*us->cr), GFP_KERNEL, |
| 259 | &us->cr_dma); |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 260 | if (!us->cr) { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 261 | pr_info("usb_ctrlrequest allocation failed\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 262 | return -ENOMEM; |
| 263 | } |
| 264 | |
Amarjargal Gundjalam | b9594b8 | 2013-05-17 01:06:49 -0700 | [diff] [blame] | 265 | us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE, GFP_KERNEL, |
| 266 | &us->iobuf_dma); |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 267 | if (!us->iobuf) { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 268 | pr_info("I/O buffer allocation failed\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 269 | return -ENOMEM; |
| 270 | } |
| 271 | |
| 272 | us->sensebuf = kmalloc(US_SENSE_SIZE, GFP_KERNEL); |
Joe Perches | 78110bb | 2013-02-11 09:41:29 -0800 | [diff] [blame] | 273 | if (!us->sensebuf) |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 274 | return -ENOMEM; |
Joe Perches | 78110bb | 2013-02-11 09:41:29 -0800 | [diff] [blame] | 275 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 276 | return 0; |
| 277 | } |
| 278 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 279 | static int get_device_info(struct us_data *us, const struct usb_device_id *id) |
| 280 | { |
| 281 | struct usb_device *dev = us->pusb_dev; |
Amarjargal Gundjalam | b9594b8 | 2013-05-17 01:06:49 -0700 | [diff] [blame] | 282 | struct usb_interface_descriptor *idesc = |
| 283 | &us->pusb_intf->cur_altsetting->desc; |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 284 | |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 285 | pr_info("usb --- get_device_info\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 286 | |
| 287 | us->subclass = idesc->bInterfaceSubClass; |
| 288 | us->protocol = idesc->bInterfaceProtocol; |
Sebastian Andrzej Siewior | f61870e | 2012-08-28 22:37:13 +0200 | [diff] [blame] | 289 | us->fflags = id->driver_info; |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 290 | us->Power_IsResum = false; |
| 291 | |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 292 | if (us->fflags & US_FL_IGNORE_DEVICE) { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 293 | pr_info("device ignored\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 294 | return -ENODEV; |
| 295 | } |
| 296 | |
| 297 | if (dev->speed != USB_SPEED_HIGH) |
| 298 | us->fflags &= ~US_FL_GO_SLOW; |
| 299 | |
| 300 | return 0; |
| 301 | } |
| 302 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 303 | static int get_transport(struct us_data *us) |
| 304 | { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 305 | pr_info("usb --- get_transport\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 306 | switch (us->protocol) { |
Greg Kroah-Hartman | bceaddd | 2010-10-28 09:53:38 -0700 | [diff] [blame] | 307 | case USB_PR_BULK: |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 308 | us->transport_name = "Bulk"; |
| 309 | us->transport = usb_stor_Bulk_transport; |
| 310 | us->transport_reset = usb_stor_Bulk_reset; |
| 311 | break; |
| 312 | |
| 313 | default: |
| 314 | return -EIO; |
| 315 | } |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 316 | |
| 317 | /* fix for single-lun devices */ |
| 318 | if (us->fflags & US_FL_SINGLE_LUN) |
| 319 | us->max_lun = 0; |
| 320 | return 0; |
| 321 | } |
| 322 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 323 | static int get_protocol(struct us_data *us) |
| 324 | { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 325 | pr_info("usb --- get_protocol\n"); |
| 326 | pr_info("us->pusb_dev->descriptor.idVendor = %x\n", |
| 327 | us->pusb_dev->descriptor.idVendor); |
| 328 | pr_info("us->pusb_dev->descriptor.idProduct = %x\n", |
| 329 | us->pusb_dev->descriptor.idProduct); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 330 | switch (us->subclass) { |
Greg Kroah-Hartman | bceaddd | 2010-10-28 09:53:38 -0700 | [diff] [blame] | 331 | case USB_SC_SCSI: |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 332 | us->protocol_name = "Transparent SCSI"; |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 333 | if ((us->pusb_dev->descriptor.idVendor == 0x0CF2) |
| 334 | && (us->pusb_dev->descriptor.idProduct == 0x6250)) |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 335 | us->proto_handler = ENE_stor_invoke_transport; |
| 336 | else |
| 337 | us->proto_handler = usb_stor_invoke_transport; |
| 338 | break; |
| 339 | |
| 340 | default: |
| 341 | return -EIO; |
| 342 | } |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 343 | return 0; |
| 344 | } |
| 345 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 346 | static int get_pipes(struct us_data *us) |
| 347 | { |
| 348 | struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting; |
| 349 | int i; |
| 350 | struct usb_endpoint_descriptor *ep; |
| 351 | struct usb_endpoint_descriptor *ep_in = NULL; |
| 352 | struct usb_endpoint_descriptor *ep_out = NULL; |
| 353 | struct usb_endpoint_descriptor *ep_int = NULL; |
| 354 | |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 355 | pr_info("usb --- get_pipes\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 356 | |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 357 | for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 358 | ep = &altsetting->endpoint[i].desc; |
| 359 | |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 360 | if (usb_endpoint_xfer_bulk(ep)) { |
| 361 | if (usb_endpoint_dir_in(ep)) { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 362 | if (!ep_in) |
| 363 | ep_in = ep; |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 364 | } else { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 365 | if (!ep_out) |
| 366 | ep_out = ep; |
| 367 | } |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 368 | } else if (usb_endpoint_is_int_in(ep)) { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 369 | if (!ep_int) |
| 370 | ep_int = ep; |
| 371 | } |
| 372 | } |
| 373 | |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 374 | if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int)) { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 375 | pr_info("Endpoint sanity check failed! Rejecting dev.\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 376 | return -EIO; |
| 377 | } |
| 378 | |
| 379 | /* Calculate and store the pipe values */ |
| 380 | us->send_ctrl_pipe = usb_sndctrlpipe(us->pusb_dev, 0); |
| 381 | us->recv_ctrl_pipe = usb_rcvctrlpipe(us->pusb_dev, 0); |
Amarjargal Gundjalam | b9594b8 | 2013-05-17 01:06:49 -0700 | [diff] [blame] | 382 | us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev, |
| 383 | ep_out->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); |
| 384 | us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev, |
| 385 | ep_in->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 386 | if (ep_int) { |
Amarjargal Gundjalam | b9594b8 | 2013-05-17 01:06:49 -0700 | [diff] [blame] | 387 | us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev, |
| 388 | ep_int->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 389 | us->ep_bInterval = ep_int->bInterval; |
| 390 | } |
| 391 | return 0; |
| 392 | } |
| 393 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 394 | static int usb_stor_acquire_resources(struct us_data *us) |
| 395 | { |
| 396 | struct task_struct *th; |
| 397 | |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 398 | pr_info("usb --- usb_stor_acquire_resources\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 399 | us->current_urb = usb_alloc_urb(0, GFP_KERNEL); |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 400 | if (!us->current_urb) { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 401 | pr_info("URB allocation failed\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 402 | return -ENOMEM; |
| 403 | } |
| 404 | |
| 405 | /* Start up our control thread */ |
| 406 | th = kthread_run(usb_stor_control_thread, us, "eucr-storage"); |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 407 | if (IS_ERR(th)) { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 408 | pr_info("Unable to start control thread\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 409 | return PTR_ERR(th); |
| 410 | } |
| 411 | us->ctl_thread = th; |
| 412 | |
| 413 | return 0; |
| 414 | } |
| 415 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 416 | static void usb_stor_release_resources(struct us_data *us) |
| 417 | { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 418 | pr_info("usb --- usb_stor_release_resources\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 419 | |
| 420 | SM_FreeMem(); |
| 421 | |
| 422 | complete(&us->cmnd_ready); |
| 423 | if (us->ctl_thread) |
| 424 | kthread_stop(us->ctl_thread); |
| 425 | |
| 426 | /* Call the destructor routine, if it exists */ |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 427 | if (us->extra_destructor) { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 428 | pr_info("-- calling extra_destructor()\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 429 | us->extra_destructor(us->extra); |
| 430 | } |
| 431 | |
| 432 | /* Free the extra data and the URB */ |
| 433 | kfree(us->extra); |
| 434 | usb_free_urb(us->current_urb); |
| 435 | } |
| 436 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 437 | static void dissociate_dev(struct us_data *us) |
| 438 | { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 439 | pr_info("usb --- dissociate_dev\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 440 | |
| 441 | kfree(us->sensebuf); |
| 442 | |
| 443 | /* Free the device-related DMA-mapped buffers */ |
Wei Yongjun | aba12e3 | 2013-05-23 17:28:34 +0800 | [diff] [blame] | 444 | usb_free_coherent(us->pusb_dev, sizeof(*us->cr), us->cr, us->cr_dma); |
| 445 | usb_free_coherent(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, |
| 446 | us->iobuf_dma); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 447 | |
| 448 | /* Remove our private data from the interface */ |
| 449 | usb_set_intfdata(us->pusb_intf, NULL); |
| 450 | } |
| 451 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 452 | static void quiesce_and_remove_host(struct us_data *us) |
| 453 | { |
| 454 | struct Scsi_Host *host = us_to_host(us); |
| 455 | |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 456 | pr_info("usb --- quiesce_and_remove_host\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 457 | |
| 458 | /* If the device is really gone, cut short reset delays */ |
| 459 | if (us->pusb_dev->state == USB_STATE_NOTATTACHED) |
| 460 | set_bit(US_FLIDX_DISCONNECTING, &us->dflags); |
| 461 | |
Kurt Kanzenbach | 531c336 | 2012-11-30 12:18:17 +0100 | [diff] [blame] | 462 | /* |
| 463 | * Prevent SCSI-scanning (if it hasn't started yet) |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 464 | * and wait for the SCSI-scanning thread to stop. |
| 465 | */ |
| 466 | set_bit(US_FLIDX_DONT_SCAN, &us->dflags); |
| 467 | wake_up(&us->delay_wait); |
| 468 | wait_for_completion(&us->scanning_done); |
| 469 | |
Kurt Kanzenbach | 531c336 | 2012-11-30 12:18:17 +0100 | [diff] [blame] | 470 | /* |
| 471 | * Removing the host will perform an orderly shutdown: caches |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 472 | * synchronized, disks spun down, etc. |
| 473 | */ |
| 474 | scsi_remove_host(host); |
| 475 | |
Kurt Kanzenbach | 531c336 | 2012-11-30 12:18:17 +0100 | [diff] [blame] | 476 | /* |
| 477 | * Prevent any new commands from being accepted and cut short |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 478 | * reset delays. |
| 479 | */ |
| 480 | scsi_lock(host); |
| 481 | set_bit(US_FLIDX_DISCONNECTING, &us->dflags); |
| 482 | scsi_unlock(host); |
| 483 | wake_up(&us->delay_wait); |
| 484 | } |
| 485 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 486 | static void release_everything(struct us_data *us) |
| 487 | { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 488 | pr_info("usb --- release_everything\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 489 | |
| 490 | usb_stor_release_resources(us); |
| 491 | dissociate_dev(us); |
| 492 | scsi_host_put(us_to_host(us)); |
| 493 | } |
| 494 | |
Johannes Schilling | 0ea8a16 | 2013-06-06 18:10:50 +0200 | [diff] [blame] | 495 | static int usb_stor_scan_thread(void *__us) |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 496 | { |
| 497 | struct us_data *us = (struct us_data *)__us; |
| 498 | |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 499 | pr_info("usb --- usb_stor_scan_thread\n"); |
| 500 | pr_info("EUCR : device found at %d\n", us->pusb_dev->devnum); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 501 | |
Al Cho | a871869 | 2010-09-16 11:51:48 +0800 | [diff] [blame] | 502 | set_freezable(); |
| 503 | /* Wait for the timeout to expire or for a disconnect */ |
| 504 | if (delay_use > 0) { |
| 505 | wait_event_freezable_timeout(us->delay_wait, |
| 506 | test_bit(US_FLIDX_DONT_SCAN, &us->dflags), |
| 507 | delay_use * HZ); |
| 508 | } |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 509 | |
| 510 | /* If the device is still connected, perform the scanning */ |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 511 | if (!test_bit(US_FLIDX_DONT_SCAN, &us->dflags)) { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 512 | /* For bulk-only devices, determine the max LUN value */ |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 513 | if (us->protocol == USB_PR_BULK |
| 514 | && !(us->fflags & US_FL_SINGLE_LUN)) { |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 515 | mutex_lock(&us->dev_mutex); |
| 516 | us->max_lun = usb_stor_Bulk_max_lun(us); |
| 517 | mutex_unlock(&us->dev_mutex); |
| 518 | } |
| 519 | scsi_scan_host(us_to_host(us)); |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 520 | pr_info("EUCR : device scan complete\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 521 | } |
| 522 | complete_and_exit(&us->scanning_done, 0); |
| 523 | } |
| 524 | |
Amarjargal Gundjalam | b9594b8 | 2013-05-17 01:06:49 -0700 | [diff] [blame] | 525 | static int eucr_probe(struct usb_interface *intf, |
| 526 | const struct usb_device_id *id) |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 527 | { |
| 528 | struct Scsi_Host *host; |
| 529 | struct us_data *us; |
| 530 | int result; |
huajun li | 41e568d | 2011-03-04 10:56:18 +0800 | [diff] [blame] | 531 | BYTE MiscReg03 = 0; |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 532 | struct task_struct *th; |
| 533 | |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 534 | pr_info("usb --- eucr_probe\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 535 | |
Amarjargal Gundjalam | 5a5097a | 2013-05-17 01:06:19 -0700 | [diff] [blame] | 536 | host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us)); |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 537 | if (!host) { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 538 | pr_info("Unable to allocate the scsi host\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 539 | return -ENOMEM; |
| 540 | } |
| 541 | |
| 542 | /* Allow 16-byte CDBs and thus > 2TB */ |
| 543 | host->max_cmd_len = 16; |
| 544 | us = host_to_us(host); |
| 545 | memset(us, 0, sizeof(struct us_data)); |
| 546 | mutex_init(&(us->dev_mutex)); |
| 547 | init_completion(&us->cmnd_ready); |
| 548 | init_completion(&(us->notify)); |
| 549 | init_waitqueue_head(&us->delay_wait); |
| 550 | init_completion(&us->scanning_done); |
| 551 | |
| 552 | /* Associate the us_data structure with the USB device */ |
| 553 | result = associate_dev(us, intf); |
| 554 | if (result) |
| 555 | goto BadDevice; |
| 556 | |
| 557 | /* Get Device info */ |
| 558 | result = get_device_info(us, id); |
| 559 | if (result) |
| 560 | goto BadDevice; |
| 561 | |
| 562 | /* Get the transport, protocol, and pipe settings */ |
| 563 | result = get_transport(us); |
| 564 | if (result) |
| 565 | goto BadDevice; |
| 566 | result = get_protocol(us); |
| 567 | if (result) |
| 568 | goto BadDevice; |
| 569 | result = get_pipes(us); |
| 570 | if (result) |
| 571 | goto BadDevice; |
| 572 | |
| 573 | /* Acquire all the other resources and add the host */ |
| 574 | result = usb_stor_acquire_resources(us); |
| 575 | if (result) |
| 576 | goto BadDevice; |
| 577 | |
| 578 | result = scsi_add_host(host, &intf->dev); |
Kurt Kanzenbach | b466eb5 | 2012-11-30 12:18:19 +0100 | [diff] [blame] | 579 | if (result) { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 580 | pr_info("Unable to add the scsi host\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 581 | goto BadDevice; |
| 582 | } |
| 583 | |
| 584 | /* Start up the thread for delayed SCSI-device scanning */ |
| 585 | th = kthread_create(usb_stor_scan_thread, us, "eucr-stor-scan"); |
Zac Storer | 7d51b77 | 2011-06-19 03:23:20 -0600 | [diff] [blame] | 586 | if (IS_ERR(th)) { |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 587 | pr_info("Unable to start the device-scanning thread\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 588 | complete(&us->scanning_done); |
| 589 | quiesce_and_remove_host(us); |
| 590 | result = PTR_ERR(th); |
| 591 | goto BadDevice; |
| 592 | } |
| 593 | wake_up_process(th); |
huajun li | 41e568d | 2011-03-04 10:56:18 +0800 | [diff] [blame] | 594 | |
| 595 | /* probe card type */ |
Katrina Prosise | 9799d12 | 2013-05-12 17:17:41 -0700 | [diff] [blame] | 596 | result = ene_read_byte(us, REG_CARD_STATUS, &MiscReg03); |
huajun li | 41e568d | 2011-03-04 10:56:18 +0800 | [diff] [blame] | 597 | if (result != USB_STOR_XFER_GOOD) { |
| 598 | result = USB_STOR_TRANSPORT_ERROR; |
| 599 | quiesce_and_remove_host(us); |
| 600 | goto BadDevice; |
| 601 | } |
| 602 | |
| 603 | if (!(MiscReg03 & 0x02)) { |
| 604 | result = -ENODEV; |
| 605 | quiesce_and_remove_host(us); |
Ebru Akagunduz | 4910071 | 2013-10-05 17:11:39 +0300 | [diff] [blame] | 606 | pr_info("keucr: The driver only supports SM/MS card. To use SD card, please build driver/usb/storage/ums-eneub6250.ko\n"); |
huajun li | 41e568d | 2011-03-04 10:56:18 +0800 | [diff] [blame] | 607 | goto BadDevice; |
| 608 | } |
| 609 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 610 | return 0; |
| 611 | |
| 612 | /* We come here if there are any problems */ |
| 613 | BadDevice: |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 614 | pr_info("usb --- eucr_probe failed\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 615 | release_everything(us); |
| 616 | return result; |
| 617 | } |
| 618 | |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 619 | static void eucr_disconnect(struct usb_interface *intf) |
| 620 | { |
| 621 | struct us_data *us = usb_get_intfdata(intf); |
| 622 | |
Cho, Yu-Chen | 871f847 | 2011-04-01 14:38:43 +0800 | [diff] [blame] | 623 | pr_info("usb --- eucr_disconnect\n"); |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 624 | quiesce_and_remove_host(us); |
| 625 | release_everything(us); |
| 626 | } |
| 627 | |
Kurt Kanzenbach | 531c336 | 2012-11-30 12:18:17 +0100 | [diff] [blame] | 628 | /* Initialization and registration */ |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 629 | static struct usb_driver usb_storage_driver = { |
| 630 | .name = "eucr", |
| 631 | .probe = eucr_probe, |
Amarjargal Gundjalam | 5a5097a | 2013-05-17 01:06:19 -0700 | [diff] [blame] | 632 | .suspend = eucr_suspend, |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 633 | .resume = eucr_resume, |
Amarjargal Gundjalam | 5a5097a | 2013-05-17 01:06:19 -0700 | [diff] [blame] | 634 | .reset_resume = eucr_reset_resume, |
Al Cho | 126bb03 | 2010-09-08 00:42:32 -0700 | [diff] [blame] | 635 | .disconnect = eucr_disconnect, |
| 636 | .pre_reset = eucr_pre_reset, |
| 637 | .post_reset = eucr_post_reset, |
| 638 | .id_table = eucr_usb_ids, |
| 639 | .soft_unbind = 1, |
| 640 | }; |
| 641 | |
Greg Kroah-Hartman | bac2c12 | 2011-11-18 09:42:11 -0800 | [diff] [blame] | 642 | module_usb_driver(usb_storage_driver); |