Re: insmod "Device or resource busy" errors - Regarding

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

 



Thank you very much for your help.

returning "0 on Success" instead of "the positive, non-zero deviceMajorNum on Success" in the hostQueryModuleInit function seems to fix the problem.

I can now do insmod, rmmod. I have tried it many times and it works.

Thanks
Vijay


Daniele Bellucci wrote:

> In function:
>
> int
>  hostQueryModuleInit
>         (
>         void
>         )
>         {
>         if (!pci_present ())
>                 {
>                 printk
>                         (
>                         KERN_WARNING "%s.%d::No pci... Aborting.\n",
>                         __FILE__,
>                         __LINE__
>                         );
>                 return -1;
>                 }
>
>         printk
>                 (
>                 KERN_INFO "After pci_present\n"
>                 );
>
>         //      ... Get dynamic major number from kernel
>         queryMajorNum = register_chrdev (0, "queryd", &queryDevice_fops);
>
>         printk
>                 (
>                 KERN_INFO "After register_chrdev\n"
>                 );
>
>         if (queryMajorNum < 0)
>                 {
>                 printk
>                         (
>                         KERN_ERR "%s.%d::register_chrdev(%s) returned (%d)...\n",
>                         __FILE__,
>                         __LINE__,
>                         "queryd",
>                         queryMajorNum
>                         );
>
>                 return queryMajorNum;
>                 }
>
>         queryDevRegistered = 1;
>
>         //hostQueryRegisterSymbols ();
>
>         printk
>                 (
>                 KERN_INFO "After hostQueryRegisterSymbols:%u \n",
>                 queryMajorNum
>                 );
>
> /*WRONG!!!*/        return queryMajorNum;
> /*MUST BE:          return 0;
>         }
>
> If register_chrdev success you don't need to return queryMajorNum,
> as a general rule:
> if a module intialization function you need to return 0 if everything success, !=0 if fail.
>
> You module is wrong because you register a chrdev, and this success... but because of
> your module_init return !=0 init_module fails without releasing resources allocated.
>
> Hope this help.
>

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[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