* Need help adding platform UIO devices to board
@ 2012-11-28 18:53 Alexander Varnin
2012-11-28 19:03 ` Nicholas Mc Guire
[not found] ` <008d01cdce0d$d6ea04d0$84be0e70$@iii.org.tw>
0 siblings, 2 replies; 5+ messages in thread
From: Alexander Varnin @ 2012-11-28 18:53 UTC (permalink / raw)
To: linux-embedded
Hello!
I'm trying to add UIO device to my system to handle interrupt. But i'm
facing following problem. Docs says, on reading device /dev/uio0 it will
block until interrupt occurs. I've made simple program for test. It
tries to write 1 to enable interrupts.
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
int main()
{
int fd;
char c = 1;
fd = open("/dev/uio0", O_RDONLY);
if (fd<0) {
printf("open error: %d\n", errno);
return 0;
}
printf("fd == %d\n", fd);
int res = write(fd, &c, 1);
if(res<0) {
printf("write error: %d\n", errno);
}
return 0;
}
And as the output i get
fd ==
3
write error: 9
error 9 means "bad file descriptor". File /dev/uio0 is here.
/sys/class/uio/uio0 folder i also. Reading are fails the same way.
Here is how i add device to the system in board specific code
static struct uio_info cross_uio_info = {
.name = "uio_mcross",
.version = "0.1",
.irq = IRQ_EINT14,
.irq_flags = 0,
};
static struct platform_device minipos_cross_device = {
.name = "uio_pdrv_genirq",
.id = -1,
.dev = {
.platform_data = &cross_uio_info,
}
};
and then add platform device.
Please, help.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Need help adding platform UIO devices to board
2012-11-28 18:53 Need help adding platform UIO devices to board Alexander Varnin
@ 2012-11-28 19:03 ` Nicholas Mc Guire
2012-11-29 9:29 ` Alexander Varnin
[not found] ` <008d01cdce0d$d6ea04d0$84be0e70$@iii.org.tw>
1 sibling, 1 reply; 5+ messages in thread
From: Nicholas Mc Guire @ 2012-11-28 19:03 UTC (permalink / raw)
To: Alexander Varnin; +Cc: linux-embedded
On Wed, 28 Nov 2012, Alexander Varnin wrote:
> Hello!
> I'm trying to add UIO device to my system to handle interrupt. But i'm
> facing following problem. Docs says, on reading device /dev/uio0 it will
> block until interrupt occurs. I've made simple program for test. It
> tries to write 1 to enable interrupts.
>
> #include <unistd.h>
> #include <errno.h>
> #include <fcntl.h>
> #include <stdio.h>
>
> int main()
> {
> int fd;
> char c = 1;
> fd = open("/dev/uio0", O_RDONLY);
> if (fd<0) {
> printf("open error: %d\n", errno);
> return 0;
> }
> printf("fd == %d\n", fd);
> int res = write(fd, &c, 1);
> if(res<0) {
> printf("write error: %d\n", errno);
> }
> return 0;
> }
>
open O_RDONLY and then write to it ?
return of 9 == EBADF
man 2 write
EBADF fd is not a valid file descriptor or is not open for writing.
hofrat
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Need help adding platform UIO devices to board
2012-11-28 19:03 ` Nicholas Mc Guire
@ 2012-11-29 9:29 ` Alexander Varnin
2012-11-29 9:47 ` Alexander Varnin
0 siblings, 1 reply; 5+ messages in thread
From: Alexander Varnin @ 2012-11-29 9:29 UTC (permalink / raw)
To: Nicholas Mc Guire; +Cc: linux-embedded
28.11.2012 23:03, Nicholas Mc Guire пишет:
> open O_RDONLY and then write to it ?
>
> return of 9 == EBADF
>
> man 2 write
>
> EBADF fd is not a valid file descriptor or is not open for writing.
>
> hofrat
Yes, sorry, stupid mistake.
But with the correct rights O_RDWR i get error 22 EINVAL both on read
and write.
So problem is still there.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Need help adding platform UIO devices to board
2012-11-29 9:29 ` Alexander Varnin
@ 2012-11-29 9:47 ` Alexander Varnin
0 siblings, 0 replies; 5+ messages in thread
From: Alexander Varnin @ 2012-11-29 9:47 UTC (permalink / raw)
To: Nicholas Mc Guire; +Cc: linux-embedded
29.11.2012 13:29, Alexander Varnin пишет:
> 28.11.2012 23:03, Nicholas Mc Guire пишет:
> Yes, sorry, stupid mistake.
> But with the correct rights O_RDWR i get error 22 EINVAL both on read
> and write.
> So problem is still there.
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-embedded" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Seems to be solved.
Problem was due to lines
if (count != sizeof(s32))
return -EINVAL;
in uio_read kernel function.
I've made read of 4 bytes, and it is ok.
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <008d01cdce0d$d6ea04d0$84be0e70$@iii.org.tw>]
end of thread, other threads:[~2012-11-29 9:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-28 18:53 Need help adding platform UIO devices to board Alexander Varnin
2012-11-28 19:03 ` Nicholas Mc Guire
2012-11-29 9:29 ` Alexander Varnin
2012-11-29 9:47 ` Alexander Varnin
[not found] ` <008d01cdce0d$d6ea04d0$84be0e70$@iii.org.tw>
2012-11-29 9:38 ` Alexander Varnin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).