LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 3/3] leds-clevo-mail: driver for Clevo mail LED
@ 2007-10-19 18:52 Németh Márton
2007-10-19 20:36 ` Randy Dunlap
0 siblings, 1 reply; 10+ messages in thread
From: Németh Márton @ 2007-10-19 18:52 UTC (permalink / raw)
To: Richard Purdie, Dmitry Torokhov; +Cc: linux-kernel, Rodrigo Pereira
From: Márton Németh <nm127@freemail.hu>
The driver supports the mail LED commonly found on different Clevo notebooks.
The driver access the LED through the i8042 hardware and implements the support for
hardware accelerated blink function.
Signed-off-by: Márton Németh <nm127@freemail.hu>
---
diff -uprN linux-2.6.23.orig/drivers/leds/Kconfig linux-2.6.23/drivers/leds/Kconfig
--- linux-2.6.23.orig/drivers/leds/Kconfig 2007-10-09 22:31:38.000000000 +0200
+++ linux-2.6.23/drivers/leds/Kconfig 2007-10-18 07:20:12.000000000 +0200
@@ -101,6 +101,26 @@ config LEDS_GPIO
outputs. To be useful the particular board must have LEDs
and they must be connected to the GPIO lines.
+config LEDS_CLEVO_MAIL
+ tristate "Mail LED on Clevo notebook (EXPERIMENTAL)"
+ depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL
+ help
+ This driver makes the mail LED accessible from userspace
+ programs through the leds subsystem. This LED can blink at
+ about 0.5Hz and 1Hz.
+
+ This module can drive the mail LED for the following notebooks:
+
+ Clevo D410J
+ Clevo D410V
+ Clevo D400V/D470V (not tested, but might work)
+ Clevo M540N
+ Clevo M5x0N (not tested, but might work)
+ Positivo Mobile (Clevo M5x0V)
+
+ To compile this driver as a module, choose M here: the
+ module will be called leds-clevo-mail.
+
comment "LED Triggers"
config LEDS_TRIGGERS
diff -uprN linux-2.6.23.orig/drivers/leds/leds-clevo-mail.c linux-2.6.23/drivers/leds/leds-clevo-mail.c
--- linux-2.6.23.orig/drivers/leds/leds-clevo-mail.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.23/drivers/leds/leds-clevo-mail.c 2007-10-18 07:17:56.000000000 +0200
@@ -0,0 +1,226 @@
+
+#include <linux/module.h>
+
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/leds.h>
+
+#include <linux/io.h>
+#include <linux/dmi.h>
+
+#include <linux/i8042.h>
+
+
+#define TRUE 1
+#define FALSE 0
+
+#define HANDLED 0
+
+#define CLEVO_MAIL_LED_OFF 0x0084
+#define CLEVO_MAIL_LED_BLINK_1HZ 0x008A
+#define CLEVO_MAIL_LED_BLINK_0_5HZ 0x0083
+
+#define MODULE_FNAME "leds-clevo-mail.c"
+#define DRVNAME "clevo-mail-led"
+#define NO_RESOURCES NULL
+
+MODULE_AUTHOR("Márton Németh <nm127@freemail.hu>");
+MODULE_DESCRIPTION("Clevo mail LED driver");
+MODULE_LICENSE("GPL");
+
+static unsigned int __initdata nodetect;
+module_param_named(nodetect, nodetect, bool, 0);
+MODULE_PARM_DESC(nodetect, "Skip DMI hardware detection");
+
+
+static struct platform_device *pdev;
+
+
+static int __init clevo_mail_led_dmi_callback(struct dmi_system_id *id)
+{
+ printk(KERN_INFO MODULE_FNAME ": '%s' found\n", id->ident);
+ return 1;
+}
+
+/**
+ * struct mail_led_whitelist - List of known good models
+ *
+ * Contains the known good models this driver is compatible with.
+ * When adding a new model try to be as strict as possible. This
+ * makes it possible to keep the false positives (the model is
+ * detected as working, but in reality it is not) as low as
+ * possible.
+ */
+static struct dmi_system_id __initdata mail_led_whitelist[] = {
+ {
+ .callback = clevo_mail_led_dmi_callback,
+ .ident = "Clevo D410J",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "VIA"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "K8N800"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "VT8204B")
+ }
+ },
+ {
+ .callback = clevo_mail_led_dmi_callback,
+ .ident = "Clevo M5x0N",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "M5x0N")
+ }
+ },
+ {
+ .callback = clevo_mail_led_dmi_callback,
+ .ident = "Positivo Mobile",
+ .matches = {
+ DMI_MATCH(DMI_BOARD_VENDOR, "CLEVO Co. "),
+ DMI_MATCH(DMI_BOARD_NAME, "M5X0V "),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Positivo Mobile"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "VT6198")
+ }
+ },
+ {
+ .callback = clevo_mail_led_dmi_callback,
+ .ident = "Clevo D410V",
+ .matches = {
+ DMI_MATCH(DMI_BOARD_VENDOR, "Clevo, Co."),
+ DMI_MATCH(DMI_BOARD_NAME, "D400V/D470V"),
+ DMI_MATCH(DMI_BOARD_VERSION, "SS78B"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "Rev. A1")
+ }
+ },
+ { }
+};
+
+
+static void clevo_mail_led_set(struct led_classdev *led_cdev,
+ enum led_brightness value)
+{
+ if (value == LED_OFF)
+ i8042_command(NULL, CLEVO_MAIL_LED_OFF);
+ else if (value <= LED_HALF)
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ);
+ else
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_1HZ);
+
+}
+
+static int clevo_mail_led_blink(struct led_classdev *led_cdev,
+ int delay_on, int delay_off)
+{
+ int status = -EINVAL;
+
+ if (delay_on == 500 /* ms */ && delay_off == 500 /* ms */) {
+ /* blink the led with 1Hz */
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_1HZ);
+ status = HANDLED;
+
+ } else if (delay_on == 1000 /* ms */ && delay_off == 1000 /* ms */) {
+ /* blink the led with 0.5Hz */
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ);
+ status = HANDLED;
+
+ } else {
+ printk(KERN_DEBUG MODULE_FNAME
+ ": clevo_mail_led_blink(..., %u, %u),"
+ " returning -EINVAL (unsupported)\n",
+ delay_on, delay_off);
+ }
+
+ return status;
+}
+
+
+static struct led_classdev clevo_mail_led = {
+ .name = "clevo::mail",
+ .brightness_set = clevo_mail_led_set,
+ .blink_set = clevo_mail_led_blink,
+};
+
+static int __init clevo_mail_led_probe(struct platform_device *pdev)
+{
+ return led_classdev_register(&pdev->dev, &clevo_mail_led);
+}
+
+static int clevo_mail_led_remove(struct platform_device *pdev)
+{
+ led_classdev_unregister(&clevo_mail_led);
+ return 0;
+}
+
+
+
+#ifdef CONFIG_PM
+static int clevo_mail_led_suspend(struct platform_device *dev,
+ pm_message_t state)
+{
+ led_classdev_suspend(&clevo_mail_led);
+ return 0;
+}
+
+static int clevo_mail_led_resume(struct platform_device *dev)
+{
+ led_classdev_resume(&clevo_mail_led);
+ return 0;
+}
+#endif
+
+static struct platform_driver clevo_mail_led_driver = {
+ .probe = clevo_mail_led_probe,
+ .remove = clevo_mail_led_remove,
+#ifdef CONFIG_PM
+ .suspend = clevo_mail_led_suspend,
+ .resume = clevo_mail_led_resume,
+#endif
+ .driver = {
+ .name = DRVNAME,
+ },
+};
+
+
+static int __init clevo_mail_led_init(void)
+{
+ int error = 0;
+ int count = 0;
+
+ /* Check with the help of DMI if we are running on supported hardware */
+ if (!nodetect) {
+ count = dmi_check_system(mail_led_whitelist);
+ } else {
+ count = 1;
+ printk(KERN_ERR MODULE_FNAME ": Skipping DMI detection. "
+ "If the driver works on your hardware please "
+ "report model and the output of dmidecode in tracker "
+ "at http://sourceforge.net/projects/clevo-mailled/\n");
+ }
+
+ if (!count) {
+ return -ENODEV;
+ }
+
+ pdev = platform_device_register_simple(DRVNAME, -1, NO_RESOURCES, 0);
+ if (!IS_ERR(pdev)) {
+ error = platform_driver_probe(&clevo_mail_led_driver,
+ clevo_mail_led_probe);
+ if (error) {
+ printk(KERN_ERR MODULE_FNAME
+ ": Can't probe platform driver\n");
+ platform_device_unregister(pdev);
+ }
+ } else {
+ error = PTR_ERR(pdev);
+ }
+
+ return error;
+}
+
+static void __exit clevo_mail_led_exit(void)
+{
+ platform_device_unregister(pdev);
+ platform_driver_unregister(&clevo_mail_led_driver);
+
+ clevo_mail_led_set(NULL, LED_OFF);
+}
+
+module_init(clevo_mail_led_init);
+module_exit(clevo_mail_led_exit);
diff -uprN linux-2.6.23.orig/drivers/leds/Makefile linux-2.6.23/drivers/leds/Makefile
--- linux-2.6.23.orig/drivers/leds/Makefile 2007-10-09 22:31:38.000000000 +0200
+++ linux-2.6.23/drivers/leds/Makefile 2007-10-18 07:18:49.000000000 +0200
@@ -17,6 +17,7 @@ obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o
obj-$(CONFIG_LEDS_H1940) += leds-h1940.o
obj-$(CONFIG_LEDS_COBALT) += leds-cobalt.o
obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o
+obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o
# LED Triggers
obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] leds-clevo-mail: driver for Clevo mail LED
2007-10-19 18:52 [PATCH 3/3] leds-clevo-mail: driver for Clevo mail LED Németh Márton
@ 2007-10-19 20:36 ` Randy Dunlap
2007-10-21 12:52 ` Németh Márton
0 siblings, 1 reply; 10+ messages in thread
From: Randy Dunlap @ 2007-10-19 20:36 UTC (permalink / raw)
To: Németh Márton
Cc: Richard Purdie, Dmitry Torokhov, linux-kernel, Rodrigo Pereira
On Fri, 19 Oct 2007 20:52:52 +0200 Németh Márton wrote:
> From: Márton Németh <nm127@freemail.hu>
>
> The driver supports the mail LED commonly found on different Clevo notebooks.
> The driver access the LED through the i8042 hardware and implements the support for
> hardware accelerated blink function.
>
> Signed-off-by: Márton Németh <nm127@freemail.hu>
> ---
> diff -uprN linux-2.6.23.orig/drivers/leds/Kconfig linux-2.6.23/drivers/leds/Kconfig
> --- linux-2.6.23.orig/drivers/leds/Kconfig 2007-10-09 22:31:38.000000000 +0200
> +++ linux-2.6.23/drivers/leds/Kconfig 2007-10-18 07:20:12.000000000 +0200
> @@ -101,6 +101,26 @@ config LEDS_GPIO
> outputs. To be useful the particular board must have LEDs
> and they must be connected to the GPIO lines.
>
> +config LEDS_CLEVO_MAIL
> + tristate "Mail LED on Clevo notebook (EXPERIMENTAL)"
> + depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL
> + help
> + This driver makes the mail LED accessible from userspace
> + programs through the leds subsystem. This LED can blink at
> + about 0.5Hz and 1Hz.
?:
can blink 1 time every 1 or 2 seconds.
> + This module can drive the mail LED for the following notebooks:
> +
> + Clevo D410J
> + Clevo D410V
> + Clevo D400V/D470V (not tested, but might work)
> + Clevo M540N
> + Clevo M5x0N (not tested, but might work)
> + Positivo Mobile (Clevo M5x0V)
> +
> + To compile this driver as a module, choose M here: the
> + module will be called leds-clevo-mail.
> +
> comment "LED Triggers"
>
> config LEDS_TRIGGERS
> diff -uprN linux-2.6.23.orig/drivers/leds/leds-clevo-mail.c linux-2.6.23/drivers/leds/leds-clevo-mail.c
> --- linux-2.6.23.orig/drivers/leds/leds-clevo-mail.c 1970-01-01 01:00:00.000000000 +0100
> +++ linux-2.6.23/drivers/leds/leds-clevo-mail.c 2007-10-18 07:17:56.000000000 +0200
> @@ -0,0 +1,226 @@
> +
> +#include <linux/module.h>
> +
> +#include <linux/platform_device.h>
> +#include <linux/err.h>
> +#include <linux/leds.h>
> +
> +#include <linux/io.h>
> +#include <linux/dmi.h>
> +
> +#include <linux/i8042.h>
> +
> +
> +#define TRUE 1
> +#define FALSE 0
Just use true / false.
> +#define HANDLED 0
> +
> +#define CLEVO_MAIL_LED_OFF 0x0084
> +#define CLEVO_MAIL_LED_BLINK_1HZ 0x008A
> +#define CLEVO_MAIL_LED_BLINK_0_5HZ 0x0083
> +
> +#define MODULE_FNAME "leds-clevo-mail.c"
> +#define DRVNAME "clevo-mail-led"
Kbuild provides KBUILD_BASENAME and KBUILD_MODNAME. Can you use
one of those?
> +#define NO_RESOURCES NULL
Just use NULL.
> +MODULE_AUTHOR("Márton Németh <nm127@freemail.hu>");
> +MODULE_DESCRIPTION("Clevo mail LED driver");
> +MODULE_LICENSE("GPL");
> +
> +
> +static int __init clevo_mail_led_dmi_callback(struct dmi_system_id *id)
> +{
> + printk(KERN_INFO MODULE_FNAME ": '%s' found\n", id->ident);
MODULE_FNAME string looks too long and out of place here.
> + return 1;
> +}
> +
> +/**
/** introduces kernel-doc, but there is no following kernel-doc....,
so just use /*, please.
> + * struct mail_led_whitelist - List of known good models
> + *
> + * Contains the known good models this driver is compatible with.
> + * When adding a new model try to be as strict as possible. This
> + * makes it possible to keep the false positives (the model is
> + * detected as working, but in reality it is not) as low as
> + * possible.
> + */
> +static struct dmi_system_id __initdata mail_led_whitelist[] = {
> + {
...
> + { }
> +};
> +
> +
> +
> +static struct led_classdev clevo_mail_led = {
> + .name = "clevo::mail",
What's the purpose of the "::"?
> + .brightness_set = clevo_mail_led_set,
> + .blink_set = clevo_mail_led_blink,
> +};
> +
> +
> +static struct platform_driver clevo_mail_led_driver = {
> + .probe = clevo_mail_led_probe,
> + .remove = clevo_mail_led_remove,
> +#ifdef CONFIG_PM
> + .suspend = clevo_mail_led_suspend,
> + .resume = clevo_mail_led_resume,
> +#endif
> + .driver = {
> + .name = DRVNAME,
> + },
> +};
We prefer to have clevo_mail_led_susped() and _resume() defined
all the time, so that the above ifdef & endif can go away, so
do more like:
#ifdef CONFIG_PM
/* those functions as you have them */
#else
#define clevo_mail_led_suspend NULL
#define clevo_mail_led_resume NULL
#endif
> +static int __init clevo_mail_led_init(void)
> +{
> + int error = 0;
> + int count = 0;
> +
> + /* Check with the help of DMI if we are running on supported hardware */
> + if (!nodetect) {
> + count = dmi_check_system(mail_led_whitelist);
> + } else {
> + count = 1;
> + printk(KERN_ERR MODULE_FNAME ": Skipping DMI detection. "
> + "If the driver works on your hardware please "
> + "report model and the output of dmidecode in tracker "
> + "at http://sourceforge.net/projects/clevo-mailled/\n");
> + }
> +
> + if (!count) {
> + return -ENODEV;
> + }
Don't use braces on one-statement/one-line "blocks."
> + pdev = platform_device_register_simple(DRVNAME, -1, NO_RESOURCES, 0);
> + if (!IS_ERR(pdev)) {
> + error = platform_driver_probe(&clevo_mail_led_driver,
> + clevo_mail_led_probe);
> + if (error) {
> + printk(KERN_ERR MODULE_FNAME
Use the module logical name, not source file name.
> + ": Can't probe platform driver\n");
> + platform_device_unregister(pdev);
> + }
> + } else {
> + error = PTR_ERR(pdev);
> + }
> +
> + return error;
> +}
---
~Randy
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] leds-clevo-mail: driver for Clevo mail LED
2007-10-19 20:36 ` Randy Dunlap
@ 2007-10-21 12:52 ` Németh Márton
2007-10-21 12:55 ` Németh Márton
0 siblings, 1 reply; 10+ messages in thread
From: Németh Márton @ 2007-10-21 12:52 UTC (permalink / raw)
To: Randy Dunlap
Cc: Richard Purdie, Dmitry Torokhov, linux-kernel, Rodrigo Pereira
Randy Dunlap wrote:
> On Fri, 19 Oct 2007 20:52:52 +0200 Németh Márton wrote:
>
>> From: Márton Németh <nm127@freemail.hu>
>>
>> The driver supports the mail LED commonly found on different Clevo notebooks.
>> The driver access the LED through the i8042 hardware and implements the support for
>> hardware accelerated blink function.
>>
>> Signed-off-by: Márton Németh <nm127@freemail.hu>
>> ---
>> diff -uprN linux-2.6.23.orig/drivers/leds/Kconfig linux-2.6.23/drivers/leds/Kconfig
>> --- linux-2.6.23.orig/drivers/leds/Kconfig 2007-10-09 22:31:38.000000000 +0200
>> +++ linux-2.6.23/drivers/leds/Kconfig 2007-10-18 07:20:12.000000000 +0200
>> @@ -101,6 +101,26 @@ config LEDS_GPIO
>> outputs. To be useful the particular board must have LEDs
>> and they must be connected to the GPIO lines.
>>
>> +config LEDS_CLEVO_MAIL
>> + tristate "Mail LED on Clevo notebook (EXPERIMENTAL)"
>> + depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL
>> + help
>> + This driver makes the mail LED accessible from userspace
>> + programs through the leds subsystem. This LED can blink at
>> + about 0.5Hz and 1Hz.
>
> ?:
> can blink 1 time every 1 or 2 seconds.
It has three modes, I'll try to explain this in more detail in my next patch version.
>
>> + This module can drive the mail LED for the following notebooks:
>> +
>> + Clevo D410J
>> + Clevo D410V
>> + Clevo D400V/D470V (not tested, but might work)
>> + Clevo M540N
>> + Clevo M5x0N (not tested, but might work)
>> + Positivo Mobile (Clevo M5x0V)
>> +
>> + To compile this driver as a module, choose M here: the
>> + module will be called leds-clevo-mail.
>> +
> comment "LED Triggers"
>
> config LEDS_TRIGGERS
I'll document the led trigger extension in more detail in the next
version of the "[PATCH 2/3] leds-clevo-mail: hw accelerated LED blink extension",
in drivers/leds/Kconfig.
>> +#define TRUE 1
>> +#define FALSE 0
>
> Just use true / false.
I'll delete these #defines.
>> +#define HANDLED 0
>> +
>> +#define CLEVO_MAIL_LED_OFF 0x0084
>> +#define CLEVO_MAIL_LED_BLINK_1HZ 0x008A
>> +#define CLEVO_MAIL_LED_BLINK_0_5HZ 0x0083
>> +
>> +#define MODULE_FNAME "leds-clevo-mail.c"
>> +#define DRVNAME "clevo-mail-led"
>
> Kbuild provides KBUILD_BASENAME and KBUILD_MODNAME. Can you use
> one of those?
I'll use KBUILD_MODNAME instead.
>> +#define NO_RESOURCES NULL
>
> Just use NULL.
I'll delete NO_RESOURCES.
>> +static int __init clevo_mail_led_dmi_callback(struct dmi_system_id *id)
>> +{
>> + printk(KERN_INFO MODULE_FNAME ": '%s' found\n", id->ident);
>
> MODULE_FNAME string looks too long and out of place here.
I'll replace MODULE_FNAME with KBUILD_MODNAME. Is this what you mean?
>> +/**
>
> /** introduces kernel-doc, but there is no following kernel-doc....,
> so just use /*, please.
OK, I'll replace.
>> +static struct led_classdev clevo_mail_led = {
>> + .name = "clevo::mail",
>
> What's the purpose of the "::"?
Here I have the problem that the different laptop models have
different colors of mail LED. So I left out the color and
introduced the type of the LED which is "mail". I'll try to
document this in Documents/leds-class.txt
>> +static struct platform_driver clevo_mail_led_driver = {
>> + .probe = clevo_mail_led_probe,
>> + .remove = clevo_mail_led_remove,
>> +#ifdef CONFIG_PM
>> + .suspend = clevo_mail_led_suspend,
>> + .resume = clevo_mail_led_resume,
>> +#endif
>> + .driver = {
>> + .name = DRVNAME,
>> + },
>> +};
>
> We prefer to have clevo_mail_led_susped() and _resume() defined
> all the time, so that the above ifdef & endif can go away, so
> do more like:
>
> #ifdef CONFIG_PM
> /* those functions as you have them */
> #else
> #define clevo_mail_led_suspend NULL
> #define clevo_mail_led_resume NULL
> #endif
I'll change this to what you proposed.
>> + if (!count) {
>> + return -ENODEV;
>> + }
>
> Don't use braces on one-statement/one-line "blocks."
I'll remove the braces for the on-line expression.
>> + pdev = platform_device_register_simple(DRVNAME, -1, NO_RESOURCES, 0);
>> + if (!IS_ERR(pdev)) {
>> + error = platform_driver_probe(&clevo_mail_led_driver,
>> + clevo_mail_led_probe);
>> + if (error) {
>> + printk(KERN_ERR MODULE_FNAME
>
> Use the module logical name, not source file name.
I'll use KBUILD_MODNAME instead.
> ---
> ~Randy
Márton Németh
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] leds-clevo-mail: driver for Clevo mail LED
2007-10-21 12:52 ` Németh Márton
@ 2007-10-21 12:55 ` Németh Márton
2007-10-23 21:48 ` Richard Purdie
0 siblings, 1 reply; 10+ messages in thread
From: Németh Márton @ 2007-10-21 12:55 UTC (permalink / raw)
To: Randy Dunlap
Cc: Richard Purdie, Dmitry Torokhov, linux-kernel, Rodrigo Pereira
From: Márton Németh <nm127@freemail.hu>
The driver supports the mail LED commonly found on different Clevo notebooks.
The driver access the LED through the i8042 hardware and implements the support for
hardware accelerated blink function.
Signed-off-by: Márton Németh <nm127@freemail.hu>
---
diff -uprN linux-2.6.23.orig/Documentation/leds-class.txt linux-2.6.23/Documentation/leds-class.txt
--- linux-2.6.23.orig/Documentation/leds-class.txt 2007-10-09 22:31:38.000000000 +0200
+++ linux-2.6.23/Documentation/leds-class.txt 2007-10-21 10:45:35.000000000 +0200
@@ -39,7 +39,9 @@ LED Device Naming
Is currently of the form:
-"devicename:colour"
+"devicename:colour" or
+"devicename:colour:type" or
+"devicename::type"
There have been calls for LED properties such as colour to be exported as
individual led class attributes. As a solution which doesn't incur as much
diff -uprN linux-2.6.23.orig/drivers/leds/Kconfig linux-2.6.23/drivers/leds/Kconfig
--- linux-2.6.23.orig/drivers/leds/Kconfig 2007-10-09 22:31:38.000000000 +0200
+++ linux-2.6.23/drivers/leds/Kconfig 2007-10-21 12:04:50.000000000 +0200
@@ -101,6 +101,39 @@ config LEDS_GPIO
outputs. To be useful the particular board must have LEDs
and they must be connected to the GPIO lines.
+config LEDS_CLEVO_MAIL
+ tristate "Mail LED on Clevo notebook (EXPERIMENTAL)"
+ depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL
+ help
+ This driver makes the mail LED accessible from userspace
+ programs through the leds subsystem. This LED have three
+ known mode: off, blink at 0.5Hz and blink at 1Hz.
+
+ The driver supports two kinds of interface: using ledtrig-timer
+ or through /sys/class/leds/clevo::mail/brightness. As this LED
+ cannot change it's brightness it blinks instead. The brightness
+ value 0 means off, 1..127 means blink at 0.5Hz and 128..255 means
+ blink at 1Hz.
+
+ Example to start blink at 0.5Hz:
+ echo 1 >/sys/class/leds/clevo::mail/brightness
+ - or -
+ echo timer >/sys/class/leds/clevo::mail/trigger
+ echo 1000 >/sys/class/leds/clevo::mail/delay_on
+ echo 1000 >/sys/class/leds/clevo::mail/delay_off
+
+ This module can drive the mail LED for the following notebooks:
+
+ Clevo D410J
+ Clevo D410V
+ Clevo D400V/D470V (not tested, but might work)
+ Clevo M540N
+ Clevo M5x0N (not tested, but might work)
+ Positivo Mobile (Clevo M5x0V)
+
+ To compile this driver as a module, choose M here: the
+ module will be called leds-clevo-mail.
+
comment "LED Triggers"
config LEDS_TRIGGERS
diff -uprN linux-2.6.23.orig/drivers/leds/leds-clevo-mail.c linux-2.6.23/drivers/leds/leds-clevo-mail.c
--- linux-2.6.23.orig/drivers/leds/leds-clevo-mail.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.23/drivers/leds/leds-clevo-mail.c 2007-10-21 10:49:32.000000000 +0200
@@ -0,0 +1,210 @@
+
+#include <linux/module.h>
+
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/leds.h>
+
+#include <linux/io.h>
+#include <linux/dmi.h>
+
+#include <linux/i8042.h>
+
+#define HANDLED 0
+
+#define CLEVO_MAIL_LED_OFF 0x0084
+#define CLEVO_MAIL_LED_BLINK_1HZ 0x008A
+#define CLEVO_MAIL_LED_BLINK_0_5HZ 0x0083
+
+MODULE_AUTHOR("Márton Németh <nm127@freemail.hu>");
+MODULE_DESCRIPTION("Clevo mail LED driver");
+MODULE_LICENSE("GPL");
+
+static unsigned int __initdata nodetect;
+module_param_named(nodetect, nodetect, bool, 0);
+MODULE_PARM_DESC(nodetect, "Skip DMI hardware detection");
+
+static struct platform_device *pdev;
+
+static int __init clevo_mail_led_dmi_callback(struct dmi_system_id *id)
+{
+ printk(KERN_INFO KBUILD_MODNAME ": '%s' found\n", id->ident);
+ return 1;
+}
+
+/*
+ * struct mail_led_whitelist - List of known good models
+ *
+ * Contains the known good models this driver is compatible with.
+ * When adding a new model try to be as strict as possible. This
+ * makes it possible to keep the false positives (the model is
+ * detected as working, but in reality it is not) as low as
+ * possible.
+ */
+static struct dmi_system_id __initdata mail_led_whitelist[] = {
+ {
+ .callback = clevo_mail_led_dmi_callback,
+ .ident = "Clevo D410J",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "VIA"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "K8N800"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "VT8204B")
+ }
+ },
+ {
+ .callback = clevo_mail_led_dmi_callback,
+ .ident = "Clevo M5x0N",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "M5x0N")
+ }
+ },
+ {
+ .callback = clevo_mail_led_dmi_callback,
+ .ident = "Positivo Mobile",
+ .matches = {
+ DMI_MATCH(DMI_BOARD_VENDOR, "CLEVO Co. "),
+ DMI_MATCH(DMI_BOARD_NAME, "M5X0V "),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Positivo Mobile"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "VT6198")
+ }
+ },
+ {
+ .callback = clevo_mail_led_dmi_callback,
+ .ident = "Clevo D410V",
+ .matches = {
+ DMI_MATCH(DMI_BOARD_VENDOR, "Clevo, Co."),
+ DMI_MATCH(DMI_BOARD_NAME, "D400V/D470V"),
+ DMI_MATCH(DMI_BOARD_VERSION, "SS78B"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "Rev. A1")
+ }
+ },
+ { }
+};
+
+static void clevo_mail_led_set(struct led_classdev *led_cdev,
+ enum led_brightness value)
+{
+ if (value == LED_OFF)
+ i8042_command(NULL, CLEVO_MAIL_LED_OFF);
+ else if (value <= LED_HALF)
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ);
+ else
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_1HZ);
+
+}
+
+static int clevo_mail_led_blink(struct led_classdev *led_cdev,
+ int delay_on, int delay_off)
+{
+ int status = -EINVAL;
+
+ if (delay_on == 500 /* ms */ && delay_off == 500 /* ms */) {
+ /* blink the led with 1Hz */
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_1HZ);
+ status = HANDLED;
+
+ } else if (delay_on == 1000 /* ms */ && delay_off == 1000 /* ms */) {
+ /* blink the led with 0.5Hz */
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ);
+ status = HANDLED;
+
+ } else {
+ printk(KERN_DEBUG KBUILD_MODNAME
+ ": clevo_mail_led_blink(..., %u, %u),"
+ " returning -EINVAL (unsupported)\n",
+ delay_on, delay_off);
+ }
+
+ return status;
+}
+
+static struct led_classdev clevo_mail_led = {
+ .name = "clevo::mail",
+ .brightness_set = clevo_mail_led_set,
+ .blink_set = clevo_mail_led_blink,
+};
+
+static int __init clevo_mail_led_probe(struct platform_device *pdev)
+{
+ return led_classdev_register(&pdev->dev, &clevo_mail_led);
+}
+
+static int clevo_mail_led_remove(struct platform_device *pdev)
+{
+ led_classdev_unregister(&clevo_mail_led);
+ return 0;
+}
+
+#ifdef CONFIG_PM
+static int clevo_mail_led_suspend(struct platform_device *dev,
+ pm_message_t state)
+{
+ led_classdev_suspend(&clevo_mail_led);
+ return 0;
+}
+
+static int clevo_mail_led_resume(struct platform_device *dev)
+{
+ led_classdev_resume(&clevo_mail_led);
+ return 0;
+}
+#else
+#define clevo_mail_led_suspend NULL
+#define clevo_mail_led_resume NULL
+#endif
+
+static struct platform_driver clevo_mail_led_driver = {
+ .probe = clevo_mail_led_probe,
+ .remove = clevo_mail_led_remove,
+ .suspend = clevo_mail_led_suspend,
+ .resume = clevo_mail_led_resume,
+ .driver = {
+ .name = KBUILD_MODNAME,
+ },
+};
+
+static int __init clevo_mail_led_init(void)
+{
+ int error = 0;
+ int count = 0;
+
+ /* Check with the help of DMI if we are running on supported hardware */
+ if (!nodetect) {
+ count = dmi_check_system(mail_led_whitelist);
+ } else {
+ count = 1;
+ printk(KERN_ERR KBUILD_MODNAME ": Skipping DMI detection. "
+ "If the driver works on your hardware please "
+ "report model and the output of dmidecode in tracker "
+ "at http://sourceforge.net/projects/clevo-mailled/\n");
+ }
+
+ if (!count)
+ return -ENODEV;
+
+ pdev = platform_device_register_simple(KBUILD_MODNAME, -1, NULL, 0);
+ if (!IS_ERR(pdev)) {
+ error = platform_driver_probe(&clevo_mail_led_driver,
+ clevo_mail_led_probe);
+ if (error) {
+ printk(KERN_ERR KBUILD_MODNAME
+ ": Can't probe platform driver\n");
+ platform_device_unregister(pdev);
+ }
+ } else
+ error = PTR_ERR(pdev);
+
+ return error;
+}
+
+static void __exit clevo_mail_led_exit(void)
+{
+ platform_device_unregister(pdev);
+ platform_driver_unregister(&clevo_mail_led_driver);
+
+ clevo_mail_led_set(NULL, LED_OFF);
+}
+
+module_init(clevo_mail_led_init);
+module_exit(clevo_mail_led_exit);
diff -uprN linux-2.6.23.orig/drivers/leds/Makefile linux-2.6.23/drivers/leds/Makefile
--- linux-2.6.23.orig/drivers/leds/Makefile 2007-10-09 22:31:38.000000000 +0200
+++ linux-2.6.23/drivers/leds/Makefile 2007-10-18 18:21:37.000000000 +0200
@@ -17,6 +17,7 @@ obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o
obj-$(CONFIG_LEDS_H1940) += leds-h1940.o
obj-$(CONFIG_LEDS_COBALT) += leds-cobalt.o
obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o
+obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o
# LED Triggers
obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] leds-clevo-mail: driver for Clevo mail LED
2007-10-21 12:55 ` Németh Márton
@ 2007-10-23 21:48 ` Richard Purdie
2007-10-28 11:22 ` Németh Márton
0 siblings, 1 reply; 10+ messages in thread
From: Richard Purdie @ 2007-10-23 21:48 UTC (permalink / raw)
To: Németh Márton
Cc: Randy Dunlap, Dmitry Torokhov, linux-kernel, Rodrigo Pereira
On Sun, 2007-10-21 at 14:55 +0200, Németh Márton wrote:
> diff -uprN linux-2.6.23.orig/Documentation/leds-class.txt linux-2.6.23/Documentation/leds-class.txt
> --- linux-2.6.23.orig/Documentation/leds-class.txt 2007-10-09 22:31:38.000000000 +0200
> +++ linux-2.6.23/Documentation/leds-class.txt 2007-10-21 10:45:35.000000000 +0200
> @@ -39,7 +39,9 @@ LED Device Naming
>
> Is currently of the form:
>
> -"devicename:colour"
> +"devicename:colour" or
> +"devicename:colour:type" or
> +"devicename::type"
Adding a the idea of function here was proposed a while back and we
probably should do that but it needs to be a separate patch and some of
the other drivers probably need tweaking for consistency. I will take
care of this for the next merge window.
> diff -uprN linux-2.6.23.orig/drivers/leds/Kconfig linux-2.6.23/drivers/leds/Kconfig
> --- linux-2.6.23.orig/drivers/leds/Kconfig 2007-10-09 22:31:38.000000000 +0200
> +++ linux-2.6.23/drivers/leds/Kconfig 2007-10-21 12:04:50.000000000 +0200
> @@ -101,6 +101,39 @@ config LEDS_GPIO
> outputs. To be useful the particular board must have LEDs
> and they must be connected to the GPIO lines.
>
> +config LEDS_CLEVO_MAIL
> + tristate "Mail LED on Clevo notebook (EXPERIMENTAL)"
> + depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL
> + help
> + This driver makes the mail LED accessible from userspace
> + programs through the leds subsystem. This LED have three
> + known mode: off, blink at 0.5Hz and blink at 1Hz.
> +
> + The driver supports two kinds of interface: using ledtrig-timer
> + or through /sys/class/leds/clevo::mail/brightness. As this LED
> + cannot change it's brightness it blinks instead. The brightness
> + value 0 means off, 1..127 means blink at 0.5Hz and 128..255 means
> + blink at 1Hz.
Hmm, there really is no way to just turn the LED on? :(
> + Example to start blink at 0.5Hz:
> + echo 1 >/sys/class/leds/clevo::mail/brightness
> + - or -
> + echo timer >/sys/class/leds/clevo::mail/trigger
> + echo 1000 >/sys/class/leds/clevo::mail/delay_on
> + echo 1000 >/sys/class/leds/clevo::mail/delay_off
The Kconfig option shouldn't need to go into this much detail. If we
need this much detail, we should probably enhance the LED documentation
in Documentation/ instead.
> diff -uprN linux-2.6.23.orig/drivers/leds/leds-clevo-mail.c linux-2.6.23/drivers/leds/leds-clevo-mail.c
> --- linux-2.6.23.orig/drivers/leds/leds-clevo-mail.c 1970-01-01 01:00:00.000000000 +0100
> +++ linux-2.6.23/drivers/leds/leds-clevo-mail.c 2007-10-21 10:49:32.000000000 +0200
> @@ -0,0 +1,210 @@
> +
> +#include <linux/module.h>
> +
> +#include <linux/platform_device.h>
> +#include <linux/err.h>
> +#include <linux/leds.h>
> +
> +#include <linux/io.h>
> +#include <linux/dmi.h>
> +
> +#include <linux/i8042.h>
> +
> +#define HANDLED 0
Probably easiest to turn the two references to this into "return 0"
Other than that the driver looks ok and I'm happy to add a version with
the above minor tweaks to the LED tree.
Cheers,
Richard
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] leds-clevo-mail: driver for Clevo mail LED
2007-10-23 21:48 ` Richard Purdie
@ 2007-10-28 11:22 ` Németh Márton
2007-10-31 14:14 ` Richard Purdie
0 siblings, 1 reply; 10+ messages in thread
From: Németh Márton @ 2007-10-28 11:22 UTC (permalink / raw)
To: Richard Purdie
Cc: Randy Dunlap, Dmitry Torokhov, linux-kernel, Rodrigo Pereira
Richard Purdie wrote:
> On Sun, 2007-10-21 at 14:55 +0200, Németh Márton wrote:
>> diff -uprN linux-2.6.23.orig/drivers/leds/Kconfig linux-2.6.23/drivers/leds/Kconfig
>> --- linux-2.6.23.orig/drivers/leds/Kconfig 2007-10-09 22:31:38.000000000 +0200
>> +++ linux-2.6.23/drivers/leds/Kconfig 2007-10-21 12:04:50.000000000 +0200
>> @@ -101,6 +101,39 @@ config LEDS_GPIO
>> outputs. To be useful the particular board must have LEDs
>> and they must be connected to the GPIO lines.
>>
>> +config LEDS_CLEVO_MAIL
>> + tristate "Mail LED on Clevo notebook (EXPERIMENTAL)"
>> + depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL
>> + help
>> + This driver makes the mail LED accessible from userspace
>> + programs through the leds subsystem. This LED have three
>> + known mode: off, blink at 0.5Hz and blink at 1Hz.
>> +
>> + The driver supports two kinds of interface: using ledtrig-timer
>> + or through /sys/class/leds/clevo::mail/brightness. As this LED
>> + cannot change it's brightness it blinks instead. The brightness
>> + value 0 means off, 1..127 means blink at 0.5Hz and 128..255 means
>> + blink at 1Hz.
>
> Hmm, there really is no way to just turn the LED on? :(
I looked up the printed manual (which can be also found at
ftp://ftp.clevo.com.tw/USRMANUAL/D4x0J/D4x0J_CUG.zip ), page 9 contains
the following information:
LED Power & Communication Indicators:
Icon | Color | Description
-----+------------------+-----------------------------------------------
Mail | Blinking Green & | New mail has arrived
LED | Orange |
+------------------+-----------------------------------------------
| Fast Blinking | New mail has arrived from users defined
| Green & Orange | in the Special Group in the Auto Mail Checker
+------------------+-----------------------------------------------
| Green | The (optional) Wireless LAN module is On
+------------------+-----------------------------------------------
| Orange | The (optional) Bluetooth module is On
+------------------+-----------------------------------------------
| Half Orange/ | Both the (optional) Wireless LAN and Bluetooth
| Half Green | modules are On (see sidebar)
-----+------------------+-----------------------------------------------
Unfortunately I do not have these optional modules so I never saw the LED
just on without blinking. I don't know if there is any hardware limitation
turning on the LED without the optional modules.
I will send a new patch collection which addresses the other mentioned topics.
Márton Németh
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] leds-clevo-mail: driver for Clevo mail LED
2007-10-28 11:22 ` Németh Márton
@ 2007-10-31 14:14 ` Richard Purdie
0 siblings, 0 replies; 10+ messages in thread
From: Richard Purdie @ 2007-10-31 14:14 UTC (permalink / raw)
To: Németh Márton
Cc: Randy Dunlap, Dmitry Torokhov, linux-kernel, Rodrigo Pereira
On Sun, 2007-10-28 at 12:22 +0100, Németh Márton wrote:
> Richard Purdie wrote:
> > Hmm, there really is no way to just turn the LED on? :(
>
> Unfortunately I do not have these optional modules so I never saw the LED
> just on without blinking. I don't know if there is any hardware limitation
> turning on the LED without the optional modules.
Ok, if we don't know how to do it or even if its possible, so be it. If
you ever do find out please do update the driver.
> I will send a new patch collection which addresses the other mentioned topics.
Thanks, I've applied the patches although I've rewritten the second one
to update the drivers with LED names that don't match the naming
convention. They'll appear in the led git tree and hence -mm.
Thanks,
Richard
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] leds-clevo-mail: driver for Clevo mail LED
2007-07-17 10:18 Németh Márton
2007-07-17 13:20 ` Dmitry Torokhov
@ 2007-07-17 18:13 ` Németh Márton
1 sibling, 0 replies; 10+ messages in thread
From: Németh Márton @ 2007-07-17 18:13 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Richard Purdie, linux-input, linux-kernel, Rodrigo Pereira
From: Márton Németh <nm127@freemail.hu>
The driver supports the mail LED commonly found on different Clevo notebooks.
The driver access the LED through the i8042 hardware and implements the support for
hardware accelerated blink function.
Signed-off-by: Márton Németh <nm127@freemail.hu>
---
diff -uprN linux-2.6.22.orig/drivers/leds/Kconfig linux-2.6.22/drivers/leds/Kconfig
--- linux-2.6.22.orig/drivers/leds/Kconfig 2007-07-09 01:32:17.000000000 +0200
+++ linux-2.6.22/drivers/leds/Kconfig 2007-07-17 10:52:43.000000000 +0200
@@ -95,6 +95,26 @@ config LEDS_COBALT
help
This option enables support for the front LED on Cobalt Server
+config LEDS_CLEVO_MAIL
+ tristate "Mail LED on Clevo notebook (EXPERIMENTAL)"
+ depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL
+ help
+ This driver makes the mail LED accessible from userspace
+ programs through the leds subsystem. This LED can blink at
+ about 0.5Hz and 1Hz.
+
+ This module can drive the mail LED for the following notebooks:
+
+ Clevo D410J
+ Clevo D410V
+ Clevo D400V/D470V (not tested, but might work)
+ Clevo M540N
+ Clevo M5x0N (not tested, but might work)
+ Positivo Mobile (Clevo M5x0V)
+
+ To compile this driver as a module, choose M here: the
+ module will be called leds-clevo-mail.
+
comment "LED Triggers"
config LEDS_TRIGGERS
diff -uprN linux-2.6.22.orig/drivers/leds/leds-clevo-mail.c linux-2.6.22/drivers/leds/leds-clevo-mail.c
--- linux-2.6.22.orig/drivers/leds/leds-clevo-mail.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.22/drivers/leds/leds-clevo-mail.c 2007-07-17 17:53:34.000000000 +0200
@@ -0,0 +1,226 @@
+
+#include <linux/module.h>
+
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/leds.h>
+
+#include <linux/io.h>
+#include <linux/dmi.h>
+
+#include <linux/i8042.h>
+
+
+#define TRUE 1
+#define FALSE 0
+
+#define HANDLED 0
+
+#define CLEVO_MAIL_LED_OFF 0x0084
+#define CLEVO_MAIL_LED_BLINK_1HZ 0x008A
+#define CLEVO_MAIL_LED_BLINK_0_5HZ 0x0083
+
+#define MODULE_FNAME "leds-clevo-mail.c"
+#define DRVNAME "clevo-mail-led"
+#define NO_RESOURCES NULL
+
+MODULE_AUTHOR("Márton Németh <nm127@freemail.hu>");
+MODULE_DESCRIPTION("Clevo mail LED driver");
+MODULE_LICENSE("GPL");
+
+static unsigned int __initdata nodetect;
+module_param_named(nodetect, nodetect, bool, 0);
+MODULE_PARM_DESC(nodetect, "Skip DMI hardware detection");
+
+
+static struct platform_device *pdev;
+
+
+static int __init clevo_mail_led_dmi_callback(struct dmi_system_id *id)
+{
+ printk(KERN_INFO MODULE_FNAME ": '%s' found\n", id->ident);
+ return 1;
+}
+
+/**
+ * struct mail_led_whitelist - List of known good models
+ *
+ * Contains the known good models this driver is compatible with.
+ * When adding a new model try to be as strict as possible. This
+ * makes it possible to keep the false positives (the model is
+ * detected as working, but in reality it is not) as low as
+ * possible.
+ */
+static struct dmi_system_id __initdata mail_led_whitelist[] = {
+ {
+ .callback = clevo_mail_led_dmi_callback,
+ .ident = "Clevo D410J",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "VIA"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "K8N800"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "VT8204B")
+ }
+ },
+ {
+ .callback = clevo_mail_led_dmi_callback,
+ .ident = "Clevo M5x0N",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "M5x0N")
+ }
+ },
+ {
+ .callback = clevo_mail_led_dmi_callback,
+ .ident = "Positivo Mobile",
+ .matches = {
+ DMI_MATCH(DMI_BOARD_VENDOR, "CLEVO Co. "),
+ DMI_MATCH(DMI_BOARD_NAME, "M5X0V "),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Positivo Mobile"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "VT6198")
+ }
+ },
+ {
+ .callback = clevo_mail_led_dmi_callback,
+ .ident = "Clevo D410V",
+ .matches = {
+ DMI_MATCH(DMI_BOARD_VENDOR, "Clevo, Co."),
+ DMI_MATCH(DMI_BOARD_NAME, "D400V/D470V"),
+ DMI_MATCH(DMI_BOARD_VERSION, "SS78B"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "Rev. A1")
+ }
+ },
+ { }
+};
+
+
+static void clevo_mail_led_set(struct led_classdev *led_cdev,
+ enum led_brightness value)
+{
+ if (value == LED_OFF)
+ i8042_command(NULL, CLEVO_MAIL_LED_OFF);
+ else if (value <= LED_HALF)
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ);
+ else
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_1HZ);
+
+}
+
+static int clevo_mail_led_blink(struct led_classdev *led_cdev,
+ int delay_on, int delay_off)
+{
+ int status = -EINVAL;
+
+ if (delay_on == 500 /* ms */ && delay_off == 500 /* ms */) {
+ /* blink the led with 1Hz */
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_1HZ);
+ status = HANDLED;
+
+ } else if (delay_on == 1000 /* ms */ && delay_off == 1000 /* ms */) {
+ /* blink the led with 0.5Hz */
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ);
+ status = HANDLED;
+
+ } else {
+ printk(KERN_DEBUG MODULE_FNAME
+ ": clevo_mail_led_blink(..., %u, %u),"
+ " returning -EINVAL (unsupported)\n",
+ delay_on, delay_off);
+ }
+
+ return status;
+}
+
+
+static struct led_classdev clevo_mail_led = {
+ .name = "clevo::mail",
+ .brightness_set = clevo_mail_led_set,
+ .blink_set = clevo_mail_led_blink,
+};
+
+static int __init clevo_mail_led_probe(struct platform_device *pdev)
+{
+ return led_classdev_register(&pdev->dev, &clevo_mail_led);
+}
+
+static int clevo_mail_led_remove(struct platform_device *pdev)
+{
+ led_classdev_unregister(&clevo_mail_led);
+ return 0;
+}
+
+
+
+#ifdef CONFIG_PM
+static int clevo_mail_led_suspend(struct platform_device *dev,
+ pm_message_t state)
+{
+ led_classdev_suspend(&clevo_mail_led);
+ return 0;
+}
+
+static int clevo_mail_led_resume(struct platform_device *dev)
+{
+ led_classdev_resume(&clevo_mail_led);
+ return 0;
+}
+#endif
+
+static struct platform_driver clevo_mail_led_driver = {
+ .probe = clevo_mail_led_probe,
+ .remove = clevo_mail_led_remove,
+#ifdef CONFIG_PM
+ .suspend = clevo_mail_led_suspend,
+ .resume = clevo_mail_led_resume,
+#endif
+ .driver = {
+ .name = DRVNAME,
+ },
+};
+
+
+static int __init clevo_mail_led_init(void)
+{
+ int error = 0;
+ int count = 0;
+
+ /* Check with the help of DMI if we are running on supported hardware */
+ if (!nodetect) {
+ count = dmi_check_system(mail_led_whitelist);
+ } else {
+ count = 1;
+ printk(KERN_ERR MODULE_FNAME ": Skipping DMI detection. "
+ "If the driver works on your hardware please "
+ "report model and the output of dmidecode in tracker "
+ "at http://sourceforge.net/projects/clevo-mailled/\n");
+ }
+
+ if (!count) {
+ return -ENODEV;
+ }
+
+ pdev = platform_device_register_simple(DRVNAME, -1, NO_RESOURCES, 0);
+ if (!IS_ERR(pdev)) {
+ error = platform_driver_probe(&clevo_mail_led_driver,
+ clevo_mail_led_probe);
+ if (error) {
+ printk(KERN_ERR MODULE_FNAME
+ ": Can't probe platform driver\n");
+ platform_device_unregister(pdev);
+ }
+ } else {
+ error = PTR_ERR(pdev);
+ }
+
+ return error;
+}
+
+static void __exit clevo_mail_led_exit(void)
+{
+ platform_device_unregister(pdev);
+ platform_driver_unregister(&clevo_mail_led_driver);
+
+ clevo_mail_led_set(NULL, LED_OFF);
+}
+
+module_init(clevo_mail_led_init);
+module_exit(clevo_mail_led_exit);
diff -uprN linux-2.6.22.orig/drivers/leds/Makefile linux-2.6.22/drivers/leds/Makefile
--- linux-2.6.22.orig/drivers/leds/Makefile 2007-07-09 01:32:17.000000000 +0200
+++ linux-2.6.22/drivers/leds/Makefile 2007-07-17 10:52:43.000000000 +0200
@@ -16,6 +16,7 @@ obj-$(CONFIG_LEDS_NET48XX) += leds-net4
obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o
obj-$(CONFIG_LEDS_H1940) += leds-h1940.o
obj-$(CONFIG_LEDS_COBALT) += leds-cobalt.o
+obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o
# LED Triggers
obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] leds-clevo-mail: driver for Clevo mail LED
2007-07-17 10:18 Németh Márton
@ 2007-07-17 13:20 ` Dmitry Torokhov
2007-07-17 18:13 ` Németh Márton
1 sibling, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2007-07-17 13:20 UTC (permalink / raw)
To: Németh Márton
Cc: Richard Purdie, linux-input, linux-kernel, Rodrigo Pereira
On 7/17/07, Németh Márton <nm127@freemail.hu> wrote:
> +
> +#define TRUE 1
> +#define FALSE 0
> +
> +#define CLEVO_MAIL_LED_OFF 0x0084
> +#define CLEVO_MAIL_LED_BLINK_1HZ 0x008A
> +#define CLEVO_MAIL_LED_BLINK_0_5HZ 0x0083
> +
> +#define MODULE_FNAME "leds-clevo-mail.c"
> +#define DRVNAME "clevo-mail-led"
> +#define NO_RESOURCES NULL
> +
> +#define printk_hint(fmt, args...) \
> + printk(KERN_ERR MODULE_FNAME ": " fmt, ## args)
> +
> +
> +#define printk_dmi(field) \
> + printk(KERN_ERR MODULE_FNAME \
> + ": " # field "=\"%s\"\n", \
> + dmi_get_system_info(field))
> +
> +
> +MODULE_AUTHOR("Márton Németh <nm127@freemail.hu>");
> +MODULE_DESCRIPTION("Clevo mail LED driver");
> +MODULE_LICENSE("GPL");
> +
> +static unsigned int __initdata nodetect;
> +module_param_named(nodetect, nodetect, bool, 0);
> +MODULE_PARM_DESC(nodetect, "Skip DMI hardware detection");
> +
> +
> +static struct platform_device *pdev;
> +
> +
> +static int __init led_dmi_callback(struct dmi_system_id *id) {
Functions are not statements (opening brace placement).
> + printk(KERN_INFO MODULE_FNAME ": '%s' found\n", id->ident);
> + return 1;
> +}
> +
> +/**
> + * struct mail_led_whitelist - List of known good models
> + *
> + * Contains the known good models this driver is compatible with.
> + * When adding a new model try to be as strict as possible. This
> + * makes it possible to keep the false positives (the model is
> + * detected as working, but in reality it is not) as low as
> + * possible.
> + */
> +static struct dmi_system_id __initdata mail_led_whitelist[] = {
> + {
> + .callback = led_dmi_callback,
> + .ident = "Clevo D410J",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "VIA"),
> + DMI_MATCH(DMI_PRODUCT_NAME, "K8N800"),
> + DMI_MATCH(DMI_PRODUCT_VERSION, "VT8204B")
> + }
> + },
> + {
> + .callback = led_dmi_callback,
> + .ident = "Clevo M5x0N",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "M5x0N")
> + }
> + },
> + {
> + .callback = led_dmi_callback,
> + .ident = "Positivo Mobile",
> + .matches = {
> + DMI_MATCH(DMI_BOARD_VENDOR, "CLEVO Co. "),
> + DMI_MATCH(DMI_BOARD_NAME, "M5X0V "),
> + DMI_MATCH(DMI_PRODUCT_NAME, "Positivo Mobile"),
> + DMI_MATCH(DMI_PRODUCT_VERSION, "VT6198")
> + }
> + },
> + {
> + .callback = led_dmi_callback,
> + .ident = "Clevo D410V",
> + .matches = {
> + DMI_MATCH(DMI_BOARD_VENDOR, "Clevo, Co."),
> + DMI_MATCH(DMI_BOARD_NAME, "D400V/D470V"),
> + DMI_MATCH(DMI_BOARD_VERSION, "SS78B"),
> + DMI_MATCH(DMI_PRODUCT_VERSION, "Rev. A1")
> + }
> + },
> + { }
> +};
> +
> +
> +static void clevo_mail_led_set(struct led_classdev *led_cdev,
> + enum led_brightness value)
> +{
> + if (value == LED_OFF) {
> + i8042_command(NULL, CLEVO_MAIL_LED_OFF);
> + } else if (value <= LED_HALF) {
> + i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ);
> + } else {
> + i8042_command(NULL, CLEVO_MAIL_LED_BLINK_1HZ);
> + }
> +
I think general preference is not to use braces for single-line bodies.
> +}
> +
> +static int clevo_mail_led_blink(struct led_classdev *led_cdev,
> + int delay_on, int delay_off)
> +{
> + int supported = 0;
> +
> + if (delay_on == 500 /* ms */ && delay_off == 500 /* ms */) {
> + /* blink the led with 1Hz */
> + i8042_command(NULL, CLEVO_MAIL_LED_BLINK_1HZ);
> + supported = 1;
> +
> + } else if (delay_on == 1000 /* ms */ && delay_off == 1000 /* ms */) {
> + /* blink the led with 0.5Hz */
> + i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ);
> + supported = 1;
> +
> + } else {
> + printk(KERN_DEBUG MODULE_FNAME
> + ": clevo_mail_led_blink(..., %u, %u),"
> + " returning 0 (unsupported)\n", delay_on, delay_off);
> + }
> +
> + return supported;
Please return 0/-EINVAL.
> +}
> +
> +
> +static struct led_classdev clevo_mail_led = {
> + .name = "clevo::mail",
> + .brightness_set = clevo_mail_led_set,
> + .blink_set = clevo_mail_led_blink,
> +};
> +
> +static int __init clevo_mail_led_probe(struct platform_device *pdev)
> +{
> + int error;
> +
> + printk(KERN_DEBUG MODULE_FNAME ": probe()\n");
> +
Use pr_debug here or just kill it - it will litter users dmesgs.
> + error = led_classdev_register(&pdev->dev, &clevo_mail_led);
> + return error;
> +}
> +
> +static int clevo_mail_led_remove(struct platform_device *pdev)
> +{
> +
> + printk(KERN_DEBUG MODULE_FNAME ": remove()\n");
> +
> + led_classdev_unregister(&clevo_mail_led);
> + return 0;
> +}
> +
> +
> +
> +#ifdef CONFIG_PM
> +static int clevo_mail_led_suspend(struct platform_device *dev,
> + pm_message_t state)
> +{
> + led_classdev_suspend(&clevo_mail_led);
> + return 0;
> +}
> +
> +static int clevo_mail_led_resume(struct platform_device *dev)
> +{
> + led_classdev_resume(&clevo_mail_led);
> + return 0;
> +}
> +#endif
> +
> +static struct platform_driver clevo_mail_led_driver = {
> + .probe = clevo_mail_led_probe,
> + .remove = clevo_mail_led_remove,
> +#ifdef CONFIG_PM
> + .suspend = clevo_mail_led_suspend,
> + .resume = clevo_mail_led_resume,
> +#endif
> + .driver = {
> + .name = DRVNAME,
> + },
> +};
> +
> +
> +static __init void print_hints(void)
> +{
> + if (!nodetect) {
> + printk_hint("Current hardware not supported:\n");
> + } else {
> + printk_hint("Current hardware is:\n");
> + }
> + printk_dmi(DMI_BIOS_VENDOR);
> + printk_dmi(DMI_BIOS_VERSION);
> + printk_dmi(DMI_BIOS_DATE);
> + printk_dmi(DMI_SYS_VENDOR);
> + printk_dmi(DMI_PRODUCT_NAME);
> + printk_dmi(DMI_PRODUCT_VERSION);
> + printk_dmi(DMI_PRODUCT_SERIAL);
> + printk_dmi(DMI_BOARD_VENDOR);
> + printk_dmi(DMI_BOARD_NAME);
> + printk_dmi(DMI_BOARD_VERSION);
> + if (!nodetect) {
> + printk_hint("Try 'nodetect' module parameter.\n");
> + }
> + printk_hint("If this driver is working with your hardware, report\n");
> + printk_hint("it through the Tracker at\n");
> + printk_hint("http://sourceforge.net/projects/clevo-mailled/ in\n");
> + printk_hint("order your laptop model can be added to the detection.\n");
> + printk_hint("Please make sure to include in the report\n");
> + printk_hint(" - all lines starting with \"%s\"\n", MODULE_FNAME);
> + printk_hint(" - the product model of the laptop and\n");
> + printk_hint(" - the color of the mail led.\n");
> +}
> +
> +static int __init led_init(void)
clevo_led_init just to be consistent with the rest of the driver?
> +{
> + int error = 0;
> + int count = 0;
> +
> + /* Check with the help of DMI if we are running on supported hardware */
> + if (!nodetect) {
> + count = dmi_check_system(mail_led_whitelist);
> + }
> + if (!count) {
> + print_hints();
I really don't want to see that dissertation on my box. Normally we
silently return if DMI data does not match. User has an option to
'force' loading the module. In that case I'd say something like
'Forcing module load. If the driver works on your hardware please
report in tracker at http://sourceforge.net/projects/clevo-mailled/"
--
Dmitry
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/3] leds-clevo-mail: driver for Clevo mail LED
@ 2007-07-17 10:18 Németh Márton
2007-07-17 13:20 ` Dmitry Torokhov
2007-07-17 18:13 ` Németh Márton
0 siblings, 2 replies; 10+ messages in thread
From: Németh Márton @ 2007-07-17 10:18 UTC (permalink / raw)
To: Richard Purdie, Dmitry Torokhov
Cc: linux-input, linux-kernel, Rodrigo Pereira
From: Márton Németh <nm127@freemail.hu>
The driver supports the mail LED commonly found on different Clevo notebooks.
The driver access the LED through the i8042 hardware and implements the support for
hardware accelerated blink function.
Signed-off-by: Márton Németh <nm127@freemail.hu>
---
diff -uprN linux-2.6.22.orig/drivers/leds/Kconfig linux-2.6.22/drivers/leds/Kconfig
--- linux-2.6.22.orig/drivers/leds/Kconfig 2007-07-09 01:32:17.000000000 +0200
+++ linux-2.6.22/drivers/leds/Kconfig 2007-07-16 20:54:36.000000000 +0200
@@ -95,6 +95,26 @@ config LEDS_COBALT
help
This option enables support for the front LED on Cobalt Server
+config LEDS_CLEVO_MAIL
+ tristate "Mail LED on Clevo notebook (EXPERIMENTAL)"
+ depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL
+ help
+ This driver makes the mail LED accessible from userspace
+ programs through the leds subsystem. This LED can blink at
+ about 0.5Hz and 1Hz.
+
+ This module can drive the mail LED for the following notebooks:
+
+ Clevo D410J
+ Clevo D410V
+ Clevo D400V/D470V (not tested, but might work)
+ Clevo M540N
+ Clevo M5x0N (not tested, but might work)
+ Positivo Mobile (Clevo M5x0V)
+
+ To compile this driver as a module, choose M here: the
+ module will be called leds-clevo-mail.
+
comment "LED Triggers"
config LEDS_TRIGGERS
diff -uprN linux-2.6.22.orig/drivers/leds/leds-clevo-mail.c linux-2.6.22/drivers/leds/leds-clevo-mail.c
--- linux-2.6.22.orig/drivers/leds/leds-clevo-mail.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.22/drivers/leds/leds-clevo-mail.c 2007-07-17 10:47:13.000000000 +0200
@@ -0,0 +1,269 @@
+
+#include <linux/module.h>
+
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/leds.h>
+
+#include <linux/io.h>
+#include <linux/dmi.h>
+
+#include <linux/i8042.h>
+
+
+#define TRUE 1
+#define FALSE 0
+
+#define CLEVO_MAIL_LED_OFF 0x0084
+#define CLEVO_MAIL_LED_BLINK_1HZ 0x008A
+#define CLEVO_MAIL_LED_BLINK_0_5HZ 0x0083
+
+#define MODULE_FNAME "leds-clevo-mail.c"
+#define DRVNAME "clevo-mail-led"
+#define NO_RESOURCES NULL
+
+#define printk_hint(fmt, args...) \
+ printk(KERN_ERR MODULE_FNAME ": " fmt, ## args)
+
+
+#define printk_dmi(field) \
+ printk(KERN_ERR MODULE_FNAME \
+ ": " # field "=\"%s\"\n", \
+ dmi_get_system_info(field))
+
+
+MODULE_AUTHOR("Márton Németh <nm127@freemail.hu>");
+MODULE_DESCRIPTION("Clevo mail LED driver");
+MODULE_LICENSE("GPL");
+
+static unsigned int __initdata nodetect;
+module_param_named(nodetect, nodetect, bool, 0);
+MODULE_PARM_DESC(nodetect, "Skip DMI hardware detection");
+
+
+static struct platform_device *pdev;
+
+
+static int __init led_dmi_callback(struct dmi_system_id *id) {
+ printk(KERN_INFO MODULE_FNAME ": '%s' found\n", id->ident);
+ return 1;
+}
+
+/**
+ * struct mail_led_whitelist - List of known good models
+ *
+ * Contains the known good models this driver is compatible with.
+ * When adding a new model try to be as strict as possible. This
+ * makes it possible to keep the false positives (the model is
+ * detected as working, but in reality it is not) as low as
+ * possible.
+ */
+static struct dmi_system_id __initdata mail_led_whitelist[] = {
+ {
+ .callback = led_dmi_callback,
+ .ident = "Clevo D410J",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "VIA"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "K8N800"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "VT8204B")
+ }
+ },
+ {
+ .callback = led_dmi_callback,
+ .ident = "Clevo M5x0N",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "M5x0N")
+ }
+ },
+ {
+ .callback = led_dmi_callback,
+ .ident = "Positivo Mobile",
+ .matches = {
+ DMI_MATCH(DMI_BOARD_VENDOR, "CLEVO Co. "),
+ DMI_MATCH(DMI_BOARD_NAME, "M5X0V "),
+ DMI_MATCH(DMI_PRODUCT_NAME, "Positivo Mobile"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "VT6198")
+ }
+ },
+ {
+ .callback = led_dmi_callback,
+ .ident = "Clevo D410V",
+ .matches = {
+ DMI_MATCH(DMI_BOARD_VENDOR, "Clevo, Co."),
+ DMI_MATCH(DMI_BOARD_NAME, "D400V/D470V"),
+ DMI_MATCH(DMI_BOARD_VERSION, "SS78B"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "Rev. A1")
+ }
+ },
+ { }
+};
+
+
+static void clevo_mail_led_set(struct led_classdev *led_cdev,
+ enum led_brightness value)
+{
+ if (value == LED_OFF) {
+ i8042_command(NULL, CLEVO_MAIL_LED_OFF);
+ } else if (value <= LED_HALF) {
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ);
+ } else {
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_1HZ);
+ }
+
+}
+
+static int clevo_mail_led_blink(struct led_classdev *led_cdev,
+ int delay_on, int delay_off)
+{
+ int supported = 0;
+
+ if (delay_on == 500 /* ms */ && delay_off == 500 /* ms */) {
+ /* blink the led with 1Hz */
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_1HZ);
+ supported = 1;
+
+ } else if (delay_on == 1000 /* ms */ && delay_off == 1000 /* ms */) {
+ /* blink the led with 0.5Hz */
+ i8042_command(NULL, CLEVO_MAIL_LED_BLINK_0_5HZ);
+ supported = 1;
+
+ } else {
+ printk(KERN_DEBUG MODULE_FNAME
+ ": clevo_mail_led_blink(..., %u, %u),"
+ " returning 0 (unsupported)\n", delay_on, delay_off);
+ }
+
+ return supported;
+}
+
+
+static struct led_classdev clevo_mail_led = {
+ .name = "clevo::mail",
+ .brightness_set = clevo_mail_led_set,
+ .blink_set = clevo_mail_led_blink,
+};
+
+static int __init clevo_mail_led_probe(struct platform_device *pdev)
+{
+ int error;
+
+ printk(KERN_DEBUG MODULE_FNAME ": probe()\n");
+
+ error = led_classdev_register(&pdev->dev, &clevo_mail_led);
+ return error;
+}
+
+static int clevo_mail_led_remove(struct platform_device *pdev)
+{
+
+ printk(KERN_DEBUG MODULE_FNAME ": remove()\n");
+
+ led_classdev_unregister(&clevo_mail_led);
+ return 0;
+}
+
+
+
+#ifdef CONFIG_PM
+static int clevo_mail_led_suspend(struct platform_device *dev,
+ pm_message_t state)
+{
+ led_classdev_suspend(&clevo_mail_led);
+ return 0;
+}
+
+static int clevo_mail_led_resume(struct platform_device *dev)
+{
+ led_classdev_resume(&clevo_mail_led);
+ return 0;
+}
+#endif
+
+static struct platform_driver clevo_mail_led_driver = {
+ .probe = clevo_mail_led_probe,
+ .remove = clevo_mail_led_remove,
+#ifdef CONFIG_PM
+ .suspend = clevo_mail_led_suspend,
+ .resume = clevo_mail_led_resume,
+#endif
+ .driver = {
+ .name = DRVNAME,
+ },
+};
+
+
+static __init void print_hints(void)
+{
+ if (!nodetect) {
+ printk_hint("Current hardware not supported:\n");
+ } else {
+ printk_hint("Current hardware is:\n");
+ }
+ printk_dmi(DMI_BIOS_VENDOR);
+ printk_dmi(DMI_BIOS_VERSION);
+ printk_dmi(DMI_BIOS_DATE);
+ printk_dmi(DMI_SYS_VENDOR);
+ printk_dmi(DMI_PRODUCT_NAME);
+ printk_dmi(DMI_PRODUCT_VERSION);
+ printk_dmi(DMI_PRODUCT_SERIAL);
+ printk_dmi(DMI_BOARD_VENDOR);
+ printk_dmi(DMI_BOARD_NAME);
+ printk_dmi(DMI_BOARD_VERSION);
+ if (!nodetect) {
+ printk_hint("Try 'nodetect' module parameter.\n");
+ }
+ printk_hint("If this driver is working with your hardware, report\n");
+ printk_hint("it through the Tracker at\n");
+ printk_hint("http://sourceforge.net/projects/clevo-mailled/ in\n");
+ printk_hint("order your laptop model can be added to the detection.\n");
+ printk_hint("Please make sure to include in the report\n");
+ printk_hint(" - all lines starting with \"%s\"\n", MODULE_FNAME);
+ printk_hint(" - the product model of the laptop and\n");
+ printk_hint(" - the color of the mail led.\n");
+}
+
+static int __init led_init(void)
+{
+ int error = 0;
+ int count = 0;
+
+ /* Check with the help of DMI if we are running on supported hardware */
+ if (!nodetect) {
+ count = dmi_check_system(mail_led_whitelist);
+ }
+ if (!count) {
+ print_hints();
+ }
+ if (!nodetect && !count) {
+ return -ENODEV;
+ }
+
+ pdev = platform_device_register_simple(DRVNAME, -1, NO_RESOURCES, 0);
+ if (!IS_ERR(pdev)) {
+ error = platform_driver_probe(&clevo_mail_led_driver,
+ clevo_mail_led_probe);
+ if (error) {
+ printk(KERN_ERR MODULE_FNAME
+ ": Can't probe platform driver\n");
+ platform_device_unregister(pdev);
+ }
+ } else {
+ error = PTR_ERR(pdev);
+ }
+
+ return error;
+}
+
+static void __exit led_exit(void)
+{
+ platform_device_unregister(pdev);
+ platform_driver_unregister(&clevo_mail_led_driver);
+
+ clevo_mail_led_set(NULL, LED_OFF);
+
+ printk(KERN_DEBUG MODULE_FNAME ": unloaded\n");
+}
+
+module_init(led_init);
+module_exit(led_exit);
diff -uprN linux-2.6.22.orig/drivers/leds/Makefile linux-2.6.22/drivers/leds/Makefile
--- linux-2.6.22.orig/drivers/leds/Makefile 2007-07-09 01:32:17.000000000 +0200
+++ linux-2.6.22/drivers/leds/Makefile 2007-07-16 20:53:38.000000000 +0200
@@ -16,6 +16,7 @@ obj-$(CONFIG_LEDS_NET48XX) += leds-net4
obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o
obj-$(CONFIG_LEDS_H1940) += leds-h1940.o
obj-$(CONFIG_LEDS_COBALT) += leds-cobalt.o
+obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o
# LED Triggers
obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-10-31 20:24 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-19 18:52 [PATCH 3/3] leds-clevo-mail: driver for Clevo mail LED Németh Márton
2007-10-19 20:36 ` Randy Dunlap
2007-10-21 12:52 ` Németh Márton
2007-10-21 12:55 ` Németh Márton
2007-10-23 21:48 ` Richard Purdie
2007-10-28 11:22 ` Németh Márton
2007-10-31 14:14 ` Richard Purdie
-- strict thread matches above, loose matches on Subject: below --
2007-07-17 10:18 Németh Márton
2007-07-17 13:20 ` Dmitry Torokhov
2007-07-17 18:13 ` Németh Márton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).