Linux drivers cannot be uninstalled after being loaded

Source: Internet
Author: User
Article Title: linux drivers cannot be uninstalled after being loaded. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Sometimes this occurs when writing a driver. After a module is loaded, it cannot be detached or uninstalled. After cat/proc/devices, it is found that the device still occupies the device number, in this case, re-loading the driver module will certainly not succeed. You must restart it to solve the problem. I recently read the book carefully and found that I did not write two function calls in the driver's unmount function, so that the devices applied for or added during module loading were not released or deleted.

Solution:

Step 1: create a directory consistent with the current kernel version in the/lib/modules/directory. For example, if uname-r returns 2.6.31.6, then mkdir-p/lib/modules/2.6.31.6 or "rmmod" appears.: chdir (2.6.31.6): No such file or directory "similar error, and the module is not uninstalled;

Step 2: unmount the cdev_del (struct cdev *) function in function _ exit in the driver module. After the function is called, The unregister_chrdev_region (dev_t devno, unsigned count) is called) the function is released in the driver load function _ init through register_chrdev_region, alloc_chrdev_region, registered master device number. (The cdev_del function and the unregister_chrdev_region function are indispensable );

After the above two steps, the rmmod Module name will not be uninstalled, and cat/proc/devices will not have information about the modules that have been uninstalled, in this way, the module will not be loaded again!

I have encountered this problem. It depends on the module name of a person. It is the same as the device name. If it is the same, rmmod * is used directly *. if ko is not the same, you have to use the rmmod device name. ko, mainly in the module name, and device name.

For the mini2440 Development Board, you need to create/lib/modules/2.6.29.4-Friendlyarm

But you have to check your kernel version, so 2.6.29.4 is not the same as yours. You need

# Uname-r

Check your kernel version and replace it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.