1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-28 09:09:42 +02:00

LED driver update

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@7180 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
florian 2007-05-11 09:57:01 +00:00
parent db92693c28
commit d72bd4532f

View File

@ -2,57 +2,51 @@
* ADM5120 LED (GPIO) driver * ADM5120 LED (GPIO) driver
* *
* Copyright (C) Jeroen Vreeken (pe1rxq@amsat.org), 2005 * Copyright (C) Jeroen Vreeken (pe1rxq@amsat.org), 2005
* Copyright (C) OpenWrt.org, Florian Fainelli <florian@openwrt.org>, 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 <linux/autoconf.h>
#include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/miscdevice.h> #include <linux/init.h>
#include <linux/fs.h> #include <linux/platform_device.h>
#include <linux/leds.h>
#define LED_MINOR 151
#define GPIO_IO ((unsigned long *)0xb20000b8) #define GPIO_IO ((unsigned long *)0xb20000b8)
static ssize_t adm5120_led_write(struct file *file, const char __user *data, static void adm5120_led_set(struct led_classdev *led_cdev, enum led_brightness brightness)
size_t len, loff_t *ppos)
{ {
unsigned char val; if (brightness)
*GPIO_IO=(*GPIO_IO & 0x00ffffff) | (brightness << 24);
if (!len || get_user(val, data)) else
return -EFAULT; *GPIO_IO=(*GPIO_IO & 0x00ffffff) | (0 << 24);
*GPIO_IO=(*GPIO_IO & 0x00ffffff) | (val<<24);
return 1;
} }
static struct file_operations adm5120_led_fops = { static struct led_classdev adm5120_gpio_led = {
.owner = THIS_MODULE, .name = "adm5120:led",
.write = adm5120_led_write, .brightness_set = adm5120_led_set,
};
static struct miscdevice adm5120_led_device = {
LED_MINOR,
"led",
&adm5120_led_fops,
}; };
static int __init adm5120_led_init(void) static int __init adm5120_led_init(void)
{ {
printk(KERN_INFO "ADM5120 LED & GPIO driver\n"); int ret = led_classdev_register(NULL, &adm5120_gpio_led);
if (misc_register(&adm5120_led_device)) {
printk(KERN_WARNING "Couldn't register device %d\n", LED_MINOR); if (ret < 0)
return -EBUSY; printk(KERN_WARNING "adm5120: unable to register LED device\n");
}
return 0; return ret;
} }
static void __exit adm5120_led_exit(void) static void __exit adm5120_led_exit(void)
{ {
misc_deregister(&adm5120_led_device); led_classdev_unregister(&adm5120_gpio_led);
} }
module_init(adm5120_led_init); module_init(adm5120_led_init);
module_exit(adm5120_led_exit); module_exit(adm5120_led_exit);
MODULE_DESCRIPTION("ADM5120 LED and GPIO driver"); MODULE_DESCRIPTION("ADM5120 LED driver");
MODULE_AUTHOR("Jeroen Vreeken"); MODULE_AUTHOR("Jeroen Vreeken, OpenWrt.org");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");