Grodriguez
Grodriguez

Reputation: 21995

Opening a device file from a Linux device driver

I have a Linux device driver that needs to manipulate another device driver. Specifically I need to open the device file and call ioctl every now and then.

I have read about sys_open, sys_ioctl etc. but I am not sure if this is the way to go. Is there a better way to do what I want to do?

If I go ahead and use sys_open, sys_ioctl, etc., how do I make sure that the driver for the device I need to open is initialised before my own device driver?

Upvotes: 1

Views: 741

Answers (1)

Sasi V
Sasi V

Reputation: 1094

open + ioctl are good enough. You can use sysfs or procfs both are simple interface and yet powerful

To ensure module load use "request_module" to load the module from your module as mentioned below If you don't want to load from user-space program.

int your_module_init (void)
{
        request_module("<module_name>");

        return 0;
}

Or In case of modprobe create inter-depedancy between modules in such a way the driver module will loaded first.

Upvotes: 1

Related Questions