mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xiaolei Wang <wangxiaolei01@kaihong.com>
To: linusw@kernel.org, florian.fainelli@broadcom.com,
	bcm-kernel-feedback-list@broadcom.com, daniel@dragonzap.com,
	wangxiaolei01@kaihong.com, iivanov@suse.de,
	andrea.porta@suse.com, phil@raspberrypi.com
Cc: linux-gpio@vger.kernel.org, linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] pinctrl: rp1: use pinctrl_utils_free_map() for map cleanup
Date: Thu, 26 Nov 2026 03:54:20 +0000	[thread overview]
Message-ID: <20261126035420.1836760-3-wangxiaolei01@kaihong.com> (raw)
In-Reply-To: <20261126035420.1836760-1-wangxiaolei01@kaihong.com>

The rp1 driver open-codes a dt_free_map callback that frees the config
arrays of pinctrl maps and the map array itself.  This duplicates
pinctrl_utils_free_map(), which the pinctrl core already provides for
exactly this purpose.

The local copy only handles CONFIGS_PIN maps.  Because the driver can
delegate map creation to the generic pinconf DT parser, CONFIGS_GROUP
maps may also be produced, and their config arrays would be leaked by
the open-coded version.  The core helper handles both types, so using
it removes the duplicate code and closes that leak at the same time.

Signed-off-by: Xiaolei Wang <wangxiaolei01@kaihong.com>
---
 drivers/pinctrl/pinctrl-rp1.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-rp1.c b/drivers/pinctrl/pinctrl-rp1.c
index 99566a25ecb4..bf2c300eef29 100644
--- a/drivers/pinctrl/pinctrl-rp1.c
+++ b/drivers/pinctrl/pinctrl-rp1.c
@@ -1089,18 +1089,6 @@ static void rp1_pctl_pin_dbg_show(struct pinctrl_dev *pctldev,
 		   irq, irq_type_names[pin->irq_type]);
 }
 
-static void rp1_pctl_dt_free_map(struct pinctrl_dev *pctldev,
-				 struct pinctrl_map *maps, unsigned int num_maps)
-{
-	int i;
-
-	for (i = 0; i < num_maps; i++)
-		if (maps[i].type == PIN_MAP_TYPE_CONFIGS_PIN)
-			kfree(maps[i].data.configs.configs);
-
-	kfree(maps);
-}
-
 static int rp1_pctl_legacy_map_func(struct rp1_pinctrl *pc,
 				    struct device_node *np, u32 pin, u32 fnum,
 				    struct pinctrl_map *maps,
@@ -1286,7 +1274,7 @@ static int rp1_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	return 0;
 
 out:
-	rp1_pctl_dt_free_map(pctldev, maps, reserved_maps);
+	pinctrl_utils_free_map(pctldev, maps, reserved_maps);
 	return err;
 }
 
@@ -1296,7 +1284,7 @@ static const struct pinctrl_ops rp1_pctl_ops = {
 	.get_group_pins = rp1_pctl_get_group_pins,
 	.pin_dbg_show = rp1_pctl_pin_dbg_show,
 	.dt_node_to_map = rp1_pctl_dt_node_to_map,
-	.dt_free_map = rp1_pctl_dt_free_map,
+	.dt_free_map = pinctrl_utils_free_map,
 };
 
 static int rp1_pmx_free(struct pinctrl_dev *pctldev, unsigned int offset)
-- 
2.34.1


      parent reply	other threads:[~2026-11-26  3:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  3:54 [PATCH 0/2] pinctrl: rp1: fix RT sleep and clean up map freeing Xiaolei Wang
2026-11-26  3:54 ` [PATCH 1/2] pinctrl: rp1: use raw spinlock for gpio regmap Xiaolei Wang
2026-11-26  3:54 ` Xiaolei Wang [this message]

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=20261126035420.1836760-3-wangxiaolei01@kaihong.com \
    --to=wangxiaolei01@kaihong.com \
    --cc=andrea.porta@suse.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=daniel@dragonzap.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=iivanov@suse.de \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=phil@raspberrypi.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®