Re: [PATCH v3 3/3] leds: add driver for SPI driven WorldSemi WS2812B RGB LEDs

From: Chuanhong Guo
Date: Thu Dec 08 2022 - 01:43:02 EST


Hi!

On Thu, Dec 8, 2022 at 11:00 AM Chuanhong Guo <gch981213@xxxxxxxxx> wrote:
> > You're saving priv in priv. What is this used for?
> >
> > There must be a way around this.
> >
> > In fact, doesn't the spi_set_drvdata() below already save priv to
> > cdev->dev->driver_data? If you move to devm_*() you may have to
> > rename this to dev_set_drvdata() to the APIs are symmetrical, but it's
> > better than this incestuous solution.
>
> I'm saving priv to struct ws2812b_led. This struct is what we got from
> LED callbacks. This struct is an array in ws2812b_priv. In order to
> use the container_of magic I will have to save the index in leds[] array
> to this struct itself.
> Since I'm saving a value anyway, save priv can make my life a lot
> easier than saving an index and calculate priv out of it.

Oh, I didn't notice that I also have access to dev in LED callbacks.
I'll try implementing your suggestions.

--
Regards,
Chuanhong Guo