From: Florian Fainelli Date: Fri, 11 May 2007 09:57:01 +0000 (+0000) Subject: LED driver update X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5d6df5babeba26af21bcbf23b8700bb970e050fc;p=librecmc%2Flibrecmc.git LED driver update SVN-Revision: 7180 --- diff --git a/target/linux/adm5120-2.6/files/drivers/char/adm5120_gpio.c b/target/linux/adm5120-2.6/files/drivers/char/adm5120_gpio.c index 6fccfb029e..090c53a25a 100644 --- a/target/linux/adm5120-2.6/files/drivers/char/adm5120_gpio.c +++ b/target/linux/adm5120-2.6/files/drivers/char/adm5120_gpio.c @@ -2,57 +2,51 @@ * ADM5120 LED (GPIO) driver * * Copyright (C) Jeroen Vreeken (pe1rxq@amsat.org), 2005 + * Copyright (C) OpenWrt.org, Florian Fainelli , 2007 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. */ -#include -#include #include -#include -#include +#include +#include +#include -#define LED_MINOR 151 #define GPIO_IO ((unsigned long *)0xb20000b8) -static ssize_t adm5120_led_write(struct file *file, const char __user *data, - size_t len, loff_t *ppos) +static void adm5120_led_set(struct led_classdev *led_cdev, enum led_brightness brightness) { - unsigned char val; - - if (!len || get_user(val, data)) - return -EFAULT; - *GPIO_IO=(*GPIO_IO & 0x00ffffff) | (val<<24); - return 1; + if (brightness) + *GPIO_IO=(*GPIO_IO & 0x00ffffff) | (brightness << 24); + else + *GPIO_IO=(*GPIO_IO & 0x00ffffff) | (0 << 24); } -static struct file_operations adm5120_led_fops = { - .owner = THIS_MODULE, - .write = adm5120_led_write, -}; - -static struct miscdevice adm5120_led_device = { - LED_MINOR, - "led", - &adm5120_led_fops, +static struct led_classdev adm5120_gpio_led = { + .name = "adm5120:led", + .brightness_set = adm5120_led_set, }; static int __init adm5120_led_init(void) { - printk(KERN_INFO "ADM5120 LED & GPIO driver\n"); - if (misc_register(&adm5120_led_device)) { - printk(KERN_WARNING "Couldn't register device %d\n", LED_MINOR); - return -EBUSY; - } - return 0; + int ret = led_classdev_register(NULL, &adm5120_gpio_led); + + if (ret < 0) + printk(KERN_WARNING "adm5120: unable to register LED device\n"); + + return ret; } static void __exit adm5120_led_exit(void) { - misc_deregister(&adm5120_led_device); + led_classdev_unregister(&adm5120_gpio_led); } module_init(adm5120_led_init); module_exit(adm5120_led_exit); -MODULE_DESCRIPTION("ADM5120 LED and GPIO driver"); -MODULE_AUTHOR("Jeroen Vreeken"); +MODULE_DESCRIPTION("ADM5120 LED driver"); +MODULE_AUTHOR("Jeroen Vreeken, OpenWrt.org"); MODULE_LICENSE("GPL");