Re: [PATCHv2 1/4] leds: driver for National Semiconductor LP5521 chip

Andrew Morton
2010-10-05T22:03:04Z

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.