Saturday 1 February 2014

Linux Device Driver Program, where the program starts?

I've started to learn linux driver programs, but I'm finding it a little difficult...
I've been studying the i2c driver, and I got quite confused by the entrance of the driver program. Does the driver program starts at the MOUDLUE_INIT() macro?
And I'd also like to know how I can know the process of how the driver program runs. I got the book, Linux Device Driver, but I'm still quite confused. Could you help me? Thanks a lot.
I'll take the i2c driver as an example. There are just so many functions in it, I just wanna know how I can get coordinating relation of the functions in the i2c drivers?

"Linux Device Driver" is a good book but it's old!
Basic example:
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Name and e-mail");
MODULE_DESCRIPTION("my_first_driver");

static int __init insert_mod(void)
{
printk(KERN_INFO "Module constructor");
return 0;
}

static void __exit remove_mod(void)
{
printk(KERN_INFO "Module destructor");
}

module_init(insert_mod);
module_exit(remove_mod);
An up-to-date tutorial, really well written, is "Linux Device Drivers Series"

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More