greybus: es1,es2: add USB vendor command to timestamp
[cascardo/linux.git] / drivers / staging / greybus / es1.c
1 /*
2  * Greybus "AP" USB driver for "ES1" controller chips
3  *
4  * Copyright 2014-2015 Google Inc.
5  * Copyright 2014-2015 Linaro Ltd.
6  *
7  * Released under the GPLv2 only.
8  */
9 #include <linux/kthread.h>
10 #include <linux/sizes.h>
11 #include <linux/usb.h>
12 #include <linux/kfifo.h>
13 #include <linux/debugfs.h>
14 #include <asm/unaligned.h>
15
16 #include "greybus.h"
17 #include "kernel_ver.h"
18 #include "connection.h"
19 #include "greybus_trace.h"
20
21 /* Memory sizes for the buffers sent to/from the ES1 controller */
22 #define ES1_GBUF_MSG_SIZE_MAX   2048
23
24 static const struct usb_device_id id_table[] = {
25         /* Made up numbers for the SVC USB Bridge in ES1 */
26         { USB_DEVICE(0xffff, 0x0001) },
27         { },
28 };
29 MODULE_DEVICE_TABLE(usb, id_table);
30
31 #define APB1_LOG_SIZE           SZ_16K
32 static struct dentry *apb1_log_dentry;
33 static struct dentry *apb1_log_enable_dentry;
34 static struct task_struct *apb1_log_task;
35 static DEFINE_KFIFO(apb1_log_fifo, char, APB1_LOG_SIZE);
36
37 /* Number of CPorts supported by es1 */
38 #define CPORT_COUNT             256
39
40 /*
41  * Number of CPort IN urbs in flight at any point in time.
42  * Adjust if we are having stalls in the USB buffer due to not enough urbs in
43  * flight.
44  */
45 #define NUM_CPORT_IN_URB        4
46
47 /* Number of CPort OUT urbs in flight at any point in time.
48  * Adjust if we get messages saying we are out of urbs in the system log.
49  */
50 #define NUM_CPORT_OUT_URB       8
51
52 /* vendor request APB1 log */
53 #define REQUEST_LOG             0x02
54
55 /* vendor request to time the latency of messages on a given cport */
56 #define REQUEST_LATENCY_TAG_EN  0x06
57 #define REQUEST_LATENCY_TAG_DIS 0x07
58
59 /**
60  * es1_ap_dev - ES1 USB Bridge to AP structure
61  * @usb_dev: pointer to the USB device we are.
62  * @usb_intf: pointer to the USB interface we are bound to.
63  * @hd: pointer to our greybus_host_device structure
64  * @cport_in_endpoint: bulk in endpoint for CPort data
65  * @cport-out_endpoint: bulk out endpoint for CPort data
66  * @cport_in_urb: array of urbs for the CPort in messages
67  * @cport_in_buffer: array of buffers for the @cport_in_urb urbs
68  * @cport_out_urb: array of urbs for the CPort out messages
69  * @cport_out_urb_busy: array of flags to see if the @cport_out_urb is busy or
70  *                      not.
71  * @cport_out_urb_cancelled: array of flags indicating whether the
72  *                      corresponding @cport_out_urb is being cancelled
73  * @cport_out_urb_lock: locks the @cport_out_urb_busy "list"
74  */
75 struct es1_ap_dev {
76         struct usb_device *usb_dev;
77         struct usb_interface *usb_intf;
78         struct greybus_host_device *hd;
79
80         __u8 cport_in_endpoint;
81         __u8 cport_out_endpoint;
82
83         struct urb *cport_in_urb[NUM_CPORT_IN_URB];
84         u8 *cport_in_buffer[NUM_CPORT_IN_URB];
85         struct urb *cport_out_urb[NUM_CPORT_OUT_URB];
86         bool cport_out_urb_busy[NUM_CPORT_OUT_URB];
87         bool cport_out_urb_cancelled[NUM_CPORT_OUT_URB];
88         spinlock_t cport_out_urb_lock;
89 };
90
91 static inline struct es1_ap_dev *hd_to_es1(struct greybus_host_device *hd)
92 {
93         return (struct es1_ap_dev *)&hd->hd_priv;
94 }
95
96 static void cport_out_callback(struct urb *urb);
97 static void usb_log_enable(struct es1_ap_dev *es1);
98 static void usb_log_disable(struct es1_ap_dev *es1);
99
100 #define ES1_TIMEOUT     500     /* 500 ms for the SVC to do something */
101
102 static struct urb *next_free_urb(struct es1_ap_dev *es1, gfp_t gfp_mask)
103 {
104         struct urb *urb = NULL;
105         unsigned long flags;
106         int i;
107
108         spin_lock_irqsave(&es1->cport_out_urb_lock, flags);
109
110         /* Look in our pool of allocated urbs first, as that's the "fastest" */
111         for (i = 0; i < NUM_CPORT_OUT_URB; ++i) {
112                 if (es1->cport_out_urb_busy[i] == false &&
113                                 es1->cport_out_urb_cancelled[i] == false) {
114                         es1->cport_out_urb_busy[i] = true;
115                         urb = es1->cport_out_urb[i];
116                         break;
117                 }
118         }
119         spin_unlock_irqrestore(&es1->cport_out_urb_lock, flags);
120         if (urb)
121                 return urb;
122
123         /*
124          * Crap, pool is empty, complain to the syslog and go allocate one
125          * dynamically as we have to succeed.
126          */
127         dev_err(&es1->usb_dev->dev,
128                 "No free CPort OUT urbs, having to dynamically allocate one!\n");
129         return usb_alloc_urb(0, gfp_mask);
130 }
131
132 static void free_urb(struct es1_ap_dev *es1, struct urb *urb)
133 {
134         unsigned long flags;
135         int i;
136         /*
137          * See if this was an urb in our pool, if so mark it "free", otherwise
138          * we need to free it ourselves.
139          */
140         spin_lock_irqsave(&es1->cport_out_urb_lock, flags);
141         for (i = 0; i < NUM_CPORT_OUT_URB; ++i) {
142                 if (urb == es1->cport_out_urb[i]) {
143                         es1->cport_out_urb_busy[i] = false;
144                         urb = NULL;
145                         break;
146                 }
147         }
148         spin_unlock_irqrestore(&es1->cport_out_urb_lock, flags);
149
150         /* If urb is not NULL, then we need to free this urb */
151         usb_free_urb(urb);
152 }
153
154 /*
155  * We (ab)use the operation-message header pad bytes to transfer the
156  * cport id in order to minimise overhead.
157  */
158 static void
159 gb_message_cport_pack(struct gb_operation_msg_hdr *header, u16 cport_id)
160 {
161         header->pad[0] = cport_id;
162 }
163
164 /* Clear the pad bytes used for the CPort id */
165 static void gb_message_cport_clear(struct gb_operation_msg_hdr *header)
166 {
167         header->pad[0] = 0;
168 }
169
170 /* Extract the CPort id packed into the header, and clear it */
171 static u16 gb_message_cport_unpack(struct gb_operation_msg_hdr *header)
172 {
173         u16 cport_id = header->pad[0];
174
175         gb_message_cport_clear(header);
176
177         return cport_id;
178 }
179
180 /*
181  * Returns zero if the message was successfully queued, or a negative errno
182  * otherwise.
183  */
184 static int message_send(struct greybus_host_device *hd, u16 cport_id,
185                         struct gb_message *message, gfp_t gfp_mask)
186 {
187         struct es1_ap_dev *es1 = hd_to_es1(hd);
188         struct usb_device *udev = es1->usb_dev;
189         size_t buffer_size;
190         int retval;
191         struct urb *urb;
192         unsigned long flags;
193
194         /*
195          * The data actually transferred will include an indication
196          * of where the data should be sent.  Do one last check of
197          * the target CPort id before filling it in.
198          */
199         if (!cport_id_valid(hd, cport_id)) {
200                 dev_err(&udev->dev, "invalid destination cport 0x%02x\n",
201                                 cport_id);
202                 return -EINVAL;
203         }
204
205         /* Find a free urb */
206         urb = next_free_urb(es1, gfp_mask);
207         if (!urb)
208                 return -ENOMEM;
209
210         spin_lock_irqsave(&es1->cport_out_urb_lock, flags);
211         message->hcpriv = urb;
212         spin_unlock_irqrestore(&es1->cport_out_urb_lock, flags);
213
214         /* Pack the cport id into the message header */
215         gb_message_cport_pack(message->header, cport_id);
216
217         buffer_size = sizeof(*message->header) + message->payload_size;
218
219         usb_fill_bulk_urb(urb, udev,
220                           usb_sndbulkpipe(udev, es1->cport_out_endpoint),
221                           message->buffer, buffer_size,
222                           cport_out_callback, message);
223         urb->transfer_flags |= URB_ZERO_PACKET;
224         trace_gb_host_device_send(hd, cport_id, buffer_size);
225         retval = usb_submit_urb(urb, gfp_mask);
226         if (retval) {
227                 dev_err(&udev->dev, "failed to submit out-urb: %d\n", retval);
228
229                 spin_lock_irqsave(&es1->cport_out_urb_lock, flags);
230                 message->hcpriv = NULL;
231                 spin_unlock_irqrestore(&es1->cport_out_urb_lock, flags);
232
233                 free_urb(es1, urb);
234                 gb_message_cport_clear(message->header);
235
236                 return retval;
237         }
238
239         return 0;
240 }
241
242 /*
243  * Can not be called in atomic context.
244  */
245 static void message_cancel(struct gb_message *message)
246 {
247         struct greybus_host_device *hd = message->operation->connection->hd;
248         struct es1_ap_dev *es1 = hd_to_es1(hd);
249         struct urb *urb;
250         int i;
251
252         might_sleep();
253
254         spin_lock_irq(&es1->cport_out_urb_lock);
255         urb = message->hcpriv;
256
257         /* Prevent dynamically allocated urb from being deallocated. */
258         usb_get_urb(urb);
259
260         /* Prevent pre-allocated urb from being reused. */
261         for (i = 0; i < NUM_CPORT_OUT_URB; ++i) {
262                 if (urb == es1->cport_out_urb[i]) {
263                         es1->cport_out_urb_cancelled[i] = true;
264                         break;
265                 }
266         }
267         spin_unlock_irq(&es1->cport_out_urb_lock);
268
269         usb_kill_urb(urb);
270
271         if (i < NUM_CPORT_OUT_URB) {
272                 spin_lock_irq(&es1->cport_out_urb_lock);
273                 es1->cport_out_urb_cancelled[i] = false;
274                 spin_unlock_irq(&es1->cport_out_urb_lock);
275         }
276
277         usb_free_urb(urb);
278 }
279
280 static int latency_tag_enable(struct greybus_host_device *hd, u16 cport_id)
281 {
282         int retval;
283         struct es1_ap_dev *es1 = hd_to_es1(hd);
284         struct usb_device *udev = es1->usb_dev;
285
286         if (!cport_id_valid(hd, cport_id)) {
287                 dev_err(&udev->dev, "invalid destination cport 0x%02x\n",
288                         cport_id);
289                 return -EINVAL;
290         }
291
292         retval = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
293                                  REQUEST_LATENCY_TAG_EN,
294                                  USB_DIR_OUT | USB_TYPE_VENDOR |
295                                  USB_RECIP_INTERFACE, cport_id, 0, NULL,
296                                  0, ES1_TIMEOUT);
297
298         if (retval < 0)
299                 dev_err(&udev->dev, "Cannot enable latency tag for cport %d\n",
300                         cport_id);
301         return retval;
302 }
303
304 static int latency_tag_disable(struct greybus_host_device *hd, u16 cport_id)
305 {
306         int retval;
307         struct es1_ap_dev *es1 = hd_to_es1(hd);
308         struct usb_device *udev = es1->usb_dev;
309
310         if (!cport_id_valid(hd, cport_id)) {
311                 dev_err(&udev->dev, "invalid destination cport 0x%02x\n",
312                         cport_id);
313                 return -EINVAL;
314         }
315
316         retval = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
317                                  REQUEST_LATENCY_TAG_DIS,
318                                  USB_DIR_OUT | USB_TYPE_VENDOR |
319                                  USB_RECIP_INTERFACE, cport_id, 0, NULL,
320                                  0, ES1_TIMEOUT);
321
322         if (retval < 0)
323                 dev_err(&udev->dev, "Cannot disable latency tag for cport %d\n",
324                         cport_id);
325         return retval;
326 }
327
328 static struct greybus_host_driver es1_driver = {
329         .hd_priv_size           = sizeof(struct es1_ap_dev),
330         .message_send           = message_send,
331         .message_cancel         = message_cancel,
332         .latency_tag_enable     = latency_tag_enable,
333         .latency_tag_disable    = latency_tag_disable,
334 };
335
336 /* Common function to report consistent warnings based on URB status */
337 static int check_urb_status(struct urb *urb)
338 {
339         struct device *dev = &urb->dev->dev;
340         int status = urb->status;
341
342         switch (status) {
343         case 0:
344                 return 0;
345
346         case -EOVERFLOW:
347                 dev_err(dev, "%s: overflow actual length is %d\n",
348                         __func__, urb->actual_length);
349         case -ECONNRESET:
350         case -ENOENT:
351         case -ESHUTDOWN:
352         case -EILSEQ:
353         case -EPROTO:
354                 /* device is gone, stop sending */
355                 return status;
356         }
357         dev_err(dev, "%s: unknown status %d\n", __func__, status);
358
359         return -EAGAIN;
360 }
361
362 static void ap_disconnect(struct usb_interface *interface)
363 {
364         struct es1_ap_dev *es1;
365         struct usb_device *udev;
366         int i;
367
368         es1 = usb_get_intfdata(interface);
369         if (!es1)
370                 return;
371
372         usb_log_disable(es1);
373
374         /* Tear down everything! */
375         for (i = 0; i < NUM_CPORT_OUT_URB; ++i) {
376                 struct urb *urb = es1->cport_out_urb[i];
377
378                 if (!urb)
379                         break;
380                 usb_kill_urb(urb);
381                 usb_free_urb(urb);
382                 es1->cport_out_urb[i] = NULL;
383                 es1->cport_out_urb_busy[i] = false;     /* just to be anal */
384         }
385
386         for (i = 0; i < NUM_CPORT_IN_URB; ++i) {
387                 struct urb *urb = es1->cport_in_urb[i];
388
389                 if (!urb)
390                         break;
391                 usb_kill_urb(urb);
392                 usb_free_urb(urb);
393                 kfree(es1->cport_in_buffer[i]);
394                 es1->cport_in_buffer[i] = NULL;
395         }
396
397         usb_set_intfdata(interface, NULL);
398         udev = es1->usb_dev;
399         greybus_remove_hd(es1->hd);
400
401         usb_put_dev(udev);
402 }
403
404 static void cport_in_callback(struct urb *urb)
405 {
406         struct greybus_host_device *hd = urb->context;
407         struct device *dev = &urb->dev->dev;
408         struct gb_operation_msg_hdr *header;
409         int status = check_urb_status(urb);
410         int retval;
411         u16 cport_id;
412
413         if (status) {
414                 if ((status == -EAGAIN) || (status == -EPROTO))
415                         goto exit;
416                 dev_err(dev, "urb cport in error %d (dropped)\n", status);
417                 return;
418         }
419
420         if (urb->actual_length < sizeof(*header)) {
421                 dev_err(dev, "short message received\n");
422                 goto exit;
423         }
424
425         /* Extract the CPort id, which is packed in the message header */
426         header = urb->transfer_buffer;
427         cport_id = gb_message_cport_unpack(header);
428
429         if (cport_id_valid(hd, cport_id)) {
430                 trace_gb_host_device_recv(hd, cport_id, urb->actual_length);
431                 greybus_data_rcvd(hd, cport_id, urb->transfer_buffer,
432                                                         urb->actual_length);
433         } else {
434                 dev_err(dev, "invalid cport id 0x%02x received\n", cport_id);
435         }
436 exit:
437         /* put our urb back in the request pool */
438         retval = usb_submit_urb(urb, GFP_ATOMIC);
439         if (retval)
440                 dev_err(dev, "failed to resubmit in-urb: %d\n", retval);
441 }
442
443 static void cport_out_callback(struct urb *urb)
444 {
445         struct gb_message *message = urb->context;
446         struct greybus_host_device *hd = message->operation->connection->hd;
447         struct es1_ap_dev *es1 = hd_to_es1(hd);
448         int status = check_urb_status(urb);
449         unsigned long flags;
450
451         gb_message_cport_clear(message->header);
452
453         spin_lock_irqsave(&es1->cport_out_urb_lock, flags);
454         message->hcpriv = NULL;
455         spin_unlock_irqrestore(&es1->cport_out_urb_lock, flags);
456
457         /*
458          * Tell the submitter that the message send (attempt) is
459          * complete, and report the status.
460          */
461         greybus_message_sent(hd, message, status);
462
463         free_urb(es1, urb);
464 }
465
466 #define APB1_LOG_MSG_SIZE       64
467 static void apb1_log_get(struct es1_ap_dev *es1, char *buf)
468 {
469         int retval;
470
471         /* SVC messages go down our control pipe */
472         do {
473                 retval = usb_control_msg(es1->usb_dev,
474                                         usb_rcvctrlpipe(es1->usb_dev, 0),
475                                         REQUEST_LOG,
476                                         USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
477                                         0x00, 0x00,
478                                         buf,
479                                         APB1_LOG_MSG_SIZE,
480                                         ES1_TIMEOUT);
481                 if (retval > 0)
482                         kfifo_in(&apb1_log_fifo, buf, retval);
483         } while (retval > 0);
484 }
485
486 static int apb1_log_poll(void *data)
487 {
488         struct es1_ap_dev *es1 = data;
489         char *buf;
490
491         buf = kmalloc(APB1_LOG_MSG_SIZE, GFP_KERNEL);
492         if (!buf)
493                 return -ENOMEM;
494
495         while (!kthread_should_stop()) {
496                 msleep(1000);
497                 apb1_log_get(es1, buf);
498         }
499
500         kfree(buf);
501
502         return 0;
503 }
504
505 static ssize_t apb1_log_read(struct file *f, char __user *buf,
506                                 size_t count, loff_t *ppos)
507 {
508         ssize_t ret;
509         size_t copied;
510         char *tmp_buf;
511
512         if (count > APB1_LOG_SIZE)
513                 count = APB1_LOG_SIZE;
514
515         tmp_buf = kmalloc(count, GFP_KERNEL);
516         if (!tmp_buf)
517                 return -ENOMEM;
518
519         copied = kfifo_out(&apb1_log_fifo, tmp_buf, count);
520         ret = simple_read_from_buffer(buf, count, ppos, tmp_buf, copied);
521
522         kfree(tmp_buf);
523
524         return ret;
525 }
526
527 static const struct file_operations apb1_log_fops = {
528         .read   = apb1_log_read,
529 };
530
531 static void usb_log_enable(struct es1_ap_dev *es1)
532 {
533         if (!IS_ERR_OR_NULL(apb1_log_task))
534                 return;
535
536         /* get log from APB1 */
537         apb1_log_task = kthread_run(apb1_log_poll, es1, "apb1_log");
538         if (IS_ERR(apb1_log_task))
539                 return;
540         apb1_log_dentry = debugfs_create_file("apb1_log", S_IRUGO,
541                                                 gb_debugfs_get(), NULL,
542                                                 &apb1_log_fops);
543 }
544
545 static void usb_log_disable(struct es1_ap_dev *es1)
546 {
547         if (IS_ERR_OR_NULL(apb1_log_task))
548                 return;
549
550         debugfs_remove(apb1_log_dentry);
551         apb1_log_dentry = NULL;
552
553         kthread_stop(apb1_log_task);
554         apb1_log_task = NULL;
555 }
556
557 static ssize_t apb1_log_enable_read(struct file *f, char __user *buf,
558                                 size_t count, loff_t *ppos)
559 {
560         char tmp_buf[3];
561         int enable = !IS_ERR_OR_NULL(apb1_log_task);
562
563         sprintf(tmp_buf, "%d\n", enable);
564         return simple_read_from_buffer(buf, count, ppos, tmp_buf, 3);
565 }
566
567 static ssize_t apb1_log_enable_write(struct file *f, const char __user *buf,
568                                 size_t count, loff_t *ppos)
569 {
570         int enable;
571         ssize_t retval;
572         struct es1_ap_dev *es1 = (struct es1_ap_dev *)f->f_inode->i_private;
573
574         retval = kstrtoint_from_user(buf, count, 10, &enable);
575         if (retval)
576                 return retval;
577
578         if (enable)
579                 usb_log_enable(es1);
580         else
581                 usb_log_disable(es1);
582
583         return count;
584 }
585
586 static const struct file_operations apb1_log_enable_fops = {
587         .read   = apb1_log_enable_read,
588         .write  = apb1_log_enable_write,
589 };
590
591 /*
592  * The ES1 USB Bridge device contains 4 endpoints
593  * 1 Control - usual USB stuff + AP -> SVC messages
594  * 1 Interrupt IN - SVC -> AP messages
595  * 1 Bulk IN - CPort data in
596  * 1 Bulk OUT - CPort data out
597  */
598 static int ap_probe(struct usb_interface *interface,
599                     const struct usb_device_id *id)
600 {
601         struct es1_ap_dev *es1;
602         struct greybus_host_device *hd;
603         struct usb_device *udev;
604         struct usb_host_interface *iface_desc;
605         struct usb_endpoint_descriptor *endpoint;
606         bool bulk_in_found = false;
607         bool bulk_out_found = false;
608         int retval = -ENOMEM;
609         int i;
610
611         /* We need to fit a CPort ID in one byte of a message header */
612         BUILD_BUG_ON(CPORT_COUNT > U8_MAX + 1);
613
614         udev = usb_get_dev(interface_to_usbdev(interface));
615
616         hd = greybus_create_hd(&es1_driver, &udev->dev, ES1_GBUF_MSG_SIZE_MAX,
617                                CPORT_COUNT);
618         if (IS_ERR(hd)) {
619                 usb_put_dev(udev);
620                 return PTR_ERR(hd);
621         }
622
623         es1 = hd_to_es1(hd);
624         es1->hd = hd;
625         es1->usb_intf = interface;
626         es1->usb_dev = udev;
627         spin_lock_init(&es1->cport_out_urb_lock);
628         usb_set_intfdata(interface, es1);
629
630         /* find all 3 of our endpoints */
631         iface_desc = interface->cur_altsetting;
632         for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
633                 endpoint = &iface_desc->endpoint[i].desc;
634
635                 if (usb_endpoint_is_bulk_in(endpoint)) {
636                         es1->cport_in_endpoint = endpoint->bEndpointAddress;
637                         bulk_in_found = true;
638                 } else if (usb_endpoint_is_bulk_out(endpoint)) {
639                         es1->cport_out_endpoint = endpoint->bEndpointAddress;
640                         bulk_out_found = true;
641                 } else {
642                         dev_err(&udev->dev,
643                                 "Unknown endpoint type found, address %x\n",
644                                 endpoint->bEndpointAddress);
645                 }
646         }
647         if ((bulk_in_found == false) ||
648             (bulk_out_found == false)) {
649                 dev_err(&udev->dev, "Not enough endpoints found in device, aborting!\n");
650                 goto error;
651         }
652
653         /* Allocate buffers for our cport in messages and start them up */
654         for (i = 0; i < NUM_CPORT_IN_URB; ++i) {
655                 struct urb *urb;
656                 u8 *buffer;
657
658                 urb = usb_alloc_urb(0, GFP_KERNEL);
659                 if (!urb)
660                         goto error;
661                 buffer = kmalloc(ES1_GBUF_MSG_SIZE_MAX, GFP_KERNEL);
662                 if (!buffer)
663                         goto error;
664
665                 usb_fill_bulk_urb(urb, udev,
666                                   usb_rcvbulkpipe(udev, es1->cport_in_endpoint),
667                                   buffer, ES1_GBUF_MSG_SIZE_MAX,
668                                   cport_in_callback, hd);
669                 es1->cport_in_urb[i] = urb;
670                 es1->cport_in_buffer[i] = buffer;
671                 retval = usb_submit_urb(urb, GFP_KERNEL);
672                 if (retval)
673                         goto error;
674         }
675
676         /* Allocate urbs for our CPort OUT messages */
677         for (i = 0; i < NUM_CPORT_OUT_URB; ++i) {
678                 struct urb *urb;
679
680                 urb = usb_alloc_urb(0, GFP_KERNEL);
681                 if (!urb)
682                         goto error;
683
684                 es1->cport_out_urb[i] = urb;
685                 es1->cport_out_urb_busy[i] = false;     /* just to be anal */
686         }
687
688         apb1_log_enable_dentry = debugfs_create_file("apb1_log_enable",
689                                                         (S_IWUSR | S_IRUGO),
690                                                         gb_debugfs_get(), es1,
691                                                         &apb1_log_enable_fops);
692         return 0;
693 error:
694         ap_disconnect(interface);
695
696         return retval;
697 }
698
699 static struct usb_driver es1_ap_driver = {
700         .name =         "es1_ap_driver",
701         .probe =        ap_probe,
702         .disconnect =   ap_disconnect,
703         .id_table =     id_table,
704 };
705
706 module_usb_driver(es1_ap_driver);
707
708 MODULE_LICENSE("GPL v2");
709 MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@linuxfoundation.org>");