hi all,
i have used skeleton driver at the host side and gadgetfs at the gadget side.
also i have made application on each side (host and gadget)and my only problem 
that after running the applications right ,at the host and the gadget ,
my pc host hangs up?

note that the host application consists of two threads each thread is an 
infinite loop and one thread for reading and the other thread is for writing.

so that i can not terminate the host application and i think that is why the pc 
is hanging after running the host application?
or this problem may occur because of another reason in the host driver?
here is the host driver read and write driver functions:

******************************************************************************
static ssize_t skel_read(struct file *file, char *buffer, size_t count, loff_t 
*ppos)
{
        struct usb_skel *dev;
        int retval = 0;
        int bytes_read;

        dev = (struct usb_skel *)file->private_data;
        
        /* do a blocking bulk read to get data from the device */
        retval = usb_bulk_msg(dev->udev,
                              usb_rcvbulkpipe(dev->udev, 
dev->bulk_in_endpointAddr),
                              dev->bulk_in_buffer,
                              /*min(dev->bulk_in_size, count)*/(1024*2),
                              &bytes_read, 0);

        /* if the read was successful, copy the data to userspace */
        if (!retval) {
                if (copy_to_user(buffer, dev->bulk_in_buffer, bytes_read))
                        retval = -EFAULT;
                else
                        retval = bytes_read;
        }

        return retval;
}

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

        dev = (struct usb_skel *)urb->context;

        /* 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;
        size_t writesize = min(count, (size_t)MAX_TRANSFER);

        dev = (struct usb_skel *)file->private_data;

        /* verify that we actually have some data to write */
        if (count == 0)
                goto exit;

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

        /* create a urb, and a buffer for it, and copy the data to the urb */
        urb = usb_alloc_urb(0, GFP_KERNEL);
        if (!urb) {
                retval = -ENOMEM;
                goto error;
        }

        buf = usb_buffer_alloc(dev->udev, writesize, GFP_KERNEL, 
&urb->transfer_dma);
        if (!buf) {
                retval = -ENOMEM;
                goto error;
        }

        if (copy_from_user(buf, user_buffer, writesize)) {
                retval = -EFAULT;
                goto error;
        }

        /* 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);
        urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;

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

        /* release our reference to this urb, the USB core will eventually free 
it entirely */
        usb_free_urb(urb);

exit:
        return writesize;

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

******************************************************************************

is there any possible answer for what reason why this hanging happens.
thanks in advance


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to