Re: Associating driver to the existing device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 5/30/05, Tyler <tyler@xxxxxxxx> wrote:
> 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.......


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux