[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <dce33cab-5d8d-48a2-9554-1ef8c23d35b7@lunn.ch>
Date: Sat, 15 Feb 2025 16:29:26 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Linus Walleij <linus.walleij@...aro.org>
Cc: Alvin Šipraga <alsi@...g-olufsen.dk>,
Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Luiz Angelo Daros de Luca <luizluca@...il.com>,
netdev@...r.kernel.org, kernel test robot <lkp@...el.com>
Subject: Re: [PATCH] net: dsa: rtl8366rb: Fix compilation problem
On Sat, Feb 15, 2025 at 01:07:32AM +0100, Linus Walleij wrote:
> On Fri, Feb 14, 2025 at 3:06 PM Andrew Lunn <andrew@...n.ch> wrote:
> > On Fri, Feb 14, 2025 at 09:59:57AM +0100, Linus Walleij wrote:
> > > When the kernel is compiled without LED framework support the
> > > rtl8366rb fails to build like this:
> > >
> > > rtl8366rb.o: in function `rtl8366rb_setup_led':
> > > rtl8366rb.c:953:(.text.unlikely.rtl8366rb_setup_led+0xe8):
> > > undefined reference to `led_init_default_state_get'
> > > rtl8366rb.c:980:(.text.unlikely.rtl8366rb_setup_led+0x240):
> > > undefined reference to `devm_led_classdev_register_ext'
> > >
> > > As this is constantly coming up in different randconfig builds,
> > > bite the bullet and add some nasty ifdefs to rid this issue.
> >
> > At least for DSA drivers, it is more normal to put the LED code into a
> > separate compilation unit and provide stubs for when it is not
> > used. That avoids a lot of nasty #ifdefs. Could you do the same here?
>
> I can pull out *some* code to a separate file like that, but
> some LED-related registers are also accessed when the LED
> framework is disabled, so it would lead to a bit of unnatural
> split between the two files with some always-available
> LED code staying in the main file.
So there is some low level code for basic LED register access which
you need to keep in rtl8366rb.c, and then a layer on top of that for
led_classdev which goes into a file of its own. At first glance, it
does not look too bad, but the devil is in the details.
In the end, you need to make a style call. Is #ifdef better than an
unnatural splitting.
Hummm..
In the example above, you are getting linker errors. So the code at
least compiles, in this example. Rather than #ifdef, can you use
if (IS_ENABLED(CONFIG_LEDS_CLASS)) {
....
}
That looks less ugly, and allows compile testing, which is what we
don't like about #ifdef.
Andrew
Powered by blists - more mailing lists