diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2018-12-13 15:48:45 +0100 |
---|---|---|
committer | Geert Uytterhoeven <geert+renesas@glider.be> | 2019-04-02 09:58:07 +0200 |
commit | fa4d36712f20e2425171ab1f62341ebb6416d3ea (patch) | |
tree | 2be6017e307c6e142f130f918b2068327c5b3674 /drivers/pinctrl/sh-pfc/core.c | |
parent | c481c8178420b8cc8b188807fe6eee8b069ce2d8 (diff) | |
download | linux-fa4d36712f20e2425171ab1f62341ebb6416d3ea.tar.bz2 |
pinctrl: sh-pfc: Validate enum IDs for regs with variable-width fields
Add a run-time check to the PINMUX_CFG_REG_VAR() macro, to ensure the
number of provided enum IDs is correct. This cannot be done at build
time, as the number of values depends on the variable-width fields in
the config register.
This helps catching bugs early.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Diffstat (limited to 'drivers/pinctrl/sh-pfc/core.c')
-rw-r--r-- | drivers/pinctrl/sh-pfc/core.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c index 2ceed2f5ac08..3f989f5cb021 100644 --- a/drivers/pinctrl/sh-pfc/core.c +++ b/drivers/pinctrl/sh-pfc/core.c @@ -756,6 +756,12 @@ static void sh_pfc_check_cfg_reg(const char *drvname, drvname, cfg_reg->reg, rw, cfg_reg->reg_width); sh_pfc_errors++; } + + if (n != cfg_reg->nr_enum_ids) { + pr_err("%s: reg 0x%x: enum_ids[] has %u instead of %u values\n", + drvname, cfg_reg->reg, cfg_reg->nr_enum_ids, n); + sh_pfc_errors++; + } } static void sh_pfc_check_info(const struct sh_pfc_soc_info *info) |