Listing 2. The skel_write Function
/* we can only write as much as 1 urb will hold */
bytes_written = (count > skel->bulk_out_size)
? skel->bulk_out_size : count;
/* copy the data from user space into our urb */
copy_from_user(skel->write_urb->transfer_buffer,
buffer, bytes_written);
/* set up our urb */
FILL_BULK_URB(skel->write_urb, skel->dev,
usb_sndbulkpipe(skel->dev,
skel->bulk_out_endpointAddr),
skel->write_urb->transfer_buffer,
bytes_written, skel_write_bulk_callback,
skel);
/* send the data out the bulk port */
result = usb_submit_urb(skel->write_urb);
if (result) {
err(__FUNCTION__ " - failed submitting write
urb, error %d", result);
}
Copyright © 1994 - 2019 Linux Journal. All rights reserved.