pwm: Add missing dummy for devm_pwmchip_add()

Message ID 12f2142991690d2b1d6890821f6e7779a4d4bdc0.1666706435.git.geert+renesas@glider.be
State New
Headers
Series pwm: Add missing dummy for devm_pwmchip_add() |

Commit Message

Geert Uytterhoeven Oct. 25, 2022, 2:03 p.m. UTC
  The PWM subsystem supports compile-testing if CONFIG_PWM is disabled.
However, no dummy is provided for devm_pwmchip_add(), which may lead to
build failures.

Fixes: bcda91bf86c1ff76 ("pwm: Add a device-managed function to add PWM chips")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 include/linux/pwm.h | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Uwe Kleine-König Oct. 26, 2022, 12:17 a.m. UTC | #1
Hello Geert,

On Tue, Oct 25, 2022 at 04:03:42PM +0200, Geert Uytterhoeven wrote:
> The PWM subsystem supports compile-testing if CONFIG_PWM is disabled.
> However, no dummy is provided for devm_pwmchip_add(), which may lead to
> build failures.
> 
> Fixes: bcda91bf86c1ff76 ("pwm: Add a device-managed function to add PWM chips")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Is this a problem that today yields a failure to compile? As of v6.1-rc1
and also in next all callers are below drivers/pwm/ which isn't included
in the build without PWM=y.

Am I missing something or is this just preparing that one of the drivers
that doesn't live in drivers/pwm might call devm_pwmchip_add in the
future? In that case I wouldn't add that Fixes: line (and also oppose to
backporting that commit to stable).

Best regards
Uwe
  
Geert Uytterhoeven Oct. 26, 2022, 7:05 a.m. UTC | #2
Hi Uwe,

On Wed, Oct 26, 2022 at 2:17 AM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> On Tue, Oct 25, 2022 at 04:03:42PM +0200, Geert Uytterhoeven wrote:
> > The PWM subsystem supports compile-testing if CONFIG_PWM is disabled.
> > However, no dummy is provided for devm_pwmchip_add(), which may lead to
> > build failures.
> >
> > Fixes: bcda91bf86c1ff76 ("pwm: Add a device-managed function to add PWM chips")
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Is this a problem that today yields a failure to compile? As of v6.1-rc1
> and also in next all callers are below drivers/pwm/ which isn't included
> in the build without PWM=y.

So none of these support compile-testing with CONFIG_PWM=n...

> Am I missing something or is this just preparing that one of the drivers
> that doesn't live in drivers/pwm might call devm_pwmchip_add in the
> future?

I saw it with the RZ/G2L MTU3 PWM driver[1], which is not yet applied.
After noticing its sibling counter driver lacked a dependency on
CONFIG_COUNTER, I tried disabling CONFIG_PWM...

> In that case I wouldn't add that Fixes: line (and also oppose to
> backporting that commit to stable).

I tend to disagree: more drivers may be converted to devm_pwmchip_add()
in the future, possibly as part of a fix, causing troubles for the
stable team when backporting such fixes.

Thanks!

[1] https://lore.kernel.org/all/CAMuHMdWE+H=aXkt61hZK6mbQairwdk1F522mZRemC0T5LxQtMg@mail.gmail.com

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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
  
Uwe Kleine-König Nov. 17, 2022, 11:27 a.m. UTC | #3
Hello,

On Wed, Oct 26, 2022 at 09:05:42AM +0200, Geert Uytterhoeven wrote:
> On Wed, Oct 26, 2022 at 2:17 AM Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
> > On Tue, Oct 25, 2022 at 04:03:42PM +0200, Geert Uytterhoeven wrote:
> > > The PWM subsystem supports compile-testing if CONFIG_PWM is disabled.
> > > However, no dummy is provided for devm_pwmchip_add(), which may lead to
> > > build failures.
> > >
> > > Fixes: bcda91bf86c1ff76 ("pwm: Add a device-managed function to add PWM chips")
> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >
> > Is this a problem that today yields a failure to compile? As of v6.1-rc1
> > and also in next all callers are below drivers/pwm/ which isn't included
> > in the build without PWM=y.
> 
> So none of these support compile-testing with CONFIG_PWM=n...

There are not many pwm providers outside of drivers/pwm:

 - drivers/gpio/gpio-mvebu.c
 - drivers/gpu/drm/bridge/ti-sn65dsi86.c
 - drivers/leds/rgb/leds-qcom-lpg.c
 - drivers/staging/greybus/pwm.c

These all call pwmchip_add() which has a dummy.

gpio-mvebu only uses it in an if (IS_ENABLED(CONFIG_PWM)) block.
ti-sn65dsi86 has it in a big #ifdef CONFIG_PWM block (and in a dedicated
driver such that the returned error doesn't hurt).

leds-qcom-lpg.c depends on PWM as does the greybus stuff.

So the dummy isn't even needed. (Unless for the corner case GPIO_MVEBU=y
+ PWM=m which is probably a bug worth fixing. Maybe a similar issue
exists for ti-sn65dsi86.)

> > Am I missing something or is this just preparing that one of the drivers
> > that doesn't live in drivers/pwm might call devm_pwmchip_add in the
> > future?
> 
> I saw it with the RZ/G2L MTU3 PWM driver[1], which is not yet applied.
> After noticing its sibling counter driver lacked a dependency on
> CONFIG_COUNTER, I tried disabling CONFIG_PWM...
> 
> > In that case I wouldn't add that Fixes: line (and also oppose to
> > backporting that commit to stable).
> 
> I tend to disagree: more drivers may be converted to devm_pwmchip_add()
> in the future, possibly as part of a fix, causing troubles for the
> stable team when backporting such fixes.

Please don't backport as a precaution not to miss to backport it in case
there is another patch that depends on it. In my experience the stable
maintainers are good at identifying such dependencies.

Best regards
Uwe
  
Uwe Kleine-König Nov. 17, 2022, 11:34 a.m. UTC | #4
Hello,

On Thu, Nov 17, 2022 at 12:27:58PM +0100, Uwe Kleine-König wrote:
> So the dummy isn't even needed. (Unless for the corner case GPIO_MVEBU=y
> + PWM=m which is probably a bug worth fixing. Maybe a similar issue
> exists for ti-sn65dsi86.)

FTR: That is not a problem, PWM is bool and so cannot be =m.

Best regards
Uwe
  

Patch

diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index d70c6e5a839d6902..bba492eea96c5552 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -478,6 +478,11 @@  static inline int pwmchip_remove(struct pwm_chip *chip)
 	return -EINVAL;
 }
 
+static inline int devm_pwmchip_add(struct device *dev, struct pwm_chip *chip)
+{
+	return -EINVAL;
+}
+
 static inline struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip,
 						       unsigned int index,
 						       const char *label)