Andriod Deep Exploration of-hal and Driver Development Eighth chapter reading notes and a little experience

Source: Internet
Author: User

Linux -driven code reuse

There are many ways to reuse Linux-driven code. The standard C program can be used in the way. Put the code you want to reuse in a different file (declared in the header file). If you want to use certain features, include the appropriate header files (this is called static reuse). You can also use another way of dynamic reuse, which means that a linux driver can use the resources (functions, variables, macros, and so on) in the other ← Linux drivers.

Forcibly uninstalling Linux Drivers

If you write a ljnux driver that is logically correct, it can be loaded and unloaded normally, but in some cases, some programs may have an exception condition. the Linux driver may not uninstall properly.

Scenario One: initialization function crashes

Because the initialization function of the Linux driver (through the functions specified by the MODULE_INIT macro) crashes, which causes the initialization function to fail to return to field two, the performance of this situation is the current the Linux driver module is not used by any other Linux driver, but it shows that it has been referenced once.

Scenario Two: The Unload function is blocked   

   rmmod command uninstall linux when driven, the system calls the Unload function (ran over module_exit macro specified function), only the Unload function successfully returns to the elbow, linux rmmod The command will also be blocked. That is, never execute to uninstall linux rmmod

In either case, an unavoidable problem is to get the module struct pointer that represents the Linux driver module to unload . Because the struct module represents information about the Linux driver.   

Buzzer (PWM) Drive

The buzzer is also called PWM, the basic principle is to control the buzzer by pulse to open and stop. This section uses the I/O command to open and stop the PWM .

Experience: The PWM drive is similar to the LED driver implementation process and may be simpler. This chapter demonstrates how to divide a Linux driver into multiple implementation files, using a simpler PWM driver. This chapter focuses on the common use of code reuse for Linux drivers. In addition, a method for forcibly uninstalling Linux drivers is described. This way, you can eliminate the pain of restarting the machine.

My blog address: http://home.cnblogs.com/u/jie617530/

Andriod Deep Exploration of-hal and Driver Development Eighth chapter reading notes and a little experience

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.