| .. | .. |
|---|
| 56 | 56 | #define FTIP_SCROLL 0x24 |
|---|
| 57 | 57 | |
|---|
| 58 | 58 | #define ftip_command(dev, command, value, index) \ |
|---|
| 59 | | - usb_control_msg (dev->udev, usb_sndctrlpipe (dev->udev, 0), command, \ |
|---|
| 59 | + usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), command, \ |
|---|
| 60 | 60 | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, value, index, NULL, 0, 1000) |
|---|
| 61 | 61 | |
|---|
| 62 | 62 | MODULE_DEVICE_TABLE(usb, idmouse_table); |
|---|
| 63 | | -static DEFINE_MUTEX(open_disc_mutex); |
|---|
| 64 | 63 | |
|---|
| 65 | 64 | /* structure to hold all of our device specific stuff */ |
|---|
| 66 | 65 | struct usb_idmouse { |
|---|
| .. | .. |
|---|
| 158 | 157 | |
|---|
| 159 | 158 | /* loop over a blocking bulk read to get data from the device */ |
|---|
| 160 | 159 | while (bytes_read < IMGSIZE) { |
|---|
| 161 | | - result = usb_bulk_msg (dev->udev, |
|---|
| 162 | | - usb_rcvbulkpipe (dev->udev, dev->bulk_in_endpointAddr), |
|---|
| 160 | + result = usb_bulk_msg(dev->udev, |
|---|
| 161 | + usb_rcvbulkpipe(dev->udev, dev->bulk_in_endpointAddr), |
|---|
| 163 | 162 | dev->bulk_in_buffer + bytes_read, |
|---|
| 164 | 163 | dev->bulk_in_size, &bulk_read, 5000); |
|---|
| 165 | 164 | if (result < 0) { |
|---|
| .. | .. |
|---|
| 178 | 177 | bytes_read += bulk_read; |
|---|
| 179 | 178 | } |
|---|
| 180 | 179 | |
|---|
| 181 | | - /* reset the device */ |
|---|
| 182 | | -reset: |
|---|
| 183 | | - ftip_command(dev, FTIP_RELEASE, 0, 0); |
|---|
| 184 | | - |
|---|
| 185 | 180 | /* check for valid image */ |
|---|
| 186 | 181 | /* right border should be black (0x00) */ |
|---|
| 187 | 182 | for (bytes_read = sizeof(HEADER)-1 + WIDTH-1; bytes_read < IMGSIZE; bytes_read += WIDTH) |
|---|
| .. | .. |
|---|
| 192 | 187 | for (bytes_read = IMGSIZE-WIDTH; bytes_read < IMGSIZE-1; bytes_read++) |
|---|
| 193 | 188 | if (dev->bulk_in_buffer[bytes_read] != 0xFF) |
|---|
| 194 | 189 | return -EAGAIN; |
|---|
| 190 | + |
|---|
| 191 | + /* reset the device */ |
|---|
| 192 | +reset: |
|---|
| 193 | + ftip_command(dev, FTIP_RELEASE, 0, 0); |
|---|
| 195 | 194 | |
|---|
| 196 | 195 | /* should be IMGSIZE == 65040 */ |
|---|
| 197 | 196 | dev_dbg(&dev->interface->dev, "read %d bytes fingerprint data\n", |
|---|
| .. | .. |
|---|
| 223 | 222 | int result; |
|---|
| 224 | 223 | |
|---|
| 225 | 224 | /* get the interface from minor number and driver information */ |
|---|
| 226 | | - interface = usb_find_interface (&idmouse_driver, iminor (inode)); |
|---|
| 225 | + interface = usb_find_interface(&idmouse_driver, iminor(inode)); |
|---|
| 227 | 226 | if (!interface) |
|---|
| 228 | 227 | return -ENODEV; |
|---|
| 229 | 228 | |
|---|
| 230 | | - mutex_lock(&open_disc_mutex); |
|---|
| 231 | 229 | /* get the device information block from the interface */ |
|---|
| 232 | 230 | dev = usb_get_intfdata(interface); |
|---|
| 233 | | - if (!dev) { |
|---|
| 234 | | - mutex_unlock(&open_disc_mutex); |
|---|
| 231 | + if (!dev) |
|---|
| 235 | 232 | return -ENODEV; |
|---|
| 236 | | - } |
|---|
| 237 | 233 | |
|---|
| 238 | 234 | /* lock this device */ |
|---|
| 239 | 235 | mutex_lock(&dev->lock); |
|---|
| 240 | | - mutex_unlock(&open_disc_mutex); |
|---|
| 241 | 236 | |
|---|
| 242 | 237 | /* check if already open */ |
|---|
| 243 | 238 | if (dev->open) { |
|---|
| .. | .. |
|---|
| 251 | 246 | result = usb_autopm_get_interface(interface); |
|---|
| 252 | 247 | if (result) |
|---|
| 253 | 248 | goto error; |
|---|
| 254 | | - result = idmouse_create_image (dev); |
|---|
| 249 | + result = idmouse_create_image(dev); |
|---|
| 255 | 250 | usb_autopm_put_interface(interface); |
|---|
| 256 | 251 | if (result) |
|---|
| 257 | 252 | goto error; |
|---|
| .. | .. |
|---|
| 280 | 275 | if (dev == NULL) |
|---|
| 281 | 276 | return -ENODEV; |
|---|
| 282 | 277 | |
|---|
| 283 | | - mutex_lock(&open_disc_mutex); |
|---|
| 284 | 278 | /* lock our device */ |
|---|
| 285 | 279 | mutex_lock(&dev->lock); |
|---|
| 286 | | - |
|---|
| 287 | | - /* are we really open? */ |
|---|
| 288 | | - if (dev->open <= 0) { |
|---|
| 289 | | - mutex_unlock(&dev->lock); |
|---|
| 290 | | - mutex_unlock(&open_disc_mutex); |
|---|
| 291 | | - return -ENODEV; |
|---|
| 292 | | - } |
|---|
| 293 | 280 | |
|---|
| 294 | 281 | --dev->open; |
|---|
| 295 | 282 | |
|---|
| 296 | 283 | if (!dev->present) { |
|---|
| 297 | 284 | /* the device was unplugged before the file was released */ |
|---|
| 298 | 285 | mutex_unlock(&dev->lock); |
|---|
| 299 | | - mutex_unlock(&open_disc_mutex); |
|---|
| 300 | 286 | idmouse_delete(dev); |
|---|
| 301 | 287 | } else { |
|---|
| 302 | 288 | mutex_unlock(&dev->lock); |
|---|
| 303 | | - mutex_unlock(&open_disc_mutex); |
|---|
| 304 | 289 | } |
|---|
| 305 | 290 | return 0; |
|---|
| 306 | 291 | } |
|---|
| .. | .. |
|---|
| 379 | 364 | if (result) { |
|---|
| 380 | 365 | /* something prevented us from registering this device */ |
|---|
| 381 | 366 | dev_err(&interface->dev, "Unable to allocate minor number.\n"); |
|---|
| 382 | | - usb_set_intfdata(interface, NULL); |
|---|
| 383 | 367 | idmouse_delete(dev); |
|---|
| 384 | 368 | return result; |
|---|
| 385 | 369 | } |
|---|
| .. | .. |
|---|
| 392 | 376 | |
|---|
| 393 | 377 | static void idmouse_disconnect(struct usb_interface *interface) |
|---|
| 394 | 378 | { |
|---|
| 395 | | - struct usb_idmouse *dev; |
|---|
| 396 | | - |
|---|
| 397 | | - /* get device structure */ |
|---|
| 398 | | - dev = usb_get_intfdata(interface); |
|---|
| 379 | + struct usb_idmouse *dev = usb_get_intfdata(interface); |
|---|
| 399 | 380 | |
|---|
| 400 | 381 | /* give back our minor */ |
|---|
| 401 | 382 | usb_deregister_dev(interface, &idmouse_class); |
|---|
| 402 | 383 | |
|---|
| 403 | | - mutex_lock(&open_disc_mutex); |
|---|
| 404 | | - usb_set_intfdata(interface, NULL); |
|---|
| 405 | 384 | /* lock the device */ |
|---|
| 406 | 385 | mutex_lock(&dev->lock); |
|---|
| 407 | | - mutex_unlock(&open_disc_mutex); |
|---|
| 408 | 386 | |
|---|
| 409 | 387 | /* prevent device read, write and ioctl */ |
|---|
| 410 | 388 | dev->present = 0; |
|---|