mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2025-01-05 00:10:14 +02:00
make morse LED trigger available as a package, and fix it to compile with 2.6.23
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@9363 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
07c2f61f37
commit
34047fa1ae
@ -334,6 +334,21 @@ endef
|
|||||||
$(eval $(call KernelPackage,leds-wrap))
|
$(eval $(call KernelPackage,leds-wrap))
|
||||||
|
|
||||||
|
|
||||||
|
define KernelPackage/ledtrig-morse
|
||||||
|
SUBMENU:=$(OTHER_MENU)
|
||||||
|
TITLE:=LED Morse Trigger
|
||||||
|
KCONFIG:=CONFIG_LEDS_TRIGGER_MORSE
|
||||||
|
FILES:=$(LINUX_DIR)/drivers/leds/ledtrig-morse.$(LINUX_KMOD_SUFFIX)
|
||||||
|
AUTOLOAD:=$(call AutoLoad,50,ledtrig-morse)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define KernelPackage/ledtrig-morse/description
|
||||||
|
Kernel module to show morse coded messages on LEDs.
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(call KernelPackage,ledtrig-morse))
|
||||||
|
|
||||||
|
|
||||||
define KernelPackage/nsc-gpio
|
define KernelPackage/nsc-gpio
|
||||||
SUBMENU:=$(OTHER_MENU)
|
SUBMENU:=$(OTHER_MENU)
|
||||||
TITLE:=Natsemi GPIO support
|
TITLE:=Natsemi GPIO support
|
||||||
|
@ -18,9 +18,10 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/version.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/jiffies.h>
|
#include <linux/jiffies.h>
|
||||||
#include <linux/kernel.h>
|
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
@ -88,7 +89,7 @@ static inline unsigned long space_len(struct morse_trig_data *morse_data)
|
|||||||
|
|
||||||
static void morse_timer_function(unsigned long data)
|
static void morse_timer_function(unsigned long data)
|
||||||
{
|
{
|
||||||
struct led_classdev *led_cdev = (struct led_classdev *) data;
|
struct led_classdev *led_cdev = (struct led_classdev *)data;
|
||||||
struct morse_trig_data *morse_data = led_cdev->trigger_data;
|
struct morse_trig_data *morse_data = led_cdev->trigger_data;
|
||||||
unsigned long brightness = LED_OFF;
|
unsigned long brightness = LED_OFF;
|
||||||
unsigned long delay = 0;
|
unsigned long delay = 0;
|
||||||
@ -144,9 +145,8 @@ set_led:
|
|||||||
led_set_brightness(led_cdev, brightness);
|
led_set_brightness(led_cdev, brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t morse_delay_show(struct class_device *dev, char *buf)
|
static ssize_t _morse_delay_show(struct led_classdev *led_cdev, char *buf)
|
||||||
{
|
{
|
||||||
struct led_classdev *led_cdev = class_get_devdata(dev);
|
|
||||||
struct morse_trig_data *morse_data = led_cdev->trigger_data;
|
struct morse_trig_data *morse_data = led_cdev->trigger_data;
|
||||||
|
|
||||||
sprintf(buf, "%lu\n", morse_data->delay);
|
sprintf(buf, "%lu\n", morse_data->delay);
|
||||||
@ -154,10 +154,9 @@ static ssize_t morse_delay_show(struct class_device *dev, char *buf)
|
|||||||
return strlen(buf) + 1;
|
return strlen(buf) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t morse_delay_store(struct class_device *dev, const char *buf,
|
static ssize_t _morse_delay_store(struct led_classdev *led_cdev,
|
||||||
size_t size)
|
const char *buf, size_t size)
|
||||||
{
|
{
|
||||||
struct led_classdev *led_cdev = class_get_devdata(dev);
|
|
||||||
struct morse_trig_data *morse_data = led_cdev->trigger_data;
|
struct morse_trig_data *morse_data = led_cdev->trigger_data;
|
||||||
char *after;
|
char *after;
|
||||||
unsigned long state = simple_strtoul(buf, &after, 10);
|
unsigned long state = simple_strtoul(buf, &after, 10);
|
||||||
@ -176,9 +175,8 @@ static ssize_t morse_delay_store(struct class_device *dev, const char *buf,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t morse_msg_show(struct class_device *dev, char *buf)
|
static ssize_t _morse_msg_show(struct led_classdev *led_cdev, char *buf)
|
||||||
{
|
{
|
||||||
struct led_classdev *led_cdev = class_get_devdata(dev);
|
|
||||||
struct morse_trig_data *morse_data = led_cdev->trigger_data;
|
struct morse_trig_data *morse_data = led_cdev->trigger_data;
|
||||||
|
|
||||||
if (!morse_data->msg)
|
if (!morse_data->msg)
|
||||||
@ -189,10 +187,9 @@ static ssize_t morse_msg_show(struct class_device *dev, char *buf)
|
|||||||
return strlen(buf) + 1;
|
return strlen(buf) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t morse_msg_store(struct class_device *dev, const char *buf,
|
static ssize_t _morse_msg_store(struct led_classdev *led_cdev,
|
||||||
size_t size)
|
const char *buf, size_t size)
|
||||||
{
|
{
|
||||||
struct led_classdev *led_cdev = class_get_devdata(dev);
|
|
||||||
struct morse_trig_data *morse_data = led_cdev->trigger_data;
|
struct morse_trig_data *morse_data = led_cdev->trigger_data;
|
||||||
char *m;
|
char *m;
|
||||||
|
|
||||||
@ -215,9 +212,88 @@ static ssize_t morse_msg_store(struct class_device *dev, const char *buf,
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
|
||||||
|
static ssize_t morse_delay_show(struct device *dev,
|
||||||
|
struct device_attribute *attr, char *buf)
|
||||||
|
{
|
||||||
|
struct led_classdev *led_cdev = dev_get_drvdata(dev);
|
||||||
|
|
||||||
|
return _morse_delay_show(led_cdev, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t morse_delay_store(struct device *dev,
|
||||||
|
struct device_attribute *attr, const char *buf, size_t size)
|
||||||
|
{
|
||||||
|
struct led_classdev *led_cdev = dev_get_drvdata(dev);
|
||||||
|
|
||||||
|
return _morse_delay_store(led_cdev, buf, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t morse_msg_show(struct device *dev,
|
||||||
|
struct device_attribute *attr, char *buf)
|
||||||
|
{
|
||||||
|
struct led_classdev *led_cdev = dev_get_drvdata(dev);
|
||||||
|
|
||||||
|
return _morse_msg_show(led_cdev, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t morse_msg_store(struct device *dev,
|
||||||
|
struct device_attribute *attr, const char *buf, size_t size)
|
||||||
|
{
|
||||||
|
struct led_classdev *led_cdev = dev_get_drvdata(dev);
|
||||||
|
|
||||||
|
return _morse_msg_store(led_cdev, buf, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static DEVICE_ATTR(delay, 0644, morse_delay_show, morse_delay_store);
|
||||||
|
static DEVICE_ATTR(message, 0644, morse_msg_show, morse_msg_store);
|
||||||
|
|
||||||
|
#define led_device_create_file(leddev, attr) \
|
||||||
|
device_create_file(leddev->dev, &dev_attr_ ## attr)
|
||||||
|
#define led_device_remove_file(leddev, attr) \
|
||||||
|
device_remove_file(leddev->dev, &dev_attr_ ## attr)
|
||||||
|
|
||||||
|
#else
|
||||||
|
static ssize_t morse_delay_show(struct class_device *dev, char *buf)
|
||||||
|
{
|
||||||
|
struct led_classdev *led_cdev = class_get_devdata(dev);
|
||||||
|
|
||||||
|
return _morse_delay_show(led_cdev, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t morse_delay_store(struct class_device *dev, const char *buf,
|
||||||
|
size_t size)
|
||||||
|
{
|
||||||
|
struct led_classdev *led_cdev = class_get_devdata(dev);
|
||||||
|
|
||||||
|
return _morse_delay_store(led_cdev, buf, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t morse_msg_show(struct class_device *dev, char *buf)
|
||||||
|
{
|
||||||
|
struct led_classdev *led_cdev = class_get_devdata(dev);
|
||||||
|
|
||||||
|
return _morse_msg_show(led_cdev, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t morse_msg_store(struct class_device *dev, const char *buf,
|
||||||
|
size_t size)
|
||||||
|
{
|
||||||
|
struct led_classdev *led_cdev = class_get_devdata(dev);
|
||||||
|
|
||||||
|
return _morse_msg_store(led_cdev, buf, size);
|
||||||
|
}
|
||||||
|
|
||||||
static CLASS_DEVICE_ATTR(delay, 0644, morse_delay_show, morse_delay_store);
|
static CLASS_DEVICE_ATTR(delay, 0644, morse_delay_show, morse_delay_store);
|
||||||
static CLASS_DEVICE_ATTR(message, 0644, morse_msg_show, morse_msg_store);
|
static CLASS_DEVICE_ATTR(message, 0644, morse_msg_show, morse_msg_store);
|
||||||
|
|
||||||
|
#define led_device_create_file(leddev, attr) \
|
||||||
|
class_device_create_file(leddev->class_dev, &class_device_attr_ ## attr)
|
||||||
|
#define led_device_remove_file(leddev, attr) \
|
||||||
|
class_device_remove_file(leddev->class_dev, &class_device_attr_ ## attr)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
static void morse_trig_activate(struct led_classdev *led_cdev)
|
static void morse_trig_activate(struct led_classdev *led_cdev)
|
||||||
{
|
{
|
||||||
struct morse_trig_data *morse_data;
|
struct morse_trig_data *morse_data;
|
||||||
@ -232,12 +308,10 @@ static void morse_trig_activate(struct led_classdev *led_cdev)
|
|||||||
morse_data->timer.function = morse_timer_function;
|
morse_data->timer.function = morse_timer_function;
|
||||||
morse_data->timer.data = (unsigned long)led_cdev;
|
morse_data->timer.data = (unsigned long)led_cdev;
|
||||||
|
|
||||||
rc = class_device_create_file(led_cdev->class_dev,
|
rc = led_device_create_file(led_cdev, delay);
|
||||||
&class_device_attr_delay);
|
|
||||||
if (rc) goto err;
|
if (rc) goto err;
|
||||||
|
|
||||||
rc = class_device_create_file(led_cdev->class_dev,
|
rc = led_device_create_file(led_cdev, message);
|
||||||
&class_device_attr_message);
|
|
||||||
if (rc) goto err_delay;
|
if (rc) goto err_delay;
|
||||||
|
|
||||||
led_cdev->trigger_data = morse_data;
|
led_cdev->trigger_data = morse_data;
|
||||||
@ -245,8 +319,7 @@ static void morse_trig_activate(struct led_classdev *led_cdev)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
err_delay:
|
err_delay:
|
||||||
class_device_remove_file(led_cdev->class_dev,
|
led_device_remove_file(led_cdev, delay);
|
||||||
&class_device_attr_delay);
|
|
||||||
err:
|
err:
|
||||||
kfree(morse_data);
|
kfree(morse_data);
|
||||||
}
|
}
|
||||||
@ -258,10 +331,8 @@ static void morse_trig_deactivate(struct led_classdev *led_cdev)
|
|||||||
if (!morse_data)
|
if (!morse_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
class_device_remove_file(led_cdev->class_dev,
|
led_device_remove_file(led_cdev, message);
|
||||||
&class_device_attr_message);
|
led_device_remove_file(led_cdev, delay);
|
||||||
class_device_remove_file(led_cdev->class_dev,
|
|
||||||
&class_device_attr_delay);
|
|
||||||
|
|
||||||
del_timer_sync(&morse_data->timer);
|
del_timer_sync(&morse_data->timer);
|
||||||
if (morse_data->msg)
|
if (morse_data->msg)
|
||||||
|
Loading…
Reference in New Issue
Block a user