USB skel_write_bulk_callback gives error -71

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hello all,
I am trying to write imx21 board connected to my host. When I write 64 bytes of data, the wrte call back gives error -71 which is protocol error.
Herewith I am giving the dmesg for my driver code along with the code.
I would like to where I am making mistake and how to rectify it?

Looking for ur help.
/T.S

dmesg
=====

skel_write
I have 64 bytes of data to write
buf 0 0x12
buf 1 0x13

::I am going to fill the bulk urb structure
I'm in usb.h::URB initialization SUCCESS
after URB submit
skel_release
skel_write_bulk_callback
STATUS::-71
=====dmesg over===

static void skel_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
{

   
   struct usb_skel *dev;
   printk("%s\n ", __FUNCTION__);
   dev = (struct usb_skel *)urb->context;
   printk("STATUS::%d\n",urb->status);

   /* sync/async unlink faults aren't errors */
   if (urb->status &&
       !(urb->status == -ENOENT ||
         urb->status == -ECONNRESET ||
         urb->status == -ESHUTDOWN)) {
       dbg("%s - nonzero write bulk status received: %d",
           __FUNCTION__, urb->status);
   }

   /* free up our allocated buffer */
   usb_buffer_free(urb->dev, urb->transfer_buffer_length,
           urb->transfer_buffer, urb->transfer_dma);
   up(&dev->limit_sem);
}
static ssize_t skel_write(struct file *file, const char *user_buffer, size_t count, loff_t *ppos)
{
   struct usb_skel *dev;
   int retval = 0;
   struct urb *urb = NULL;
   char *buf = NULL;
   unsigned int pipe,temp,is_out;//PE added for testing
   struct usb_device *udev;//PE added for testing
   unsigned epnum ;//PE added for testing
   struct usb_host_endpoint *ep;//PE added for testing


   size_t writesize = min(count, (size_t)MAX_TRANSFER);
   printk("writesize::%d\n",writesize);
   printk("%s\n",__FUNCTION__);
   dev = (struct usb_skel *)file->private_data;


   /* verify that we actually have some data to write */
   if (count == 0)
   {
       printk("sw count 0\n");
       goto exit;
   }
   printk("I have %d bytes of data to write\n",count);

   /* limit the number of URBs in flight to stop a user from using up all RAM */
   if (down_interruptible(&dev->limit_sem)) {
       printk("sw down_interruptible\n");
       retval = -ERESTARTSYS;
       goto exit;
   }

   /* create a urb, and a buffer for it, and copy the data to the urb */
   urb = usb_alloc_urb(0, SLAB_NOIO);
   if (!urb) {
       printk("Skell Write usb alloc urb fail\n");
       retval = -ENOMEM;
       goto error;
   }

   buf = usb_buffer_alloc(dev->udev, writesize, SLAB_NOIO, &urb->transfer_dma);
   if (!buf) {
       retval = -ENOMEM;
       printk("sw usb buffer alloc fail\n");
       goto error;
   }

   if (copy_from_user(buf, user_buffer, writesize)) {
       retval = -EFAULT;
       printk("sw copy from user fail\n");
       goto error;
   }
   printk("buf 0 0x%x\n",buf[0]);//PE SEN added for testing
   printk("buf 1 0x%x\n",buf[1]);//PE SEN added for testing

   printk("::I am going to fill the bulk urb structure\n");
   /* initialize the urb properly */
   usb_fill_bulk_urb(urb, dev->udev,
             usb_sndbulkpipe(dev->udev, dev->bulk_out_endpointAddr),
             buf, writesize, skel_write_bulk_callback, dev);

   printk("URB initialization SUCCESS\n");
   urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
   

   /* send the data out the bulk port */
   retval = usb_submit_urb(urb, SLAB_ATOMIC);
   if (retval) {
       err("%s - failed submitting write urb, error %d", __FUNCTION__, retval);
       goto error;
   }

   printk("after URB submit\n");
   /* release our reference to this urb, the USB core will eventually free it entirely */
   usb_free_urb(urb);

#endif

exit:
   return writesize;

error:
   usb_buffer_free(dev->udev, writesize, buf, urb->transfer_dma);
   usb_free_urb(urb);
   up(&dev->limit_sem);
   return retval;

return writesize;
}



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux