Commit 4d404fd5 authored by Németh Márton's avatar Németh Márton Committed by Richard Purdie

leds: Cleanup various whitespace and code style issues

Break the lines which were more than 80 characters into more
lines; replace SPACEs with TABs; correct ident at switch-case;
change character encoding from ISO-8859-2 to UTF-8.

The order of the functions in led-triggers.c changed in order
the similar functions can still be together under titles
"Used by LED Class", "LED Trigger Interface" and "Simple
LED Tigger Interface" as was grouped before when exported
with EXPORT_SYMBOL.
Signed-off-by: default avatarMárton Németh <nm127@freemail.hu>
Signed-off-by: default avatarRichard Purdie <rpurdie@rpsys.net>
parent 0013b23d
......@@ -19,7 +19,7 @@
#include "leds.h"
DECLARE_RWSEM(leds_list_lock);
LIST_HEAD(leds_list);
EXPORT_SYMBOL_GPL(leds_list_lock);
LIST_HEAD(leds_list);
EXPORT_SYMBOL_GPL(leds_list);
EXPORT_SYMBOL_GPL(leds_list_lock);
......@@ -29,6 +29,8 @@
static DECLARE_RWSEM(triggers_list_lock);
static LIST_HEAD(trigger_list);
/* Used by LED Class */
ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
......@@ -64,7 +66,7 @@ ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
return -EINVAL;
}
EXPORT_SYMBOL_GPL(led_trigger_store);
ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
char *buf)
......@@ -94,24 +96,7 @@ ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
len += sprintf(len+buf, "\n");
return len;
}
void led_trigger_event(struct led_trigger *trigger,
enum led_brightness brightness)
{
struct list_head *entry;
if (!trigger)
return;
read_lock(&trigger->leddev_list_lock);
list_for_each(entry, &trigger->led_cdevs) {
struct led_classdev *led_cdev;
led_cdev = list_entry(entry, struct led_classdev, trig_list);
led_set_brightness(led_cdev, brightness);
}
read_unlock(&trigger->leddev_list_lock);
}
EXPORT_SYMBOL_GPL(led_trigger_show);
/* Caller must ensure led_cdev->trigger_lock held */
void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger)
......@@ -122,7 +107,8 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger)
if (led_cdev->trigger) {
write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags);
list_del(&led_cdev->trig_list);
write_unlock_irqrestore(&led_cdev->trigger->leddev_list_lock, flags);
write_unlock_irqrestore(&led_cdev->trigger->leddev_list_lock,
flags);
if (led_cdev->trigger->deactivate)
led_cdev->trigger->deactivate(led_cdev);
led_set_brightness(led_cdev, LED_OFF);
......@@ -136,6 +122,7 @@ void led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger)
}
led_cdev->trigger = trigger;
}
EXPORT_SYMBOL_GPL(led_trigger_set);
void led_trigger_remove(struct led_classdev *led_cdev)
{
......@@ -143,6 +130,7 @@ void led_trigger_remove(struct led_classdev *led_cdev)
led_trigger_set(led_cdev, NULL);
up_write(&led_cdev->trigger_lock);
}
EXPORT_SYMBOL_GPL(led_trigger_remove);
void led_trigger_set_default(struct led_classdev *led_cdev)
{
......@@ -160,6 +148,9 @@ void led_trigger_set_default(struct led_classdev *led_cdev)
up_write(&led_cdev->trigger_lock);
up_read(&triggers_list_lock);
}
EXPORT_SYMBOL_GPL(led_trigger_set_default);
/* LED Trigger Interface */
int led_trigger_register(struct led_trigger *trigger)
{
......@@ -186,26 +177,7 @@ int led_trigger_register(struct led_trigger *trigger)
return 0;
}
void led_trigger_register_simple(const char *name, struct led_trigger **tp)
{
struct led_trigger *trigger;
int err;
trigger = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
if (trigger) {
trigger->name = name;
err = led_trigger_register(trigger);
if (err < 0)
printk(KERN_WARNING "LED trigger %s failed to register"
" (%d)\n", name, err);
} else
printk(KERN_WARNING "LED trigger %s failed to register"
" (no memory)\n", name);
*tp = trigger;
}
EXPORT_SYMBOL_GPL(led_trigger_register);
void led_trigger_unregister(struct led_trigger *trigger)
{
......@@ -226,29 +198,57 @@ void led_trigger_unregister(struct led_trigger *trigger)
}
up_read(&leds_list_lock);
}
EXPORT_SYMBOL_GPL(led_trigger_unregister);
void led_trigger_unregister_simple(struct led_trigger *trigger)
/* Simple LED Tigger Interface */
void led_trigger_event(struct led_trigger *trigger,
enum led_brightness brightness)
{
if (trigger)
led_trigger_unregister(trigger);
kfree(trigger);
struct list_head *entry;
if (!trigger)
return;
read_lock(&trigger->leddev_list_lock);
list_for_each(entry, &trigger->led_cdevs) {
struct led_classdev *led_cdev;
led_cdev = list_entry(entry, struct led_classdev, trig_list);
led_set_brightness(led_cdev, brightness);
}
read_unlock(&trigger->leddev_list_lock);
}
EXPORT_SYMBOL_GPL(led_trigger_event);
/* Used by LED Class */
EXPORT_SYMBOL_GPL(led_trigger_set);
EXPORT_SYMBOL_GPL(led_trigger_remove);
EXPORT_SYMBOL_GPL(led_trigger_set_default);
EXPORT_SYMBOL_GPL(led_trigger_show);
EXPORT_SYMBOL_GPL(led_trigger_store);
void led_trigger_register_simple(const char *name, struct led_trigger **tp)
{
struct led_trigger *trigger;
int err;
/* LED Trigger Interface */
EXPORT_SYMBOL_GPL(led_trigger_register);
EXPORT_SYMBOL_GPL(led_trigger_unregister);
trigger = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
/* Simple LED Tigger Interface */
if (trigger) {
trigger->name = name;
err = led_trigger_register(trigger);
if (err < 0)
printk(KERN_WARNING "LED trigger %s failed to register"
" (%d)\n", name, err);
} else
printk(KERN_WARNING "LED trigger %s failed to register"
" (no memory)\n", name);
*tp = trigger;
}
EXPORT_SYMBOL_GPL(led_trigger_register_simple);
void led_trigger_unregister_simple(struct led_trigger *trigger)
{
if (trigger)
led_trigger_unregister(trigger);
kfree(trigger);
}
EXPORT_SYMBOL_GPL(led_trigger_unregister_simple);
EXPORT_SYMBOL_GPL(led_trigger_event);
MODULE_AUTHOR("Richard Purdie");
MODULE_LICENSE("GPL");
......
......@@ -14,7 +14,7 @@
#define CLEVO_MAIL_LED_BLINK_1HZ 0x008A
#define CLEVO_MAIL_LED_BLINK_0_5HZ 0x0083
MODULE_AUTHOR("Mrton Nmeth <nm127@freemail.hu>");
MODULE_AUTHOR("Márton Németh <nm127@freemail.hu>");
MODULE_DESCRIPTION("Clevo mail LED driver");
MODULE_LICENSE("GPL");
......@@ -103,8 +103,8 @@ static void clevo_mail_led_set(struct led_classdev *led_cdev,
}
static int clevo_mail_led_blink(struct led_classdev *led_cdev,
unsigned long* delay_on,
unsigned long* delay_off)
unsigned long *delay_on,
unsigned long *delay_off)
{
int status = -EINVAL;
......
......@@ -21,7 +21,8 @@
#include <asm/arch/pxa-regs.h>
#include <asm/hardware/scoop.h>
static void corgiled_amber_set(struct led_classdev *led_cdev, enum led_brightness value)
static void corgiled_amber_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
if (value)
GPSR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
......@@ -29,7 +30,8 @@ static void corgiled_amber_set(struct led_classdev *led_cdev, enum led_brightnes
GPCR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE);
}
static void corgiled_green_set(struct led_classdev *led_cdev, enum led_brightness value)
static void corgiled_green_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
if (value)
set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN);
......@@ -53,7 +55,8 @@ static struct led_classdev corgi_green_led = {
static int corgiled_suspend(struct platform_device *dev, pm_message_t state)
{
#ifdef CONFIG_LEDS_TRIGGERS
if (corgi_amber_led.trigger && strcmp(corgi_amber_led.trigger->name, "sharpsl-charge"))
if (corgi_amber_led.trigger &&
strcmp(corgi_amber_led.trigger->name, "sharpsl-charge"))
#endif
led_classdev_suspend(&corgi_amber_led);
led_classdev_suspend(&corgi_green_led);
......
......@@ -27,18 +27,18 @@ void h1940_greenled_set(struct led_classdev *led_dev, enum led_brightness value)
{
switch (value) {
case LED_HALF:
h1940_latch_control(0,H1940_LATCH_LED_FLASH);
s3c2410_gpio_setpin(S3C2410_GPA7,1);
h1940_latch_control(0, H1940_LATCH_LED_FLASH);
s3c2410_gpio_setpin(S3C2410_GPA7, 1);
break;
case LED_FULL:
h1940_latch_control(0,H1940_LATCH_LED_GREEN);
s3c2410_gpio_setpin(S3C2410_GPA7,1);
h1940_latch_control(0, H1940_LATCH_LED_GREEN);
s3c2410_gpio_setpin(S3C2410_GPA7, 1);
break;
default:
case LED_OFF:
h1940_latch_control(H1940_LATCH_LED_FLASH,0);
h1940_latch_control(H1940_LATCH_LED_GREEN,0);
s3c2410_gpio_setpin(S3C2410_GPA7,0);
h1940_latch_control(H1940_LATCH_LED_FLASH, 0);
h1940_latch_control(H1940_LATCH_LED_GREEN, 0);
s3c2410_gpio_setpin(S3C2410_GPA7, 0);
break;
}
}
......@@ -56,18 +56,18 @@ void h1940_redled_set(struct led_classdev *led_dev, enum led_brightness value)
{
switch (value) {
case LED_HALF:
h1940_latch_control(0,H1940_LATCH_LED_FLASH);
s3c2410_gpio_setpin(S3C2410_GPA1,1);
h1940_latch_control(0, H1940_LATCH_LED_FLASH);
s3c2410_gpio_setpin(S3C2410_GPA1, 1);
break;
case LED_FULL:
h1940_latch_control(0,H1940_LATCH_LED_RED);
s3c2410_gpio_setpin(S3C2410_GPA1,1);
h1940_latch_control(0, H1940_LATCH_LED_RED);
s3c2410_gpio_setpin(S3C2410_GPA1, 1);
break;
default:
case LED_OFF:
h1940_latch_control(H1940_LATCH_LED_FLASH,0);
h1940_latch_control(H1940_LATCH_LED_RED,0);
s3c2410_gpio_setpin(S3C2410_GPA1,0);
h1940_latch_control(H1940_LATCH_LED_FLASH, 0);
h1940_latch_control(H1940_LATCH_LED_RED, 0);
s3c2410_gpio_setpin(S3C2410_GPA1, 0);
break;
}
}
......@@ -86,11 +86,11 @@ void h1940_blueled_set(struct led_classdev *led_dev, enum led_brightness value)
{
if (value) {
/* flashing Blue */
h1940_latch_control(0,H1940_LATCH_LED_FLASH);
s3c2410_gpio_setpin(S3C2410_GPA3,1);
h1940_latch_control(0, H1940_LATCH_LED_FLASH);
s3c2410_gpio_setpin(S3C2410_GPA3, 1);
} else {
h1940_latch_control(H1940_LATCH_LED_FLASH,0);
s3c2410_gpio_setpin(S3C2410_GPA3,0);
h1940_latch_control(H1940_LATCH_LED_FLASH, 0);
s3c2410_gpio_setpin(S3C2410_GPA3, 0);
}
}
......
......@@ -17,7 +17,8 @@
#include <asm/hd64461.h>
#include <asm/hp6xx.h>
static void hp6xxled_green_set(struct led_classdev *led_cdev, enum led_brightness value)
static void hp6xxled_green_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
u8 v8;
......@@ -28,7 +29,8 @@ static void hp6xxled_green_set(struct led_classdev *led_cdev, enum led_brightnes
outb(v8 | PKDR_LED_GREEN, PKDR);
}
static void hp6xxled_red_set(struct led_classdev *led_cdev, enum led_brightness value)
static void hp6xxled_red_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
u16 v16;
......
......@@ -21,7 +21,8 @@
#include <asm/arch/pxa-regs.h>
#include <asm/arch/spitz.h>
static void spitzled_amber_set(struct led_classdev *led_cdev, enum led_brightness value)
static void spitzled_amber_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
if (value)
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_ORANGE);
......@@ -29,7 +30,8 @@ static void spitzled_amber_set(struct led_classdev *led_cdev, enum led_brightnes
reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_ORANGE);
}
static void spitzled_green_set(struct led_classdev *led_cdev, enum led_brightness value)
static void spitzled_green_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
if (value)
set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN);
......@@ -53,7 +55,8 @@ static struct led_classdev spitz_green_led = {
static int spitzled_suspend(struct platform_device *dev, pm_message_t state)
{
#ifdef CONFIG_LEDS_TRIGGERS
if (spitz_amber_led.trigger && strcmp(spitz_amber_led.trigger->name, "sharpsl-charge"))
if (spitz_amber_led.trigger &&
strcmp(spitz_amber_led.trigger->name, "sharpsl-charge"))
#endif
led_classdev_suspend(&spitz_amber_led);
led_classdev_suspend(&spitz_green_led);
......
......@@ -41,9 +41,9 @@ void led_trigger_set(struct led_classdev *led_cdev,
struct led_trigger *trigger);
void led_trigger_remove(struct led_classdev *led_cdev);
#else
#define led_trigger_set_default(x) do {} while(0)
#define led_trigger_set(x, y) do {} while(0)
#define led_trigger_remove(x) do {} while(0)
#define led_trigger_set_default(x) do {} while (0)
#define led_trigger_set(x, y) do {} while (0)
#define led_trigger_remove(x) do {} while (0)
#endif
ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment