public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Samu Onkalo <samu.p.onkalo@nokia.com>
Cc: rpurdie@linux.intel.com, linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCHv2 1/4] leds: driver for National Semiconductor LP5521 chip
Date: Tue, 5 Oct 2010 15:02:56 -0700	[thread overview]
Message-ID: <20101005150256.7769a8c7.akpm@linux-foundation.org> (raw)
In-Reply-To: <1285751405-22039-2-git-send-email-samu.p.onkalo@nokia.com>

On Wed, 29 Sep 2010 12:10:02 +0300
Samu Onkalo <samu.p.onkalo@nokia.com> wrote:

> +#define cdev_to_led(c)		container_of(c, struct lp5521_led, cdev)
> +#define engine_to_lp5521(eng)	container_of((eng), struct lp5521_chip, \
> +						engines[(eng)->id - 1])
> +#define led_to_lp5521(led)	container_of((led), struct lp5521_chip, \
> +						leds[(led)->id])

It would be better if these were implemented as C functions.  That would
make them cqearer, cleaner and more type-safe (container_of uses
typecasts in a way which makes it possible to misuse).

Also that would fix the bug which cdev_to_led(foo++) adds.

Similar improvements can be made to the other driver.  Also
SHIFT_MASK() and LE_ACTIVE() could become regular old lower-case C
functions, I think.


  reply	other threads:[~2010-10-05 22:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-29  9:10 [PATCHv2 0/4] Led driver support for LP5521 and LP5523 chips Samu Onkalo
2010-09-29  9:10 ` [PATCHv2 1/4] leds: driver for National Semiconductor LP5521 chip Samu Onkalo
2010-10-05 22:02   ` Andrew Morton [this message]
2010-09-29  9:10 ` [PATCHv2 2/4] leds: Driver for National Semiconductors LP5523 chip Samu Onkalo
2010-09-29  9:10 ` [PATCHv2 3/4] leds: Update LP552x support Kconfig and Makefile Samu Onkalo
2010-09-29  9:10 ` [PATCHv2 4/4] Documentation: led drivers lp5521 and lp5523 Samu Onkalo
2010-10-05 22:03 ` [PATCHv2 0/4] Led driver support for LP5521 and LP5523 chips Andrew Morton

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=20101005150256.7769a8c7.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rpurdie@linux.intel.com \
    --cc=samu.p.onkalo@nokia.com \
    /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