[PATCH v6 11/13] leds: rgb: mt6370: Add MediaTek MT6370 current sink type LED Indicator support
Andy Shevchenko
andy.shevchenko at gmail.com
Tue Jul 26 05:17:44 PDT 2022
On Tue, Jul 26, 2022 at 1:46 PM ChiaEn Wu <peterwu.pub at gmail.com> wrote:
> On Mon, Jul 25, 2022 at 4:41 PM Andy Shevchenko
> <andy.shevchenko at gmail.com> wrote:
...
> > > +struct mt6370_led {
> > > + union {
> > > + struct led_classdev isink;
> > > + struct led_classdev_mc mc;
> > > + };
> >
> > Where is the field that makes union work?
>
> Just for saving memory space.
> Because these led_classdevs do not be used at the same time.
> Or do you think it would be better to rewrite it as follows?
> -------------------------------------------------------------------------------------
> struct mt6370_led {
> struct led_classdev isink;
> struct led_classdev_mc mc;
> struct mt6370_priv *priv;
> u32 default_state;
> u32 index;
> };
> -------------------------------------------------------------------------------------
You obviously didn't get what I'm talking about...
Each union to work properly should have an associated variable that
holds the information of which field of the union is in use. Do you
have such a variable? If not, how does your code know which one to
use? If yes, add a proper comment there.
--
With Best Regards,
Andy Shevchenko
More information about the Linux-mediatek
mailing list