Using ioctl from with the kernel ???
Hi there,
I use a device driver (/dev/status_led from DENX) to manipulate some frontpanel LEDs from user space via some ioctls.
Now I'd like to access them from the kernel space. How can I do that? AFAIK I can't use fopen and ioctl...
Thanks,
Steven
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Hello Steven,
Your right IOCTL is not applicable for this. You can simply call the driver functions directly. If these functions are called different from different context(s) (like your driver and the IOCTL function) you have to add some protection mechanism. (The code is not reentrant right?) You may try spin_lock() for this job (linux/spinlock.h). If you are calling the functions from interrupt contect too some extra protection is required...
Regards, Stephan
Quoted 16 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Steven Scholz
Sent: Dienstag, 12. November 2002 15:48
To: LinuxPPC
Subject: Using ioctl from with the kernel ???Hi there,
I use a device driver (
/dev/status_ledfrom DENX) to manipulate some frontpanel
LEDs from user space via some ioctls.
Quoted 8 lines
Now I'd like to access them from the kernel space. How can I do that? AFAIK I
can't use fopen and ioctl...Thanks,
Steven
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Hi Stephan,
Quoted 6 lines
Your right IOCTL is not applicable for this. You can simply call the driver functions directly. If these functions are called different from different context(s) (like your driver and the IOCTL function) you have to add some protection mechanism. (The code is not reentrant right?) You may try
spin_lock()for this job (linux/spinlock.h). If you are calling the functions from interrupt contect too some extra protection is required...
Thanks for your reply.
But how could I call the ioctl handler of the driver? I would need some (dummy) inode...
Steven
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
R: Using ioctl from with the kernel ???
Hi,
the driver is linked to the kernel, so global (not static) functions
declared in a driver can be called from the kernel and in particular from another driver, so you can bound the code of your ioctl in a function and call it from the ioctl handler and from the other driver ... using the protection mechanism suggested by Stephan.
Bye.
Stefano.
Quoted 22 lines
-----Messaggio originale-----
Da: [email protected] [mailto:[email protected]]Per conto di Steven Scholz
Inviato: martedi 12 novembre 2002 16.11
A: Stephan Linke
Cc: Linuxppc-Embedded
Oggetto: Re: Using ioctl from with the kernel ???Hi Stephan,
Quoted 1 line
Your right IOCTL is not applicable for this. You can simply
call the driver
Quoted 1 line
functions directly. If these functions are called different
from different
Quoted 1 line
context(s) (like your driver and the IOCTL function) you have
to add some
Quoted 3 lines
protection mechanism. (The code is not reentrant right?) You may try
spin_lock()for this job (linux/spinlock.h). If you are calling the functions from interrupt contect too some extra protection is
Quoted 12 lines
required...
Thanks for your reply.
But how could I call the ioctl handler of the driver? I would need some (dummy) inode...
Steven
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Hi Steve,
If you realy like to do so you can call the LEDDRIVER_ioctl() function directly with some dummy parameter (the one of you LED driver, not the one from user space wich is to be called using an file descriptor). But I would prefer to move the functionality into some extra function and call these function from LEDDRIVER_ioctl() and from OTHERDRIVER_change_led() (like Stefano suggested).
Regards, Stephveano :)
Quoted 9 lines
Hi,
the driver is linked to the kernel, so global (not static) functions
declared in a driver can be called from the kernel and in particular from another driver, so you can bound the code of your ioctl in a function and call it from the ioctl handler and from the other driver ... using the protection mechanism suggested by Stephan.
Quoted 36 lines
Bye.
Stefano.
Quoted 32 lines
-----Messaggio originale-----
Da: [email protected] [mailto:[email protected]]Per conto di Steven Scholz
Inviato: martedi 12 novembre 2002 16.11
A: Stephan Linke
Cc: Linuxppc-Embedded
Oggetto: Re: Using ioctl from with the kernel ???Hi Stephan,
Quoted 1 line
Your right IOCTL is not applicable for this. You can simply
call the driver
Quoted 1 line
functions directly. If these functions are called different
from different
Quoted 1 line
context(s) (like your driver and the IOCTL function) you have
to add some
Quoted 3 lines
protection mechanism. (The code is not reentrant right?) You may try
spin_lock()for this job (linux/spinlock.h). If you are calling the functions from interrupt contect too some extra protection isrequired...
Thanks for your reply.
But how could I call the ioctl handler of the driver? I would need some (dummy) inode...
Steven
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 9 lines · Stephan Linke
Hi Steve,
If you realy like to do so you can call the
LEDDRIVER_ioctl()function directly with some dummy parameter (the one of you LED driver, not the one from user space wich is to be called using an file descriptor). But I would prefer to move the functionality into some extra function and call these function fromLEDDRIVER_ioctl()and fromOTHERDRIVER_change_led()(like Stefano suggested).
Many thanks to you both.
I'll try that!
Good luck,
Steven
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/