Compilation of drivers for hybrid Devices

Source: Internet
Author: User

Hybrid device

Definition:LinUXA diversity of devices that cannot be categorized is defined as a hybrid device., ImageLED, Buttons, etc.All devices are assigned a master device number 10, but each device can select a separate sub-device number.
Use a hybrid DeviceStruct miscdeviceStruct to describe,The hybrid driver can complete all the steps of the character driver by calling misc_register:

 

# Include <Linux/miscdevice. h>

 

Create oneMiscdeviceStruct

Static struct miscdevice MISC = {

. Minor = misc_dynamic_minor,

. Name = device_name,

. Fops = & dev_fops,

};

Register this hybrid device in driver function Initialization

Misc_register (& MISC );

Cancel the device when the driver is detached.

Misc_deregister (& MISC );

 

Hybrid deviceMiscdeviceDescription

MiscdeviceStruct

Struct miscdevice {

Int minor;

Const char * Name;

Const struct file_operations * fops;

Struct list_head list;

Struct device * parent;

Struct device * this_device;

Const char * nodename;

Mode_t mode;

};

Device registration and cancellation

Extern int misc_register (structmiscdevice * MISC );

Extern int misc_deregister (structmiscdevice * MISC );

 

write led Program is driven by a device, Io put the port configuration in device initialization; led control usage IOCTL , for gpio all the operating functions are in

# Include <Mach/gpio-fns.h>

, Such

Voids3c2410_gpio_cfgpin (unsigned int pin, unsigned int function );

Voids3c2410_gpio_setpin (unsigned int pin, unsigned int );

Voids3c2410_gpio_pullup (unsigned int pin, unsigned int );

Unsigned ints3c2410_gpio_getpin (unsigned int pin );

 

WhileGpioThe port is defined in

# Include <Mach/regs-gpio.h>

, Such

S3c2410_gpbcon

S3c2410_gpbdat

S3c2410_gpbup

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.