Skip to contentSkip to conversation

pwm: stm32: fix build warning with CONFIG_DMA_ENGINE disabled

PATCH Applied Arnd Bergmann 5 participants 6 messages May 25, 2018 – Jun 12, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pwm: stm32: fix build warning with CONFIG_DMA_ENGINE disabled

Without dmaengine support, we get a harmless warning about an unused function:

drivers/pwm/pwm-stm32.c:166:12: error: 'stm32_pwm_capture' defined but not used [-Werror=unused-function]

Changing the #ifdef to an IS_ENABLED() check shuts up that warning and is slightly nicer to read.

Fixes 53e38fe73f94 ("pwm: stm32: Add capture support")
---
 drivers/pwm/pwm-stm32.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pwm/pwm-stm32.c +1 -3
index 60bfc07c4912..97bbc1f18fd6 100644
@@ -484,9 +484,7 @@ static int stm32_pwm_apply_locked(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops stm32pwm_ops = {
 	.owner = THIS_MODULE,
 	.apply = stm32_pwm_apply_locked,
-#if IS_ENABLED(CONFIG_DMA_ENGINE)
-	.capture = stm32_pwm_capture,
-#endif
+	.capture = IS_ENABLED(CONFIG_DMA_ENGINE) ? stm32_pwm_capture : NULL,
 };
 
 static int stm32_pwm_set_breakinput(struct stm32_pwm *priv,
Signature · 1 line
2.9.0
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Arnd Bergmann

Without dmaengine support, we get a harmless warning about an unused function:

drivers/pwm/pwm-stm32.c:166:12: error: 'stm32_pwm_capture' defined but not used [-Werror=unused-function]

Quoted 8 lines

Changing the #ifdef to an IS_ENABLED() check shuts up that warning and is slightly nicer to read.

Fixes 53e38fe73f94 ("pwm: stm32: Add capture support")
---
 drivers/pwm/pwm-stm32.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Hi Arnd,

Thanks,
Fabrice

Quoted 17 lines
drivers/pwm/pwm-stm32.c +1 -3
index 60bfc07c4912..97bbc1f18fd6 100644
@@ -484,9 +484,7 @@ static int stm32_pwm_apply_locked(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops stm32pwm_ops = {
 	.owner = THIS_MODULE,
 	.apply = stm32_pwm_apply_locked,
-#if IS_ENABLED(CONFIG_DMA_ENGINE)
-	.capture = stm32_pwm_capture,
-#endif
+	.capture = IS_ENABLED(CONFIG_DMA_ENGINE) ? stm32_pwm_capture : NULL,
 };
 
 static int stm32_pwm_set_breakinput(struct stm32_pwm *priv,
#2 lore raw
In reply to Arnd Bergmann
Quoted 5 lines · Arnd Bergmann

Without dmaengine support, we get a harmless warning about an unused function:

drivers/pwm/pwm-stm32.c:166:12: error: 'stm32_pwm_capture' defined but not used [-Werror=unused-function]

Quoted 8 lines

Changing the #ifdef to an IS_ENABLED() check shuts up that warning and is slightly nicer to read.

Fixes 53e38fe73f94 ("pwm: stm32: Add capture support")
---
 drivers/pwm/pwm-stm32.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Applied, thanks.

Lee, I applied this on top of your immutable MFD/PWM branch because it depends on the capture support that you applied. I wasn't sure what your PR timing was going to be, so I thought I'd do it this way since I'm pulling in some last minute fixes for v4.18.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180606/e5ca7938/attachment-0001.sig>

#3 lore raw
Quoted 15 lines · Thierry Reding
Quoted 5 lines · Arnd Bergmann

Without dmaengine support, we get a harmless warning about an unused function:

drivers/pwm/pwm-stm32.c:166:12: error: 'stm32_pwm_capture' defined but not used [-Werror=unused-function]

Quoted 8 lines

Changing the #ifdef to an IS_ENABLED() check shuts up that warning and is slightly nicer to read.

Fixes 53e38fe73f94 ("pwm: stm32: Add capture support")
---
 drivers/pwm/pwm-stm32.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Quoted 6 lines

Applied, thanks.

Lee, I applied this on top of your immutable MFD/PWM branch because it depends on the capture support that you applied. I wasn't sure what your PR timing was going to be, so I thought I'd do it this way since I'm pulling in some last minute fixes for v4.18.

I don't see a problem with that.

Signature · 4 lines
Lee Jones [???]
Linaro Services Technical Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Acked-by on v1 1/1
#4 lore raw
In reply to Arnd Bergmann

Hi Arnd,

Quoted 10 lines · Arnd Bergmann

Without dmaengine support, we get a harmless warning about an unused function:

drivers/pwm/pwm-stm32.c:166:12: error: 'stm32_pwm_capture' defined but not used [-Werror=unused-function]

Changing the #ifdef to an IS_ENABLED() check shuts up that warning and is slightly nicer to read.

Fixes 53e38fe73f94 ("pwm: stm32: Add capture support")

Thanks!

drivers/pwm/pwm-stm32.c static int stm32_pwm_apply_locked(struct pwm_chip *chip, struct pwm_device *pwm, · line 487

Quoted 10 lines
drivers/pwm/pwm-stm32.c +1 -3
@@ -484,9 +484,7 @@ static int stm32_pwm_apply_locked(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops stm32pwm_ops = {
        .owner = THIS_MODULE,
        .apply = stm32_pwm_apply_locked,
-#if IS_ENABLED(CONFIG_DMA_ENGINE)
-       .capture = stm32_pwm_capture,
-#endif
+       .capture = IS_ENABLED(CONFIG_DMA_ENGINE) ? stm32_pwm_capture : NULL,

Cool, I didn't know IS_ENABLED() can be used in static initializers. I guess it's too late/much work to use this trick in e.g. SET_*_PM_OPS(), as there are lots of places protecting the functions by #ifdefs?

drivers/pwm/pwm-stm32.c static int stm32_pwm_apply_locked(struct pwm_chip *chip, struct pwm_device *pwm, · line 488

Quoted 1 line
drivers/pwm/pwm-stm32.c +0 -0
 };

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at 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
#5 lore raw
Quoted 6 lines · Geert Uytterhoeven
Quoted 6 lines
drivers/pwm/pwm-stm32.c +0 -0
@@ -484,9 +484,7 @@ static int stm32_pwm_apply_locked(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops stm32pwm_ops = {
        .owner = THIS_MODULE,
        .apply = stm32_pwm_apply_locked,
Quoted 8 lines

drivers/pwm/pwm-stm32.c static int stm32_pwm_apply_locked(struct pwm_chip *chip, struct pwm_device *pwm, · line 487

Quoted 4 lines
drivers/pwm/pwm-stm32.c +1 -3
-#if IS_ENABLED(CONFIG_DMA_ENGINE)
-       .capture = stm32_pwm_capture,
-#endif
+       .capture = IS_ENABLED(CONFIG_DMA_ENGINE) ? stm32_pwm_capture : NULL,

Cool, I didn't know IS_ENABLED() can be used in static initializers. I guess it's too late/much work to use this trick in e.g. SET_*_PM_OPS(), as there are lots of places protecting the functions by #ifdefs?

It's one of those things I've been planning to do for a long time, but as you noticed, we can't just change the macro but have to come up with a replacement that works without those #ifdefs. Unfortunately, nobody has come up with a good /name/ for those macros, which is still the main blocker ;-)

Arnd