From: j.neuschaefer@gmx.net (Jonathan Neuschäfer)
To: kernelnewbies@lists.kernelnewbies.org
Subject: rev2 - Driver for BlinkM i2c LED module
Date: Sun, 3 Jun 2012 19:32:08 +0200 [thread overview]
Message-ID: <20120603173208.GB2377@debian.debian> (raw)
In-Reply-To: <201206021129.46698.dl9pf@gmx.de>
On Sat, Jun 02, 2012 at 11:29:46AM +0200, Jan-Simon M?ller wrote:
> static const struct {
> char cmdchar;
> u8 cmdbyte;
> u8 nr_args;
> u8 nr_ret;
> u8 dir:2;
> } blinkm_cmds[17] = {
> /* cmdnr, cmdchar, cmdbyte, nr_args, nr_ret, dir */
cmdnr isn't there anymore.
> /* We start hardware transfers which are not to be
> * mixed with other commands. Aquire a lock now. */
> if (mutex_lock_interruptible(&data->update_lock) < 0)
> return -EAGAIN;
>
> /* switch cmd - usually write before reads */
> switch (cmd) {
[...]
> default:
> printk(KERN_INFO "BlinkM: unknown command %d\n", cmd);
> return -1;
You need to unlock the mutex in the error case, too.
Also the -1 looks suspicious to me. When interpreted as -errno it would
be -EPERM on most (or even all) architectures. (according to
include/asm-generic/errno-base.h)
> static int blinkm_led_common_set(struct led_classdev *led_cdev,
> enum led_brightness value, int color)
> {
> /* led_brightness is 0, 127 or 255 - we just use it here as-is */
> struct blinkm_led *led = cdev_to_blmled(led_cdev);
> struct blinkm_data *data = i2c_get_clientdata(led->i2c_client);
> struct blinkm_work *bl_work = kzalloc(sizeof(struct blinkm_work),
> GFP_ATOMIC);
>
> switch (color) {
> case RED:
> data->red = (u8)value;
> break;
> case GREEN:
> data->green = (u8)value;
> break;
> case BLUE:
> data->blue = (u8)value;
> break;
> default:
> printk(KERN_INFO "BlinkM: unknown color.\n");
> return -1;
> }
> /* data->red=(u8)value; we know it fits ... 0..255 */
This comment looks a little misplaced now.
> /* red fade to off */
> data->red = 0xff;
> ret = blinkm_transfer_hw(client, BLM_GO_RGB);
> if (ret < 0)
> printk(KERN_INFO
> "Failure in blinkm_remove ignored. Continuing.\n");
>
> /* off */
> data->red = 0x00;
> data->green = 0x00;
> data->blue = 0x00;
> ret = blinkm_transfer_hw(client, BLM_FADE_RGB);
> if (ret < 0)
> printk(KERN_INFO
> "Failure in blinkm_remove ignored. Continuing.\n");
Did you leave this fading in for testing?
Thanks,
Jonathan Neusch?fer
next prev parent reply other threads:[~2012-06-03 17:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-01 13:45 Driver for BlinkM i2c LED module Jan-Simon Möller
2012-06-01 15:16 ` Jonathan Neuschäfer
2012-06-01 21:45 ` Jan-Simon Möller
2012-06-01 22:09 ` Jonathan Neuschäfer
2012-06-02 9:29 ` rev2 - " Jan-Simon Möller
2012-06-03 17:32 ` Jonathan Neuschäfer [this message]
2012-06-03 20:27 ` Jan-Simon Möller
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=20120603173208.GB2377@debian.debian \
--to=j.neuschaefer@gmx.net \
--cc=kernelnewbies@lists.kernelnewbies.org \
/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 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).