static const struct file_operations gpioled_fops = {
.owner = THIS_MODULE,
.read = led_read,
.write = led_write,
.open = led_open,
.release = led_close,
.unlocked_ioctl = led_ioctl,
};
static int __init gpioled_init(void)
{
int ret = 0;
if (led->major) {
ret = register_chrdev_region(led->major, GPIOLED_CNT, GPIOLED_NAME);
} else {
ret = alloc_chrdev_region(&led->devid, 0, GPIOLED_CNT, GPIOLED_NAME);
}
led->c_dev.owner = fp->owner;
cdev_init(&led->c_dev, fp);
cdev_add(&led->c_dev,led->devid,GPIOLED_CNT
led->usr_class = class_create(led->c_dev.owner,GPIOLED_NAME);
led->usr_dev = device_create(led->usr_class,led->usr_dev,
led->devid,NULL,GPIOLED_NAME);
ret = gpioled_io_init(&gpioled);
led_timer_init(&gpioled);
return 0;
}
static void __exit gpioled_exit(void)
{
del_timer_sync(&gpioled.timer);
gpio_free(gpioled.pin);
cdev_del(&gpioled.c_dev);
unregister_chrdev_region(gpioled.devid, GPIOLED_CNT);
device_destroy(gpioled.usr_class, gpioled.devid);
class_destroy(gpioled.usr_class);
}
module_init(gpioled_init);
module_exit(gpioled_exit);
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("lala0903");