From nobody Fri Oct 3 11:22:20 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5EAB531280F for ; Tue, 2 Sep 2025 11:59:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756814377; cv=none; b=o3RP1WWJT5ziuSCU5TdZ669l/wZe8+NsWfrAUuspdi69UXidIURJpVt0hMjBLCuy3dOZnJw/IM2XYATy47IYLLB1lbZSxo91dTheLPxUbAFAhllJ4gbdUJa4l955ingvhsj0Ts7swRW/m1X42xRGoMlFMSgQ+M7fAlyIRzluTKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756814377; c=relaxed/simple; bh=fE/sdxLuLVdF+s/hmIyKox10uqamZF81pz2izGaZE30=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X61/i2n70y6IaOeFyg6xHm2h/JPw5L9p55XK91a/ySz/HM9Zz9NUVznWDFj/9adZmB9AbM369oyiO8B7SF0ouJaMgagj1eeuaF09UP8MJnnnV6zQpp+iTLBtJrMfO8JGZWVX8LR3ci4/f6Q1njSJCgB0qcCGvCqo6TETIx1VaS0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=mwfpAm3l; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="mwfpAm3l" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-45b4d89217aso32476945e9.2 for ; Tue, 02 Sep 2025 04:59:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1756814371; x=1757419171; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=FaCre2GzdHbdQSV0ImBvBUo9sM3J8CdQV8vbp4R8HMY=; b=mwfpAm3lchhRSUB7bfE8jhas21dzob18gNmNX8da27DtQGtwpGqzHvdY45aMrNUPV6 B7qTjijiKu/6WK6GyP7Nfh2U2v0CDtcGaJNDvkRfxLLtgvge8pV8649q65twIjQwMdCg oe+lyvrZ51NSuTP7NGaq6Q8QTRbY2gPiK9dV7A3YRUFiqZcePZWYURi288Ly06FsUqFi K6TDCV6qWIWRure38eG168yrDiMgamaG73JaS53TSiU3inOdBgxfh279rpdu693eZZMh fzbOMgO6kLj0BqYzu8qPYBF8L8g4gT3Yw8Xi7N4tkzvUc86d+ZK6ICuKK+CZfEuXt5G/ jHoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756814371; x=1757419171; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FaCre2GzdHbdQSV0ImBvBUo9sM3J8CdQV8vbp4R8HMY=; b=KfPIqDS3f4JHoaT00ONy/ypqJiW261yZzHMgbpk0DOvVN2FjTBTwjqF+rqbVeUfHT4 bas29WlOncGBv/5fMbW0Wq23qKHFe7WWsnoMCEsFUwJ6QcaHI+PxzqA9+W+8YEKQY5eY IYLEMNBgWBYsnJcxoYJu9SV5e2zHgvU4DHUntwS6Cq+v1wDqzLwECPnzxg+lXIobDMx6 mAmygpcxmTlTq2FrfdeOu/e9D2ddki+tWhFjOPy+sMxBY7yGaEjwDKRmSjmK/FWEHe4j +69lvxPY9vQGt8Y+qp4/3OnGHPxG0pbIuN7L6rjdzGWY+lTkCKT0L3BFzfQkXzSxnYXQ ZSQA== X-Forwarded-Encrypted: i=1; AJvYcCVv5kd4rDux3nr7rX+vUMS2PaJxbbe7HAdXvzaAtuiyr/MCPxxlH9nRCpdY8KiQAA1U21L5ypljGH+7VcA=@vger.kernel.org X-Gm-Message-State: AOJu0YwZNKM8AXmrNSQWIYzIgehb9tHbPXlgpHLFEYdjvNejnjF+t2Yj FAU8rU1IU9Sw63C88kCE11M4FQAHJZgAIvTm2eOsLdHNzM4ZUO7nP+3+Xm/tw3PLqq0= X-Gm-Gg: ASbGncuvo22EZVm3pFphEO9vhJhdXqmnS3fO7av7TlGrR8uqL4Zw1Uxcye4u926coca a/5ZRbnhEu4wvHnOLJPm7GX9PU2CYt25gqnGYHGilXytofaMzyVgVbc27HbQsXkeduOqJy00Rgx C3wc/uE99LT7g9wT89A/ZrspwRMFfAQ0AngTonoNZx286DZ1Z89+mIo+MAxz1zfc/0wLuFiAqU2 rjylVQX8fkqa4EYnF/R/LgyRwHyFk8xEcdLwrA+z3P1lGaiQa6BFuZqfFaxGY8m7lioqdYUTmzV GAsyv9c0zadZKmVa8edhOQPRRGQe5TvqDFiTa/5s4bMw94nr8wIM1OVxOBAqhsIKwywGkRnrfrg ceDEjeHtDg1Sgb2tN X-Google-Smtp-Source: AGHT+IEly0vxxEclpdvYe6RqlF5Qq+Fgr46eky8ZTTtYsSRx7+N3oq1XDfjPTJar+7PHSisK+6uKbg== X-Received: by 2002:a05:600c:8b42:b0:45b:7e86:7378 with SMTP id 5b1f17b1804b1-45b8558be6emr82490175e9.34.1756814370975; Tue, 02 Sep 2025 04:59:30 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:dc:7e00:3327:447f:34e9:44f7]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b9c234b24sm10224195e9.16.2025.09.02.04.59.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Sep 2025 04:59:30 -0700 (PDT) From: Bartosz Golaszewski Date: Tue, 02 Sep 2025 13:59:16 +0200 Subject: [PATCH v7 07/16] pinctrl: imx: don't access the pin function radix tree directly Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250902-pinctrl-gpio-pinfuncs-v7-7-bb091daedc52@linaro.org> References: <20250902-pinctrl-gpio-pinfuncs-v7-0-bb091daedc52@linaro.org> In-Reply-To: <20250902-pinctrl-gpio-pinfuncs-v7-0-bb091daedc52@linaro.org> To: Linus Walleij , Bjorn Andersson , Konrad Dybcio , Alexey Klimov , Lorenzo Bianconi , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Paul Cercueil , Kees Cook , Andy Shevchenko , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Dong Aisheng , Fabio Estevam , Shawn Guo , Jacky Bai , Pengutronix Kernel Team , NXP S32 Linux Team , Sascha Hauer , Tony Lindgren , Haojian Zhuang , Geert Uytterhoeven , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Neil Armstrong , Mark Brown Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-hardening@vger.kernel.org, linux-mm@kvack.org, imx@lists.linux.dev, linux-omap@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Bartosz Golaszewski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3263; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=UHL45bU3ycpBbK/9v0T/s+H5JbIm9uq6QUqV6dCnaD4=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBottwTg2jeHg7MNqyFVpB53OT3hBDpMLMqtzNww Mda9A73U02JAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCaLbcEwAKCRARpy6gFHHX chIjD/9z/2COMvLdzt0sZZcC2v2YMaEH7j/ovLMC4xkic7o5czvRo1n7/S6B6mXDm90zT8g9iqO sKmPGq1jec9ahZ/sG7AjV6HIK9GMa6Jm/RZJWIakFs9QpzxgwQmqzQ4XG1z/zSW8jp5CD5tqC7K tYF18u3wvifVH3S9+DbzsNBWeifEDHRCxQ3pVUz/u1q8gk8FmjiUeRFXLOj1T4ibMLkU2jsD2ZV CAksogKfbUZoxCPgosTITDGYDwe3BROXhrBlm7OV1ZQsgJKkBwQgTSG18KV/KJuWLirWxPj/Tjk 4ey1rb0m9dbIpYGtOoGuGXeaZYsejj1HciGAjPItW63hafjF8OFhYALR6ujBpAxC+xDXy6eVTTy NNfK6tvT/ZVzY1SiVxzkyYDg+q8ntrQu/x4CF7rc35jomHHsLis0VGtkedibJ2aMszPzSO2U+Gp 5zzmGNkKITiSdLPojpJQZj0laaPjQi+t4ehqxXw6r6ViTzAk12e+QMSWPYJbypz4HMmPxYLqHek qPCtTOGtwHdg7eqSe3upVSYpcTwVZPBYORfF6Wo7oPN33vEhKtL/UZxCOFjUD4maqIH3MpD8Snr nfGpdqkEfAAOQrs64YvtHt6UTCTkOCcy3/CxRO/fDciQ30/X5DgLQ5ZT/FoySFzYiKZNiA+++6S z+eUAM19e+0hQxw== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski The radix tree containing pin function descriptors should not be accessed directly by drivers. There are dedicated functions for it. I suppose this driver does it so that the memory containing the function description is not duplicated but we're going to address that shortly so convert it to using generic pinctrl APIs. Tested-by: Neil Armstrong Signed-off-by: Bartosz Golaszewski Tested-by: Mark Brown --- drivers/pinctrl/freescale/pinctrl-imx.c | 41 +++++++++++++++--------------= ---- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/free= scale/pinctrl-imx.c index 18de31328540458b7f7e8e2e539a39d61829deb9..c5b17c5ecfb5ee7856bc499de21= 8c288099f334b 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.c +++ b/drivers/pinctrl/freescale/pinctrl-imx.c @@ -580,33 +580,38 @@ static int imx_pinctrl_parse_functions(struct device_= node *np, u32 index) { struct pinctrl_dev *pctl =3D ipctl->pctl; - struct function_desc *func; + struct pinfunction *func; struct group_desc *grp; const char **group_names; + int ret; u32 i; =20 dev_dbg(pctl->dev, "parse function(%d): %pOFn\n", index, np); =20 - func =3D pinmux_generic_get_function(pctl, index); + func =3D devm_kzalloc(ipctl->dev, sizeof(*func), GFP_KERNEL); if (!func) - return -EINVAL; + return -ENOMEM; =20 /* Initialise function */ - func->func.name =3D np->name; - func->func.ngroups =3D of_get_child_count(np); - if (func->func.ngroups =3D=3D 0) { + func->name =3D np->name; + func->ngroups =3D of_get_child_count(np); + if (func->ngroups =3D=3D 0) { dev_info(ipctl->dev, "no groups defined in %pOF\n", np); return -EINVAL; } =20 - group_names =3D devm_kcalloc(ipctl->dev, func->func.ngroups, - sizeof(*func->func.groups), GFP_KERNEL); + group_names =3D devm_kcalloc(ipctl->dev, func->ngroups, + sizeof(*func->groups), GFP_KERNEL); if (!group_names) return -ENOMEM; i =3D 0; for_each_child_of_node_scoped(np, child) group_names[i++] =3D child->name; - func->func.groups =3D group_names; + func->groups =3D group_names; + + ret =3D pinmux_generic_add_pinfunction(pctl, func, NULL); + if (ret < 0) + return ret; =20 i =3D 0; for_each_child_of_node_scoped(np, child) { @@ -615,6 +620,10 @@ static int imx_pinctrl_parse_functions(struct device_n= ode *np, return -ENOMEM; =20 mutex_lock(&ipctl->mutex); + /* + * FIXME: This should use pinctrl_generic_add_group() and not + * access the private radix tree directly. + */ radix_tree_insert(&pctl->pin_group_tree, ipctl->group_index++, grp); mutex_unlock(&ipctl->mutex); @@ -669,20 +678,6 @@ static int imx_pinctrl_probe_dt(struct platform_device= *pdev, } } =20 - for (i =3D 0; i < nfuncs; i++) { - struct function_desc *function; - - function =3D devm_kzalloc(&pdev->dev, sizeof(*function), - GFP_KERNEL); - if (!function) - return -ENOMEM; - - mutex_lock(&ipctl->mutex); - radix_tree_insert(&pctl->pin_function_tree, i, function); - mutex_unlock(&ipctl->mutex); - } - pctl->num_functions =3D nfuncs; - ipctl->group_index =3D 0; if (flat_funcs) { pctl->num_groups =3D of_get_child_count(np); --=20 2.48.1