2023-09-20 10:56:31

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH] mfd: cs42l43: fix defined but not used warnings

On Tue, 05 Sep 2023, zhangshida wrote:

> From: Shida Zhang <[email protected]>
>
> Warnings were generated during compiling for functions like
> cs42l43_*_{resume,suspend}:
>
> ../drivers/mfd/cs42l43.c:1138:12: error: ‘cs42l43_runtime_resume’ defined but not used [-Werror=unused-function]
> 1138 | static int cs42l43_runtime_resume(struct device *dev)
> | ^~~~~~~~~~~~~~~~~~~~~~
> ../drivers/mfd/cs42l43.c:1124:12: error: ‘cs42l43_runtime_suspend’ defined but not used [-Werror=unused-function]
> 1124 | static int cs42l43_runtime_suspend(struct device *dev)
> | ^~~~~~~~~~~~~~~~~~~~~~~
> ../drivers/mfd/cs42l43.c:1106:12: error: ‘cs42l43_resume’ defined but not used [-Werror=unused-function]
> 1106 | static int cs42l43_resume(struct device *dev)
> | ^~~~~~~~~~~~~~
> ../drivers/mfd/cs42l43.c:1076:12: error: ‘cs42l43_suspend’ defined but not used [-Werror=unused-function]
> 1076 | static int cs42l43_suspend(struct device *dev)
>
> Fix it by guarding it with CONFIG_PM/CONFIG_PM_SLEEP.
>
> Reported-by: k2ci <[email protected]>
> Signed-off-by: Shida Zhang <[email protected]>
> ---
> drivers/mfd/cs42l43.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/mfd/cs42l43.c b/drivers/mfd/cs42l43.c
> index 37b23e9bae82..e589a61c118d 100644
> --- a/drivers/mfd/cs42l43.c
> +++ b/drivers/mfd/cs42l43.c
> @@ -1073,6 +1073,7 @@ void cs42l43_dev_remove(struct cs42l43 *cs42l43)
> }
> EXPORT_SYMBOL_NS_GPL(cs42l43_dev_remove, MFD_CS42L43);
>
> +#ifdef CONFIG_PM_SLEEP
> static int cs42l43_suspend(struct device *dev)
> {
> struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
> @@ -1120,7 +1121,9 @@ static int cs42l43_resume(struct device *dev)
>
> return 0;
> }
> +#endif
>
> +#ifdef CONFIG_PM
> static int cs42l43_runtime_suspend(struct device *dev)
> {
> struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
> @@ -1176,6 +1179,7 @@ static int cs42l43_runtime_resume(struct device *dev)
>
> return ret;
> }
> +#endif
>
> EXPORT_NS_GPL_DEV_PM_OPS(cs42l43_pm_ops, MFD_CS42L43) = {
> SET_SYSTEM_SLEEP_PM_OPS(cs42l43_suspend, cs42l43_resume)

I see a bunch of drivers using PM helpers and not many of them are
are being guarded by ugly #ifery. Please find out what they're doing to
solve the same issue and replicate that instead.

Here's a really big hint:

`git log --oneline 02313a90095fb`

--
Lee Jones [李琼斯]


2023-09-21 07:51:09

by Stephen Zhang

[permalink] [raw]
Subject: Re: [PATCH] mfd: cs42l43: fix defined but not used warnings

Lee Jones <[email protected]> 于2023年9月20日周三 17:52写道:
>
> On Tue, 05 Sep 2023, zhangshida wrote:
>
> > From: Shida Zhang <[email protected]>
> >
> > Warnings were generated during compiling for functions like
> > cs42l43_*_{resume,suspend}:
> >
> > ../drivers/mfd/cs42l43.c:1138:12: error: ‘cs42l43_runtime_resume’ defined but not used [-Werror=unused-function]
> > 1138 | static int cs42l43_runtime_resume(struct device *dev)
> > | ^~~~~~~~~~~~~~~~~~~~~~
> > ../drivers/mfd/cs42l43.c:1124:12: error: ‘cs42l43_runtime_suspend’ defined but not used [-Werror=unused-function]
> > 1124 | static int cs42l43_runtime_suspend(struct device *dev)
> > | ^~~~~~~~~~~~~~~~~~~~~~~
> > ../drivers/mfd/cs42l43.c:1106:12: error: ‘cs42l43_resume’ defined but not used [-Werror=unused-function]
> > 1106 | static int cs42l43_resume(struct device *dev)
> > | ^~~~~~~~~~~~~~
> > ../drivers/mfd/cs42l43.c:1076:12: error: ‘cs42l43_suspend’ defined but not used [-Werror=unused-function]
> > 1076 | static int cs42l43_suspend(struct device *dev)
> >
> > Fix it by guarding it with CONFIG_PM/CONFIG_PM_SLEEP.
> >
> > Reported-by: k2ci <[email protected]>
> > Signed-off-by: Shida Zhang <[email protected]>
> > ---
> > drivers/mfd/cs42l43.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/mfd/cs42l43.c b/drivers/mfd/cs42l43.c
> > index 37b23e9bae82..e589a61c118d 100644
> > --- a/drivers/mfd/cs42l43.c
> > +++ b/drivers/mfd/cs42l43.c
> > @@ -1073,6 +1073,7 @@ void cs42l43_dev_remove(struct cs42l43 *cs42l43)
> > }
> > EXPORT_SYMBOL_NS_GPL(cs42l43_dev_remove, MFD_CS42L43);
> >
> > +#ifdef CONFIG_PM_SLEEP
> > static int cs42l43_suspend(struct device *dev)
> > {
> > struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
> > @@ -1120,7 +1121,9 @@ static int cs42l43_resume(struct device *dev)
> >
> > return 0;
> > }
> > +#endif
> >
> > +#ifdef CONFIG_PM
> > static int cs42l43_runtime_suspend(struct device *dev)
> > {
> > struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
> > @@ -1176,6 +1179,7 @@ static int cs42l43_runtime_resume(struct device *dev)
> >
> > return ret;
> > }
> > +#endif
> >
> > EXPORT_NS_GPL_DEV_PM_OPS(cs42l43_pm_ops, MFD_CS42L43) = {
> > SET_SYSTEM_SLEEP_PM_OPS(cs42l43_suspend, cs42l43_resume)
>
> I see a bunch of drivers using PM helpers and not many of them are
> are being guarded by ugly #ifery. Please find out what they're doing to
> solve the same issue and replicate that instead.
>
> Here's a really big hint:
>
> `git log --oneline 02313a90095fb`
>

Thanks, I've learned something from the hint.

And I also checked the code:
-----
EXPORT_NS_GPL_DEV_PM_OPS(cs42l43_pm_ops, MFD_CS42L43) = {
SET_SYSTEM_SLEEP_PM_OPS(cs42l43_suspend, cs42l43_resume)
SET_RUNTIME_PM_OPS(cs42l43_runtime_suspend,
cs42l43_runtime_resume, NULL)
};
----
#ifdef CONFIG_PM_SLEEP
#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
#else
#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
#endif
----
#define SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
.suspend = pm_sleep_ptr(suspend_fn), \
.resume = pm_sleep_ptr(resume_fn), \
.freeze = pm_sleep_ptr(suspend_fn), \
.thaw = pm_sleep_ptr(resume_fn), \
.poweroff = pm_sleep_ptr(suspend_fn), \
.restore = pm_sleep_ptr(resume_fn),
----
The technique has already been used by the marcos, but it still
reports the defined-but-not-used warning.
Maybe some compilers still choose to compile these functions in...
Anyway, I will just leave it alone since it is really not a big problem...

Thanks,
Shida


> --
> Lee Jones [李琼斯]

2023-09-21 23:55:03

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH] mfd: cs42l43: fix defined but not used warnings

On Thu, 21 Sep 2023, Stephen Zhang wrote:

> Lee Jones <[email protected]> 于2023年9月20日周三 17:52写道:
> >
> > On Tue, 05 Sep 2023, zhangshida wrote:
> >
> > > From: Shida Zhang <[email protected]>
> > >
> > > Warnings were generated during compiling for functions like
> > > cs42l43_*_{resume,suspend}:
> > >
> > > ../drivers/mfd/cs42l43.c:1138:12: error: ‘cs42l43_runtime_resume’ defined but not used [-Werror=unused-function]
> > > 1138 | static int cs42l43_runtime_resume(struct device *dev)
> > > | ^~~~~~~~~~~~~~~~~~~~~~
> > > ../drivers/mfd/cs42l43.c:1124:12: error: ‘cs42l43_runtime_suspend’ defined but not used [-Werror=unused-function]
> > > 1124 | static int cs42l43_runtime_suspend(struct device *dev)
> > > | ^~~~~~~~~~~~~~~~~~~~~~~
> > > ../drivers/mfd/cs42l43.c:1106:12: error: ‘cs42l43_resume’ defined but not used [-Werror=unused-function]
> > > 1106 | static int cs42l43_resume(struct device *dev)
> > > | ^~~~~~~~~~~~~~
> > > ../drivers/mfd/cs42l43.c:1076:12: error: ‘cs42l43_suspend’ defined but not used [-Werror=unused-function]
> > > 1076 | static int cs42l43_suspend(struct device *dev)
> > >
> > > Fix it by guarding it with CONFIG_PM/CONFIG_PM_SLEEP.
> > >
> > > Reported-by: k2ci <[email protected]>
> > > Signed-off-by: Shida Zhang <[email protected]>
> > > ---
> > > drivers/mfd/cs42l43.c | 4 ++++
> > > 1 file changed, 4 insertions(+)
> > >
> > > diff --git a/drivers/mfd/cs42l43.c b/drivers/mfd/cs42l43.c
> > > index 37b23e9bae82..e589a61c118d 100644
> > > --- a/drivers/mfd/cs42l43.c
> > > +++ b/drivers/mfd/cs42l43.c
> > > @@ -1073,6 +1073,7 @@ void cs42l43_dev_remove(struct cs42l43 *cs42l43)
> > > }
> > > EXPORT_SYMBOL_NS_GPL(cs42l43_dev_remove, MFD_CS42L43);
> > >
> > > +#ifdef CONFIG_PM_SLEEP
> > > static int cs42l43_suspend(struct device *dev)
> > > {
> > > struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
> > > @@ -1120,7 +1121,9 @@ static int cs42l43_resume(struct device *dev)
> > >
> > > return 0;
> > > }
> > > +#endif
> > >
> > > +#ifdef CONFIG_PM
> > > static int cs42l43_runtime_suspend(struct device *dev)
> > > {
> > > struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
> > > @@ -1176,6 +1179,7 @@ static int cs42l43_runtime_resume(struct device *dev)
> > >
> > > return ret;
> > > }
> > > +#endif
> > >
> > > EXPORT_NS_GPL_DEV_PM_OPS(cs42l43_pm_ops, MFD_CS42L43) = {
> > > SET_SYSTEM_SLEEP_PM_OPS(cs42l43_suspend, cs42l43_resume)
> >
> > I see a bunch of drivers using PM helpers and not many of them are
> > are being guarded by ugly #ifery. Please find out what they're doing to
> > solve the same issue and replicate that instead.
> >
> > Here's a really big hint:
> >
> > `git log --oneline 02313a90095fb`
> >
>
> Thanks, I've learned something from the hint.
>
> And I also checked the code:
> -----
> EXPORT_NS_GPL_DEV_PM_OPS(cs42l43_pm_ops, MFD_CS42L43) = {
> SET_SYSTEM_SLEEP_PM_OPS(cs42l43_suspend, cs42l43_resume)
> SET_RUNTIME_PM_OPS(cs42l43_runtime_suspend,
> cs42l43_runtime_resume, NULL)
> };
> ----
> #ifdef CONFIG_PM_SLEEP
> #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
> SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
> #else
> #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
> #endif
> ----
> #define SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
> .suspend = pm_sleep_ptr(suspend_fn), \
> .resume = pm_sleep_ptr(resume_fn), \
> .freeze = pm_sleep_ptr(suspend_fn), \
> .thaw = pm_sleep_ptr(resume_fn), \
> .poweroff = pm_sleep_ptr(suspend_fn), \
> .restore = pm_sleep_ptr(resume_fn),
> ----
> The technique has already been used by the marcos, but it still
> reports the defined-but-not-used warning.

The MACROS can use #ifery since they are located in header files.

#ifery in C files is to be avoided if at all possible.

> Maybe some compilers still choose to compile these functions in...
> Anyway, I will just leave it alone since it is really not a big problem...

If you're seeing an error, it should be fixed.

Why is this not an issue anywhere else?

Does the same build complain about all the other drivers too?

--
Lee Jones [李琼斯]

2023-09-22 02:03:46

by Stephen Zhang

[permalink] [raw]
Subject: Re: [PATCH] mfd: cs42l43: fix defined but not used warnings

Lee Jones <[email protected]> 于2023年9月21日周四 18:37写道:
>
> On Thu, 21 Sep 2023, Stephen Zhang wrote:
>
> > Lee Jones <[email protected]> 于2023年9月20日周三 17:52写道:
> > >
> > > On Tue, 05 Sep 2023, zhangshida wrote:
> > >
> > > > From: Shida Zhang <[email protected]>
> > > >
> > > > Warnings were generated during compiling for functions like
> > > > cs42l43_*_{resume,suspend}:
> > > >
> > > > ../drivers/mfd/cs42l43.c:1138:12: error: ‘cs42l43_runtime_resume’ defined but not used [-Werror=unused-function]
> > > > 1138 | static int cs42l43_runtime_resume(struct device *dev)
> > > > | ^~~~~~~~~~~~~~~~~~~~~~
> > > > ../drivers/mfd/cs42l43.c:1124:12: error: ‘cs42l43_runtime_suspend’ defined but not used [-Werror=unused-function]
> > > > 1124 | static int cs42l43_runtime_suspend(struct device *dev)
> > > > | ^~~~~~~~~~~~~~~~~~~~~~~
> > > > ../drivers/mfd/cs42l43.c:1106:12: error: ‘cs42l43_resume’ defined but not used [-Werror=unused-function]
> > > > 1106 | static int cs42l43_resume(struct device *dev)
> > > > | ^~~~~~~~~~~~~~
> > > > ../drivers/mfd/cs42l43.c:1076:12: error: ‘cs42l43_suspend’ defined but not used [-Werror=unused-function]
> > > > 1076 | static int cs42l43_suspend(struct device *dev)
> > > >
> > > > Fix it by guarding it with CONFIG_PM/CONFIG_PM_SLEEP.
> > > >
> > > > Reported-by: k2ci <[email protected]>
> > > > Signed-off-by: Shida Zhang <[email protected]>
> > > > ---
> > > > drivers/mfd/cs42l43.c | 4 ++++
> > > > 1 file changed, 4 insertions(+)
> > > >
> > > > diff --git a/drivers/mfd/cs42l43.c b/drivers/mfd/cs42l43.c
> > > > index 37b23e9bae82..e589a61c118d 100644
> > > > --- a/drivers/mfd/cs42l43.c
> > > > +++ b/drivers/mfd/cs42l43.c
> > > > @@ -1073,6 +1073,7 @@ void cs42l43_dev_remove(struct cs42l43 *cs42l43)
> > > > }
> > > > EXPORT_SYMBOL_NS_GPL(cs42l43_dev_remove, MFD_CS42L43);
> > > >
> > > > +#ifdef CONFIG_PM_SLEEP
> > > > static int cs42l43_suspend(struct device *dev)
> > > > {
> > > > struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
> > > > @@ -1120,7 +1121,9 @@ static int cs42l43_resume(struct device *dev)
> > > >
> > > > return 0;
> > > > }
> > > > +#endif
> > > >
> > > > +#ifdef CONFIG_PM
> > > > static int cs42l43_runtime_suspend(struct device *dev)
> > > > {
> > > > struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
> > > > @@ -1176,6 +1179,7 @@ static int cs42l43_runtime_resume(struct device *dev)
> > > >
> > > > return ret;
> > > > }
> > > > +#endif
> > > >
> > > > EXPORT_NS_GPL_DEV_PM_OPS(cs42l43_pm_ops, MFD_CS42L43) = {
> > > > SET_SYSTEM_SLEEP_PM_OPS(cs42l43_suspend, cs42l43_resume)
> > >
> > > I see a bunch of drivers using PM helpers and not many of them are
> > > are being guarded by ugly #ifery. Please find out what they're doing to
> > > solve the same issue and replicate that instead.
> > >
> > > Here's a really big hint:
> > >
> > > `git log --oneline 02313a90095fb`
> > >
> >
> > Thanks, I've learned something from the hint.
> >
> > And I also checked the code:
> > -----
> > EXPORT_NS_GPL_DEV_PM_OPS(cs42l43_pm_ops, MFD_CS42L43) = {
> > SET_SYSTEM_SLEEP_PM_OPS(cs42l43_suspend, cs42l43_resume)
> > SET_RUNTIME_PM_OPS(cs42l43_runtime_suspend,
> > cs42l43_runtime_resume, NULL)
> > };
> > ----
> > #ifdef CONFIG_PM_SLEEP
> > #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
> > SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
> > #else
> > #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
> > #endif
> > ----
> > #define SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
> > .suspend = pm_sleep_ptr(suspend_fn), \
> > .resume = pm_sleep_ptr(resume_fn), \
> > .freeze = pm_sleep_ptr(suspend_fn), \
> > .thaw = pm_sleep_ptr(resume_fn), \
> > .poweroff = pm_sleep_ptr(suspend_fn), \
> > .restore = pm_sleep_ptr(resume_fn),
> > ----
> > The technique has already been used by the marcos, but it still
> > reports the defined-but-not-used warning.
>
> The MACROS can use #ifery since they are located in header files.
>
> #ifery in C files is to be avoided if at all possible.
>
> > Maybe some compilers still choose to compile these functions in...
> > Anyway, I will just leave it alone since it is really not a big problem...
>
> If you're seeing an error, it should be fixed.

<nod>

>
> Why is this not an issue anywhere else?
>
> Does the same build complain about all the other drivers too?
>

Nope, at least 88pm860x-core.c is good:
----
drivers/mfd/88pm860x-core.c
static int pm860x_suspend(struct device *dev)
static DEFINE_SIMPLE_DEV_PM_OPS(pm860x_pm_ops, pm860x_suspend, pm860x_resume);
static struct i2c_driver pm860x_driver = {
.driver = {
.name = "88PM860x",
.pm = pm_sleep_ptr(&pm860x_pm_ops),
.of_match_table = pm860x_dt_ids,
},
.probe_new = pm860x_probe,
----
...
LD [M] sound/pci/echoaudio/snd-layla20.o
CC drivers/mfd/88pm860x-core.o
CC drivers/misc/eeprom/max6875.o
CC arch/mips/vdso/vdso-image.o
...
----

It is generated by mips-linux-gnu-gcc, which always exhibits some
peculiar behavior.

Since it reports 'defined but not used,' it implies that the macro
successfully removed any usage of 'cs42l43_*.'
However, the compiler still chose not to optimize these functions out.
It's very weird.
Maybe the problem comes from the optimization process in mips compiler?

I will attach the kernel.config and the build.log for your reference.

> --
> Lee Jones [李琼斯]


Attachments:
build.log (389.81 kB)
kernel.conifg (186.80 kB)
Download all attachments

2023-09-22 07:34:20

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] mfd: cs42l43: fix defined but not used warnings

Hi Lee,

On Wed, Sep 20, 2023 at 12:07 PM Lee Jones <[email protected]> wrote:
> On Tue, 05 Sep 2023, zhangshida wrote:
> > From: Shida Zhang <[email protected]>
> >
> > Warnings were generated during compiling for functions like
> > cs42l43_*_{resume,suspend}:
> >
> > ../drivers/mfd/cs42l43.c:1138:12: error: ‘cs42l43_runtime_resume’ defined but not used [-Werror=unused-function]
> > 1138 | static int cs42l43_runtime_resume(struct device *dev)
> > | ^~~~~~~~~~~~~~~~~~~~~~
> > ../drivers/mfd/cs42l43.c:1124:12: error: ‘cs42l43_runtime_suspend’ defined but not used [-Werror=unused-function]
> > 1124 | static int cs42l43_runtime_suspend(struct device *dev)
> > | ^~~~~~~~~~~~~~~~~~~~~~~
> > ../drivers/mfd/cs42l43.c:1106:12: error: ‘cs42l43_resume’ defined but not used [-Werror=unused-function]
> > 1106 | static int cs42l43_resume(struct device *dev)
> > | ^~~~~~~~~~~~~~
> > ../drivers/mfd/cs42l43.c:1076:12: error: ‘cs42l43_suspend’ defined but not used [-Werror=unused-function]
> > 1076 | static int cs42l43_suspend(struct device *dev)
> >
> > Fix it by guarding it with CONFIG_PM/CONFIG_PM_SLEEP.
> >
> > Reported-by: k2ci <[email protected]>
> > Signed-off-by: Shida Zhang <[email protected]>
> > ---
> > drivers/mfd/cs42l43.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/mfd/cs42l43.c b/drivers/mfd/cs42l43.c
> > index 37b23e9bae82..e589a61c118d 100644
> > --- a/drivers/mfd/cs42l43.c
> > +++ b/drivers/mfd/cs42l43.c
> > @@ -1073,6 +1073,7 @@ void cs42l43_dev_remove(struct cs42l43 *cs42l43)
> > }
> > EXPORT_SYMBOL_NS_GPL(cs42l43_dev_remove, MFD_CS42L43);
> >
> > +#ifdef CONFIG_PM_SLEEP
> > static int cs42l43_suspend(struct device *dev)
> > {
> > struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
> > @@ -1120,7 +1121,9 @@ static int cs42l43_resume(struct device *dev)
> >
> > return 0;
> > }
> > +#endif
> >
> > +#ifdef CONFIG_PM
> > static int cs42l43_runtime_suspend(struct device *dev)
> > {
> > struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
> > @@ -1176,6 +1179,7 @@ static int cs42l43_runtime_resume(struct device *dev)
> >
> > return ret;
> > }
> > +#endif
> >
> > EXPORT_NS_GPL_DEV_PM_OPS(cs42l43_pm_ops, MFD_CS42L43) = {
> > SET_SYSTEM_SLEEP_PM_OPS(cs42l43_suspend, cs42l43_resume)
>
> I see a bunch of drivers using PM helpers and not many of them are
> are being guarded by ugly #ifery. Please find out what they're doing to
> solve the same issue and replicate that instead.
>
> Here's a really big hint:
>
> `git log --oneline 02313a90095fb`

And there's no need to create another fix, as a Good Old fix is
available (and still not upstream):
https://lore.kernel.org/all/[email protected]

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2023-09-25 08:07:36

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH] mfd: cs42l43: fix defined but not used warnings

On Fri, 22 Sep 2023, Geert Uytterhoeven wrote:

> Hi Lee,
>
> On Wed, Sep 20, 2023 at 12:07 PM Lee Jones <[email protected]> wrote:
> > On Tue, 05 Sep 2023, zhangshida wrote:
> > > From: Shida Zhang <[email protected]>
> > >
> > > Warnings were generated during compiling for functions like
> > > cs42l43_*_{resume,suspend}:
> > >
> > > ../drivers/mfd/cs42l43.c:1138:12: error: ‘cs42l43_runtime_resume’ defined but not used [-Werror=unused-function]
> > > 1138 | static int cs42l43_runtime_resume(struct device *dev)
> > > | ^~~~~~~~~~~~~~~~~~~~~~
> > > ../drivers/mfd/cs42l43.c:1124:12: error: ‘cs42l43_runtime_suspend’ defined but not used [-Werror=unused-function]
> > > 1124 | static int cs42l43_runtime_suspend(struct device *dev)
> > > | ^~~~~~~~~~~~~~~~~~~~~~~
> > > ../drivers/mfd/cs42l43.c:1106:12: error: ‘cs42l43_resume’ defined but not used [-Werror=unused-function]
> > > 1106 | static int cs42l43_resume(struct device *dev)
> > > | ^~~~~~~~~~~~~~
> > > ../drivers/mfd/cs42l43.c:1076:12: error: ‘cs42l43_suspend’ defined but not used [-Werror=unused-function]
> > > 1076 | static int cs42l43_suspend(struct device *dev)
> > >
> > > Fix it by guarding it with CONFIG_PM/CONFIG_PM_SLEEP.
> > >
> > > Reported-by: k2ci <[email protected]>
> > > Signed-off-by: Shida Zhang <[email protected]>
> > > ---
> > > drivers/mfd/cs42l43.c | 4 ++++
> > > 1 file changed, 4 insertions(+)
> > >
> > > diff --git a/drivers/mfd/cs42l43.c b/drivers/mfd/cs42l43.c
> > > index 37b23e9bae82..e589a61c118d 100644
> > > --- a/drivers/mfd/cs42l43.c
> > > +++ b/drivers/mfd/cs42l43.c
> > > @@ -1073,6 +1073,7 @@ void cs42l43_dev_remove(struct cs42l43 *cs42l43)
> > > }
> > > EXPORT_SYMBOL_NS_GPL(cs42l43_dev_remove, MFD_CS42L43);
> > >
> > > +#ifdef CONFIG_PM_SLEEP
> > > static int cs42l43_suspend(struct device *dev)
> > > {
> > > struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
> > > @@ -1120,7 +1121,9 @@ static int cs42l43_resume(struct device *dev)
> > >
> > > return 0;
> > > }
> > > +#endif
> > >
> > > +#ifdef CONFIG_PM
> > > static int cs42l43_runtime_suspend(struct device *dev)
> > > {
> > > struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
> > > @@ -1176,6 +1179,7 @@ static int cs42l43_runtime_resume(struct device *dev)
> > >
> > > return ret;
> > > }
> > > +#endif
> > >
> > > EXPORT_NS_GPL_DEV_PM_OPS(cs42l43_pm_ops, MFD_CS42L43) = {
> > > SET_SYSTEM_SLEEP_PM_OPS(cs42l43_suspend, cs42l43_resume)
> >
> > I see a bunch of drivers using PM helpers and not many of them are
> > are being guarded by ugly #ifery. Please find out what they're doing to
> > solve the same issue and replicate that instead.
> >
> > Here's a really big hint:
> >
> > `git log --oneline 02313a90095fb`
>
> And there's no need to create another fix, as a Good Old fix is
> available (and still not upstream):
> https://lore.kernel.org/all/[email protected]

I beg to differ;

eb72d5207008d ("mfd: cs42l43: Use correct macro for new-style PM runtime ops")

:)

--
Lee Jones [李琼斯]

2023-09-25 08:46:10

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] mfd: cs42l43: fix defined but not used warnings

Hi Lee,

On Mon, Sep 25, 2023 at 9:56 AM Lee Jones <[email protected]> wrote:
> On Fri, 22 Sep 2023, Geert Uytterhoeven wrote:
> > On Wed, Sep 20, 2023 at 12:07 PM Lee Jones <[email protected]> wrote:
> > > On Tue, 05 Sep 2023, zhangshida wrote:
> > > > From: Shida Zhang <[email protected]>
> > > >
> > > > Warnings were generated during compiling for functions like
> > > > cs42l43_*_{resume,suspend}:
> > > >
> > > > ../drivers/mfd/cs42l43.c:1138:12: error: ‘cs42l43_runtime_resume’ defined but not used [-Werror=unused-function]
> > > > 1138 | static int cs42l43_runtime_resume(struct device *dev)
> > > > | ^~~~~~~~~~~~~~~~~~~~~~
> > > > ../drivers/mfd/cs42l43.c:1124:12: error: ‘cs42l43_runtime_suspend’ defined but not used [-Werror=unused-function]
> > > > 1124 | static int cs42l43_runtime_suspend(struct device *dev)
> > > > | ^~~~~~~~~~~~~~~~~~~~~~~
> > > > ../drivers/mfd/cs42l43.c:1106:12: error: ‘cs42l43_resume’ defined but not used [-Werror=unused-function]
> > > > 1106 | static int cs42l43_resume(struct device *dev)
> > > > | ^~~~~~~~~~~~~~
> > > > ../drivers/mfd/cs42l43.c:1076:12: error: ‘cs42l43_suspend’ defined but not used [-Werror=unused-function]
> > > > 1076 | static int cs42l43_suspend(struct device *dev)
> > > >
> > > > Fix it by guarding it with CONFIG_PM/CONFIG_PM_SLEEP.
> > > >
> > > > Reported-by: k2ci <[email protected]>
> > > > Signed-off-by: Shida Zhang <[email protected]>
> > > > ---
> > > > drivers/mfd/cs42l43.c | 4 ++++
> > > > 1 file changed, 4 insertions(+)
> > > >
> > > > diff --git a/drivers/mfd/cs42l43.c b/drivers/mfd/cs42l43.c
> > > > index 37b23e9bae82..e589a61c118d 100644
> > > > --- a/drivers/mfd/cs42l43.c
> > > > +++ b/drivers/mfd/cs42l43.c
> > > > @@ -1073,6 +1073,7 @@ void cs42l43_dev_remove(struct cs42l43 *cs42l43)
> > > > }
> > > > EXPORT_SYMBOL_NS_GPL(cs42l43_dev_remove, MFD_CS42L43);
> > > >
> > > > +#ifdef CONFIG_PM_SLEEP
> > > > static int cs42l43_suspend(struct device *dev)
> > > > {
> > > > struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
> > > > @@ -1120,7 +1121,9 @@ static int cs42l43_resume(struct device *dev)
> > > >
> > > > return 0;
> > > > }
> > > > +#endif
> > > >
> > > > +#ifdef CONFIG_PM
> > > > static int cs42l43_runtime_suspend(struct device *dev)
> > > > {
> > > > struct cs42l43 *cs42l43 = dev_get_drvdata(dev);
> > > > @@ -1176,6 +1179,7 @@ static int cs42l43_runtime_resume(struct device *dev)
> > > >
> > > > return ret;
> > > > }
> > > > +#endif
> > > >
> > > > EXPORT_NS_GPL_DEV_PM_OPS(cs42l43_pm_ops, MFD_CS42L43) = {
> > > > SET_SYSTEM_SLEEP_PM_OPS(cs42l43_suspend, cs42l43_resume)
> > >
> > > I see a bunch of drivers using PM helpers and not many of them are
> > > are being guarded by ugly #ifery. Please find out what they're doing to
> > > solve the same issue and replicate that instead.
> > >
> > > Here's a really big hint:
> > >
> > > `git log --oneline 02313a90095fb`
> >
> > And there's no need to create another fix, as a Good Old fix is
> > available (and still not upstream):
> > https://lore.kernel.org/all/[email protected]
>
> I beg to differ;
>
> eb72d5207008d ("mfd: cs42l43: Use correct macro for new-style PM runtime ops")
>
> :)

Commit: Linus Torvalds <[email protected]>
CommitDate: Sat Sep 23 11:10:23 2023 -0700

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds