On 5/30/05, Tyler <tyler@xxxxxxxx> wrote:
I am not getting errors.
I understand, what u say........ i wud do this.......
> 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 :)
I am not getting errors.
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).
I understand, what u say........ i wud do this.......