Commit 3c261864 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven

pinctrl: sh-pfc: checker: Add check for config register conflicts

Add a helper to verify that register addresses are unique, and use it to
validate config register descriptors.
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20200110131927.1029-5-geert+renesas@glider.be
parent 1251887c
...@@ -726,8 +726,12 @@ static int sh_pfc_suspend_init(struct sh_pfc *pfc) { return 0; } ...@@ -726,8 +726,12 @@ static int sh_pfc_suspend_init(struct sh_pfc *pfc) { return 0; }
#endif /* CONFIG_PM_SLEEP && CONFIG_ARM_PSCI_FW */ #endif /* CONFIG_PM_SLEEP && CONFIG_ARM_PSCI_FW */
#ifdef DEBUG #ifdef DEBUG
#define SH_PFC_MAX_REGS 300
static unsigned int sh_pfc_errors __initdata = 0; static unsigned int sh_pfc_errors __initdata = 0;
static unsigned int sh_pfc_warnings __initdata = 0; static unsigned int sh_pfc_warnings __initdata = 0;
static u32 *sh_pfc_regs __initdata = NULL;
static u32 sh_pfc_num_regs __initdata = 0;
#define sh_pfc_err(fmt, ...) \ #define sh_pfc_err(fmt, ...) \
do { \ do { \
...@@ -759,11 +763,31 @@ static bool __init same_name(const char *a, const char *b) ...@@ -759,11 +763,31 @@ static bool __init same_name(const char *a, const char *b)
return !strcmp(a, b); return !strcmp(a, b);
} }
static void __init sh_pfc_check_reg(const char *drvname, u32 reg)
{
unsigned int i;
for (i = 0; i < sh_pfc_num_regs; i++)
if (reg == sh_pfc_regs[i]) {
sh_pfc_err("reg 0x%x conflict\n", reg);
return;
}
if (sh_pfc_num_regs == SH_PFC_MAX_REGS) {
pr_warn_once("%s: Please increase SH_PFC_MAX_REGS\n", drvname);
return;
}
sh_pfc_regs[sh_pfc_num_regs++] = reg;
}
static void __init sh_pfc_check_cfg_reg(const char *drvname, static void __init sh_pfc_check_cfg_reg(const char *drvname,
const struct pinmux_cfg_reg *cfg_reg) const struct pinmux_cfg_reg *cfg_reg)
{ {
unsigned int i, n, rw, fw; unsigned int i, n, rw, fw;
sh_pfc_check_reg(drvname, cfg_reg->reg);
if (cfg_reg->field_width) { if (cfg_reg->field_width) {
/* Checked at build time */ /* Checked at build time */
return; return;
...@@ -794,6 +818,7 @@ static void __init sh_pfc_check_info(const struct sh_pfc_soc_info *info) ...@@ -794,6 +818,7 @@ static void __init sh_pfc_check_info(const struct sh_pfc_soc_info *info)
unsigned int i, j, k; unsigned int i, j, k;
pr_info("Checking %s\n", drvname); pr_info("Checking %s\n", drvname);
sh_pfc_num_regs = 0;
/* Check pins */ /* Check pins */
for (i = 0; i < info->nr_pins; i++) { for (i = 0; i < info->nr_pins; i++) {
...@@ -868,6 +893,11 @@ static void __init sh_pfc_check_driver(const struct platform_driver *pdrv) ...@@ -868,6 +893,11 @@ static void __init sh_pfc_check_driver(const struct platform_driver *pdrv)
{ {
unsigned int i; unsigned int i;
sh_pfc_regs = kcalloc(SH_PFC_MAX_REGS, sizeof(*sh_pfc_regs),
GFP_KERNEL);
if (!sh_pfc_regs)
return;
pr_warn("Checking builtin pinmux tables\n"); pr_warn("Checking builtin pinmux tables\n");
for (i = 0; pdrv->id_table[i].name[0]; i++) for (i = 0; pdrv->id_table[i].name[0]; i++)
...@@ -880,6 +910,8 @@ static void __init sh_pfc_check_driver(const struct platform_driver *pdrv) ...@@ -880,6 +910,8 @@ static void __init sh_pfc_check_driver(const struct platform_driver *pdrv)
pr_warn("Detected %u errors and %u warnings\n", sh_pfc_errors, pr_warn("Detected %u errors and %u warnings\n", sh_pfc_errors,
sh_pfc_warnings); sh_pfc_warnings);
kfree(sh_pfc_regs);
} }
#else /* !DEBUG */ #else /* !DEBUG */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment