From: Randy Dunlap <randy.dunlap@oracle.com>
To: "Németh Márton" <nm127@freemail.hu>
Cc: Richard Purdie <rpurdie@rpsys.net>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-kernel@vger.kernel.org, Rodrigo Pereira <rodripe@gmail.com>
Subject: Re: [PATCH 3/3] leds-clevo-mail: driver for Clevo mail LED
Date: Fri, 19 Oct 2007 13:36:07 -0700 [thread overview]
Message-ID: <20071019133607.3419b00a.randy.dunlap@oracle.com> (raw)
In-Reply-To: <4718FD04.3080602@freemail.hu>
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
next prev parent reply other threads:[~2007-10-19 20:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071019133607.3419b00a.randy.dunlap@oracle.com \
--to=randy.dunlap@oracle.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nm127@freemail.hu \
--cc=rodripe@gmail.com \
--cc=rpurdie@rpsys.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.