Message ID | 20181213162855.14190-7-geert+renesas@glider.be |
---|---|
State | New |
Headers | show |
Series | pinctrl: sh-pfc: Fix number of pins/marks mismatches | expand |
On Thu, Dec 13, 2018 at 05:28:55PM +0100, Geert Uytterhoeven wrote: > Add a build-time check, to ensure the number of pins and pin marks in a > pin group matches. This helps catching bugs early. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> A very nice enhancement :) Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
On Thu, Dec 13, 2018 at 5:29 PM Geert Uytterhoeven <geert+renesas@glider.be> wrote: > Add a build-time check, to ensure the number of pins and pin marks in a > pin group matches. This helps catching bugs early. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> > --- > drivers/pinctrl/sh-pfc/sh_pfc.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/pinctrl/sh-pfc/sh_pfc.h b/drivers/pinctrl/sh-pfc/sh_pfc.h > index 78dc342d7b390e02..a2c5d530aaa1c0b3 100644 > --- a/drivers/pinctrl/sh-pfc/sh_pfc.h > +++ b/drivers/pinctrl/sh-pfc/sh_pfc.h > @@ -41,7 +41,8 @@ struct sh_pfc_pin { > .name = #alias, \ > .pins = n##_pins, \ > .mux = n##_mux, \ > - .nr_pins = ARRAY_SIZE(n##_pins), \ > + .nr_pins = ARRAY_SIZE(n##_pins) + \ > + BUILD_BUG_ON_ZERO(!(sizeof(n##_pins) == sizeof(n##_mux))), \ Obviously the above can be written as BUILD_BUG_ON_ZERO(sizeof(n##_pins) != sizeof(n##_mux)), \ too. The "ZERO" applies to the return value, not to the condition, which initially mislead me, but I still got the actual code right ;-) > } > #define SH_PFC_PIN_GROUP(n) SH_PFC_PIN_GROUP_ALIAS(n, n) Gr{oetje,eeting}s, Geert
diff --git a/drivers/pinctrl/sh-pfc/sh_pfc.h b/drivers/pinctrl/sh-pfc/sh_pfc.h index 78dc342d7b390e02..a2c5d530aaa1c0b3 100644 --- a/drivers/pinctrl/sh-pfc/sh_pfc.h +++ b/drivers/pinctrl/sh-pfc/sh_pfc.h @@ -41,7 +41,8 @@ struct sh_pfc_pin { .name = #alias, \ .pins = n##_pins, \ .mux = n##_mux, \ - .nr_pins = ARRAY_SIZE(n##_pins), \ + .nr_pins = ARRAY_SIZE(n##_pins) + \ + BUILD_BUG_ON_ZERO(!(sizeof(n##_pins) == sizeof(n##_mux))), \ } #define SH_PFC_PIN_GROUP(n) SH_PFC_PIN_GROUP_ALIAS(n, n)
Add a build-time check, to ensure the number of pins and pin marks in a pin group matches. This helps catching bugs early. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- drivers/pinctrl/sh-pfc/sh_pfc.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)