* Driver on Linux
@ 2003-06-27 17:10 Christophe.LINDHEIMER
2003-06-27 17:24 ` Wolfgang Grandegger
2003-06-30 7:00 ` Samuel Ortiz
0 siblings, 2 replies; 4+ messages in thread
From: Christophe.LINDHEIMER @ 2003-06-27 17:10 UTC (permalink / raw)
To: linuxppc-embedded
Hi.
I am working on a PPC860.
I have developped two drivers.
The driver 2 needs to use functions that are in driver 1.
driver 1 is /dev/visu.
I thought I could make fd=open("/dev/visu", 0) in init of the driver 2 but I
get ooops.
I also need to make something like ioctl(fd, IO_Special... )but the function
ioctl is unknown in the kernel.
What is the right way to work when you need to do that ?
Thanks.
Chris
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Driver on Linux
@ 2003-06-27 17:18 Jean-Denis Boyer
0 siblings, 0 replies; 4+ messages in thread
From: Jean-Denis Boyer @ 2003-06-27 17:18 UTC (permalink / raw)
To: Christophe.LINDHEIMER; +Cc: linuxppc-embedded
> I thought I could make fd=open("/dev/visu", 0) in init of the
> driver 2 but I
> get ooops.
To open a device from kernel mode, you need to:
/* Bypass argument validity check in FS calls. See <asm/uaccess.h> */
mm_segment_t oldfs = get_fs();
set_fs(KERNEL_DS);
fd=open("/dev/visu", 0)
/* Restore argument validity check */
set_fs(oldfs);
> I also need to make something like ioctl(fd, IO_Special...
> )but the function
> ioctl is unknown in the kernel.
To have the ioctl, you should add to the beginning of your source file:
#include <linux/unistd.h>
/* Declare "ioctl" system call */
static inline _syscall3(int,ioctl,int,fd,int,request,void*,arg1)
Regards,
--------------------------------------------
Jean-Denis Boyer, Software Designer
M5T Centre d'Excellence en Télécom Inc.
4283 Garlock Street
Sherbrooke (Québec)
J1L 2C8 CANADA
(819)829-3972 x241
--------------------------------------------
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Driver on Linux
2003-06-27 17:10 Driver on Linux Christophe.LINDHEIMER
@ 2003-06-27 17:24 ` Wolfgang Grandegger
2003-06-30 7:00 ` Samuel Ortiz
1 sibling, 0 replies; 4+ messages in thread
From: Wolfgang Grandegger @ 2003-06-27 17:24 UTC (permalink / raw)
To: Christophe.LINDHEIMER; +Cc: linuxppc-embedded
On 06/27/2003 07:10 PM Christophe.LINDHEIMER@fr•thalesgroup.com wrote:
> Hi.
>
> I am working on a PPC860.
>
> I have developped two drivers.
>
> The driver 2 needs to use functions that are in driver 1.
> driver 1 is /dev/visu.
>
> I thought I could make fd=open("/dev/visu", 0) in init of the driver 2 but I
> get ooops.
For file access within the kernel see for example:
http://www.fenrus.demon.nl/kernel.html
> I also need to make
> I also need to make something like ioctl(fd, IO_Special... )but the function
> ioctl is unknown in the kernel.
>
> What is the right way to work when you need to do that ?
Using file access in the kernel is usually a bad thing. I think it's
easier and more straightforward to provide a small set of exported
kernel functions which the second (driver) module can use.
Hope it helps.
Wolfgang.
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Driver on Linux
2003-06-27 17:10 Driver on Linux Christophe.LINDHEIMER
2003-06-27 17:24 ` Wolfgang Grandegger
@ 2003-06-30 7:00 ` Samuel Ortiz
1 sibling, 0 replies; 4+ messages in thread
From: Samuel Ortiz @ 2003-06-30 7:00 UTC (permalink / raw)
To: Christophe.LINDHEIMER; +Cc: linuxppc-embedded
On Fri, 27 Jun 2003 Christophe.LINDHEIMER@fr•thalesgroup.com wrote:
>
> Hi.
>
> I am working on a PPC860.
>
> I have developped two drivers.
>
> The driver 2 needs to use functions that are in driver 1.
> driver 1 is /dev/visu.
>
> I thought I could make fd=open("/dev/visu", 0) in init of the driver 2 but I
> get ooops.
Kernel file opening is usually considered a very bad idea. If driver 2
needs some of driver 1 functions, then you should consider exporting these
functions from driver 1 (EXPORT(driver1_function);).
Once driver1 is loaded, and thus initialized, any other driver will be
able to call driver 1 exported functions.
Hope this helps,
Samuel.
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-06-30 7:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-27 17:10 Driver on Linux Christophe.LINDHEIMER
2003-06-27 17:24 ` Wolfgang Grandegger
2003-06-30 7:00 ` Samuel Ortiz
-- strict thread matches above, loose matches on Subject: below --
2003-06-27 17:18 Jean-Denis Boyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox