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

From: Andrew Morton
Date: Tue Oct 05 2010 - 18:03:10 EST


On Wed, 29 Sep 2010 12:10:02 +0300
Samu Onkalo <samu.p.onkalo@xxxxxxxxx> 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.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/