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