Idle to have nothing to do, throw a misc drive template to run
#include <linux/kernel.h> #include <linux/module.h> #include <linux/miscdevice.h> #include < linux/fs.h> #include <linux/types.h> #include <linux/moduleparam.h> #include <linux/slab.h># Include <linux/ioctl.h> #include <linux/cdev.h> #include <linux/delay.h> #include <linux/gpio.h > #include <mach/gpio.h> #include <plat/gpio-cfg.h> #define DEVICE_NAME "misc_dev0" Static long misc_dev_ IOCTL (struct file *filp, unsigned int cmd, unsigned long arg) {//Undefinedreturn 0;} static struct File_operations Misc_dev_fops = {. owner= this_module,.unlocked_ioctl= misc_dev_ioctl,}static struct Miscdevice Misc_dev_dev = {. minor= misc_dynamic_minor,.name= device_name,.fops= &misc_dev_fops,}static int __init Misc_dev_init (void) {int ret = -1;/* power of ETH WiFi mic ... */ret = gpio_request (exynos5260_gpx0 (1), "peripheral power C TRL "), if (ret) {PRINTK ("%s:request GPIO%d failed, ret =%d\n ", Device_name, Gpio_request (exynos5260_gpx0 (1), ret)); return ret;} S3c_gpio_cfgpin (exynos5260_gpx0 (1), s3c_gpio_output); Gpio_set_value (exynos5260_gpx0 (1), 1); Misc_register (& Misc_dev_dev);p rintk (device_name "\tinitialized\n"); return ret;} static void __exit misc_dev_exit (void) {int i;misc_deregister (&MISC_DEV_DEV);} Module_init (Misc_dev_init); Module_exit (Misc_dev_exit); Module_license ("GPL"); Module_author ("Morphy Inc.");
Misc Device Driver Template-linux