[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAB95QAQPRVO=Cd27QthFZ_fDTr=Nvzqzrh0QnFs5475yTx+qJw@mail.gmail.com>
Date: Wed, 27 Apr 2022 15:34:06 +0200
From: Eugene Shalygin <eugene.shalygin@...il.com>
To: Guenter Roeck <linux@...ck-us.net>
Cc: Jean Delvare <jdelvare@...e.com>, linux-hwmon@...r.kernel.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 1/4] hwmon: (asus-ec-sensors) introduce ec_board_info
struct for board data
Maybe I'd better leave a comment why module_platform_driver_probe() is
used as opposed to module_platform_driver()? I think that one would be
more straightforward...
Regards,
Eugene
On Wed, 27 Apr 2022 at 15:20, Guenter Roeck <linux@...ck-us.net> wrote:
>
> On 4/27/22 05:16, Eugene Shalygin wrote:
> >> Sorry, I don't follow that part. One can add "__init" or "__initdata",
> >> as in
> >>
> >> static struct platform_driver asus_ec_sensors_platform_driver __initdata = {
> >>
> >> to mark a function or data structure as __init. I don't think adding
> >> "_probe" to the struct platform_driver variable name does that.
> >>
> >
> > __initdata leads to modpost warning:
> > WARNING: modpost: drivers/hwmon/asus-ec-sensors.o(.exit.text+0x3):
> > Section mismatch in reference from the function cleanup_module() to
> > the variable .init.data:asus_ec_sensors_platform_driver
> > The function __exit cleanup_module() references
> > a variable __initdata asus_ec_sensors_platform_driver.
> > This is often seen when error handling in the exit function
> > uses functionality in the init path.
> > The fix is often to remove the __initdata annotation of
> > asus_ec_sensors_platform_driver so it may be used outside an init section.
> >
> > Compiling without attributes resulted in another message:
> > WARNING: modpost: drivers/hwmon/asus-ec-sensors.o(.data+0x0): Section
> > mismatch in reference from the variable
> > asus_ec_sensors_platform_driver to the function
> > .init.text:asus_ec_probe()
> > The variable asus_ec_sensors_platform_driver references
> > the function __init asus_ec_probe()
> > If the reference is valid then annotate the
> > variable with __init* or __refdata (see linux/init.h) or name the variable:
> > *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
> >
> > Here is why I added the "_probe" suffix.
> >
> > Eugene
>
> Ah yes, I forgot about the exit function. It needs a pointer to
> the structure, which would be gone if marked __initdata.
> Please add a comment to the structure name explaining why
> it is named _probe.
>
> Thanks,
> Guenter
Powered by blists - more mailing lists