[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALNs47us3fuD_Aa3vtK4F0Bz_RK9qyf5mvPoOccJGv+J4t=QjA@mail.gmail.com>
Date: Fri, 20 Sep 2024 17:45:32 +0200
From: Trevor Gross <tmgross@...ch.edu>
To: FUJITA Tomonori <fujita.tomonori@...il.com>
Cc: aliceryhl@...gle.com, netdev@...r.kernel.org,
rust-for-linux@...r.kernel.org, andrew@...n.ch, lkp@...el.com
Subject: Re: [PATCH net] net: phy: qt2025: Fix warning: unused import DeviceId
On Fri, Sep 20, 2024 at 3:54 PM FUJITA Tomonori
<fujita.tomonori@...il.com> wrote:
>
> Hi,
>
> On Thu, 19 Sep 2024 08:17:42 +0200
> Alice Ryhl <aliceryhl@...gle.com> wrote:
>
> > It may be nice to change the macro to always use the expression so
> > that this warning doesn't happen again.
>
> Like the C code does, a valuable is defined only when the driver is
> built as module because the valuable is used to create the information
> for module loading. So the macro adds `#[cfg(MODULE)]` like the
> following:
>
> #[cfg(MODULE)]
> #[no_mangle]
> static __mod_mdio__phydev_device_table: [::kernel::bindings::mdio_device_id; 2] = [
> ::kernel::bindings::mdio_device_id {
> phy_id: 0x00000001,
> phy_id_mask: 0xffffffff,
> },
> ::kernel::bindings::mdio_device_id {
> phy_id: 0,
> phy_id_mask: 0,
> },
> ];
>
> We can remove `#[cfg(MODULE)]` however an unused valuable to added to
> the kernel image when the driver is compiled as built-in. Seems that
> with `#[no_mangle]`, the compiler doesn't give a warning about unused
> valuable though.
>
> Is there a nice way to handle such case?
Maybe just something like the following?
#[cfg(not(MODULE))]
const _: [::kernel::bindings::mdio_device_id; 2] = [ /* .. */ ];
- Trevor
Powered by blists - more mailing lists