All of lore.kernel.org
 help / color / mirror / Atom feed
From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Cannot read using USB Skeleton Driver
Date: Fri, 16 Sep 2011 09:01:57 +0200	[thread overview]
Message-ID: <20110916070157.GA7661@kroah.com> (raw)
In-Reply-To: <CAKRE6mtojsS=toxG8uuZ2fDXEYztmMtn_55s4pGW2MBsNMKB3A@mail.gmail.com>

On Thu, Sep 15, 2011 at 07:02:59PM +0530, Felix Varghese wrote:
> Hi,
> 
> I have been trying to communicate with a custom usb device from a
> SAM9G20-EK board using the usb-skeleton.c driver example in the linux
> source. I modified the driver to add my device's vendor and product
> id. The USB device enumerates with two bulk endpoints - one IN and one
> OUT. The (modified) skel driver successfully detects my device and I
> get a minor number allocated. After creating a device file with that
> minor number, I am able to write into the device by typing 'echo "HI"
> > /dev/mydevice'. I verified that this data arrives at my device
> intact. Next, I started sending data back from the device and tried to
> read it back using 'cat /dev/mydevice'. The problem is that read not
> only doesn't work, but also makes the app get totally stuck. Ctrl-C
> doesn't work and I have to reboot the board.
> 
> Some debugging using printk's led me to the following snippet which
> seems to be causing the hang. If I change the wait to a
> wait_for_completion_interruptible, Ctrl-C starts working, but still no
> data is received.
> 
> if (!dev->processed_urb) {
> 		/*
> 		 * the URB hasn't been processed
> 		 * do it now
> 		 */
> 		wait_for_completion(&dev->bulk_in_completion);
> 		dev->bulk_in_copied = 0;
> 		dev->processed_urb = 1;
> 	}
> 
> Oh, btw I am using linux kernel 2.6.39.4. Any Ideas anyone??

Odds are you need to send the proper command to your device in order to
get it to send data to you.  You are hanging, waiting for device to be
sent from the device to userspace, and if no data is sent, then it will
continue to wait.

So, please read the documentation on how to talk to your device and send
the proper USB commands to it and all should be fine.

But note, the usb-skeleton driver really isn't a good framework for a
"real" USB device in that it doesn't expose the proper userspace
interface for it.

What type of device is this you are wishing to write a driver for?  That
will determine the type of interface you need to use, odds are it is not
going to be a simple char device.

greg k-h

  reply	other threads:[~2011-09-16  7:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-15 13:32 Cannot read using USB Skeleton Driver Felix Varghese
2011-09-16  7:01 ` Greg KH [this message]
2011-09-16 11:29   ` Felix Varghese
2011-09-16 14:31     ` Greg KH
2011-09-19  5:43       ` Felix Varghese
2011-09-19 12:38         ` Greg KH
2011-09-19 13:21           ` Felix Varghese
2011-09-19 13:46             ` Greg KH
2011-09-20  3:49               ` Felix Varghese
2011-09-21 13:29                 ` Felix Varghese
2011-09-21 16:00                   ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110916070157.GA7661@kroah.com \
    --to=greg@kroah.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.