• Home
  • Raw
  • Download

Lines Matching +full:needs +full:- +full:reset +full:- +full:on +full:- +full:resume

1 .. _writing-usb-driver:
7 :Author: Greg Kroah-Hartman
16 mice, modems, printers and speakers) and an ever-growing number of
17 vendor-specific devices (such as USB to serial converters, digital
21 The remaining kinds of USB devices that do not have support on Linux are
22 almost all vendor-specific devices. Each vendor decides to implement a
24 needs to be created. Some vendors are open with their USB protocols and
26 them, and developers are forced to reverse-engineer. See Resources for
27 some links to handy reverse-engineering tools.
31 pci-skeleton.c file in the kernel source tree upon which many PCI
33 drivers/usb/usb-skeleton.c in the kernel source tree. In this article I
35 different pieces and what needs to be done to customize it to your
49 The first thing a Linux USB driver needs to do is register itself with
61 .resume = skel_resume,
78 subsystem, and any user-space interactions are provided through that
83 this user-space interaction. The skeleton driver needs this kind of
99 return -1;
107 When the driver is unloaded from the system, it needs to deregister
119 To enable the linux-hotplug system to load the driver automatically when
134 drivers. See :ref:`usb.h <usb_header>` for more information on this.
148 The driver now needs to verify that this device is actually one that it
150 initialization, an errorcode (such as ``-ENOMEM`` or ``-ENODEV``) is
154 bulk-in and bulk-out. We create buffers to hold the data that will be
159 function is called with the device pointer. The driver needs to clean
174 kref_get(&dev->kref);
177 file->private_data = dev;
184 data it can send to the device based on the size of the write urb it has
185 created (this size depends on the size of the bulk out end point that
198 dev->udev,
199 usb_sndbulkpipe(dev->udev, dev->bulk_out_endpointAddr),
208 dev_err(&dev->interface->dev,
209 "%s - failed submitting write urb, error %d\n",
234 retval = usb_bulk_msg (skel->dev,
235 usb_rcvbulkpipe (skel->dev,
236 skel->bulk_in_endpointAddr),
237 skel->bulk_in_buffer,
238 skel->bulk_in_size,
242 if (copy_to_user (buffer, skel->bulk_in_buffer, count))
243 retval = -EFAULT;
260 --skel->open_count;
266 it. It needs to be able to shut down any current reads and writes and
267 notify the user-space programs that the device is no longer there. The
273 kfree (dev->bulk_in_buffer);
274 if (dev->bulk_out_buffer != NULL)
275 usb_free_coherent (dev->udev, dev->bulk_out_size,
276 dev->bulk_out_buffer,
277 dev->write_urb->transfer_dma);
278 usb_free_urb (dev->write_urb);
283 If a program currently has an open handle to the device, we reset the
287 that the device has disappeared, and a ``-ENODEV`` error is returned to the
288 user-space program. When the release function is eventually called, it
291 on the device (see Listing 5).
296 This usb-skeleton driver does not have any examples of interrupt or
308 usb-skeleton driver shows. This driver, combined with the other current
310 create a working driver in a minimal amount of time. The linux-usb-devel
317 http://www.linux-usb.org/
320 http://linux-hotplug.sourceforge.net/
322 linux-usb Mailing List Archives:
323 https://lore.kernel.org/linux-usb/