public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: "Alvin Šipraga" <alsi@bang-olufsen.dk>,
	"Vladimir Oltean" <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Luiz Angelo Daros de Luca" <luizluca@gmail.com>,
	netdev@vger.kernel.org, "kernel test robot" <lkp@intel.com>
Subject: Re: [PATCH] net: dsa: rtl8366rb: Fix compilation problem
Date: Sat, 15 Feb 2025 16:29:26 +0100	[thread overview]
Message-ID: <dce33cab-5d8d-48a2-9554-1ef8c23d35b7@lunn.ch> (raw)
In-Reply-To: <CACRpkdYWXyw6qZBmkf_uN0WcXL3v2iRWbsHjqvmkZ1bWC8Bbmw@mail.gmail.com>

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@lunn.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


  reply	other threads:[~2025-02-15 15:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-14  8:59 [PATCH] net: dsa: rtl8366rb: Fix compilation problem Linus Walleij
2025-02-14 14:06 ` Andrew Lunn
2025-02-15  0:07   ` Linus Walleij
2025-02-15 15:29     ` Andrew Lunn [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-02-14  9:37 Subbaraya Sundeep

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dce33cab-5d8d-48a2-9554-1ef8c23d35b7@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=alsi@bang-olufsen.dk \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=lkp@intel.com \
    --cc=luizluca@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox