All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert+renesas@glider.be>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org,
	Geert Uytterhoeven <geert+renesas@glider.be>
Subject: [PATCH 05/10] pinctrl: renesas: checker: Add pin group sharing checks
Date: Thu, 23 Dec 2021 15:56:21 +0100	[thread overview]
Message-ID: <e16fdf729156e13b591d2f082f2cc934da580074.1640270559.git.geert+renesas@glider.be> (raw)
In-Reply-To: <cover.1640270559.git.geert+renesas@glider.be>

Add checks for discovering pin groups that could share pin data, as
sharing reduces kernel size.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/pinctrl/renesas/core.c | 37 +++++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/renesas/core.c b/drivers/pinctrl/renesas/core.c
index 5c0a6212706270e7..57a06b5ea17444e2 100644
--- a/drivers/pinctrl/renesas/core.c
+++ b/drivers/pinctrl/renesas/core.c
@@ -924,6 +924,35 @@ static void __init sh_pfc_check_bias_reg(const struct sh_pfc_soc_info *info,
 		sh_pfc_check_pin(info, bias->puen, bias->pins[i]);
 }
 
+static void __init sh_pfc_compare_groups(const char *drvname,
+					 const struct sh_pfc_pin_group *a,
+					 const struct sh_pfc_pin_group *b)
+{
+	unsigned int i;
+	size_t len;
+
+	if (same_name(a->name, b->name))
+		sh_pfc_err("group %s: name conflict\n", a->name);
+
+	if (a->nr_pins > b->nr_pins)
+		swap(a, b);
+
+	len = a->nr_pins * sizeof(a->pins[0]);
+	for (i = 0; i <= b->nr_pins - a->nr_pins; i++) {
+		if (a->pins == b->pins + i || a->mux == b->mux + i ||
+		    memcmp(a->pins, b->pins + i, len) ||
+		    memcmp(a->mux, b->mux + i, len))
+			continue;
+
+		if (a->nr_pins == b->nr_pins)
+			sh_pfc_warn("group %s can be an alias for %s\n",
+				    a->name, b->name);
+		else
+			sh_pfc_warn("group %s is a subset of %s\n", a->name,
+				    b->name);
+	}
+}
+
 static void __init sh_pfc_check_info(const struct sh_pfc_soc_info *info)
 {
 	const struct pinmux_bias_reg *bias_regs = info->bias_regs;
@@ -1000,11 +1029,9 @@ static void __init sh_pfc_check_info(const struct sh_pfc_soc_info *info)
 			sh_pfc_err("empty group %u\n", i);
 			continue;
 		}
-		for (j = 0; j < i; j++) {
-			if (same_name(group->name, info->groups[j].name))
-				sh_pfc_err("group %s: name conflict\n",
-					   group->name);
-		}
+		for (j = 0; j < i; j++)
+			sh_pfc_compare_groups(drvname, group, &info->groups[j]);
+
 		if (!refcnts[i])
 			sh_pfc_err("orphan group %s\n", group->name);
 		else if (refcnts[i] > 1)
-- 
2.25.1


  parent reply	other threads:[~2021-12-23 14:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-23 14:56 [PATCH 00/10] pinctrl: renesas: checker: Miscellaneous improvements Geert Uytterhoeven
2021-12-23 14:56 ` [PATCH 01/10] pinctrl: renesas: Remove unused pfc parameter from .pin_to_pocctrl() Geert Uytterhoeven
2021-12-23 14:56 ` [PATCH 02/10] pinctrl: renesas: Factor out .pin_to_portcr() address handling Geert Uytterhoeven
2021-12-23 14:56 ` [PATCH 03/10] pinctrl: renesas: Pass sh_pfc_soc_info to rcar_pin_to_bias_reg() Geert Uytterhoeven
2021-12-23 14:56 ` [PATCH 04/10] pinctrl: renesas: checker: Simplify same_name() Geert Uytterhoeven
2021-12-23 14:56 ` Geert Uytterhoeven [this message]
2021-12-23 14:56 ` [PATCH 06/10] pinctrl: renesas: checker: Validate bias configs consistency Geert Uytterhoeven
2021-12-23 14:56 ` [PATCH 07/10] pinctrl: renesas: checker: Validate drive strength " Geert Uytterhoeven
2021-12-23 14:56 ` [PATCH 08/10] pinctrl: renesas: checker: Validate I/O voltage " Geert Uytterhoeven
2021-12-23 14:56 ` [PATCH 09/10] pinctrl: renesas: checker: Check bias pin conflicts Geert Uytterhoeven
2021-12-23 14:56 ` [PATCH 10/10] pinctrl: renesas: checker: Check drive " Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e16fdf729156e13b591d2f082f2cc934da580074.1640270559.git.geert+renesas@glider.be \
    --to=geert+renesas@glider.be \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.