Misc Device Driver Template-linux

Source: Internet
Author: User


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 (&AMP;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

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.