All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: da903x: don't build with clang
@ 2019-03-07 10:26 Arnd Bergmann
  2019-03-07 19:09 ` Nick Desaulniers
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2019-03-07 10:26 UTC (permalink / raw)
  To: Mark Brown
  Cc: Nick Desaulniers, Arnd Bergmann, Liam Girdwood, Axel Lin, linux-kernel

The da903x driver produces an annoying false-positive warning
when built with clang:

drivers/regulator/da903x.c:395:2: error: division by zero is undefined [-Werror,-Wdivision-by-zero]
        DA9030_LDO(13, 2100, 2100, 0, INVAL, 0, 0, RCTL11, 3), /* fixed @2.1V */
        ^                          ~
drivers/regulator/da903x.c:359:2: note: expanded from macro 'DA9030_LDO'
        DA903x_LDO(DA9030, _id, min, max, step, vreg, shift, nbits, ereg, ebit)
        ^                                 ~~~~
drivers/regulator/da903x.c:320:39: note: expanded from macro 'DA903x_LDO'
                .n_voltages = (step) ? ((max - min) / step + 1) : 1,    \
                                                    ^ ~~~~
drivers/regulator/da903x.c:415:2: error: division by zero is undefined [-Werror,-Wdivision-by-zero]
        DA9034_LDO(5, 3100, 3100, 0, INVAL, 0, 0, OVER3, 7), /* fixed @3.1V */
        ^                         ~
drivers/regulator/da903x.c:356:2: note: expanded from macro 'DA9034_LDO'
        DA903x_LDO(DA9034, _id, min, max, step, vreg, shift, nbits, ereg, ebit)
        ^                                 ~~~~
drivers/regulator/da903x.c:320:39: note: expanded from macro 'DA903x_LDO'
                .n_voltages = (step) ? ((max - min) / step + 1) : 1,    \
                                                    ^ ~~~~

I already reported this as a bug in clang, but it may take a
while to fix it. As I have not been able to come up with any
reasonable workaround, I would just disable compilation here.

Link: https://bugs.llvm.org/show_bug.cgi?id=38789
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/regulator/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index b7f249ee5e68..6d2651cd9887 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -223,6 +223,7 @@ config REGULATOR_CPCAP
 config REGULATOR_DA903X
 	tristate "Dialog Semiconductor DA9030/DA9034 regulators"
 	depends on PMIC_DA903X
+	depends on !CC_IS_CLANG # https://bugs.llvm.org/show_bug.cgi?id=38789
 	help
 	  Say y here to support the BUCKs and LDOs regulators found on
 	  Dialog Semiconductor DA9030/DA9034 PMIC.
-- 
2.20.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] regulator: da903x: don't build with clang
  2019-03-07 10:26 [PATCH] regulator: da903x: don't build with clang Arnd Bergmann
@ 2019-03-07 19:09 ` Nick Desaulniers
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2019-03-07 19:09 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Mark Brown, Liam Girdwood, Axel Lin, LKML

On Thu, Mar 7, 2019 at 2:26 AM Arnd Bergmann <arnd@arndb.de> wrote:
>
> The da903x driver produces an annoying false-positive warning
> when built with clang:
>
> drivers/regulator/da903x.c:395:2: error: division by zero is undefined [-Werror,-Wdivision-by-zero]
>         DA9030_LDO(13, 2100, 2100, 0, INVAL, 0, 0, RCTL11, 3), /* fixed @2.1V */
>         ^                          ~
> drivers/regulator/da903x.c:359:2: note: expanded from macro 'DA9030_LDO'
>         DA903x_LDO(DA9030, _id, min, max, step, vreg, shift, nbits, ereg, ebit)
>         ^                                 ~~~~
> drivers/regulator/da903x.c:320:39: note: expanded from macro 'DA903x_LDO'
>                 .n_voltages = (step) ? ((max - min) / step + 1) : 1,    \
>                                                     ^ ~~~~
> drivers/regulator/da903x.c:415:2: error: division by zero is undefined [-Werror,-Wdivision-by-zero]
>         DA9034_LDO(5, 3100, 3100, 0, INVAL, 0, 0, OVER3, 7), /* fixed @3.1V */
>         ^                         ~
> drivers/regulator/da903x.c:356:2: note: expanded from macro 'DA9034_LDO'
>         DA903x_LDO(DA9034, _id, min, max, step, vreg, shift, nbits, ereg, ebit)
>         ^                                 ~~~~
> drivers/regulator/da903x.c:320:39: note: expanded from macro 'DA903x_LDO'
>                 .n_voltages = (step) ? ((max - min) / step + 1) : 1,    \
>                                                     ^ ~~~~
>
> I already reported this as a bug in clang, but it may take a
> while to fix it. As I have not been able to come up with any
> reasonable workaround, I would just disable compilation here.
>
> Link: https://bugs.llvm.org/show_bug.cgi?id=38789
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/regulator/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
> index b7f249ee5e68..6d2651cd9887 100644
> --- a/drivers/regulator/Kconfig
> +++ b/drivers/regulator/Kconfig
> @@ -223,6 +223,7 @@ config REGULATOR_CPCAP
>  config REGULATOR_DA903X
>         tristate "Dialog Semiconductor DA9030/DA9034 regulators"
>         depends on PMIC_DA903X
> +       depends on !CC_IS_CLANG # https://bugs.llvm.org/show_bug.cgi?id=38789
>         help
>           Say y here to support the BUCKs and LDOs regulators found on
>           Dialog Semiconductor DA9030/DA9034 PMIC.
> --
> 2.20.0
>

Most pragmatic solution for now. Thanks for the patch.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-07 19:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 10:26 [PATCH] regulator: da903x: don't build with clang Arnd Bergmann
2019-03-07 19:09 ` Nick Desaulniers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.