Message ID | 20190125165305.8567-2-geert+renesas@glider.be (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Geert Uytterhoeven |
Headers | show |
Series | pinctrl: sh-pfc: Validation and compile-testing | expand |
On Fri, Jan 25, 2019 at 05:52:56PM +0100, Geert Uytterhoeven wrote: > Add a build-time check, to ensure the register and field widths in > descriptors for config registers with fixed-width fields are sane. > This helps catching bugs early. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> > --- > v2: > - Convert from run-time to build-time check. Nice :) Reviewed-by: Simon Horman <horms+renesas@verge.net.au> > --- > 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 46d477ff510921f3..56016cb76769c97b 100644 > --- a/drivers/pinctrl/sh-pfc/sh_pfc.h > +++ b/drivers/pinctrl/sh-pfc/sh_pfc.h > @@ -126,7 +126,8 @@ struct pinmux_cfg_reg { > * one for each possible combination of the register field bit values. > */ > #define PINMUX_CFG_REG(name, r, r_width, f_width) \ > - .reg = r, .reg_width = r_width, .field_width = f_width, \ > + .reg = r, .reg_width = r_width, \ > + .field_width = f_width + BUILD_BUG_ON_ZERO(r_width % f_width), \ > .enum_ids = (const u16 [(r_width / f_width) * (1 << f_width)]) > > /* > -- > 2.17.1 >
diff --git a/drivers/pinctrl/sh-pfc/sh_pfc.h b/drivers/pinctrl/sh-pfc/sh_pfc.h index 46d477ff510921f3..56016cb76769c97b 100644 --- a/drivers/pinctrl/sh-pfc/sh_pfc.h +++ b/drivers/pinctrl/sh-pfc/sh_pfc.h @@ -126,7 +126,8 @@ struct pinmux_cfg_reg { * one for each possible combination of the register field bit values. */ #define PINMUX_CFG_REG(name, r, r_width, f_width) \ - .reg = r, .reg_width = r_width, .field_width = f_width, \ + .reg = r, .reg_width = r_width, \ + .field_width = f_width + BUILD_BUG_ON_ZERO(r_width % f_width), \ .enum_ids = (const u16 [(r_width / f_width) * (1 << f_width)]) /*
Add a build-time check, to ensure the register and field widths in descriptors for config registers with fixed-width fields are sane. This helps catching bugs early. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- v2: - Convert from run-time to build-time check. --- drivers/pinctrl/sh-pfc/sh_pfc.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)