[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJsYDVJK3jnHezHRHOdfN9oPgA+cVwuRszXDorObNjVZWF9_1A@mail.gmail.com>
Date: Thu, 8 Dec 2022 14:42:43 +0800
From: Chuanhong Guo <gch981213@...il.com>
To: Lee Jones <lee@...nel.org>
Cc: linux-leds@...r.kernel.org, Pavel Machek <pavel@....cz>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Stanislav Jakubek <stano.jakubek@...il.com>,
Linus Walleij <linus.walleij@...aro.org>,
Shawn Guo <shawnguo@...nel.org>,
Johan Hovold <johan+linaro@...nel.org>,
Bjorn Andersson <andersson@...nel.org>,
Marijn Suijten <marijn.suijten@...ainline.org>,
Sven Schwermer <sven.schwermer@...ruptive-technologies.com>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 3/3] leds: add driver for SPI driven WorldSemi WS2812B
RGB LEDs
Hi!
On Thu, Dec 8, 2022 at 11:00 AM Chuanhong Guo <gch981213@...il.com> 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
Powered by blists - more mailing lists