Adding new driver in Linux 2.6 - read fails with -1
Jenkins, Clive
Clive.Jenkins at xerox.com
Fri Jan 18 22:22:51 EST 2008
> From: linuxppc-embedded-bounces+clive.jenkins=xerox.com at ozlabs.org
> [mailto:linuxppc-embedded-bounces+clive.jenkins=xerox.com at ozlabs.org]
> On Behalf Of Ramkumar J
> Sent: 18 January 2008 10:54
> To: linuxppc-embedded at ozlabs.org
> Subject: Adding new driver in Linux 2.6 - read fails with -1
>
> Hi All,
>
> I m using the Linux 2.6(2.6.23-rc2) from Grants for ML-403 and
> I tried to add a new driver for a hardware based stream.
> [...] For read, the function doesnt seem calling the drivers read
> routine and exits with -1. [...]
You are not giving enough information -- better to supply the complete
code of driver and application, and the complete kernel log, or put
them on a web/ftp site and supply pointers to them.
When your application calls read(), I cannot see whether you are
passing a valid file descriptor, whether you have opened the device
etc. You say read() returns -1, but you don't give the value of errno
or the error string corresponding to that value. An easy way to get
this is to use perror() in your app.
> /* Wait while empty. */
> while (((status=readl( ((volatile unsigned char*)
remapped_address)
> + 8)&3))==0)
One thing I can see is that you have a "busy wait" loop in your
driver's read method. This will waste CPU time and may hang
indefinitely. Better to use wait-event_interruptible, and check for
termination of the wait by unexpected events such as signals and
changes of power management state.
Clive
More information about the Linuxppc-embedded
mailing list