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