wouldnt it error out if the requested major is already in use ?
yes it errors in fact. That's not the error.
After briefly looking at the new character device system in chapter 3 of
ldd 3rd, I think I got the error :)
Here's your code :
int LinuxTestMemDevice_init(void)
{
int rv = -1;
int devno = MKDEV(1,1);
struct cdev my_cdev;
printk("Skelton Driver, version %s\n", DRIVER_VERSION);
my_cdev.owner=THIS_MODULE;
my_cdev.ops =&my_fops;
rv = cdev_add(&my_cdev,devno,1);
You have to alloc a cdev struct in kernel memory :
struct cdev *my_cdev = cdev_alloc();
my_cdev->owner = THIS_MODULE;
....
In C language, the local variables are pushed on the stack and are not
persistent (only in the function).
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/