| .. | .. |
|---|
| 39 | 39 | #include <linux/fs.h> |
|---|
| 40 | 40 | #include <linux/mm.h> |
|---|
| 41 | 41 | #include <linux/gfp.h> |
|---|
| 42 | | -#include <linux/poll.h> |
|---|
| 43 | 42 | #include <linux/usb.h> |
|---|
| 44 | 43 | #include <linux/usbdevice_fs.h> |
|---|
| 45 | 44 | #include <linux/usb/hcd.h> |
|---|
| .. | .. |
|---|
| 97 | 96 | /* E: Ad=xx(s) Atr=xx(ssss) MxPS=dddd Ivl=D?s */ |
|---|
| 98 | 97 | "E: Ad=%02x(%c) Atr=%02x(%-4s) MxPS=%4d Ivl=%d%cs\n"; |
|---|
| 99 | 98 | |
|---|
| 100 | | -/* |
|---|
| 101 | | - * Wait for an connect/disconnect event to happen. We initialize |
|---|
| 102 | | - * the event counter with an odd number, and each event will increment |
|---|
| 103 | | - * the event counter by two, so it will always _stay_ odd. That means |
|---|
| 104 | | - * that it will never be zero, so "event 0" will never match a current |
|---|
| 105 | | - * event, and thus 'poll' will always trigger as readable for the first |
|---|
| 106 | | - * time it gets called. |
|---|
| 107 | | - */ |
|---|
| 108 | | -static struct device_connect_event { |
|---|
| 109 | | - atomic_t count; |
|---|
| 110 | | - wait_queue_head_t wait; |
|---|
| 111 | | -} device_event = { |
|---|
| 112 | | - .count = ATOMIC_INIT(1), |
|---|
| 113 | | - .wait = __WAIT_QUEUE_HEAD_INITIALIZER(device_event.wait) |
|---|
| 114 | | -}; |
|---|
| 115 | | - |
|---|
| 116 | 99 | struct class_info { |
|---|
| 117 | 100 | int class; |
|---|
| 118 | 101 | char *class_name; |
|---|
| .. | .. |
|---|
| 133 | 116 | {USB_CLASS_CSCID, "scard"}, |
|---|
| 134 | 117 | {USB_CLASS_CONTENT_SEC, "c-sec"}, |
|---|
| 135 | 118 | {USB_CLASS_VIDEO, "video"}, |
|---|
| 119 | + {USB_CLASS_PERSONAL_HEALTHCARE, "perhc"}, |
|---|
| 120 | + {USB_CLASS_AUDIO_VIDEO, "av"}, |
|---|
| 121 | + {USB_CLASS_BILLBOARD, "blbrd"}, |
|---|
| 122 | + {USB_CLASS_USB_TYPE_C_BRIDGE, "bridg"}, |
|---|
| 136 | 123 | {USB_CLASS_WIRELESS_CONTROLLER, "wlcon"}, |
|---|
| 137 | 124 | {USB_CLASS_MISC, "misc"}, |
|---|
| 138 | 125 | {USB_CLASS_APP_SPEC, "app."}, |
|---|
| .. | .. |
|---|
| 141 | 128 | }; |
|---|
| 142 | 129 | |
|---|
| 143 | 130 | /*****************************************************************/ |
|---|
| 144 | | - |
|---|
| 145 | | -void usbfs_conn_disc_event(void) |
|---|
| 146 | | -{ |
|---|
| 147 | | - atomic_add(2, &device_event.count); |
|---|
| 148 | | - wake_up(&device_event.wait); |
|---|
| 149 | | -} |
|---|
| 150 | 131 | |
|---|
| 151 | 132 | static const char *class_decode(const int class) |
|---|
| 152 | 133 | { |
|---|
| .. | .. |
|---|
| 176 | 157 | switch (usb_endpoint_type(desc)) { |
|---|
| 177 | 158 | case USB_ENDPOINT_XFER_CONTROL: |
|---|
| 178 | 159 | type = "Ctrl"; |
|---|
| 179 | | - if (speed == USB_SPEED_HIGH) /* uframes per NAK */ |
|---|
| 180 | | - interval = desc->bInterval; |
|---|
| 181 | | - else |
|---|
| 182 | | - interval = 0; |
|---|
| 183 | 160 | dir = 'B'; /* ctrl is bidirectional */ |
|---|
| 184 | 161 | break; |
|---|
| 185 | 162 | case USB_ENDPOINT_XFER_ISOC: |
|---|
| 186 | 163 | type = "Isoc"; |
|---|
| 187 | | - interval = 1 << (desc->bInterval - 1); |
|---|
| 188 | 164 | break; |
|---|
| 189 | 165 | case USB_ENDPOINT_XFER_BULK: |
|---|
| 190 | 166 | type = "Bulk"; |
|---|
| 191 | | - if (speed == USB_SPEED_HIGH && dir == 'O') /* uframes per NAK */ |
|---|
| 192 | | - interval = desc->bInterval; |
|---|
| 193 | | - else |
|---|
| 194 | | - interval = 0; |
|---|
| 195 | 167 | break; |
|---|
| 196 | 168 | case USB_ENDPOINT_XFER_INT: |
|---|
| 197 | 169 | type = "Int."; |
|---|
| 198 | | - if (speed == USB_SPEED_HIGH || speed >= USB_SPEED_SUPER) |
|---|
| 199 | | - interval = 1 << (desc->bInterval - 1); |
|---|
| 200 | | - else |
|---|
| 201 | | - interval = desc->bInterval; |
|---|
| 202 | 170 | break; |
|---|
| 203 | 171 | default: /* "can't happen" */ |
|---|
| 204 | 172 | return start; |
|---|
| 205 | 173 | } |
|---|
| 206 | | - interval *= (speed == USB_SPEED_HIGH || |
|---|
| 207 | | - speed >= USB_SPEED_SUPER) ? 125 : 1000; |
|---|
| 208 | | - if (interval % 1000) |
|---|
| 174 | + |
|---|
| 175 | + interval = usb_decode_interval(desc, speed); |
|---|
| 176 | + if (interval % 1000) { |
|---|
| 209 | 177 | unit = 'u'; |
|---|
| 210 | | - else { |
|---|
| 178 | + } else { |
|---|
| 211 | 179 | unit = 'm'; |
|---|
| 212 | 180 | interval /= 1000; |
|---|
| 213 | 181 | } |
|---|
| .. | .. |
|---|
| 598 | 566 | return -EINVAL; |
|---|
| 599 | 567 | if (nbytes <= 0) |
|---|
| 600 | 568 | return 0; |
|---|
| 601 | | - if (!access_ok(VERIFY_WRITE, buf, nbytes)) |
|---|
| 602 | | - return -EFAULT; |
|---|
| 603 | 569 | |
|---|
| 604 | 570 | mutex_lock(&usb_bus_idr_lock); |
|---|
| 605 | 571 | /* print devices for all busses */ |
|---|
| .. | .. |
|---|
| 621 | 587 | return total_written; |
|---|
| 622 | 588 | } |
|---|
| 623 | 589 | |
|---|
| 624 | | -/* Kernel lock for "lastev" protection */ |
|---|
| 625 | | -static __poll_t usb_device_poll(struct file *file, |
|---|
| 626 | | - struct poll_table_struct *wait) |
|---|
| 627 | | -{ |
|---|
| 628 | | - unsigned int event_count; |
|---|
| 629 | | - |
|---|
| 630 | | - poll_wait(file, &device_event.wait, wait); |
|---|
| 631 | | - |
|---|
| 632 | | - event_count = atomic_read(&device_event.count); |
|---|
| 633 | | - if (file->f_version != event_count) { |
|---|
| 634 | | - file->f_version = event_count; |
|---|
| 635 | | - return EPOLLIN | EPOLLRDNORM; |
|---|
| 636 | | - } |
|---|
| 637 | | - |
|---|
| 638 | | - return 0; |
|---|
| 639 | | -} |
|---|
| 640 | | - |
|---|
| 641 | 590 | const struct file_operations usbfs_devices_fops = { |
|---|
| 642 | 591 | .llseek = no_seek_end_llseek, |
|---|
| 643 | 592 | .read = usb_device_read, |
|---|
| 644 | | - .poll = usb_device_poll, |
|---|
| 645 | 593 | }; |
|---|