summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/sh-pfc/core.c
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2020-01-10 14:19:17 +0100
committerGeert Uytterhoeven <geert+renesas@glider.be>2020-02-21 13:57:44 +0100
commit1251887c0c78fe7fee1eb1e13546c86a75368cef (patch)
treec6bf79188baf6f50709a8ca9e2eaed645f8baeef /drivers/pinctrl/sh-pfc/core.c
parentc3f8dcee7a0cfe2a94103c6213d74eac99122f01 (diff)
downloadlinux-1251887c0c78fe7fee1eb1e13546c86a75368cef.tar.bz2
pinctrl: sh-pfc: checker: Add helper for safe name comparison
Add a helper to check if two strings are identical, skipping NULL pointers. This simplifies callers. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Link: https://lore.kernel.org/r/20200110131927.1029-4-geert+renesas@glider.be
Diffstat (limited to 'drivers/pinctrl/sh-pfc/core.c')
-rw-r--r--drivers/pinctrl/sh-pfc/core.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c
index d0b87a024516..aad3f62c583f 100644
--- a/drivers/pinctrl/sh-pfc/core.c
+++ b/drivers/pinctrl/sh-pfc/core.c
@@ -751,6 +751,14 @@ static bool __init is0s(const u16 *enum_ids, unsigned int n)
return true;
}
+static bool __init same_name(const char *a, const char *b)
+{
+ if (!a || !b)
+ return false;
+
+ return !strcmp(a, b);
+}
+
static void __init sh_pfc_check_cfg_reg(const char *drvname,
const struct pinmux_cfg_reg *cfg_reg)
{
@@ -790,7 +798,7 @@ static void __init sh_pfc_check_info(const struct sh_pfc_soc_info *info)
/* Check pins */
for (i = 0; i < info->nr_pins; i++) {
for (j = 0; j < i; j++) {
- if (!strcmp(info->pins[i].name, info->pins[j].name))
+ if (same_name(info->pins[i].name, info->pins[j].name))
sh_pfc_err("pin %s/%s: name conflict\n",
info->pins[i].name,
info->pins[j].name);
@@ -824,9 +832,8 @@ static void __init sh_pfc_check_info(const struct sh_pfc_soc_info *info)
}
for (j = 0; j < func->nr_groups; j++) {
for (k = 0; k < info->nr_groups; k++) {
- if (info->groups[k].name &&
- !strcmp(func->groups[j],
- info->groups[k].name)) {
+ if (same_name(func->groups[j],
+ info->groups[k].name)) {
refcnts[k]++;
break;
}