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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux