* [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category
@ 2025-07-24 9:24 Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 01/15] lib: provide kmemdup_const() Bartosz Golaszewski
` (14 more replies)
0 siblings, 15 replies; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski, Konrad Dybcio
NOTE: This is obviously targetting v6.18.
NOTER: This series is a bit all over the place and looks like it should
be split into at least two separate ones but I figured sending it in its
entirety better shows the whole picture - namely the fact that the
pinfunction handling rework is there to allow using the generic pinux
functions in qualcomm drivers without ballooning up runtime memory
usage.
NOTEST: I tested several Qualcomm platforms but I have no means of
testing Mediatek and others. Tested-by tags are appreciated.
Problem: when pinctrl core binds pins to a consumer device and the
pinmux ops of the underlying driver are marked as strict, the pin in
question can no longer be requested as a GPIO using the GPIO descriptor
API. It will result in the following error:
[ 5.095688] sc8280xp-tlmm f100000.pinctrl: pin GPIO_25 already requested by regulator-edp-3p3; cannot claim for f100000.pinctrl:570
[ 5.107822] sc8280xp-tlmm f100000.pinctrl: error -EINVAL: pin-25 (f100000.pinctrl:570)
This typically makes sense except when the pins are muxed to a function
that actually says "GPIO". Of course, the function name is just a string
so it has no meaning to the pinctrl subsystem.
We have many Qualcomm SoCs (and I can imagine it's a common pattern in
other platforms as well) where we mux a pin to "gpio" function using the
`pinctrl-X` property in order to configure bias or drive-strength and
then access it using the gpiod API. This makes it impossible to mark the
pin controller module as "strict".
This series proposes to introduce a concept of a sub-category of
pinfunctions: GPIO functions where the above is not true and the pin
muxed as a GPIO can still be accessed via the GPIO consumer API even for
strict pinmuxers.
To that end: we first clean up the drivers that use struct function_desc
and make them use the smaller struct pinfunction instead - which is the
correct structure for drivers to describe their pin functions with. We
also rework pinmux core to not duplicate memory used to store the
pinfunctions unless they're allocated dynamically.
First: provide the kmemdup_const() helper which only duplicates memory
if it's not in the .rodata section. Then rework all pinctrl drivers that
instantiate objects of type struct function_desc as they should only be
created by pinmux core. Next constify the return value of the accessor
used to expose these structures to users and finally convert the
pinfunction object within struct function_desc to a pointer and use
kmemdup_const() to assign it. With this done proceed to add
infrastructure for the GPIO pin function category and use it in Qualcomm
drivers. At the very end: make the Qualcomm pinmuxer strict.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
Changes in v3:
- Add more patches in front: convert pinctrl drivers to stop defining
their own struct function_desc objects and make pinmux core not
duplicate .rodata memory in which struct pinfunction objects are
stored.
- Add a patch constifying pinmux_generic_get_function().
- Drop patches that were applied upstream.
- Link to v2: https://lore.kernel.org/r/20250709-pinctrl-gpio-pinfuncs-v2-0-b6135149c0d9@linaro.org
Changes in v2:
- Extend the series with providing pinmux_generic_add_pinfunction(),
using it in several drivers and converting pinctrl-msm to using
generic pinmux helpers
- Add a generic function_is_gpio() callback for pinmux_ops
- Convert all qualcomm drivers to using the new GPIO pin category so
that we can actually enable the strict flag
- Link to v1: https://lore.kernel.org/r/20250702-pinctrl-gpio-pinfuncs-v1-0-ed2bd0f9468d@linaro.org
---
Bartosz Golaszewski (15):
lib: provide kmemdup_const()
pinctrl: ingenic: use struct pinfunction instead of struct function_desc
pinctrl: airoha: replace struct function_desc with struct pinfunction
pinctrl: mediatek: mt7988: use PINCTRL_PIN_FUNCTION()
pinctrl: mediatek: moore: replace struct function_desc with struct pinfunction
pinctrl: imx: don't access the pin function radix tree directly
pinctrl: keembay: release allocated memory in detach path
pinctrl: keembay: use a dedicated structure for the pinfunction description
pinctrl: constify pinmux_generic_get_function()
pinctrl: make struct pinfunction a pointer in struct function_desc
pinctrl: qcom: use generic pin function helpers
pinctrl: allow to mark pin functions as requestable GPIOs
pinctrl: qcom: add infrastructure for marking pin functions as GPIOs
pinctrl: qcom: mark the `gpio` and `egpio` pins function as non-strict functions
pinctrl: qcom: make the pinmuxing strict
drivers/pinctrl/freescale/pinctrl-imx.c | 42 ++++++----------
drivers/pinctrl/mediatek/pinctrl-airoha.c | 18 +++----
drivers/pinctrl/mediatek/pinctrl-moore.c | 10 ++--
drivers/pinctrl/mediatek/pinctrl-moore.h | 7 +--
drivers/pinctrl/mediatek/pinctrl-mt7622.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-mt7623.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-mt7629.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-mt7981.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-mt7986.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-mt7988.c | 44 +++++++----------
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 2 +-
drivers/pinctrl/pinctrl-equilibrium.c | 2 +-
drivers/pinctrl/pinctrl-ingenic.c | 49 +++++++++---------
drivers/pinctrl/pinctrl-keembay.c | 25 ++++++----
drivers/pinctrl/pinctrl-single.c | 4 +-
drivers/pinctrl/pinmux.c | 63 +++++++++++++++++++++---
drivers/pinctrl/pinmux.h | 9 ++--
drivers/pinctrl/qcom/pinctrl-ipq5018.c | 2 +-
drivers/pinctrl/qcom/pinctrl-ipq5332.c | 2 +-
drivers/pinctrl/qcom/pinctrl-ipq5424.c | 2 +-
drivers/pinctrl/qcom/pinctrl-ipq6018.c | 2 +-
drivers/pinctrl/qcom/pinctrl-ipq8074.c | 2 +-
drivers/pinctrl/qcom/pinctrl-ipq9574.c | 2 +-
drivers/pinctrl/qcom/pinctrl-mdm9607.c | 2 +-
drivers/pinctrl/qcom/pinctrl-mdm9615.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm.c | 45 ++++++-----------
drivers/pinctrl/qcom/pinctrl-msm.h | 5 ++
drivers/pinctrl/qcom/pinctrl-msm8226.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8660.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8909.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8916.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8917.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8953.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8960.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8976.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8994.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8996.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8998.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8x74.c | 2 +-
drivers/pinctrl/qcom/pinctrl-qcm2290.c | 4 +-
drivers/pinctrl/qcom/pinctrl-qcs404.c | 2 +-
drivers/pinctrl/qcom/pinctrl-qcs615.c | 2 +-
drivers/pinctrl/qcom/pinctrl-qcs8300.c | 4 +-
drivers/pinctrl/qcom/pinctrl-qdu1000.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sa8775p.c | 4 +-
drivers/pinctrl/qcom/pinctrl-sar2130p.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sc7180.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sc7280.c | 4 +-
drivers/pinctrl/qcom/pinctrl-sc8180x.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sc8280xp.c | 4 +-
drivers/pinctrl/qcom/pinctrl-sdm660.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sdm670.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sdm845.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sdx55.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sdx65.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sdx75.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm4450.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm6115.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm6125.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm6350.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm6375.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm7150.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm8150.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm8250.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm8350.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm8450.c | 4 +-
drivers/pinctrl/qcom/pinctrl-sm8550.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm8650.c | 4 +-
drivers/pinctrl/qcom/pinctrl-sm8750.c | 4 +-
drivers/pinctrl/qcom/pinctrl-x1e80100.c | 2 +-
drivers/pinctrl/renesas/pinctrl-rza1.c | 2 +-
drivers/pinctrl/renesas/pinctrl-rza2.c | 2 +-
drivers/pinctrl/renesas/pinctrl-rzg2l.c | 2 +-
drivers/pinctrl/renesas/pinctrl-rzv2m.c | 2 +-
include/linux/pinctrl/pinctrl.h | 14 ++++++
include/linux/pinctrl/pinmux.h | 2 +
include/linux/string.h | 1 +
mm/util.c | 21 ++++++++
78 files changed, 275 insertions(+), 224 deletions(-)
---
base-commit: 05adbee3ad528100ab0285c15c91100e19e10138
change-id: 20250701-pinctrl-gpio-pinfuncs-de82bd9aac43
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v3 01/15] lib: provide kmemdup_const()
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
@ 2025-07-24 9:24 ` Bartosz Golaszewski
2025-07-24 11:04 ` Andy Shevchenko
2025-07-24 11:09 ` Lorenzo Stoakes
2025-07-24 9:24 ` [PATCH v3 02/15] pinctrl: ingenic: use struct pinfunction instead of struct function_desc Bartosz Golaszewski
` (13 subsequent siblings)
14 siblings, 2 replies; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Provide a function similar to strdup_const() but for copying blocks of
memory that are likely to be placed in .rodata.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
include/linux/string.h | 1 +
mm/util.c | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/include/linux/string.h b/include/linux/string.h
index fdd3442c6bcbd786e177b6e87358e1065a0ffafc..1a86d61de91204563e4179938c4dfc77108e03aa 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -304,6 +304,7 @@ extern char *kstrndup(const char *s, size_t len, gfp_t gfp);
extern void *kmemdup_noprof(const void *src, size_t len, gfp_t gfp) __realloc_size(2);
#define kmemdup(...) alloc_hooks(kmemdup_noprof(__VA_ARGS__))
+extern const void *kmemdup_const(const void *src, size_t len, gfp_t gfp);
extern void *kvmemdup(const void *src, size_t len, gfp_t gfp) __realloc_size(2);
extern char *kmemdup_nul(const char *s, size_t len, gfp_t gfp);
extern void *kmemdup_array(const void *src, size_t count, size_t element_size, gfp_t gfp)
diff --git a/mm/util.c b/mm/util.c
index f814e6a59ab1d354b8cd04ebf3903626f6b23a6c..f4df9194b0c69c27ff06e6ba1d1137c559035470 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -142,6 +142,27 @@ void *kmemdup_noprof(const void *src, size_t len, gfp_t gfp)
}
EXPORT_SYMBOL(kmemdup_noprof);
+/**
+ * kmemdup_const - conditionally duplicate a region of memory
+ *
+ * @src: memory region to duplicate
+ * @len: memory region length,
+ * @gfp: GFP mask to use
+ *
+ * Return: source address if it is in .rodata or the return value of kmemdup()
+ * to which the function falls back otherwise.
+ *
+ * Note: the returned address must not be passed to kfree(), the caller must
+ * use kfree_const() instead.
+ */
+const void *kmemdup_const(const void *src, size_t len, gfp_t gfp)
+{
+ if (is_kernel_rodata((unsigned long)src))
+ return src;
+
+ return kmemdup(src, len, gfp);
+}
+
/**
* kmemdup_array - duplicate a given array.
*
--
2.48.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 02/15] pinctrl: ingenic: use struct pinfunction instead of struct function_desc
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 01/15] lib: provide kmemdup_const() Bartosz Golaszewski
@ 2025-07-24 9:24 ` Bartosz Golaszewski
2025-07-30 15:35 ` Paul Cercueil
2025-07-24 9:24 ` [PATCH v3 03/15] pinctrl: airoha: replace struct function_desc with struct pinfunction Bartosz Golaszewski
` (12 subsequent siblings)
14 siblings, 1 reply; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
struct function_desc is a wrapper around struct pinfunction with an
additional void *data pointer. This driver doesn't use the data pointer.
We're also working towards reducing the usage of struct function_desc in
pinctrl drivers - they should only be created by pinmux core and
accessed by drivers using pinmux_generic_get_function(). Replace the
struct function_desc objects in this driver with smaller struct
pinfunction instances.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/pinctrl/pinctrl-ingenic.c | 45 +++++++++++++++++----------------------
1 file changed, 20 insertions(+), 25 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index 79119cf20efcf8cc701647d9ff979c2b71bf7589..0ee8554c5446c4167c9b0e6b9397a2507ca57419 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -96,11 +96,8 @@
.data = (void *)func, \
}
-#define INGENIC_PIN_FUNCTION(_name_, id) \
- { \
- .func = PINCTRL_PINFUNCTION(_name_, id##_groups, ARRAY_SIZE(id##_groups)), \
- .data = NULL, \
- }
+#define INGENIC_PIN_FUNCTION(_name_, id) \
+ PINCTRL_PINFUNCTION(_name_, id##_groups, ARRAY_SIZE(id##_groups))
enum jz_version {
ID_JZ4730,
@@ -128,7 +125,7 @@ struct ingenic_chip_info {
const struct group_desc *groups;
unsigned int num_groups;
- const struct function_desc *functions;
+ const struct pinfunction *functions;
unsigned int num_functions;
const u32 *pull_ups, *pull_downs;
@@ -263,7 +260,7 @@ static const char *jz4730_pwm1_groups[] = { "pwm1", };
static const char *jz4730_mii_groups[] = { "mii", };
static const char *jz4730_i2s_groups[] = { "i2s-data", "i2s-master", "i2s-slave", };
-static const struct function_desc jz4730_functions[] = {
+static const struct pinfunction jz4730_functions[] = {
INGENIC_PIN_FUNCTION("mmc", jz4730_mmc),
INGENIC_PIN_FUNCTION("uart0", jz4730_uart0),
INGENIC_PIN_FUNCTION("uart1", jz4730_uart1),
@@ -370,7 +367,7 @@ static const char *jz4740_pwm5_groups[] = { "pwm5", };
static const char *jz4740_pwm6_groups[] = { "pwm6", };
static const char *jz4740_pwm7_groups[] = { "pwm7", };
-static const struct function_desc jz4740_functions[] = {
+static const struct pinfunction jz4740_functions[] = {
INGENIC_PIN_FUNCTION("mmc", jz4740_mmc),
INGENIC_PIN_FUNCTION("uart0", jz4740_uart0),
INGENIC_PIN_FUNCTION("uart1", jz4740_uart1),
@@ -474,7 +471,7 @@ static const char *jz4725b_pwm3_groups[] = { "pwm3", };
static const char *jz4725b_pwm4_groups[] = { "pwm4", };
static const char *jz4725b_pwm5_groups[] = { "pwm5", };
-static const struct function_desc jz4725b_functions[] = {
+static const struct pinfunction jz4725b_functions[] = {
INGENIC_PIN_FUNCTION("mmc0", jz4725b_mmc0),
INGENIC_PIN_FUNCTION("mmc1", jz4725b_mmc1),
INGENIC_PIN_FUNCTION("uart", jz4725b_uart),
@@ -606,7 +603,7 @@ static const char *jz4750_pwm3_groups[] = { "pwm3", };
static const char *jz4750_pwm4_groups[] = { "pwm4", };
static const char *jz4750_pwm5_groups[] = { "pwm5", };
-static const struct function_desc jz4750_functions[] = {
+static const struct pinfunction jz4750_functions[] = {
INGENIC_PIN_FUNCTION("uart0", jz4750_uart0),
INGENIC_PIN_FUNCTION("uart1", jz4750_uart1),
INGENIC_PIN_FUNCTION("uart2", jz4750_uart2),
@@ -771,7 +768,7 @@ static const char *jz4755_pwm3_groups[] = { "pwm3", };
static const char *jz4755_pwm4_groups[] = { "pwm4", };
static const char *jz4755_pwm5_groups[] = { "pwm5", };
-static const struct function_desc jz4755_functions[] = {
+static const struct pinfunction jz4755_functions[] = {
INGENIC_PIN_FUNCTION("uart0", jz4755_uart0),
INGENIC_PIN_FUNCTION("uart1", jz4755_uart1),
INGENIC_PIN_FUNCTION("uart2", jz4755_uart2),
@@ -1106,7 +1103,7 @@ static const char *jz4760_pwm6_groups[] = { "pwm6", };
static const char *jz4760_pwm7_groups[] = { "pwm7", };
static const char *jz4760_otg_groups[] = { "otg-vbus", };
-static const struct function_desc jz4760_functions[] = {
+static const struct pinfunction jz4760_functions[] = {
INGENIC_PIN_FUNCTION("uart0", jz4760_uart0),
INGENIC_PIN_FUNCTION("uart1", jz4760_uart1),
INGENIC_PIN_FUNCTION("uart2", jz4760_uart2),
@@ -1444,7 +1441,7 @@ static const char *jz4770_pwm6_groups[] = { "pwm6", };
static const char *jz4770_pwm7_groups[] = { "pwm7", };
static const char *jz4770_mac_groups[] = { "mac-rmii", "mac-mii", };
-static const struct function_desc jz4770_functions[] = {
+static const struct pinfunction jz4770_functions[] = {
INGENIC_PIN_FUNCTION("uart0", jz4770_uart0),
INGENIC_PIN_FUNCTION("uart1", jz4770_uart1),
INGENIC_PIN_FUNCTION("uart2", jz4770_uart2),
@@ -1723,7 +1720,7 @@ static const char *jz4775_mac_groups[] = {
};
static const char *jz4775_otg_groups[] = { "otg-vbus", };
-static const struct function_desc jz4775_functions[] = {
+static const struct pinfunction jz4775_functions[] = {
INGENIC_PIN_FUNCTION("uart0", jz4775_uart0),
INGENIC_PIN_FUNCTION("uart1", jz4775_uart1),
INGENIC_PIN_FUNCTION("uart2", jz4775_uart2),
@@ -1976,7 +1973,7 @@ static const char *jz4780_dmic_groups[] = { "dmic", };
static const char *jz4780_cim_groups[] = { "cim-data", };
static const char *jz4780_hdmi_ddc_groups[] = { "hdmi-ddc", };
-static const struct function_desc jz4780_functions[] = {
+static const struct pinfunction jz4780_functions[] = {
INGENIC_PIN_FUNCTION("uart0", jz4770_uart0),
INGENIC_PIN_FUNCTION("uart1", jz4770_uart1),
INGENIC_PIN_FUNCTION("uart2", jz4780_uart2),
@@ -2211,7 +2208,7 @@ static const char *x1000_pwm3_groups[] = { "pwm3", };
static const char *x1000_pwm4_groups[] = { "pwm4", };
static const char *x1000_mac_groups[] = { "mac", };
-static const struct function_desc x1000_functions[] = {
+static const struct pinfunction x1000_functions[] = {
INGENIC_PIN_FUNCTION("uart0", x1000_uart0),
INGENIC_PIN_FUNCTION("uart1", x1000_uart1),
INGENIC_PIN_FUNCTION("uart2", x1000_uart2),
@@ -2341,7 +2338,7 @@ static const char *x1500_pwm2_groups[] = { "pwm2", };
static const char *x1500_pwm3_groups[] = { "pwm3", };
static const char *x1500_pwm4_groups[] = { "pwm4", };
-static const struct function_desc x1500_functions[] = {
+static const struct pinfunction x1500_functions[] = {
INGENIC_PIN_FUNCTION("uart0", x1500_uart0),
INGENIC_PIN_FUNCTION("uart1", x1500_uart1),
INGENIC_PIN_FUNCTION("uart2", x1500_uart2),
@@ -2562,7 +2559,7 @@ static const char * const x1600_pwm7_groups[] = { "pwm7-b10", "pwm7-b21", };
static const char * const x1600_mac_groups[] = { "mac", };
-static const struct function_desc x1600_functions[] = {
+static const struct pinfunction x1600_functions[] = {
INGENIC_PIN_FUNCTION("uart0", x1600_uart0),
INGENIC_PIN_FUNCTION("uart1", x1600_uart1),
INGENIC_PIN_FUNCTION("uart2", x1600_uart2),
@@ -2779,7 +2776,7 @@ static const char *x1830_pwm6_groups[] = { "pwm6-c-17", "pwm6-c-27", };
static const char *x1830_pwm7_groups[] = { "pwm7-c-18", "pwm7-c-28", };
static const char *x1830_mac_groups[] = { "mac", };
-static const struct function_desc x1830_functions[] = {
+static const struct pinfunction x1830_functions[] = {
INGENIC_PIN_FUNCTION("uart0", x1830_uart0),
INGENIC_PIN_FUNCTION("uart1", x1830_uart1),
INGENIC_PIN_FUNCTION("sfc", x1830_sfc),
@@ -3225,7 +3222,7 @@ static const char *x2000_mac0_groups[] = { "mac0-rmii", "mac0-rgmii", };
static const char *x2000_mac1_groups[] = { "mac1-rmii", "mac1-rgmii", };
static const char *x2000_otg_groups[] = { "otg-vbus", };
-static const struct function_desc x2000_functions[] = {
+static const struct pinfunction x2000_functions[] = {
INGENIC_PIN_FUNCTION("uart0", x2000_uart0),
INGENIC_PIN_FUNCTION("uart1", x2000_uart1),
INGENIC_PIN_FUNCTION("uart2", x2000_uart2),
@@ -3449,7 +3446,7 @@ static const struct group_desc x2100_groups[] = {
static const char *x2100_mac_groups[] = { "mac", };
-static const struct function_desc x2100_functions[] = {
+static const struct pinfunction x2100_functions[] = {
INGENIC_PIN_FUNCTION("uart0", x2000_uart0),
INGENIC_PIN_FUNCTION("uart1", x2000_uart1),
INGENIC_PIN_FUNCTION("uart2", x2000_uart2),
@@ -4571,11 +4568,9 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev)
}
for (i = 0; i < chip_info->num_functions; i++) {
- const struct function_desc *function = &chip_info->functions[i];
- const struct pinfunction *func = &function->func;
+ const struct pinfunction *func = &chip_info->functions[i];
- err = pinmux_generic_add_pinfunction(jzpc->pctl, func,
- function->data);
+ err = pinmux_generic_add_pinfunction(jzpc->pctl, func, NULL);
if (err < 0) {
dev_err(dev, "Failed to register function %s\n", func->name);
return err;
--
2.48.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 03/15] pinctrl: airoha: replace struct function_desc with struct pinfunction
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 01/15] lib: provide kmemdup_const() Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 02/15] pinctrl: ingenic: use struct pinfunction instead of struct function_desc Bartosz Golaszewski
@ 2025-07-24 9:24 ` Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 04/15] pinctrl: mediatek: mt7988: use PINCTRL_PIN_FUNCTION() Bartosz Golaszewski
` (11 subsequent siblings)
14 siblings, 0 replies; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
struct function_desc is a wrapper around struct pinfunction with an
additional void *data pointer. This driver doesn't use the data pointer.
We're also working towards reducing the usage of struct function_desc in
pinctrl drivers - they should only be created by pinmux core and
accessed by drivers using pinmux_generic_get_function(). Replace the
struct function_desc objects in this driver with smaller struct
pinfunction instances.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/pinctrl/mediatek/pinctrl-airoha.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-airoha.c b/drivers/pinctrl/mediatek/pinctrl-airoha.c
index 1737b88530c385644a360e8abe583416bd6d3fe9..aa71e02b661c992c117418af910ae157c4f75fff 100644
--- a/drivers/pinctrl/mediatek/pinctrl-airoha.c
+++ b/drivers/pinctrl/mediatek/pinctrl-airoha.c
@@ -36,11 +36,9 @@
#define PINCTRL_FUNC_DESC(id) \
{ \
.desc = { \
- .func = { \
- .name = #id, \
- .groups = id##_groups, \
- .ngroups = ARRAY_SIZE(id##_groups), \
- } \
+ .name = #id, \
+ .groups = id##_groups, \
+ .ngroups = ARRAY_SIZE(id##_groups), \
}, \
.groups = id##_func_group, \
.group_size = ARRAY_SIZE(id##_func_group), \
@@ -334,7 +332,7 @@ struct airoha_pinctrl_func_group {
};
struct airoha_pinctrl_func {
- const struct function_desc desc;
+ const struct pinfunction desc;
const struct airoha_pinctrl_func_group *groups;
u8 group_size;
};
@@ -2908,11 +2906,11 @@ static int airoha_pinctrl_probe(struct platform_device *pdev)
func = &airoha_pinctrl_funcs[i];
err = pinmux_generic_add_pinfunction(pinctrl->ctrl,
- &func->desc.func,
+ &func->desc,
(void *)func);
if (err < 0) {
dev_err(dev, "Failed to register function %s\n",
- func->desc.func.name);
+ func->desc.name);
return err;
}
}
--
2.48.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 04/15] pinctrl: mediatek: mt7988: use PINCTRL_PIN_FUNCTION()
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
` (2 preceding siblings ...)
2025-07-24 9:24 ` [PATCH v3 03/15] pinctrl: airoha: replace struct function_desc with struct pinfunction Bartosz Golaszewski
@ 2025-07-24 9:24 ` Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 05/15] pinctrl: mediatek: moore: replace struct function_desc with struct pinfunction Bartosz Golaszewski
` (10 subsequent siblings)
14 siblings, 0 replies; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
We have a dedicated initializer macro for defining pin functions for
mediatek drivers so use it here.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/pinctrl/mediatek/pinctrl-mt7988.c | 42 ++++++++++++-------------------
1 file changed, 16 insertions(+), 26 deletions(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7988.c b/drivers/pinctrl/mediatek/pinctrl-mt7988.c
index 68b4097792b88356babe4368db7d0f60194e7309..55c8674d8d66f12d2f2246c215056d4e51296a9b 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt7988.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7988.c
@@ -1465,32 +1465,22 @@ static const char * const mt7988_usb_groups[] = {
};
static const struct function_desc mt7988_functions[] = {
- { { "audio", mt7988_audio_groups, ARRAY_SIZE(mt7988_audio_groups) },
- NULL },
- { { "jtag", mt7988_jtag_groups, ARRAY_SIZE(mt7988_jtag_groups) },
- NULL },
- { { "int_usxgmii", mt7988_int_usxgmii_groups,
- ARRAY_SIZE(mt7988_int_usxgmii_groups) },
- NULL },
- { { "pwm", mt7988_pwm_groups, ARRAY_SIZE(mt7988_pwm_groups) }, NULL },
- { { "dfd", mt7988_dfd_groups, ARRAY_SIZE(mt7988_dfd_groups) }, NULL },
- { { "i2c", mt7988_i2c_groups, ARRAY_SIZE(mt7988_i2c_groups) }, NULL },
- { { "eth", mt7988_ethernet_groups, ARRAY_SIZE(mt7988_ethernet_groups) },
- NULL },
- { { "pcie", mt7988_pcie_groups, ARRAY_SIZE(mt7988_pcie_groups) },
- NULL },
- { { "pmic", mt7988_pmic_groups, ARRAY_SIZE(mt7988_pmic_groups) },
- NULL },
- { { "watchdog", mt7988_wdt_groups, ARRAY_SIZE(mt7988_wdt_groups) },
- NULL },
- { { "spi", mt7988_spi_groups, ARRAY_SIZE(mt7988_spi_groups) }, NULL },
- { { "flash", mt7988_flash_groups, ARRAY_SIZE(mt7988_flash_groups) },
- NULL },
- { { "uart", mt7988_uart_groups, ARRAY_SIZE(mt7988_uart_groups) },
- NULL },
- { { "udi", mt7988_udi_groups, ARRAY_SIZE(mt7988_udi_groups) }, NULL },
- { { "usb", mt7988_usb_groups, ARRAY_SIZE(mt7988_usb_groups) }, NULL },
- { { "led", mt7988_led_groups, ARRAY_SIZE(mt7988_led_groups) }, NULL },
+ PINCTRL_PIN_FUNCTION("audio", mt7988_audio),
+ PINCTRL_PIN_FUNCTION("jtag", mt7988_jtag),
+ PINCTRL_PIN_FUNCTION("int_usxgmii", mt7988_int_usxgmii),
+ PINCTRL_PIN_FUNCTION("pwm", mt7988_pwm),
+ PINCTRL_PIN_FUNCTION("dfd", mt7988_dfd),
+ PINCTRL_PIN_FUNCTION("i2c", mt7988_i2c),
+ PINCTRL_PIN_FUNCTION("eth", mt7988_ethernet),
+ PINCTRL_PIN_FUNCTION("pcie", mt7988_pcie),
+ PINCTRL_PIN_FUNCTION("pmic", mt7988_pmic),
+ PINCTRL_PIN_FUNCTION("watchdog", mt7988_wdt),
+ PINCTRL_PIN_FUNCTION("spi", mt7988_spi),
+ PINCTRL_PIN_FUNCTION("flash", mt7988_flash),
+ PINCTRL_PIN_FUNCTION("uart", mt7988_uart),
+ PINCTRL_PIN_FUNCTION("udi", mt7988_udi),
+ PINCTRL_PIN_FUNCTION("usb", mt7988_usb),
+ PINCTRL_PIN_FUNCTION("led", mt7988_led),
};
static const struct mtk_eint_hw mt7988_eint_hw = {
--
2.48.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 05/15] pinctrl: mediatek: moore: replace struct function_desc with struct pinfunction
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
` (3 preceding siblings ...)
2025-07-24 9:24 ` [PATCH v3 04/15] pinctrl: mediatek: mt7988: use PINCTRL_PIN_FUNCTION() Bartosz Golaszewski
@ 2025-07-24 9:24 ` Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 06/15] pinctrl: imx: don't access the pin function radix tree directly Bartosz Golaszewski
` (9 subsequent siblings)
14 siblings, 0 replies; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
struct function_desc is a wrapper around struct pinfunction with an
additional void *data pointer. This driver doesn't use the data pointer.
We're also working towards reducing the usage of struct function_desc in
pinctrl drivers - they should only be created by pinmux core and
accessed by drivers using pinmux_generic_get_function(). Replace the
struct function_desc objects in this driver with smaller struct
pinfunction instances.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/pinctrl/mediatek/pinctrl-moore.c | 6 ++----
drivers/pinctrl/mediatek/pinctrl-moore.h | 7 ++-----
drivers/pinctrl/mediatek/pinctrl-mt7622.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-mt7623.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-mt7629.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-mt7981.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-mt7986.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-mt7988.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 2 +-
9 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.c b/drivers/pinctrl/mediatek/pinctrl-moore.c
index ba0d6f880c6e1624720f0ed8e7b36e4734dda004..68710dab2aa3ff649bb0cf579122ecaa0c257fdf 100644
--- a/drivers/pinctrl/mediatek/pinctrl-moore.c
+++ b/drivers/pinctrl/mediatek/pinctrl-moore.c
@@ -622,11 +622,9 @@ static int mtk_build_functions(struct mtk_pinctrl *hw)
int i, err;
for (i = 0; i < hw->soc->nfuncs ; i++) {
- const struct function_desc *function = hw->soc->funcs + i;
- const struct pinfunction *func = &function->func;
+ const struct pinfunction *func = hw->soc->funcs + i;
- err = pinmux_generic_add_pinfunction(hw->pctrl, func,
- function->data);
+ err = pinmux_generic_add_pinfunction(hw->pctrl, func, NULL);
if (err < 0) {
dev_err(hw->dev, "Failed to register function %s\n",
func->name);
diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.h b/drivers/pinctrl/mediatek/pinctrl-moore.h
index 229d19561e229c77714e5fccb3d4fb68eacc77fd..fe1f087cacd0446e40628cb4fa35a135496ca848 100644
--- a/drivers/pinctrl/mediatek/pinctrl-moore.h
+++ b/drivers/pinctrl/mediatek/pinctrl-moore.h
@@ -43,11 +43,8 @@
.data = id##_funcs, \
}
-#define PINCTRL_PIN_FUNCTION(_name_, id) \
- { \
- .func = PINCTRL_PINFUNCTION(_name_, id##_groups, ARRAY_SIZE(id##_groups)), \
- .data = NULL, \
- }
+#define PINCTRL_PIN_FUNCTION(_name_, id) \
+ PINCTRL_PINFUNCTION(_name_, id##_groups, ARRAY_SIZE(id##_groups))
int mtk_moore_pinctrl_probe(struct platform_device *pdev,
const struct mtk_pin_soc *soc);
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7622.c b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
index 2dc1019910662a2a52e81f277a10a32bd83b33d4..d5777889448aab86e82fa6821fdea0d30a5a7246 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt7622.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7622.c
@@ -822,7 +822,7 @@ static const char *mt7622_uart_groups[] = { "uart0_0_tx_rx",
"uart4_2_rts_cts",};
static const char *mt7622_wdt_groups[] = { "watchdog", };
-static const struct function_desc mt7622_functions[] = {
+static const struct pinfunction mt7622_functions[] = {
PINCTRL_PIN_FUNCTION("antsel", mt7622_antsel),
PINCTRL_PIN_FUNCTION("emmc", mt7622_emmc),
PINCTRL_PIN_FUNCTION("eth", mt7622_ethernet),
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7623.c b/drivers/pinctrl/mediatek/pinctrl-mt7623.c
index 3e59eada2825277b3d7500cb1f2cf740242a4a8b..69c06c2c0e21e4ce785f65539254eb070bff9a0d 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt7623.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7623.c
@@ -1340,7 +1340,7 @@ static const char *mt7623_uart_groups[] = { "uart0_0_txd_rxd",
"uart3_rts_cts", };
static const char *mt7623_wdt_groups[] = { "watchdog_0", "watchdog_1", };
-static const struct function_desc mt7623_functions[] = {
+static const struct pinfunction mt7623_functions[] = {
PINCTRL_PIN_FUNCTION("audck", mt7623_aud_clk),
PINCTRL_PIN_FUNCTION("disp", mt7623_disp_pwm),
PINCTRL_PIN_FUNCTION("eth", mt7623_ethernet),
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7629.c b/drivers/pinctrl/mediatek/pinctrl-mt7629.c
index 98142e8c98011d17339da74f61d6f917372dfcd5..cc0694881ac9dc536db0e46eefe5eb7359735a60 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt7629.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7629.c
@@ -384,7 +384,7 @@ static const char *mt7629_wdt_groups[] = { "watchdog", };
static const char *mt7629_wifi_groups[] = { "wf0_5g", "wf0_2g", };
static const char *mt7629_flash_groups[] = { "snfi", "spi_nor" };
-static const struct function_desc mt7629_functions[] = {
+static const struct pinfunction mt7629_functions[] = {
PINCTRL_PIN_FUNCTION("eth", mt7629_ethernet),
PINCTRL_PIN_FUNCTION("i2c", mt7629_i2c),
PINCTRL_PIN_FUNCTION("led", mt7629_led),
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7981.c b/drivers/pinctrl/mediatek/pinctrl-mt7981.c
index 83092be5b614cc164590fe5ec2b756fe6579b263..6216c2e057f6499b32741b6bd3a4854878c061c9 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt7981.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7981.c
@@ -977,7 +977,7 @@ static const char *mt7981_ethernet_groups[] = { "smi_mdc_mdio", "gbe_ext_mdc_mdi
"wf0_mode1", "wf0_mode3", "mt7531_int", };
static const char *mt7981_ant_groups[] = { "ant_sel", };
-static const struct function_desc mt7981_functions[] = {
+static const struct pinfunction mt7981_functions[] = {
PINCTRL_PIN_FUNCTION("wa_aice", mt7981_wa_aice),
PINCTRL_PIN_FUNCTION("dfd", mt7981_dfd),
PINCTRL_PIN_FUNCTION("jtag", mt7981_jtag),
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7986.c b/drivers/pinctrl/mediatek/pinctrl-mt7986.c
index 5816b5fdb7ca918486f57a890f73543b3198c728..2a762ade9c35505505c932b6fea75fa0cf77d961 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt7986.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7986.c
@@ -878,7 +878,7 @@ static const char *mt7986_uart_groups[] = {
static const char *mt7986_wdt_groups[] = { "watchdog", };
static const char *mt7986_wf_groups[] = { "wf_2g", "wf_5g", "wf_dbdc", };
-static const struct function_desc mt7986_functions[] = {
+static const struct pinfunction mt7986_functions[] = {
PINCTRL_PIN_FUNCTION("audio", mt7986_audio),
PINCTRL_PIN_FUNCTION("emmc", mt7986_emmc),
PINCTRL_PIN_FUNCTION("eth", mt7986_ethernet),
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7988.c b/drivers/pinctrl/mediatek/pinctrl-mt7988.c
index 55c8674d8d66f12d2f2246c215056d4e51296a9b..9569e8c0cec15fb6a4a8e359d6483fa163487b0c 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt7988.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7988.c
@@ -1464,7 +1464,7 @@ static const char * const mt7988_usb_groups[] = {
"drv_vbus_p1",
};
-static const struct function_desc mt7988_functions[] = {
+static const struct pinfunction mt7988_functions[] = {
PINCTRL_PIN_FUNCTION("audio", mt7988_audio),
PINCTRL_PIN_FUNCTION("jtag", mt7988_jtag),
PINCTRL_PIN_FUNCTION("int_usxgmii", mt7988_int_usxgmii),
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
index 36d2898037dd041ebc7e06526ebc085eb42f2828..fa7c0ed49346486ba32ec615aa2b3483217f5077 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
@@ -238,7 +238,7 @@ struct mtk_pin_soc {
unsigned int npins;
const struct group_desc *grps;
unsigned int ngrps;
- const struct function_desc *funcs;
+ const struct pinfunction *funcs;
unsigned int nfuncs;
const struct mtk_eint_regs *eint_regs;
const struct mtk_eint_hw *eint_hw;
--
2.48.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 06/15] pinctrl: imx: don't access the pin function radix tree directly
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
` (4 preceding siblings ...)
2025-07-24 9:24 ` [PATCH v3 05/15] pinctrl: mediatek: moore: replace struct function_desc with struct pinfunction Bartosz Golaszewski
@ 2025-07-24 9:24 ` Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 07/15] pinctrl: keembay: release allocated memory in detach path Bartosz Golaszewski
` (8 subsequent siblings)
14 siblings, 0 replies; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
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.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/pinctrl/freescale/pinctrl-imx.c | 38 +++++++++++----------------------
1 file changed, 13 insertions(+), 25 deletions(-)
diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
index 18de31328540458b7f7e8e2e539a39d61829deb9..d5d42c9ad5fe9dcf7c25ad393688e714b02db678 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
@@ -580,33 +580,34 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
u32 index)
{
struct pinctrl_dev *pctl = ipctl->pctl;
- struct function_desc *func;
+ struct pinfunction *func;
struct group_desc *grp;
const char **group_names;
+ int ret;
u32 i;
dev_dbg(pctl->dev, "parse function(%d): %pOFn\n", index, np);
- func = pinmux_generic_get_function(pctl, index);
+ func = devm_kzalloc(ipctl->dev, sizeof(*func), GFP_KERNEL);
if (!func)
- return -EINVAL;
+ return -ENOMEM;
/* Initialise function */
- func->func.name = np->name;
- func->func.ngroups = of_get_child_count(np);
- if (func->func.ngroups == 0) {
+ func->name = np->name;
+ func->ngroups = of_get_child_count(np);
+ if (func->ngroups == 0) {
dev_info(ipctl->dev, "no groups defined in %pOF\n", np);
return -EINVAL;
}
- group_names = devm_kcalloc(ipctl->dev, func->func.ngroups,
- sizeof(*func->func.groups), GFP_KERNEL);
+ group_names = devm_kcalloc(ipctl->dev, func->ngroups,
+ sizeof(*func->groups), GFP_KERNEL);
if (!group_names)
return -ENOMEM;
i = 0;
for_each_child_of_node_scoped(np, child)
group_names[i++] = child->name;
- func->func.groups = group_names;
+ func->groups = group_names;
i = 0;
for_each_child_of_node_scoped(np, child) {
@@ -614,10 +615,9 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
if (!grp)
return -ENOMEM;
- mutex_lock(&ipctl->mutex);
- radix_tree_insert(&pctl->pin_group_tree,
- ipctl->group_index++, grp);
- mutex_unlock(&ipctl->mutex);
+ ret = pinmux_generic_add_pinfunction(pctl, func, NULL);
+ if (ret < 0)
+ return ret;
imx_pinctrl_parse_groups(child, grp, ipctl, i++);
}
@@ -669,18 +669,6 @@ static int imx_pinctrl_probe_dt(struct platform_device *pdev,
}
}
- for (i = 0; i < nfuncs; i++) {
- struct function_desc *function;
-
- function = 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 = nfuncs;
ipctl->group_index = 0;
--
2.48.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 07/15] pinctrl: keembay: release allocated memory in detach path
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
` (5 preceding siblings ...)
2025-07-24 9:24 ` [PATCH v3 06/15] pinctrl: imx: don't access the pin function radix tree directly Bartosz Golaszewski
@ 2025-07-24 9:24 ` Bartosz Golaszewski
2025-07-24 11:06 ` Andy Shevchenko
2025-07-24 9:24 ` [PATCH v3 08/15] pinctrl: keembay: use a dedicated structure for the pinfunction description Bartosz Golaszewski
` (7 subsequent siblings)
14 siblings, 1 reply; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Unlike all the other allocations in this driver, the memory for storing
the pin function descriptions allocated with kcalloc() and later resized
with krealloc() is never freed. Use devres like elsewhere to handle
that.
Note: the logic in this module is pretty convoluted and could probably
use some revisiting, we should probably be able to calculate the exact
amount of memory needed in advance or even skip the allocation
alltogether and just add each function to the radix tree separately.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/pinctrl/pinctrl-keembay.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-keembay.c b/drivers/pinctrl/pinctrl-keembay.c
index 30e641571cfe5396075cb28febd2d0776326365d..b4c7b3ef79e0a34111f46f23adfee4c269e5be6e 100644
--- a/drivers/pinctrl/pinctrl-keembay.c
+++ b/drivers/pinctrl/pinctrl-keembay.c
@@ -1603,7 +1603,8 @@ static int keembay_build_functions(struct keembay_pinctrl *kpc)
* being part of 8 (hw maximum) globally unique muxes.
*/
kpc->nfuncs = 0;
- keembay_funcs = kcalloc(kpc->npins * 8, sizeof(*keembay_funcs), GFP_KERNEL);
+ keembay_funcs = devm_kcalloc(kpc->dev, kpc->npins * 8,
+ sizeof(*keembay_funcs), GFP_KERNEL);
if (!keembay_funcs)
return -ENOMEM;
@@ -1634,7 +1635,8 @@ static int keembay_build_functions(struct keembay_pinctrl *kpc)
}
/* Reallocate memory based on actual number of functions */
- new_funcs = krealloc(keembay_funcs, kpc->nfuncs * sizeof(*new_funcs), GFP_KERNEL);
+ new_funcs = devm_krealloc(kpc->dev, keembay_funcs,
+ kpc->nfuncs * sizeof(*new_funcs), GFP_KERNEL);
if (!new_funcs) {
kfree(keembay_funcs);
return -ENOMEM;
--
2.48.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 08/15] pinctrl: keembay: use a dedicated structure for the pinfunction description
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
` (6 preceding siblings ...)
2025-07-24 9:24 ` [PATCH v3 07/15] pinctrl: keembay: release allocated memory in detach path Bartosz Golaszewski
@ 2025-07-24 9:24 ` Bartosz Golaszewski
2025-07-24 11:11 ` Andy Shevchenko
2025-07-24 9:24 ` [PATCH v3 09/15] pinctrl: constify pinmux_generic_get_function() Bartosz Golaszewski
` (6 subsequent siblings)
14 siblings, 1 reply; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
struct function_desc is a wrapper around struct pinfunction with an
additional void *data pointer. We're working towards reducing the usage
of struct function_desc in pinctrl drivers - they should only be created
by pinmux core and accessed by drivers using
pinmux_generic_get_function(). This driver uses the data pointer so in
order to stop using struct function_desc, we need to provide an
alternative that also wraps the mux mode which is passed to pinctrl core
as user data.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/pinctrl/pinctrl-keembay.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-keembay.c b/drivers/pinctrl/pinctrl-keembay.c
index b4c7b3ef79e0a34111f46f23adfee4c269e5be6e..060d64ff3d9f01ecd3374935af66b55c38f60d67 100644
--- a/drivers/pinctrl/pinctrl-keembay.c
+++ b/drivers/pinctrl/pinctrl-keembay.c
@@ -135,6 +135,11 @@ struct keembay_pin_soc {
const struct pinctrl_pin_desc *pins;
};
+struct keembay_pinfunction {
+ struct pinfunction func;
+ u8 mux_mode;
+};
+
static const struct pinctrl_pin_desc keembay_pins[] = {
KEEMBAY_PIN_DESC(0, "GPIO0",
KEEMBAY_MUX(0x0, "I2S0_M0"),
@@ -1556,13 +1561,13 @@ static int keembay_pinctrl_reg(struct keembay_pinctrl *kpc, struct device *dev)
}
static int keembay_add_functions(struct keembay_pinctrl *kpc,
- struct function_desc *functions)
+ struct keembay_pinfunction *functions)
{
unsigned int i;
/* Assign the groups for each function */
for (i = 0; i < kpc->nfuncs; i++) {
- struct function_desc *func = &functions[i];
+ struct keembay_pinfunction *func = &functions[i];
const char **group_names;
unsigned int grp_idx = 0;
int j;
@@ -1588,14 +1593,14 @@ static int keembay_add_functions(struct keembay_pinctrl *kpc,
/* Add all functions */
for (i = 0; i < kpc->nfuncs; i++)
pinmux_generic_add_pinfunction(kpc->pctrl, &functions[i].func,
- functions[i].data);
+ &functions[i].mux_mode);
return 0;
}
static int keembay_build_functions(struct keembay_pinctrl *kpc)
{
- struct function_desc *keembay_funcs, *new_funcs;
+ struct keembay_pinfunction *keembay_funcs, *new_funcs;
int i;
/*
@@ -1614,7 +1619,7 @@ static int keembay_build_functions(struct keembay_pinctrl *kpc)
struct keembay_mux_desc *mux;
for (mux = pdesc->drv_data; mux->name; mux++) {
- struct function_desc *fdesc;
+ struct keembay_pinfunction *fdesc;
/* Check if we already have function for this mux */
for (fdesc = keembay_funcs; fdesc->func.name; fdesc++) {
@@ -1628,7 +1633,7 @@ static int keembay_build_functions(struct keembay_pinctrl *kpc)
if (!fdesc->func.name) {
fdesc->func.name = mux->name;
fdesc->func.ngroups = 1;
- fdesc->data = &mux->mode;
+ fdesc->mux_mode = mux->mode;
kpc->nfuncs++;
}
}
--
2.48.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 09/15] pinctrl: constify pinmux_generic_get_function()
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
` (7 preceding siblings ...)
2025-07-24 9:24 ` [PATCH v3 08/15] pinctrl: keembay: use a dedicated structure for the pinfunction description Bartosz Golaszewski
@ 2025-07-24 9:24 ` Bartosz Golaszewski
2025-07-24 11:14 ` Andy Shevchenko
2025-07-30 14:53 ` Geert Uytterhoeven
2025-07-24 9:24 ` [PATCH v3 10/15] pinctrl: make struct pinfunction a pointer in struct function_desc Bartosz Golaszewski
` (5 subsequent siblings)
14 siblings, 2 replies; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
With all users of struct function_desc limited to only accessing it using
the dedicated function and never modifying it, we can now constify the
return value of pinmux_generic_get_function() treewide.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/pinctrl/freescale/pinctrl-imx.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-airoha.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-moore.c | 2 +-
drivers/pinctrl/pinctrl-equilibrium.c | 2 +-
drivers/pinctrl/pinctrl-ingenic.c | 2 +-
drivers/pinctrl/pinctrl-keembay.c | 2 +-
drivers/pinctrl/pinctrl-single.c | 4 ++--
drivers/pinctrl/pinmux.c | 4 ++--
drivers/pinctrl/pinmux.h | 4 ++--
drivers/pinctrl/renesas/pinctrl-rza1.c | 2 +-
drivers/pinctrl/renesas/pinctrl-rza2.c | 2 +-
drivers/pinctrl/renesas/pinctrl-rzg2l.c | 2 +-
drivers/pinctrl/renesas/pinctrl-rzv2m.c | 2 +-
13 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
index d5d42c9ad5fe9dcf7c25ad393688e714b02db678..9ed84479a5b43871861f46fe1326f1dfadc7f63c 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
@@ -245,7 +245,7 @@ static int imx_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
{
struct imx_pinctrl *ipctl = pinctrl_dev_get_drvdata(pctldev);
const struct imx_pinctrl_soc_info *info = ipctl->info;
- struct function_desc *func;
+ const struct function_desc *func;
struct group_desc *grp;
struct imx_pin *pin;
unsigned int npins;
diff --git a/drivers/pinctrl/mediatek/pinctrl-airoha.c b/drivers/pinctrl/mediatek/pinctrl-airoha.c
index aa71e02b661c992c117418af910ae157c4f75fff..9a95577439a1b50607427756a713c8122c7c4af1 100644
--- a/drivers/pinctrl/mediatek/pinctrl-airoha.c
+++ b/drivers/pinctrl/mediatek/pinctrl-airoha.c
@@ -2446,7 +2446,7 @@ static int airoha_pinmux_set_mux(struct pinctrl_dev *pctrl_dev,
{
struct airoha_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev);
const struct airoha_pinctrl_func *func;
- struct function_desc *desc;
+ const struct function_desc *desc;
struct group_desc *grp;
int i;
diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.c b/drivers/pinctrl/mediatek/pinctrl-moore.c
index 68710dab2aa3ff649bb0cf579122ecaa0c257fdf..ec0005246c19a156079807acddc93bcb767d1222 100644
--- a/drivers/pinctrl/mediatek/pinctrl-moore.c
+++ b/drivers/pinctrl/mediatek/pinctrl-moore.c
@@ -43,7 +43,7 @@ static int mtk_pinmux_set_mux(struct pinctrl_dev *pctldev,
unsigned int selector, unsigned int group)
{
struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
- struct function_desc *func;
+ const struct function_desc *func;
struct group_desc *grp;
int i, err;
diff --git a/drivers/pinctrl/pinctrl-equilibrium.c b/drivers/pinctrl/pinctrl-equilibrium.c
index fce804d42e7d7f9233b2da0fb26e482170629424..18f0da58c96d4f0fad6535fd88e69fc8acf96a94 100644
--- a/drivers/pinctrl/pinctrl-equilibrium.c
+++ b/drivers/pinctrl/pinctrl-equilibrium.c
@@ -319,7 +319,7 @@ static int eqbr_pinmux_set_mux(struct pinctrl_dev *pctldev,
unsigned int selector, unsigned int group)
{
struct eqbr_pinctrl_drv_data *pctl = pinctrl_dev_get_drvdata(pctldev);
- struct function_desc *func;
+ const struct function_desc *func;
struct group_desc *grp;
unsigned int *pinmux;
int i;
diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index 0ee8554c5446c4167c9b0e6b9397a2507ca57419..f89f8ec06ac63227930a38dbc80f00333cc15b48 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -4000,7 +4000,7 @@ static int ingenic_pinmux_set_mux(struct pinctrl_dev *pctldev,
unsigned int selector, unsigned int group)
{
struct ingenic_pinctrl *jzpc = pinctrl_dev_get_drvdata(pctldev);
- struct function_desc *func;
+ const struct function_desc *func;
struct group_desc *grp;
unsigned int i;
uintptr_t mode;
diff --git a/drivers/pinctrl/pinctrl-keembay.c b/drivers/pinctrl/pinctrl-keembay.c
index 060d64ff3d9f01ecd3374935af66b55c38f60d67..87d081226f45467d9c92cc9e8ea63d41fd2f0fcb 100644
--- a/drivers/pinctrl/pinctrl-keembay.c
+++ b/drivers/pinctrl/pinctrl-keembay.c
@@ -935,7 +935,7 @@ static int keembay_set_mux(struct pinctrl_dev *pctldev, unsigned int fun_sel,
unsigned int grp_sel)
{
struct keembay_pinctrl *kpc = pinctrl_dev_get_drvdata(pctldev);
- struct function_desc *func;
+ const struct function_desc *func;
struct group_desc *grp;
unsigned int val;
u8 pin_mode;
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 5cda6201b60f53e62f3f50b8641ec894106111e0..c9adf5fcb1c76445d4812de449edf09878771a46 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -336,7 +336,7 @@ static int pcs_get_function(struct pinctrl_dev *pctldev, unsigned pin,
struct pcs_device *pcs = pinctrl_dev_get_drvdata(pctldev);
struct pin_desc *pdesc = pin_desc_get(pctldev, pin);
const struct pinctrl_setting_mux *setting;
- struct function_desc *function;
+ const struct function_desc *function;
unsigned fselector;
/* If pin is not described in DTS & enabled, mux_setting is NULL. */
@@ -360,7 +360,7 @@ static int pcs_set_mux(struct pinctrl_dev *pctldev, unsigned fselector,
unsigned group)
{
struct pcs_device *pcs;
- struct function_desc *function;
+ const struct function_desc *function;
struct pcs_function *func;
int i;
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 79814758a084570adea0ea1a3151d186f65d1d1f..62bd4aa53b2b22cb09eacfb05398205f2fe391b9 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -847,8 +847,8 @@ EXPORT_SYMBOL_GPL(pinmux_generic_get_function_groups);
* @pctldev: pin controller device
* @selector: function number
*/
-struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,
- unsigned int selector)
+const struct function_desc *
+pinmux_generic_get_function(struct pinctrl_dev *pctldev, unsigned int selector)
{
struct function_desc *function;
diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h
index bdb5be1a636ead9695410824b5557937c5baa89a..549ab10f7afbda32fadf4ad151401180bed2064f 100644
--- a/drivers/pinctrl/pinmux.h
+++ b/drivers/pinctrl/pinmux.h
@@ -152,8 +152,8 @@ int pinmux_generic_get_function_groups(struct pinctrl_dev *pctldev,
const char * const **groups,
unsigned int * const ngroups);
-struct function_desc *pinmux_generic_get_function(struct pinctrl_dev *pctldev,
- unsigned int selector);
+const struct function_desc *
+pinmux_generic_get_function(struct pinctrl_dev *pctldev, unsigned int selector);
int pinmux_generic_add_function(struct pinctrl_dev *pctldev,
const char *name,
diff --git a/drivers/pinctrl/renesas/pinctrl-rza1.c b/drivers/pinctrl/renesas/pinctrl-rza1.c
index 3d8492c917104afbf15c8f697ba4afabafa3a5cf..26826c8b5441b1a056900fdfc1d68c0c5cd3e6ba 100644
--- a/drivers/pinctrl/renesas/pinctrl-rza1.c
+++ b/drivers/pinctrl/renesas/pinctrl-rza1.c
@@ -1120,7 +1120,7 @@ static int rza1_set_mux(struct pinctrl_dev *pctldev, unsigned int selector,
{
struct rza1_pinctrl *rza1_pctl = pinctrl_dev_get_drvdata(pctldev);
struct rza1_mux_conf *mux_confs;
- struct function_desc *func;
+ const struct function_desc *func;
struct group_desc *grp;
int i;
diff --git a/drivers/pinctrl/renesas/pinctrl-rza2.c b/drivers/pinctrl/renesas/pinctrl-rza2.c
index 7a0b268d3eb91a42911f372e66805291344f8750..7e9eff522204413c83779932cd702edc02ec2686 100644
--- a/drivers/pinctrl/renesas/pinctrl-rza2.c
+++ b/drivers/pinctrl/renesas/pinctrl-rza2.c
@@ -442,7 +442,7 @@ static int rza2_set_mux(struct pinctrl_dev *pctldev, unsigned int selector,
unsigned int group)
{
struct rza2_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev);
- struct function_desc *func;
+ const struct function_desc *func;
unsigned int i, *psel_val;
struct group_desc *grp;
diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c
index 2a10ae0bf5bdd97c10ff4fe4b890a70744a97578..76d4ce78d0dece3bb95779d60f235ce85df25403 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c
@@ -549,7 +549,7 @@ static int rzg2l_pinctrl_set_mux(struct pinctrl_dev *pctldev,
{
struct rzg2l_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
const struct rzg2l_hwcfg *hwcfg = pctrl->data->hwcfg;
- struct function_desc *func;
+ const struct function_desc *func;
unsigned int i, *psel_val;
struct group_desc *group;
const unsigned int *pins;
diff --git a/drivers/pinctrl/renesas/pinctrl-rzv2m.c b/drivers/pinctrl/renesas/pinctrl-rzv2m.c
index a17b68b4c466e2ca91cb26a713a088e309d5e167..a60cdf8f3eef6e3f14e3fe19e7d57515d6b455fa 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzv2m.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzv2m.c
@@ -162,7 +162,7 @@ static int rzv2m_pinctrl_set_mux(struct pinctrl_dev *pctldev,
unsigned int group_selector)
{
struct rzv2m_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
- struct function_desc *func;
+ const struct function_desc *func;
unsigned int i, *psel_val;
struct group_desc *group;
const unsigned int *pins;
--
2.48.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 10/15] pinctrl: make struct pinfunction a pointer in struct function_desc
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
` (8 preceding siblings ...)
2025-07-24 9:24 ` [PATCH v3 09/15] pinctrl: constify pinmux_generic_get_function() Bartosz Golaszewski
@ 2025-07-24 9:24 ` Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 11/15] pinctrl: qcom: use generic pin function helpers Bartosz Golaszewski
` (4 subsequent siblings)
14 siblings, 0 replies; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
We currently duplicate the entire struct pinfunction object in
pinmux_generic_add_pinfunction(). While this is inevitable when the
arguments come in split through pinmux_generic_add_function(), users of
pinmux_generic_add_pinfunction() will typically pass addresses of
structures in .rodata, meaning we can try to avoid the duplication with
the help from kmemdup_const(). To that end: don't wrap the entire struct
pinfunction in struct function_desc but rather just store the address.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/pinctrl/freescale/pinctrl-imx.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-airoha.c | 2 +-
drivers/pinctrl/mediatek/pinctrl-moore.c | 2 +-
drivers/pinctrl/pinctrl-ingenic.c | 2 +-
drivers/pinctrl/pinmux.c | 23 +++++++++++++++++++----
drivers/pinctrl/pinmux.h | 2 +-
6 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
index 9ed84479a5b43871861f46fe1326f1dfadc7f63c..0df7eba8ccd3209fbc4b2e67ffdea12b77b90858 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
@@ -266,7 +266,7 @@ static int imx_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
npins = grp->grp.npins;
dev_dbg(ipctl->dev, "enable function %s group %s\n",
- func->func.name, grp->grp.name);
+ func->func->name, grp->grp.name);
for (i = 0; i < npins; i++) {
/*
diff --git a/drivers/pinctrl/mediatek/pinctrl-airoha.c b/drivers/pinctrl/mediatek/pinctrl-airoha.c
index 9a95577439a1b50607427756a713c8122c7c4af1..148b6e235db53290c48d717a994d88cd53c3a135 100644
--- a/drivers/pinctrl/mediatek/pinctrl-airoha.c
+++ b/drivers/pinctrl/mediatek/pinctrl-airoha.c
@@ -2459,7 +2459,7 @@ static int airoha_pinmux_set_mux(struct pinctrl_dev *pctrl_dev,
return -EINVAL;
dev_dbg(pctrl_dev->dev, "enable function %s group %s\n",
- desc->func.name, grp->grp.name);
+ desc->func->name, grp->grp.name);
func = desc->data;
for (i = 0; i < func->group_size; i++) {
diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.c b/drivers/pinctrl/mediatek/pinctrl-moore.c
index ec0005246c19a156079807acddc93bcb767d1222..8ebd731675f69c8b076a7e7767be8ff7c6d3dd79 100644
--- a/drivers/pinctrl/mediatek/pinctrl-moore.c
+++ b/drivers/pinctrl/mediatek/pinctrl-moore.c
@@ -56,7 +56,7 @@ static int mtk_pinmux_set_mux(struct pinctrl_dev *pctldev,
return -EINVAL;
dev_dbg(pctldev->dev, "enable function %s group %s\n",
- func->func.name, grp->grp.name);
+ func->func->name, grp->grp.name);
for (i = 0; i < grp->grp.npins; i++) {
const struct mtk_pin_desc *desc;
diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index f89f8ec06ac63227930a38dbc80f00333cc15b48..d81788aea5cb002a86869e22eaab430f7ad18e77 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -4015,7 +4015,7 @@ static int ingenic_pinmux_set_mux(struct pinctrl_dev *pctldev,
return -EINVAL;
dev_dbg(pctldev->dev, "enable function %s group %s\n",
- func->func.name, grp->grp.name);
+ func->func->name, grp->grp.name);
mode = (uintptr_t)grp->data;
if (mode <= 3) {
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 62bd4aa53b2b22cb09eacfb05398205f2fe391b9..504dbb3e97cf334e39b49121137c6768081fcd40 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -810,7 +810,7 @@ pinmux_generic_get_function_name(struct pinctrl_dev *pctldev,
if (!function)
return NULL;
- return function->func.name;
+ return function->func->name;
}
EXPORT_SYMBOL_GPL(pinmux_generic_get_function_name);
@@ -835,8 +835,8 @@ int pinmux_generic_get_function_groups(struct pinctrl_dev *pctldev,
__func__, selector);
return -EINVAL;
}
- *groups = function->func.groups;
- *ngroups = function->func.ngroups;
+ *groups = function->func->groups;
+ *ngroups = function->func->ngroups;
return 0;
}
@@ -903,7 +903,22 @@ int pinmux_generic_add_pinfunction(struct pinctrl_dev *pctldev,
if (!function)
return -ENOMEM;
- function->func = *func;
+ function->func = kmemdup_const(func, sizeof(*func), GFP_KERNEL);
+ if (!function->func)
+ return -ENOMEM;
+
+ /*
+ * FIXME: It's generally a bad idea to use devres in subsystem core
+ * code - managed interfaces are aimed at drivers - but pinctrl already
+ * uses it all over the place so it's a larger piece of technical debt
+ * to fix.
+ */
+ error = devm_add_action_or_reset(pctldev->dev,
+ (void (*)(void *))kfree_const,
+ (void *)function->func);
+ if (error)
+ return error;
+
function->data = data;
error = radix_tree_insert(&pctldev->pin_function_tree, selector, function);
diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h
index 549ab10f7afbda32fadf4ad151401180bed2064f..653684290666d78fd725febb5f8bc987b66a1afb 100644
--- a/drivers/pinctrl/pinmux.h
+++ b/drivers/pinctrl/pinmux.h
@@ -137,7 +137,7 @@ static inline void pinmux_init_device_debugfs(struct dentry *devroot,
* @data: pin controller driver specific data
*/
struct function_desc {
- struct pinfunction func;
+ const struct pinfunction *func;
void *data;
};
--
2.48.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 11/15] pinctrl: qcom: use generic pin function helpers
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
` (9 preceding siblings ...)
2025-07-24 9:24 ` [PATCH v3 10/15] pinctrl: make struct pinfunction a pointer in struct function_desc Bartosz Golaszewski
@ 2025-07-24 9:24 ` Bartosz Golaszewski
2025-07-24 10:57 ` Konrad Dybcio
2025-07-24 9:24 ` [PATCH v3 12/15] pinctrl: allow to mark pin functions as requestable GPIOs Bartosz Golaszewski
` (3 subsequent siblings)
14 siblings, 1 reply; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
With the pinmux core no longer duplicating memory used to store the
struct pinfunction objects in .rodata, we can now use the existing
infrastructure for storing and looking up pin functions in qualcomm
drivers. Remove hand-crafted callbacks.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/pinctrl/qcom/pinctrl-msm.c | 43 ++++++++++++--------------------------
1 file changed, 13 insertions(+), 30 deletions(-)
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index f713c80d7f3eda06de027cd539e8decd4412876a..965f0cceac56697bc4cdb851c8201db7508c042e 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -31,6 +31,7 @@
#include "../core.h"
#include "../pinconf.h"
#include "../pinctrl-utils.h"
+#include "../pinmux.h"
#include "pinctrl-msm.h"
@@ -150,33 +151,6 @@ static int msm_pinmux_request(struct pinctrl_dev *pctldev, unsigned offset)
return gpiochip_line_is_valid(chip, offset) ? 0 : -EINVAL;
}
-static int msm_get_functions_count(struct pinctrl_dev *pctldev)
-{
- struct msm_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
-
- return pctrl->soc->nfunctions;
-}
-
-static const char *msm_get_function_name(struct pinctrl_dev *pctldev,
- unsigned function)
-{
- struct msm_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
-
- return pctrl->soc->functions[function].name;
-}
-
-static int msm_get_function_groups(struct pinctrl_dev *pctldev,
- unsigned function,
- const char * const **groups,
- unsigned * const num_groups)
-{
- struct msm_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
-
- *groups = pctrl->soc->functions[function].groups;
- *num_groups = pctrl->soc->functions[function].ngroups;
- return 0;
-}
-
static int msm_pinmux_set_mux(struct pinctrl_dev *pctldev,
unsigned function,
unsigned group)
@@ -288,9 +262,9 @@ static int msm_pinmux_request_gpio(struct pinctrl_dev *pctldev,
static const struct pinmux_ops msm_pinmux_ops = {
.request = msm_pinmux_request,
- .get_functions_count = msm_get_functions_count,
- .get_function_name = msm_get_function_name,
- .get_function_groups = msm_get_function_groups,
+ .get_functions_count = pinmux_generic_get_function_count,
+ .get_function_name = pinmux_generic_get_function_name,
+ .get_function_groups = pinmux_generic_get_function_groups,
.gpio_request_enable = msm_pinmux_request_gpio,
.set_mux = msm_pinmux_set_mux,
};
@@ -1552,6 +1526,7 @@ EXPORT_SYMBOL(msm_pinctrl_dev_pm_ops);
int msm_pinctrl_probe(struct platform_device *pdev,
const struct msm_pinctrl_soc_data *soc_data)
{
+ const struct pinfunction *func;
struct msm_pinctrl *pctrl;
struct resource *res;
int ret;
@@ -1606,6 +1581,14 @@ int msm_pinctrl_probe(struct platform_device *pdev,
return PTR_ERR(pctrl->pctrl);
}
+ for (i = 0; i < soc_data->nfunctions; i++) {
+ func = &soc_data->functions[i];
+
+ ret = pinmux_generic_add_pinfunction(pctrl->pctrl, func, NULL);
+ if (ret < 0)
+ return ret;
+ }
+
ret = msm_gpio_init(pctrl);
if (ret)
return ret;
--
2.48.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 12/15] pinctrl: allow to mark pin functions as requestable GPIOs
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
` (10 preceding siblings ...)
2025-07-24 9:24 ` [PATCH v3 11/15] pinctrl: qcom: use generic pin function helpers Bartosz Golaszewski
@ 2025-07-24 9:24 ` Bartosz Golaszewski
2025-07-24 12:21 ` Andy Shevchenko
2025-07-24 9:24 ` [PATCH v3 13/15] pinctrl: qcom: add infrastructure for marking pin functions as GPIOs Bartosz Golaszewski
` (2 subsequent siblings)
14 siblings, 1 reply; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
The name of the pin function has no real meaning to pinctrl core and is
there only for human readability of device properties. Some pins are
muxed as GPIOs but for "strict" pinmuxers it's impossible to request
them as GPIOs if they're bound to a devide - even if their function name
explicitly says "gpio". Add a new field to struct pinfunction that
allows to pass additional flags to pinctrl core. While we could go with
a boolean "is_gpio" field, a flags field is more future-proof.
If the PINFUNCTION_FLAG_GPIO is set for a given function, the pin muxed
to it can be requested as GPIO even on strict pin controllers. Add a new
callback to struct pinmux_ops - function_is_gpio() - that allows pinmux
core to inspect a function and see if it's a GPIO one. Provide a generic
implementation of this callback.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/pinctrl/pinmux.c | 36 ++++++++++++++++++++++++++++++++++--
drivers/pinctrl/pinmux.h | 3 +++
include/linux/pinctrl/pinctrl.h | 14 ++++++++++++++
include/linux/pinctrl/pinmux.h | 2 ++
4 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 504dbb3e97cf334e39b49121137c6768081fcd40..52623b47cc87b49b649610eabfa547d7543292dd 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -89,13 +89,19 @@ bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev, unsigned int pin)
{
struct pin_desc *desc = pin_desc_get(pctldev, pin);
const struct pinmux_ops *ops = pctldev->desc->pmxops;
+ const struct pinctrl_setting_mux *mux_setting = desc->mux_setting;
+ bool func_is_gpio = false;
/* Can't inspect pin, assume it can be used */
if (!desc || !ops)
return true;
guard(mutex)(&desc->mux_lock);
- if (ops->strict && desc->mux_usecount)
+ if (ops->function_is_gpio && mux_setting)
+ func_is_gpio = ops->function_is_gpio(pctldev,
+ mux_setting->func);
+
+ if (ops->strict && desc->mux_usecount && !func_is_gpio)
return false;
return !(ops->strict && !!desc->gpio_owner);
@@ -116,7 +122,9 @@ static int pin_request(struct pinctrl_dev *pctldev,
{
struct pin_desc *desc;
const struct pinmux_ops *ops = pctldev->desc->pmxops;
+ const struct pinctrl_setting_mux *mux_setting;
int status = -EINVAL;
+ bool func_is_gpio = false;
desc = pin_desc_get(pctldev, pin);
if (desc == NULL) {
@@ -126,11 +134,16 @@ static int pin_request(struct pinctrl_dev *pctldev,
goto out;
}
+ mux_setting = desc->mux_setting;
+
dev_dbg(pctldev->dev, "request pin %d (%s) for %s\n",
pin, desc->name, owner);
scoped_guard(mutex, &desc->mux_lock) {
- if ((!gpio_range || ops->strict) &&
+ if (ops->function_is_gpio && mux_setting)
+ func_is_gpio = ops->function_is_gpio(pctldev,
+ mux_setting->func);
+ if ((!gpio_range || ops->strict) && !func_is_gpio &&
desc->mux_usecount && strcmp(desc->mux_owner, owner)) {
dev_err(pctldev->dev,
"pin %s already requested by %s; cannot claim for %s\n",
@@ -861,6 +874,25 @@ pinmux_generic_get_function(struct pinctrl_dev *pctldev, unsigned int selector)
}
EXPORT_SYMBOL_GPL(pinmux_generic_get_function);
+/**
+ * pinmux_generic_function_is_gpio() - returns true if given function is a GPIO
+ * @pctldev: pin controller device
+ * @selector: function number
+ */
+bool pinmux_generic_function_is_gpio(struct pinctrl_dev *pctldev,
+ unsigned int selector)
+{
+ struct function_desc *function;
+
+ function = radix_tree_lookup(&pctldev->pin_function_tree,
+ selector);
+ if (!function)
+ return false;
+
+ return function->func->flags & PINFUNCTION_FLAG_GPIO;
+}
+EXPORT_SYMBOL_GPL(pinmux_generic_function_is_gpio);
+
/**
* pinmux_generic_add_function() - adds a function group
* @pctldev: pin controller device
diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h
index 653684290666d78fd725febb5f8bc987b66a1afb..4e826c1a5246cf8b1ac814c8c0df24c4e036edd2 100644
--- a/drivers/pinctrl/pinmux.h
+++ b/drivers/pinctrl/pinmux.h
@@ -169,6 +169,9 @@ int pinmux_generic_remove_function(struct pinctrl_dev *pctldev,
void pinmux_generic_free_functions(struct pinctrl_dev *pctldev);
+bool pinmux_generic_function_is_gpio(struct pinctrl_dev *pctldev,
+ unsigned int selector);
+
#else
static inline void pinmux_generic_free_functions(struct pinctrl_dev *pctldev)
diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h
index d138e18156452e008f24ca06358fcab45135632f..1a8084e2940537f8f0862761d3e47c56c8783193 100644
--- a/include/linux/pinctrl/pinctrl.h
+++ b/include/linux/pinctrl/pinctrl.h
@@ -11,6 +11,7 @@
#ifndef __LINUX_PINCTRL_PINCTRL_H
#define __LINUX_PINCTRL_PINCTRL_H
+#include <linux/bits.h>
#include <linux/types.h>
struct device;
@@ -206,16 +207,20 @@ extern int pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
const char *pin_group, const unsigned int **pins,
unsigned int *num_pins);
+#define PINFUNCTION_FLAG_GPIO BIT(0)
+
/**
* struct pinfunction - Description about a function
* @name: Name of the function
* @groups: An array of groups for this function
* @ngroups: Number of groups in @groups
+ * @flags: Additional pin function flags
*/
struct pinfunction {
const char *name;
const char * const *groups;
size_t ngroups;
+ unsigned long flags;
};
/* Convenience macro to define a single named pinfunction */
@@ -226,6 +231,15 @@ struct pinfunction {
.ngroups = (_ngroups), \
}
+/* Same as PINCTRL_PINFUNCTION() but for the GPIO category of functions */
+#define PINCTRL_GPIO_PINFUNCTION(_name, _groups, _ngroups) \
+(struct pinfunction) { \
+ .name = (_name), \
+ .groups = (_groups), \
+ .ngroups = (_ngroups), \
+ .flags = PINFUNCTION_FLAG_GPIO, \
+ }
+
#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_PINCTRL)
extern struct pinctrl_dev *of_pinctrl_get(struct device_node *np);
#else
diff --git a/include/linux/pinctrl/pinmux.h b/include/linux/pinctrl/pinmux.h
index d6f7b58d6ad0cce421aad80463529c9ccc65d68e..6db6c3e1ccc2249d4b4204e6fc19bf7b4397cc81 100644
--- a/include/linux/pinctrl/pinmux.h
+++ b/include/linux/pinctrl/pinmux.h
@@ -66,6 +66,8 @@ struct pinmux_ops {
unsigned int selector,
const char * const **groups,
unsigned int *num_groups);
+ bool (*function_is_gpio) (struct pinctrl_dev *pctldev,
+ unsigned int selector);
int (*set_mux) (struct pinctrl_dev *pctldev, unsigned int func_selector,
unsigned int group_selector);
int (*gpio_request_enable) (struct pinctrl_dev *pctldev,
--
2.48.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 13/15] pinctrl: qcom: add infrastructure for marking pin functions as GPIOs
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
` (11 preceding siblings ...)
2025-07-24 9:24 ` [PATCH v3 12/15] pinctrl: allow to mark pin functions as requestable GPIOs Bartosz Golaszewski
@ 2025-07-24 9:24 ` Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 14/15] pinctrl: qcom: mark the `gpio` and `egpio` pins function as non-strict functions Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 15/15] pinctrl: qcom: make the pinmuxing strict Bartosz Golaszewski
14 siblings, 0 replies; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski, Konrad Dybcio
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Add a helper macro that wraps PINCTRL_GPIO_PINFUNCTION() for pinctrl-msm
pin functions and assign the .function_is_gpio() callback in pinmux_ops.
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/pinctrl/qcom/pinctrl-msm.c | 1 +
drivers/pinctrl/qcom/pinctrl-msm.h | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index 965f0cceac56697bc4cdb851c8201db7508c042e..7010be8d1ace062fcf7743e539d2065d4aed856b 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -265,6 +265,7 @@ static const struct pinmux_ops msm_pinmux_ops = {
.get_functions_count = pinmux_generic_get_function_count,
.get_function_name = pinmux_generic_get_function_name,
.get_function_groups = pinmux_generic_get_function_groups,
+ .function_is_gpio = pinmux_generic_function_is_gpio,
.gpio_request_enable = msm_pinmux_request_gpio,
.set_mux = msm_pinmux_set_mux,
};
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.h b/drivers/pinctrl/qcom/pinctrl-msm.h
index d7dc0947bb161868c8f433dc2536719b8afc8bd8..4625fa5320a95a4d24e3a0c98a249e4f163dd4c7 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.h
+++ b/drivers/pinctrl/qcom/pinctrl-msm.h
@@ -29,6 +29,11 @@ struct pinctrl_pin_desc;
fname##_groups, \
ARRAY_SIZE(fname##_groups))
+#define MSM_GPIO_PIN_FUNCTION(fname) \
+ [msm_mux_##fname] = PINCTRL_GPIO_PINFUNCTION(#fname, \
+ fname##_groups, \
+ ARRAY_SIZE(fname##_groups))
+
#define QCA_PIN_FUNCTION(fname) \
[qca_mux_##fname] = PINCTRL_PINFUNCTION(#fname, \
fname##_groups, \
--
2.48.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 14/15] pinctrl: qcom: mark the `gpio` and `egpio` pins function as non-strict functions
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
` (12 preceding siblings ...)
2025-07-24 9:24 ` [PATCH v3 13/15] pinctrl: qcom: add infrastructure for marking pin functions as GPIOs Bartosz Golaszewski
@ 2025-07-24 9:24 ` Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 15/15] pinctrl: qcom: make the pinmuxing strict Bartosz Golaszewski
14 siblings, 0 replies; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski, Konrad Dybcio
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Allow pins muxed to the "gpio" or "egpio" function to be requested as
GPIOs even if pinmux_ops say the controller should be strict.
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/pinctrl/qcom/pinctrl-ipq5018.c | 2 +-
drivers/pinctrl/qcom/pinctrl-ipq5332.c | 2 +-
drivers/pinctrl/qcom/pinctrl-ipq5424.c | 2 +-
drivers/pinctrl/qcom/pinctrl-ipq6018.c | 2 +-
drivers/pinctrl/qcom/pinctrl-ipq8074.c | 2 +-
drivers/pinctrl/qcom/pinctrl-ipq9574.c | 2 +-
drivers/pinctrl/qcom/pinctrl-mdm9607.c | 2 +-
drivers/pinctrl/qcom/pinctrl-mdm9615.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8226.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8660.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8909.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8916.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8917.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8953.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8960.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8976.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8994.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8996.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8998.c | 2 +-
drivers/pinctrl/qcom/pinctrl-msm8x74.c | 2 +-
drivers/pinctrl/qcom/pinctrl-qcm2290.c | 4 ++--
drivers/pinctrl/qcom/pinctrl-qcs404.c | 2 +-
drivers/pinctrl/qcom/pinctrl-qcs615.c | 2 +-
drivers/pinctrl/qcom/pinctrl-qcs8300.c | 4 ++--
drivers/pinctrl/qcom/pinctrl-qdu1000.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sa8775p.c | 4 ++--
drivers/pinctrl/qcom/pinctrl-sar2130p.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sc7180.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sc7280.c | 4 ++--
drivers/pinctrl/qcom/pinctrl-sc8180x.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sc8280xp.c | 4 ++--
drivers/pinctrl/qcom/pinctrl-sdm660.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sdm670.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sdm845.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sdx55.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sdx65.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sdx75.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm4450.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm6115.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm6125.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm6350.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm6375.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm7150.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm8150.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm8250.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm8350.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm8450.c | 4 ++--
drivers/pinctrl/qcom/pinctrl-sm8550.c | 2 +-
drivers/pinctrl/qcom/pinctrl-sm8650.c | 4 ++--
drivers/pinctrl/qcom/pinctrl-sm8750.c | 4 ++--
drivers/pinctrl/qcom/pinctrl-x1e80100.c | 2 +-
51 files changed, 59 insertions(+), 59 deletions(-)
diff --git a/drivers/pinctrl/qcom/pinctrl-ipq5018.c b/drivers/pinctrl/qcom/pinctrl-ipq5018.c
index 10b99d5d8a11db644e974a80b9d7d04ffc09bd4c..cbf34854f8826507430a9bb5a527bdc5d87b9a8c 100644
--- a/drivers/pinctrl/qcom/pinctrl-ipq5018.c
+++ b/drivers/pinctrl/qcom/pinctrl-ipq5018.c
@@ -630,7 +630,7 @@ static const struct pinfunction ipq5018_functions[] = {
MSM_PIN_FUNCTION(eud_gpio),
MSM_PIN_FUNCTION(gcc_plltest),
MSM_PIN_FUNCTION(gcc_tlmm),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(led0),
MSM_PIN_FUNCTION(led2),
MSM_PIN_FUNCTION(mac0),
diff --git a/drivers/pinctrl/qcom/pinctrl-ipq5332.c b/drivers/pinctrl/qcom/pinctrl-ipq5332.c
index 1ac2fc09c11923cd716495b16a7f4af5686ce398..239cbe75f198d3fadf39ed13387f5cea625a8f63 100644
--- a/drivers/pinctrl/qcom/pinctrl-ipq5332.c
+++ b/drivers/pinctrl/qcom/pinctrl-ipq5332.c
@@ -692,7 +692,7 @@ static const struct pinfunction ipq5332_functions[] = {
MSM_PIN_FUNCTION(dbg_out),
MSM_PIN_FUNCTION(gcc_plltest),
MSM_PIN_FUNCTION(gcc_tlmm),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(lock_det),
MSM_PIN_FUNCTION(mac0),
MSM_PIN_FUNCTION(mac1),
diff --git a/drivers/pinctrl/qcom/pinctrl-ipq5424.c b/drivers/pinctrl/qcom/pinctrl-ipq5424.c
index 7ff1f8acc1a3a81037298464130fda59f329d53e..67b452a033d62340d669bfff4b6ae7b6d6cc430d 100644
--- a/drivers/pinctrl/qcom/pinctrl-ipq5424.c
+++ b/drivers/pinctrl/qcom/pinctrl-ipq5424.c
@@ -641,7 +641,7 @@ static const struct pinfunction ipq5424_functions[] = {
MSM_PIN_FUNCTION(dbg_out),
MSM_PIN_FUNCTION(gcc_plltest),
MSM_PIN_FUNCTION(gcc_tlmm),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(i2c0_scl),
MSM_PIN_FUNCTION(i2c0_sda),
MSM_PIN_FUNCTION(i2c1_scl),
diff --git a/drivers/pinctrl/qcom/pinctrl-ipq6018.c b/drivers/pinctrl/qcom/pinctrl-ipq6018.c
index a4ba980252e187879947e7057004fa48815f2620..be177fb0a92d957bd57126df9c2a495b69ef1457 100644
--- a/drivers/pinctrl/qcom/pinctrl-ipq6018.c
+++ b/drivers/pinctrl/qcom/pinctrl-ipq6018.c
@@ -891,7 +891,7 @@ static const struct pinfunction ipq6018_functions[] = {
MSM_PIN_FUNCTION(dbg_out),
MSM_PIN_FUNCTION(gcc_plltest),
MSM_PIN_FUNCTION(gcc_tlmm),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(lpass_aud),
MSM_PIN_FUNCTION(lpass_aud0),
MSM_PIN_FUNCTION(lpass_aud1),
diff --git a/drivers/pinctrl/qcom/pinctrl-ipq8074.c b/drivers/pinctrl/qcom/pinctrl-ipq8074.c
index 482f13282fc2be951032cbe6dc5100bf9129ea5f..e94de90833140c83d50535778e64044bb315c4ea 100644
--- a/drivers/pinctrl/qcom/pinctrl-ipq8074.c
+++ b/drivers/pinctrl/qcom/pinctrl-ipq8074.c
@@ -838,7 +838,7 @@ static const struct pinfunction ipq8074_functions[] = {
MSM_PIN_FUNCTION(dbg_out),
MSM_PIN_FUNCTION(gcc_plltest),
MSM_PIN_FUNCTION(gcc_tlmm),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(ldo_en),
MSM_PIN_FUNCTION(ldo_update),
MSM_PIN_FUNCTION(led0),
diff --git a/drivers/pinctrl/qcom/pinctrl-ipq9574.c b/drivers/pinctrl/qcom/pinctrl-ipq9574.c
index 89c05d8eb55034dea3e1c7299ede6567c20e0159..3ed093ea8eb9074426934336dcfb9d74e3b8af22 100644
--- a/drivers/pinctrl/qcom/pinctrl-ipq9574.c
+++ b/drivers/pinctrl/qcom/pinctrl-ipq9574.c
@@ -651,7 +651,7 @@ static const struct pinfunction ipq9574_functions[] = {
MSM_PIN_FUNCTION(dwc_ddrphy),
MSM_PIN_FUNCTION(gcc_plltest),
MSM_PIN_FUNCTION(gcc_tlmm),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(mac),
MSM_PIN_FUNCTION(mdc),
MSM_PIN_FUNCTION(mdio),
diff --git a/drivers/pinctrl/qcom/pinctrl-mdm9607.c b/drivers/pinctrl/qcom/pinctrl-mdm9607.c
index 3e18ba124fede923f56eab1aec5aaf875f06e343..cef330547ce78d4c8cc873251d77f18b29aff57b 100644
--- a/drivers/pinctrl/qcom/pinctrl-mdm9607.c
+++ b/drivers/pinctrl/qcom/pinctrl-mdm9607.c
@@ -861,7 +861,7 @@ static const struct pinfunction mdm9607_functions[] = {
MSM_PIN_FUNCTION(gcc_plltest),
MSM_PIN_FUNCTION(gcc_tlmm),
MSM_PIN_FUNCTION(gmac_mdio),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(gsm0_tx),
MSM_PIN_FUNCTION(lcd_rst),
MSM_PIN_FUNCTION(ldo_en),
diff --git a/drivers/pinctrl/qcom/pinctrl-mdm9615.c b/drivers/pinctrl/qcom/pinctrl-mdm9615.c
index bea1ca3d1b7f84c28c23af2a52cc464da44a90b0..729fe3d7e14efcfa247da2daac999c4038e1613c 100644
--- a/drivers/pinctrl/qcom/pinctrl-mdm9615.c
+++ b/drivers/pinctrl/qcom/pinctrl-mdm9615.c
@@ -313,7 +313,7 @@ static const char * const cdc_mclk_groups[] = {
};
static const struct pinfunction mdm9615_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(gsbi2_i2c),
MSM_PIN_FUNCTION(gsbi3),
MSM_PIN_FUNCTION(gsbi4),
diff --git a/drivers/pinctrl/qcom/pinctrl-msm8226.c b/drivers/pinctrl/qcom/pinctrl-msm8226.c
index f9a957347340813f87e58d3bcbea81faa9d6255e..a81aa092ef1240c9e951352720d48db6d269aff9 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm8226.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm8226.c
@@ -483,7 +483,7 @@ static const struct pinfunction msm8226_functions[] = {
MSM_PIN_FUNCTION(cci_i2c0),
MSM_PIN_FUNCTION(gp0_clk),
MSM_PIN_FUNCTION(gp1_clk),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(sdc3),
MSM_PIN_FUNCTION(wlan),
};
diff --git a/drivers/pinctrl/qcom/pinctrl-msm8660.c b/drivers/pinctrl/qcom/pinctrl-msm8660.c
index 4dbc19ffd80efcdab059a253904e1ffe95fd36f7..5ded00396cd949f432c4bdcd3b1224cbfae34f8c 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm8660.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm8660.c
@@ -714,7 +714,7 @@ static const char * const ebi2_groups[] = {
};
static const struct pinfunction msm8660_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(cam_mclk),
MSM_PIN_FUNCTION(dsub),
MSM_PIN_FUNCTION(ext_gps),
diff --git a/drivers/pinctrl/qcom/pinctrl-msm8909.c b/drivers/pinctrl/qcom/pinctrl-msm8909.c
index 0aa4f77b774f45947ffade7d167dd25cc4da5297..544a52fb8f3d6e6abfd97e2c0736e8242b51d7ba 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm8909.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm8909.c
@@ -696,7 +696,7 @@ static const struct pinfunction msm8909_functions[] = {
MSM_PIN_FUNCTION(gcc_gp3_clk_a),
MSM_PIN_FUNCTION(gcc_gp3_clk_b),
MSM_PIN_FUNCTION(gcc_plltest),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(gsm0_tx),
MSM_PIN_FUNCTION(ldo_en),
MSM_PIN_FUNCTION(ldo_update),
diff --git a/drivers/pinctrl/qcom/pinctrl-msm8916.c b/drivers/pinctrl/qcom/pinctrl-msm8916.c
index 0dfc6dd33d58b2d9df7a5cc3f7ff8890976207d3..b1b6934bb4b6357f04d84ce9c244ba930c1916ba 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm8916.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm8916.c
@@ -743,7 +743,7 @@ static const struct pinfunction msm8916_functions[] = {
MSM_PIN_FUNCTION(gcc_gp2_clk_b),
MSM_PIN_FUNCTION(gcc_gp3_clk_a),
MSM_PIN_FUNCTION(gcc_gp3_clk_b),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(gsm0_tx0),
MSM_PIN_FUNCTION(gsm0_tx1),
MSM_PIN_FUNCTION(gsm1_tx0),
diff --git a/drivers/pinctrl/qcom/pinctrl-msm8917.c b/drivers/pinctrl/qcom/pinctrl-msm8917.c
index 2e1a94ab18b219f818c591ff3b07280578822d1a..f23d92d6615b8926dc04ba0056cbce6715cc7b21 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm8917.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm8917.c
@@ -1302,7 +1302,7 @@ static const struct pinfunction msm8917_functions[] = {
MSM_PIN_FUNCTION(gcc_gp3_clk_b),
MSM_PIN_FUNCTION(gcc_plltest),
MSM_PIN_FUNCTION(gcc_tlmm),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(gsm0_tx),
MSM_PIN_FUNCTION(key_focus),
MSM_PIN_FUNCTION(key_snapshot),
diff --git a/drivers/pinctrl/qcom/pinctrl-msm8953.c b/drivers/pinctrl/qcom/pinctrl-msm8953.c
index 956383341a7a777edf28c710353dc6deab124ef9..67db062fdf5628fb41588f2dc5a79a9e3499e5b6 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm8953.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm8953.c
@@ -1533,7 +1533,7 @@ static const struct pinfunction msm8953_functions[] = {
MSM_PIN_FUNCTION(gcc_gp3_clk_b),
MSM_PIN_FUNCTION(gcc_plltest),
MSM_PIN_FUNCTION(gcc_tlmm),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(gsm0_tx),
MSM_PIN_FUNCTION(gsm1_tx),
MSM_PIN_FUNCTION(gyro_int),
diff --git a/drivers/pinctrl/qcom/pinctrl-msm8960.c b/drivers/pinctrl/qcom/pinctrl-msm8960.c
index a937ea867de709326a2aea77f980cae1d8480f35..2fb15208aba050a1bf669a2e304e389fd10fe0be 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm8960.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm8960.c
@@ -974,7 +974,7 @@ static const struct pinfunction msm8960_functions[] = {
MSM_PIN_FUNCTION(gp_pdm_1b),
MSM_PIN_FUNCTION(gp_pdm_2a),
MSM_PIN_FUNCTION(gp_pdm_2b),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(gsbi1),
MSM_PIN_FUNCTION(gsbi1_spi_cs1_n),
MSM_PIN_FUNCTION(gsbi1_spi_cs2a_n),
diff --git a/drivers/pinctrl/qcom/pinctrl-msm8976.c b/drivers/pinctrl/qcom/pinctrl-msm8976.c
index 3bcb03387781f803bf7e0251496a88a43b562b8d..345539b9e696f0decdb02b24eb0f966c7439af9d 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm8976.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm8976.c
@@ -812,7 +812,7 @@ static const char * const ss_switch_groups[] = {
};
static const struct pinfunction msm8976_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(blsp_spi1),
MSM_PIN_FUNCTION(smb_int),
MSM_PIN_FUNCTION(blsp_i2c1),
diff --git a/drivers/pinctrl/qcom/pinctrl-msm8994.c b/drivers/pinctrl/qcom/pinctrl-msm8994.c
index 7a3b6cbccb687c8b5040ee6bf372f092f21aa872..94e042d1f4b2a5f20c3c3e9287b254e1e06c4050 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm8994.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm8994.c
@@ -1071,7 +1071,7 @@ static const struct pinfunction msm8994_functions[] = {
MSM_PIN_FUNCTION(uim2),
MSM_PIN_FUNCTION(uim3),
MSM_PIN_FUNCTION(uim4),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
};
static const struct msm_pingroup msm8994_groups[] = {
diff --git a/drivers/pinctrl/qcom/pinctrl-msm8996.c b/drivers/pinctrl/qcom/pinctrl-msm8996.c
index d86d83106d3ba12343a4685e5b87c661f823c35b..e5b55693d02377c1bd992504a9d15a9ce015cf84 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm8996.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm8996.c
@@ -1532,7 +1532,7 @@ static const struct pinfunction msm8996_functions[] = {
MSM_PIN_FUNCTION(gcc_gp2_clk_b),
MSM_PIN_FUNCTION(gcc_gp3_clk_a),
MSM_PIN_FUNCTION(gcc_gp3_clk_b),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(gsm_tx),
MSM_PIN_FUNCTION(hdmi_cec),
MSM_PIN_FUNCTION(hdmi_ddc),
diff --git a/drivers/pinctrl/qcom/pinctrl-msm8998.c b/drivers/pinctrl/qcom/pinctrl-msm8998.c
index 1daee815888f54b711505dfacefd614df83affc0..b727593af34af94925fd9c938e3c03c40ad59eaa 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm8998.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm8998.c
@@ -1160,7 +1160,7 @@ static const char * const mss_lte_groups[] = {
};
static const struct pinfunction msm8998_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(adsp_ext),
MSM_PIN_FUNCTION(agera_pll),
MSM_PIN_FUNCTION(atest_char),
diff --git a/drivers/pinctrl/qcom/pinctrl-msm8x74.c b/drivers/pinctrl/qcom/pinctrl-msm8x74.c
index 8253aa25775b247dc54a377c9781094e465e22b6..202bec003e96f1d2d68703676e6e8a88f1ffdae5 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm8x74.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm8x74.c
@@ -778,7 +778,7 @@ static const char * const slimbus_groups[] = { "gpio70", "gpio71" };
static const char * const hsic_ctl_groups[] = { "hsic_strobe", "hsic_data" };
static const struct pinfunction msm8x74_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(cci_i2c0),
MSM_PIN_FUNCTION(cci_i2c1),
MSM_PIN_FUNCTION(uim1),
diff --git a/drivers/pinctrl/qcom/pinctrl-qcm2290.c b/drivers/pinctrl/qcom/pinctrl-qcm2290.c
index eeeec6434f6a68a588ff58641b7c25c261b5749a..38200957451e1975b7215eae6a2d10329a30a57d 100644
--- a/drivers/pinctrl/qcom/pinctrl-qcm2290.c
+++ b/drivers/pinctrl/qcom/pinctrl-qcm2290.c
@@ -870,11 +870,11 @@ static const struct pinfunction qcm2290_functions[] = {
MSM_PIN_FUNCTION(ddr_pxi1),
MSM_PIN_FUNCTION(ddr_pxi2),
MSM_PIN_FUNCTION(ddr_pxi3),
- MSM_PIN_FUNCTION(egpio),
+ MSM_GPIO_PIN_FUNCTION(egpio),
MSM_PIN_FUNCTION(gcc_gp1),
MSM_PIN_FUNCTION(gcc_gp2),
MSM_PIN_FUNCTION(gcc_gp3),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(gp_pdm0),
MSM_PIN_FUNCTION(gp_pdm1),
MSM_PIN_FUNCTION(gp_pdm2),
diff --git a/drivers/pinctrl/qcom/pinctrl-qcs404.c b/drivers/pinctrl/qcom/pinctrl-qcs404.c
index 54e3b44353494e9398a88702945b7a85ff901b4d..0b8db2c7e58a9b6f6b832c8998766f2711068dd2 100644
--- a/drivers/pinctrl/qcom/pinctrl-qcs404.c
+++ b/drivers/pinctrl/qcom/pinctrl-qcs404.c
@@ -1296,7 +1296,7 @@ static const char * const i2s_3_ws_a_groups[] = {
};
static const struct pinfunction qcs404_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(hdmi_tx),
MSM_PIN_FUNCTION(hdmi_ddc),
MSM_PIN_FUNCTION(blsp_uart_tx_a2),
diff --git a/drivers/pinctrl/qcom/pinctrl-qcs615.c b/drivers/pinctrl/qcom/pinctrl-qcs615.c
index 2a943bc46a6299899abd87523f24e7e291f24c57..4dfa820d4e77ce8157a3503ee8ec6e426b54e030 100644
--- a/drivers/pinctrl/qcom/pinctrl-qcs615.c
+++ b/drivers/pinctrl/qcom/pinctrl-qcs615.c
@@ -819,7 +819,7 @@ static const char *const wsa_data_groups[] = {
};
static const struct pinfunction qcs615_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(adsp_ext),
MSM_PIN_FUNCTION(agera_pll),
MSM_PIN_FUNCTION(aoss_cti),
diff --git a/drivers/pinctrl/qcom/pinctrl-qcs8300.c b/drivers/pinctrl/qcom/pinctrl-qcs8300.c
index d6437e26392b60f5d345f2591e98516a9d933a0f..f1af1a620684cd48e0282d4452c3f00af6ca0302 100644
--- a/drivers/pinctrl/qcom/pinctrl-qcs8300.c
+++ b/drivers/pinctrl/qcom/pinctrl-qcs8300.c
@@ -929,7 +929,7 @@ static const char *const vsense_trigger_groups[] = {
};
static const struct pinfunction qcs8300_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(aoss_cti),
MSM_PIN_FUNCTION(atest_char),
MSM_PIN_FUNCTION(atest_usb2),
@@ -949,7 +949,7 @@ static const struct pinfunction qcs8300_functions[] = {
MSM_PIN_FUNCTION(edp0_hot),
MSM_PIN_FUNCTION(edp0_lcd),
MSM_PIN_FUNCTION(edp1_lcd),
- MSM_PIN_FUNCTION(egpio),
+ MSM_GPIO_PIN_FUNCTION(egpio),
MSM_PIN_FUNCTION(emac0_mcg0),
MSM_PIN_FUNCTION(emac0_mcg1),
MSM_PIN_FUNCTION(emac0_mcg2),
diff --git a/drivers/pinctrl/qcom/pinctrl-qdu1000.c b/drivers/pinctrl/qcom/pinctrl-qdu1000.c
index eacb89fa388850ef39ceb50497df9e5cca54191c..7c535698a780041c2660c08d22146c8d700ce081 100644
--- a/drivers/pinctrl/qcom/pinctrl-qdu1000.c
+++ b/drivers/pinctrl/qcom/pinctrl-qdu1000.c
@@ -904,7 +904,7 @@ static const char * const vsense_trigger_groups[] = {
};
static const struct pinfunction qdu1000_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(cmo_pri),
MSM_PIN_FUNCTION(si5518_int),
MSM_PIN_FUNCTION(atest_char),
diff --git a/drivers/pinctrl/qcom/pinctrl-sa8775p.c b/drivers/pinctrl/qcom/pinctrl-sa8775p.c
index 1b62eb3e6620c978225c5fd2ab541451cbe93093..53f28b9c49ba2dba7cfbbeb13774d011bd31fae9 100644
--- a/drivers/pinctrl/qcom/pinctrl-sa8775p.c
+++ b/drivers/pinctrl/qcom/pinctrl-sa8775p.c
@@ -1181,7 +1181,7 @@ static const char * const vsense_trigger_groups[] = {
};
static const struct pinfunction sa8775p_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(atest_char),
MSM_PIN_FUNCTION(atest_usb2),
MSM_PIN_FUNCTION(audio_ref),
@@ -1217,7 +1217,7 @@ static const struct pinfunction sa8775p_functions[] = {
MSM_PIN_FUNCTION(edp2_lcd),
MSM_PIN_FUNCTION(edp3_hot),
MSM_PIN_FUNCTION(edp3_lcd),
- MSM_PIN_FUNCTION(egpio),
+ MSM_GPIO_PIN_FUNCTION(egpio),
MSM_PIN_FUNCTION(emac0_mcg0),
MSM_PIN_FUNCTION(emac0_mcg1),
MSM_PIN_FUNCTION(emac0_mcg2),
diff --git a/drivers/pinctrl/qcom/pinctrl-sar2130p.c b/drivers/pinctrl/qcom/pinctrl-sar2130p.c
index 3dd1b5e5cfee489ec34b16ee2ae1c8d2c2756553..4a53f4ee20418e755926770693f81a582c431e6f 100644
--- a/drivers/pinctrl/qcom/pinctrl-sar2130p.c
+++ b/drivers/pinctrl/qcom/pinctrl-sar2130p.c
@@ -1128,7 +1128,7 @@ static const char * const vsense_trigger_groups[] = {
};
static const struct pinfunction sar2130p_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(qup0),
MSM_PIN_FUNCTION(ibi_i3c),
MSM_PIN_FUNCTION(jitter_bist),
diff --git a/drivers/pinctrl/qcom/pinctrl-sc7180.c b/drivers/pinctrl/qcom/pinctrl-sc7180.c
index c43fe10b71add7d6294c90e86578ed472b8759a3..3eae51472b137372f358278a7fb04ace7430bcf4 100644
--- a/drivers/pinctrl/qcom/pinctrl-sc7180.c
+++ b/drivers/pinctrl/qcom/pinctrl-sc7180.c
@@ -903,7 +903,7 @@ static const struct pinfunction sc7180_functions[] = {
MSM_PIN_FUNCTION(gcc_gp1),
MSM_PIN_FUNCTION(gcc_gp2),
MSM_PIN_FUNCTION(gcc_gp3),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(gp_pdm0),
MSM_PIN_FUNCTION(gp_pdm1),
MSM_PIN_FUNCTION(gp_pdm2),
diff --git a/drivers/pinctrl/qcom/pinctrl-sc7280.c b/drivers/pinctrl/qcom/pinctrl-sc7280.c
index 1b070e9d41f5972470d245edb821d202ca24522b..44e09608aad07acbd8354d5cb3e7f02b6e736f01 100644
--- a/drivers/pinctrl/qcom/pinctrl-sc7280.c
+++ b/drivers/pinctrl/qcom/pinctrl-sc7280.c
@@ -1153,11 +1153,11 @@ static const struct pinfunction sc7280_functions[] = {
MSM_PIN_FUNCTION(dp_lcd),
MSM_PIN_FUNCTION(edp_hot),
MSM_PIN_FUNCTION(edp_lcd),
- MSM_PIN_FUNCTION(egpio),
+ MSM_GPIO_PIN_FUNCTION(egpio),
MSM_PIN_FUNCTION(gcc_gp1),
MSM_PIN_FUNCTION(gcc_gp2),
MSM_PIN_FUNCTION(gcc_gp3),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(host2wlan_sol),
MSM_PIN_FUNCTION(ibi_i3c),
MSM_PIN_FUNCTION(jitter_bist),
diff --git a/drivers/pinctrl/qcom/pinctrl-sc8180x.c b/drivers/pinctrl/qcom/pinctrl-sc8180x.c
index 26dd165d154348a8659720335ec16c3e5ace30ef..d494e176383d25a369c217d1c649b580c374d35b 100644
--- a/drivers/pinctrl/qcom/pinctrl-sc8180x.c
+++ b/drivers/pinctrl/qcom/pinctrl-sc8180x.c
@@ -1272,7 +1272,7 @@ static const struct pinfunction sc8180x_functions[] = {
MSM_PIN_FUNCTION(gcc_gp3),
MSM_PIN_FUNCTION(gcc_gp4),
MSM_PIN_FUNCTION(gcc_gp5),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(gps),
MSM_PIN_FUNCTION(grfc),
MSM_PIN_FUNCTION(hs1_mi2s),
diff --git a/drivers/pinctrl/qcom/pinctrl-sc8280xp.c b/drivers/pinctrl/qcom/pinctrl-sc8280xp.c
index 6ccd7e5648d420072f7ce467d92ef0764a6d7764..cf8297e8b8f8c98add4cc5d305e99a2cd1f7a52a 100644
--- a/drivers/pinctrl/qcom/pinctrl-sc8280xp.c
+++ b/drivers/pinctrl/qcom/pinctrl-sc8280xp.c
@@ -1506,7 +1506,7 @@ static const struct pinfunction sc8280xp_functions[] = {
MSM_PIN_FUNCTION(edp2_lcd),
MSM_PIN_FUNCTION(edp3_lcd),
MSM_PIN_FUNCTION(edp_hot),
- MSM_PIN_FUNCTION(egpio),
+ MSM_GPIO_PIN_FUNCTION(egpio),
MSM_PIN_FUNCTION(emac0_dll),
MSM_PIN_FUNCTION(emac0_mcg0),
MSM_PIN_FUNCTION(emac0_mcg1),
@@ -1527,7 +1527,7 @@ static const struct pinfunction sc8280xp_functions[] = {
MSM_PIN_FUNCTION(gcc_gp3),
MSM_PIN_FUNCTION(gcc_gp4),
MSM_PIN_FUNCTION(gcc_gp5),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(hs1_mi2s),
MSM_PIN_FUNCTION(hs2_mi2s),
MSM_PIN_FUNCTION(hs3_mi2s),
diff --git a/drivers/pinctrl/qcom/pinctrl-sdm660.c b/drivers/pinctrl/qcom/pinctrl-sdm660.c
index 1a78288f1bc832837d5c72d9eb1659f397d79b94..687d986de75c4df5d91c6cda3c43beecfb24795b 100644
--- a/drivers/pinctrl/qcom/pinctrl-sdm660.c
+++ b/drivers/pinctrl/qcom/pinctrl-sdm660.c
@@ -1157,7 +1157,7 @@ static const struct pinfunction sdm660_functions[] = {
MSM_PIN_FUNCTION(gcc_gp1),
MSM_PIN_FUNCTION(gcc_gp2),
MSM_PIN_FUNCTION(gcc_gp3),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(gps_tx_a),
MSM_PIN_FUNCTION(gps_tx_b),
MSM_PIN_FUNCTION(gps_tx_c),
diff --git a/drivers/pinctrl/qcom/pinctrl-sdm670.c b/drivers/pinctrl/qcom/pinctrl-sdm670.c
index 0fe1fa94cd6da13591397442a63ce8daec9f4674..486b72edf7b4ec9d30bbbffbf53d41db2c9e8157 100644
--- a/drivers/pinctrl/qcom/pinctrl-sdm670.c
+++ b/drivers/pinctrl/qcom/pinctrl-sdm670.c
@@ -991,7 +991,7 @@ static const char * const mss_lte_groups[] = {
};
static const struct pinfunction sdm670_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(adsp_ext),
MSM_PIN_FUNCTION(agera_pll),
MSM_PIN_FUNCTION(atest_char),
diff --git a/drivers/pinctrl/qcom/pinctrl-sdm845.c b/drivers/pinctrl/qcom/pinctrl-sdm845.c
index 0446e291aa4831da439af12b7934fbda5915ee5a..4cf8575797a0f49646e0dd7a93480dfbd6ba3a04 100644
--- a/drivers/pinctrl/qcom/pinctrl-sdm845.c
+++ b/drivers/pinctrl/qcom/pinctrl-sdm845.c
@@ -976,7 +976,7 @@ static const char * const tsif1_sync_groups[] = {
};
static const struct pinfunction sdm845_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(adsp_ext),
MSM_PIN_FUNCTION(agera_pll),
MSM_PIN_FUNCTION(atest_char),
diff --git a/drivers/pinctrl/qcom/pinctrl-sdx55.c b/drivers/pinctrl/qcom/pinctrl-sdx55.c
index 2c17bf889146362edf9f482d33b17d35a255882e..79a7010b73f187f4aeab8ff7e27461984c1c9c3f 100644
--- a/drivers/pinctrl/qcom/pinctrl-sdx55.c
+++ b/drivers/pinctrl/qcom/pinctrl-sdx55.c
@@ -796,7 +796,7 @@ static const struct pinfunction sdx55_functions[] = {
MSM_PIN_FUNCTION(gcc_gp2),
MSM_PIN_FUNCTION(gcc_gp3),
MSM_PIN_FUNCTION(gcc_plltest),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(i2s_mclk),
MSM_PIN_FUNCTION(jitter_bist),
MSM_PIN_FUNCTION(ldo_en),
diff --git a/drivers/pinctrl/qcom/pinctrl-sdx65.c b/drivers/pinctrl/qcom/pinctrl-sdx65.c
index 85b5c0206dbd199c6efc15aad10784d20c1addde..cc8a99a6a91ed253883535f3eb0338939db9a677 100644
--- a/drivers/pinctrl/qcom/pinctrl-sdx65.c
+++ b/drivers/pinctrl/qcom/pinctrl-sdx65.c
@@ -732,7 +732,7 @@ static const struct pinfunction sdx65_functions[] = {
MSM_PIN_FUNCTION(gcc_gp2),
MSM_PIN_FUNCTION(gcc_gp3),
MSM_PIN_FUNCTION(gcc_plltest),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(i2s_mclk),
MSM_PIN_FUNCTION(jitter_bist),
MSM_PIN_FUNCTION(ldo_en),
diff --git a/drivers/pinctrl/qcom/pinctrl-sdx75.c b/drivers/pinctrl/qcom/pinctrl-sdx75.c
index ab13a3a57a830781f35916ff508ca65d6699271d..4078d83d818c3352253563fc45273a293cfe4ce8 100644
--- a/drivers/pinctrl/qcom/pinctrl-sdx75.c
+++ b/drivers/pinctrl/qcom/pinctrl-sdx75.c
@@ -852,7 +852,7 @@ static const struct pinfunction sdx75_functions[] = {
MSM_PIN_FUNCTION(gcc_gp2_clk),
MSM_PIN_FUNCTION(gcc_gp3_clk),
MSM_PIN_FUNCTION(gcc_plltest),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(i2s_mclk),
MSM_PIN_FUNCTION(jitter_bist),
MSM_PIN_FUNCTION(ldo_en),
diff --git a/drivers/pinctrl/qcom/pinctrl-sm4450.c b/drivers/pinctrl/qcom/pinctrl-sm4450.c
index 1ecdf1ab4f275ede7cb629321f9c37d3f81a25e9..d51e271e336101796b75d64e56f573f3547f1121 100644
--- a/drivers/pinctrl/qcom/pinctrl-sm4450.c
+++ b/drivers/pinctrl/qcom/pinctrl-sm4450.c
@@ -722,7 +722,7 @@ static const char * const wlan1_adc_dtest1_groups[] = {
};
static const struct pinfunction sm4450_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(atest_char),
MSM_PIN_FUNCTION(atest_usb0),
MSM_PIN_FUNCTION(audio_ref_clk),
diff --git a/drivers/pinctrl/qcom/pinctrl-sm6115.c b/drivers/pinctrl/qcom/pinctrl-sm6115.c
index c273efa4399630a2187845382e231fe150d997fd..06700685ea2a380b84464d17955d040e55eb587c 100644
--- a/drivers/pinctrl/qcom/pinctrl-sm6115.c
+++ b/drivers/pinctrl/qcom/pinctrl-sm6115.c
@@ -687,7 +687,7 @@ static const struct pinfunction sm6115_functions[] = {
MSM_PIN_FUNCTION(gcc_gp1),
MSM_PIN_FUNCTION(gcc_gp2),
MSM_PIN_FUNCTION(gcc_gp3),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(gp_pdm0),
MSM_PIN_FUNCTION(gp_pdm1),
MSM_PIN_FUNCTION(gp_pdm2),
diff --git a/drivers/pinctrl/qcom/pinctrl-sm6125.c b/drivers/pinctrl/qcom/pinctrl-sm6125.c
index 5092f20e0c1bdee2e99b768f12cfbec31972c24c..5d3d1e402345ebb86524b508c45cf9fc9a0f2031 100644
--- a/drivers/pinctrl/qcom/pinctrl-sm6125.c
+++ b/drivers/pinctrl/qcom/pinctrl-sm6125.c
@@ -943,7 +943,7 @@ static const char * const dmic1_data_groups[] = {
static const struct pinfunction sm6125_functions[] = {
MSM_PIN_FUNCTION(qup00),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(qdss),
MSM_PIN_FUNCTION(qup01),
MSM_PIN_FUNCTION(qup02),
diff --git a/drivers/pinctrl/qcom/pinctrl-sm6350.c b/drivers/pinctrl/qcom/pinctrl-sm6350.c
index ba4686c86c54b8c1dc32522c83587521e149a5ae..220fb582cac9fcc97271cc0feb2adc5b32c85994 100644
--- a/drivers/pinctrl/qcom/pinctrl-sm6350.c
+++ b/drivers/pinctrl/qcom/pinctrl-sm6350.c
@@ -1048,7 +1048,7 @@ static const struct pinfunction sm6350_functions[] = {
MSM_PIN_FUNCTION(gp_pdm0),
MSM_PIN_FUNCTION(gp_pdm1),
MSM_PIN_FUNCTION(gp_pdm2),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(gps_tx),
MSM_PIN_FUNCTION(ibi_i3c),
MSM_PIN_FUNCTION(jitter_bist),
diff --git a/drivers/pinctrl/qcom/pinctrl-sm6375.c b/drivers/pinctrl/qcom/pinctrl-sm6375.c
index 49031571e65ee3291fb1e5269e071a08a77c87de..08b8ef6efaf09741e8826e08a2c12ef49680504a 100644
--- a/drivers/pinctrl/qcom/pinctrl-sm6375.c
+++ b/drivers/pinctrl/qcom/pinctrl-sm6375.c
@@ -1172,7 +1172,7 @@ static const struct pinfunction sm6375_functions[] = {
MSM_PIN_FUNCTION(gp_pdm0),
MSM_PIN_FUNCTION(gp_pdm1),
MSM_PIN_FUNCTION(gp_pdm2),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(gps_tx),
MSM_PIN_FUNCTION(ibi_i3c),
MSM_PIN_FUNCTION(jitter_bist),
diff --git a/drivers/pinctrl/qcom/pinctrl-sm7150.c b/drivers/pinctrl/qcom/pinctrl-sm7150.c
index 6e89966cd70e34bcb74cfb50e80e110e40655b0e..78dd8153a4d4e5bb68dd5d22aa7f2b6dc6a5fddb 100644
--- a/drivers/pinctrl/qcom/pinctrl-sm7150.c
+++ b/drivers/pinctrl/qcom/pinctrl-sm7150.c
@@ -960,7 +960,7 @@ static const char * const wsa_data_groups[] = {
};
static const struct pinfunction sm7150_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(adsp_ext),
MSM_PIN_FUNCTION(agera_pll),
MSM_PIN_FUNCTION(aoss_cti),
diff --git a/drivers/pinctrl/qcom/pinctrl-sm8150.c b/drivers/pinctrl/qcom/pinctrl-sm8150.c
index 794ed99463f76032f56be9464a4aa3018537df94..ad861cd66958c4faa929737e5088b82a35ffc95b 100644
--- a/drivers/pinctrl/qcom/pinctrl-sm8150.c
+++ b/drivers/pinctrl/qcom/pinctrl-sm8150.c
@@ -1217,7 +1217,7 @@ static const struct pinfunction sm8150_functions[] = {
MSM_PIN_FUNCTION(gcc_gp1),
MSM_PIN_FUNCTION(gcc_gp2),
MSM_PIN_FUNCTION(gcc_gp3),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(hs1_mi2s),
MSM_PIN_FUNCTION(hs2_mi2s),
MSM_PIN_FUNCTION(hs3_mi2s),
diff --git a/drivers/pinctrl/qcom/pinctrl-sm8250.c b/drivers/pinctrl/qcom/pinctrl-sm8250.c
index fb6f005d64f53f318d58e69681f07e36404439cf..6021d9f6e407ef57a6b1ebaaa27039c0fea7e18c 100644
--- a/drivers/pinctrl/qcom/pinctrl-sm8250.c
+++ b/drivers/pinctrl/qcom/pinctrl-sm8250.c
@@ -1021,7 +1021,7 @@ static const struct pinfunction sm8250_functions[] = {
MSM_PIN_FUNCTION(gcc_gp1),
MSM_PIN_FUNCTION(gcc_gp2),
MSM_PIN_FUNCTION(gcc_gp3),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(ibi_i3c),
MSM_PIN_FUNCTION(jitter_bist),
MSM_PIN_FUNCTION(lpass_slimbus),
diff --git a/drivers/pinctrl/qcom/pinctrl-sm8350.c b/drivers/pinctrl/qcom/pinctrl-sm8350.c
index c8a3f39ce6f1b8565a783f04100269b3cadb9bcc..99949b552021131f5aade06a80bd01799835e67a 100644
--- a/drivers/pinctrl/qcom/pinctrl-sm8350.c
+++ b/drivers/pinctrl/qcom/pinctrl-sm8350.c
@@ -1267,7 +1267,7 @@ static const struct pinfunction sm8350_functions[] = {
MSM_PIN_FUNCTION(gcc_gp1),
MSM_PIN_FUNCTION(gcc_gp2),
MSM_PIN_FUNCTION(gcc_gp3),
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(ibi_i3c),
MSM_PIN_FUNCTION(jitter_bist),
MSM_PIN_FUNCTION(lpass_slimbus),
diff --git a/drivers/pinctrl/qcom/pinctrl-sm8450.c b/drivers/pinctrl/qcom/pinctrl-sm8450.c
index f2e52d5a0f9369d21922d0651539908d592301e5..9889fc5dc2cd204588abd06cfd7d1ae0e4513af0 100644
--- a/drivers/pinctrl/qcom/pinctrl-sm8450.c
+++ b/drivers/pinctrl/qcom/pinctrl-sm8450.c
@@ -1269,7 +1269,7 @@ static const char * const vsense_trigger_groups[] = {
};
static const struct pinfunction sm8450_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(aon_cam),
MSM_PIN_FUNCTION(atest_char),
MSM_PIN_FUNCTION(atest_usb),
@@ -1291,7 +1291,7 @@ static const struct pinfunction sm8450_functions[] = {
MSM_PIN_FUNCTION(ddr_pxi2),
MSM_PIN_FUNCTION(ddr_pxi3),
MSM_PIN_FUNCTION(dp_hot),
- MSM_PIN_FUNCTION(egpio),
+ MSM_GPIO_PIN_FUNCTION(egpio),
MSM_PIN_FUNCTION(gcc_gp1),
MSM_PIN_FUNCTION(gcc_gp2),
MSM_PIN_FUNCTION(gcc_gp3),
diff --git a/drivers/pinctrl/qcom/pinctrl-sm8550.c b/drivers/pinctrl/qcom/pinctrl-sm8550.c
index 1b4496cb39eb46b2b660ef213e1f3c8fdac2b21e..10a62031fdfd044f851165e346059d1834ff7c9c 100644
--- a/drivers/pinctrl/qcom/pinctrl-sm8550.c
+++ b/drivers/pinctrl/qcom/pinctrl-sm8550.c
@@ -1340,7 +1340,7 @@ static const char *const vsense_trigger_mirnat_groups[] = {
};
static const struct pinfunction sm8550_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(aon_cci),
MSM_PIN_FUNCTION(aoss_cti),
MSM_PIN_FUNCTION(atest_char),
diff --git a/drivers/pinctrl/qcom/pinctrl-sm8650.c b/drivers/pinctrl/qcom/pinctrl-sm8650.c
index 449a0077f4b10666ecd9dfaae8e0057a91e181a6..e2ae038002060d2f93c091c716b1ec7fb9b6498d 100644
--- a/drivers/pinctrl/qcom/pinctrl-sm8650.c
+++ b/drivers/pinctrl/qcom/pinctrl-sm8650.c
@@ -1328,7 +1328,7 @@ static const char *const vsense_trigger_mirnat_groups[] = {
};
static const struct pinfunction sm8650_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(aoss_cti),
MSM_PIN_FUNCTION(atest_char),
MSM_PIN_FUNCTION(atest_usb),
@@ -1359,7 +1359,7 @@ static const struct pinfunction sm8650_functions[] = {
MSM_PIN_FUNCTION(ddr_pxi3),
MSM_PIN_FUNCTION(do_not),
MSM_PIN_FUNCTION(dp_hot),
- MSM_PIN_FUNCTION(egpio),
+ MSM_GPIO_PIN_FUNCTION(egpio),
MSM_PIN_FUNCTION(gcc_gp1),
MSM_PIN_FUNCTION(gcc_gp2),
MSM_PIN_FUNCTION(gcc_gp3),
diff --git a/drivers/pinctrl/qcom/pinctrl-sm8750.c b/drivers/pinctrl/qcom/pinctrl-sm8750.c
index 8516693d1db51d3e890e298ea6500ae62333bc69..6f92f176edd4593563a95dc8b0cfde2b6ad3a213 100644
--- a/drivers/pinctrl/qcom/pinctrl-sm8750.c
+++ b/drivers/pinctrl/qcom/pinctrl-sm8750.c
@@ -1290,7 +1290,7 @@ static const char *const wcn_sw_ctrl_groups[] = {
};
static const struct pinfunction sm8750_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(aoss_cti),
MSM_PIN_FUNCTION(atest_char),
MSM_PIN_FUNCTION(atest_usb),
@@ -1319,7 +1319,7 @@ static const struct pinfunction sm8750_functions[] = {
MSM_PIN_FUNCTION(ddr_pxi2),
MSM_PIN_FUNCTION(ddr_pxi3),
MSM_PIN_FUNCTION(dp_hot),
- MSM_PIN_FUNCTION(egpio),
+ MSM_GPIO_PIN_FUNCTION(egpio),
MSM_PIN_FUNCTION(gcc_gp1),
MSM_PIN_FUNCTION(gcc_gp2),
MSM_PIN_FUNCTION(gcc_gp3),
diff --git a/drivers/pinctrl/qcom/pinctrl-x1e80100.c b/drivers/pinctrl/qcom/pinctrl-x1e80100.c
index d4b215f34c39bf67a0656a3f894b8639491e898b..bb36f40b19fa53eedf68d46d02986410d07a733c 100644
--- a/drivers/pinctrl/qcom/pinctrl-x1e80100.c
+++ b/drivers/pinctrl/qcom/pinctrl-x1e80100.c
@@ -1407,7 +1407,7 @@ static const char * const vsense_trigger_groups[] = {
};
static const struct pinfunction x1e80100_functions[] = {
- MSM_PIN_FUNCTION(gpio),
+ MSM_GPIO_PIN_FUNCTION(gpio),
MSM_PIN_FUNCTION(RESOUT_GPIO),
MSM_PIN_FUNCTION(aon_cci),
MSM_PIN_FUNCTION(aoss_cti),
--
2.48.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v3 15/15] pinctrl: qcom: make the pinmuxing strict
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
` (13 preceding siblings ...)
2025-07-24 9:24 ` [PATCH v3 14/15] pinctrl: qcom: mark the `gpio` and `egpio` pins function as non-strict functions Bartosz Golaszewski
@ 2025-07-24 9:24 ` Bartosz Golaszewski
14 siblings, 0 replies; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-24 9:24 UTC (permalink / raw)
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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski, Konrad Dybcio
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
The strict flag in struct pinmux_ops disallows the usage of the same pin
as a GPIO and for another function. Without it, a rouge user-space
process with enough privileges (or even a buggy driver) can request a
used pin as GPIO and drive it, potentially confusing devices or even
crashing the system. Set it globally for all pinctrl-msm users.
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
drivers/pinctrl/qcom/pinctrl-msm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index 7010be8d1ace062fcf7743e539d2065d4aed856b..ad572c923e2ab8caed134207ec02c4107d4dc2bd 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -268,6 +268,7 @@ static const struct pinmux_ops msm_pinmux_ops = {
.function_is_gpio = pinmux_generic_function_is_gpio,
.gpio_request_enable = msm_pinmux_request_gpio,
.set_mux = msm_pinmux_set_mux,
+ .strict = true,
};
static int msm_config_reg(struct msm_pinctrl *pctrl,
--
2.48.1
^ permalink raw reply related [flat|nested] 36+ messages in thread
* Re: [PATCH v3 11/15] pinctrl: qcom: use generic pin function helpers
2025-07-24 9:24 ` [PATCH v3 11/15] pinctrl: qcom: use generic pin function helpers Bartosz Golaszewski
@ 2025-07-24 10:57 ` Konrad Dybcio
0 siblings, 0 replies; 36+ messages in thread
From: Konrad Dybcio @ 2025-07-24 10:57 UTC (permalink / raw)
To: Bartosz Golaszewski, 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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On 7/24/25 11:24 AM, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> With the pinmux core no longer duplicating memory used to store the
> struct pinfunction objects in .rodata, we can now use the existing
> infrastructure for storing and looking up pin functions in qualcomm
> drivers. Remove hand-crafted callbacks.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Konrad
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 01/15] lib: provide kmemdup_const()
2025-07-24 9:24 ` [PATCH v3 01/15] lib: provide kmemdup_const() Bartosz Golaszewski
@ 2025-07-24 11:04 ` Andy Shevchenko
2025-07-24 11:09 ` Lorenzo Stoakes
1 sibling, 0 replies; 36+ messages in thread
From: Andy Shevchenko @ 2025-07-24 11:04 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: 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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Thu, Jul 24, 2025 at 11:24 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Provide a function similar to strdup_const() but for copying blocks of
> memory that are likely to be placed in .rodata.
Makes sense, one nit-pick below.
...
> extern void *kmemdup_noprof(const void *src, size_t len, gfp_t gfp) __realloc_size(2);
> #define kmemdup(...) alloc_hooks(kmemdup_noprof(__VA_ARGS__))
>
> +extern const void *kmemdup_const(const void *src, size_t len, gfp_t gfp);
Can we locate this in the similar order to the C-file? I would put it
before kmemdup_array().
> extern void *kvmemdup(const void *src, size_t len, gfp_t gfp) __realloc_size(2);
> extern char *kmemdup_nul(const char *s, size_t len, gfp_t gfp);
> extern void *kmemdup_array(const void *src, size_t count, size_t element_size, gfp_t gfp)
(below left for the context)
> +
> /**
> * kmemdup_array - duplicate a given array.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 07/15] pinctrl: keembay: release allocated memory in detach path
2025-07-24 9:24 ` [PATCH v3 07/15] pinctrl: keembay: release allocated memory in detach path Bartosz Golaszewski
@ 2025-07-24 11:06 ` Andy Shevchenko
0 siblings, 0 replies; 36+ messages in thread
From: Andy Shevchenko @ 2025-07-24 11:06 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: 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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Thu, Jul 24, 2025 at 11:25 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Unlike all the other allocations in this driver, the memory for storing
> the pin function descriptions allocated with kcalloc() and later resized
> with krealloc() is never freed. Use devres like elsewhere to handle
> that.
>
> Note: the logic in this module is pretty convoluted and could probably
> use some revisiting, we should probably be able to calculate the exact
> amount of memory needed in advance or even skip the allocation
> alltogether and just add each function to the radix tree separately.
altogether
...
> /* Reallocate memory based on actual number of functions */
> - new_funcs = krealloc(keembay_funcs, kpc->nfuncs * sizeof(*new_funcs), GFP_KERNEL);
> + new_funcs = devm_krealloc(kpc->dev, keembay_funcs,
> + kpc->nfuncs * sizeof(*new_funcs), GFP_KERNEL);
> if (!new_funcs) {
krealloc_array() ?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 01/15] lib: provide kmemdup_const()
2025-07-24 9:24 ` [PATCH v3 01/15] lib: provide kmemdup_const() Bartosz Golaszewski
2025-07-24 11:04 ` Andy Shevchenko
@ 2025-07-24 11:09 ` Lorenzo Stoakes
2025-07-24 11:12 ` Andy Shevchenko
1 sibling, 1 reply; 36+ messages in thread
From: Lorenzo Stoakes @ 2025-07-24 11:09 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: 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,
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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Thu, Jul 24, 2025 at 11:24:29AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Provide a function similar to strdup_const() but for copying blocks of
> memory that are likely to be placed in .rodata.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
LGTM afaict aside from nit below, so:
Acked-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> ---
> include/linux/string.h | 1 +
> mm/util.c | 21 +++++++++++++++++++++
> 2 files changed, 22 insertions(+)
>
> diff --git a/include/linux/string.h b/include/linux/string.h
> index fdd3442c6bcbd786e177b6e87358e1065a0ffafc..1a86d61de91204563e4179938c4dfc77108e03aa 100644
> --- a/include/linux/string.h
> +++ b/include/linux/string.h
> @@ -304,6 +304,7 @@ extern char *kstrndup(const char *s, size_t len, gfp_t gfp);
> extern void *kmemdup_noprof(const void *src, size_t len, gfp_t gfp) __realloc_size(2);
> #define kmemdup(...) alloc_hooks(kmemdup_noprof(__VA_ARGS__))
>
> +extern const void *kmemdup_const(const void *src, size_t len, gfp_t gfp);
Please drop extern, it's unnecessary.
> extern void *kvmemdup(const void *src, size_t len, gfp_t gfp) __realloc_size(2);
> extern char *kmemdup_nul(const char *s, size_t len, gfp_t gfp);
> extern void *kmemdup_array(const void *src, size_t count, size_t element_size, gfp_t gfp)
> diff --git a/mm/util.c b/mm/util.c
> index f814e6a59ab1d354b8cd04ebf3903626f6b23a6c..f4df9194b0c69c27ff06e6ba1d1137c559035470 100644
> --- a/mm/util.c
> +++ b/mm/util.c
> @@ -142,6 +142,27 @@ void *kmemdup_noprof(const void *src, size_t len, gfp_t gfp)
> }
> EXPORT_SYMBOL(kmemdup_noprof);
>
> +/**
> + * kmemdup_const - conditionally duplicate a region of memory
> + *
> + * @src: memory region to duplicate
> + * @len: memory region length,
> + * @gfp: GFP mask to use
> + *
> + * Return: source address if it is in .rodata or the return value of kmemdup()
> + * to which the function falls back otherwise.
> + *
> + * Note: the returned address must not be passed to kfree(), the caller must
> + * use kfree_const() instead.
> + */
> +const void *kmemdup_const(const void *src, size_t len, gfp_t gfp)
> +{
> + if (is_kernel_rodata((unsigned long)src))
> + return src;
> +
> + return kmemdup(src, len, gfp);
> +}
> +
> /**
> * kmemdup_array - duplicate a given array.
> *
>
> --
> 2.48.1
>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 08/15] pinctrl: keembay: use a dedicated structure for the pinfunction description
2025-07-24 9:24 ` [PATCH v3 08/15] pinctrl: keembay: use a dedicated structure for the pinfunction description Bartosz Golaszewski
@ 2025-07-24 11:11 ` Andy Shevchenko
2025-07-29 9:23 ` Bartosz Golaszewski
0 siblings, 1 reply; 36+ messages in thread
From: Andy Shevchenko @ 2025-07-24 11:11 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: 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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Thu, Jul 24, 2025 at 11:25 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> struct function_desc is a wrapper around struct pinfunction with an
> additional void *data pointer. We're working towards reducing the usage
> of struct function_desc in pinctrl drivers - they should only be created
> by pinmux core and accessed by drivers using
> pinmux_generic_get_function().
Any link to the discussion and perhaps an updated in-kernel
documentation and/or TODO?
> This driver uses the data pointer so in
> order to stop using struct function_desc, we need to provide an
> alternative that also wraps the mux mode which is passed to pinctrl core
> as user data.
...
> +struct keembay_pinfunction {
> + struct pinfunction func;
> + u8 mux_mode;
> +};
My gut's feeling that this type of construction will be in tons of the
drivers, perhaps better to provide an alternative like
struct pinfunction_with_mode {
...
};
Or even with variadic arguments... (just saying)
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 01/15] lib: provide kmemdup_const()
2025-07-24 11:09 ` Lorenzo Stoakes
@ 2025-07-24 11:12 ` Andy Shevchenko
2025-07-24 11:15 ` Lorenzo Stoakes
0 siblings, 1 reply; 36+ messages in thread
From: Andy Shevchenko @ 2025-07-24 11:12 UTC (permalink / raw)
To: Lorenzo Stoakes
Cc: Bartosz Golaszewski, 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,
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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Thu, Jul 24, 2025 at 1:10 PM Lorenzo Stoakes
<lorenzo.stoakes@oracle.com> wrote:
> On Thu, Jul 24, 2025 at 11:24:29AM +0200, Bartosz Golaszewski wrote:
...
> > extern void *kmemdup_noprof(const void *src, size_t len, gfp_t gfp) __realloc_size(2);
> > #define kmemdup(...) alloc_hooks(kmemdup_noprof(__VA_ARGS__))
> >
> > +extern const void *kmemdup_const(const void *src, size_t len, gfp_t gfp);
>
> Please drop extern, it's unnecessary.
It's all over the header. This should be done as a precursor patch and
I know that usually people push back on doing that. I gave up on this.
Kernel is going to rot sooner or later... :-(
> > extern void *kvmemdup(const void *src, size_t len, gfp_t gfp) __realloc_size(2);
> > extern char *kmemdup_nul(const char *s, size_t len, gfp_t gfp);
> > extern void *kmemdup_array(const void *src, size_t count, size_t element_size, gfp_t gfp)
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 09/15] pinctrl: constify pinmux_generic_get_function()
2025-07-24 9:24 ` [PATCH v3 09/15] pinctrl: constify pinmux_generic_get_function() Bartosz Golaszewski
@ 2025-07-24 11:14 ` Andy Shevchenko
2025-07-30 14:53 ` Geert Uytterhoeven
1 sibling, 0 replies; 36+ messages in thread
From: Andy Shevchenko @ 2025-07-24 11:14 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: 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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Thu, Jul 24, 2025 at 11:25 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> With all users of struct function_desc limited to only accessing it using
> the dedicated function and never modifying it, we can now constify the
> return value of pinmux_generic_get_function() treewide.
I like this change.
Reviewed-by: Andy Shevchenko <andy@kernel.org>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 01/15] lib: provide kmemdup_const()
2025-07-24 11:12 ` Andy Shevchenko
@ 2025-07-24 11:15 ` Lorenzo Stoakes
2025-07-24 11:52 ` Andy Shevchenko
0 siblings, 1 reply; 36+ messages in thread
From: Lorenzo Stoakes @ 2025-07-24 11:15 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Bartosz Golaszewski, 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,
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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Thu, Jul 24, 2025 at 01:12:49PM +0200, Andy Shevchenko wrote:
> On Thu, Jul 24, 2025 at 1:10 PM Lorenzo Stoakes
> <lorenzo.stoakes@oracle.com> wrote:
> > On Thu, Jul 24, 2025 at 11:24:29AM +0200, Bartosz Golaszewski wrote:
> > > +extern const void *kmemdup_const(const void *src, size_t len, gfp_t gfp);
> >
> > Please drop extern, it's unnecessary.
>
> It's all over the header. This should be done as a precursor patch and
> I know that usually people push back on doing that. I gave up on this.
> Kernel is going to rot sooner or later... :-(
In mm we just update as we go, this is probably the best approach to avoid
unnecessary churn.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 01/15] lib: provide kmemdup_const()
2025-07-24 11:15 ` Lorenzo Stoakes
@ 2025-07-24 11:52 ` Andy Shevchenko
2025-07-24 11:57 ` David Hildenbrand
0 siblings, 1 reply; 36+ messages in thread
From: Andy Shevchenko @ 2025-07-24 11:52 UTC (permalink / raw)
To: Lorenzo Stoakes
Cc: Andy Shevchenko, Bartosz Golaszewski, 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, 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, linux-gpio, linux-kernel, linux-arm-msm,
linux-mediatek, linux-arm-kernel, linux-mips, linux-hardening,
linux-mm, imx, linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Thu, Jul 24, 2025 at 12:15:11PM +0100, Lorenzo Stoakes wrote:
> On Thu, Jul 24, 2025 at 01:12:49PM +0200, Andy Shevchenko wrote:
> > On Thu, Jul 24, 2025 at 1:10 PM Lorenzo Stoakes
> > <lorenzo.stoakes@oracle.com> wrote:
> > > On Thu, Jul 24, 2025 at 11:24:29AM +0200, Bartosz Golaszewski wrote:
> > > > +extern const void *kmemdup_const(const void *src, size_t len, gfp_t gfp);
> > >
> > > Please drop extern, it's unnecessary.
> >
> > It's all over the header. This should be done as a precursor patch and
> > I know that usually people push back on doing that. I gave up on this.
> > Kernel is going to rot sooner or later... :-(
>
> In mm we just update as we go, this is probably the best approach to avoid
> unnecessary churn.
I agree on the idea of eliminating it, but also I agree on the consistency over
redundancy. That's why I prefer to see this done at once for all (in the same
header) than doing one-by-one. And this approach got a lot of pushes back, while
the former even more pushed back on the (in)consistency matters.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 01/15] lib: provide kmemdup_const()
2025-07-24 11:52 ` Andy Shevchenko
@ 2025-07-24 11:57 ` David Hildenbrand
0 siblings, 0 replies; 36+ messages in thread
From: David Hildenbrand @ 2025-07-24 11:57 UTC (permalink / raw)
To: Andy Shevchenko, Lorenzo Stoakes
Cc: Andy Shevchenko, Bartosz Golaszewski, 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,
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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On 24.07.25 13:52, Andy Shevchenko wrote:
> On Thu, Jul 24, 2025 at 12:15:11PM +0100, Lorenzo Stoakes wrote:
>> On Thu, Jul 24, 2025 at 01:12:49PM +0200, Andy Shevchenko wrote:
>>> On Thu, Jul 24, 2025 at 1:10 PM Lorenzo Stoakes
>>> <lorenzo.stoakes@oracle.com> wrote:
>>>> On Thu, Jul 24, 2025 at 11:24:29AM +0200, Bartosz Golaszewski wrote:
>>>>> +extern const void *kmemdup_const(const void *src, size_t len, gfp_t gfp);
>>>>
>>>> Please drop extern, it's unnecessary.
>>>
>>> It's all over the header. This should be done as a precursor patch and
>>> I know that usually people push back on doing that. I gave up on this.
>>> Kernel is going to rot sooner or later... :-(
>>
>> In mm we just update as we go, this is probably the best approach to avoid
>> unnecessary churn.
>
> I agree on the idea of eliminating it, but also I agree on the consistency over
> redundancy. That's why I prefer to see this done at once for all (in the same
> header) than doing one-by-one. And this approach got a lot of pushes back, while
> the former even more pushed back on the (in)consistency matters.
No new extern where unnecessary.
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 12/15] pinctrl: allow to mark pin functions as requestable GPIOs
2025-07-24 9:24 ` [PATCH v3 12/15] pinctrl: allow to mark pin functions as requestable GPIOs Bartosz Golaszewski
@ 2025-07-24 12:21 ` Andy Shevchenko
2025-07-30 9:54 ` Bartosz Golaszewski
0 siblings, 1 reply; 36+ messages in thread
From: Andy Shevchenko @ 2025-07-24 12:21 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: 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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Thu, Jul 24, 2025 at 11:25 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> The name of the pin function has no real meaning to pinctrl core and is
> there only for human readability of device properties. Some pins are
> muxed as GPIOs but for "strict" pinmuxers it's impossible to request
> them as GPIOs if they're bound to a devide - even if their function name
> explicitly says "gpio". Add a new field to struct pinfunction that
> allows to pass additional flags to pinctrl core. While we could go with
passing
to the pinctrl
> a boolean "is_gpio" field, a flags field is more future-proof.
>
> If the PINFUNCTION_FLAG_GPIO is set for a given function, the pin muxed
> to it can be requested as GPIO even on strict pin controllers. Add a new
"...the pin, which is muxed to it, ..."
> callback to struct pinmux_ops - function_is_gpio() - that allows pinmux
> core to inspect a function and see if it's a GPIO one. Provide a generic
> implementation of this callback.
...
> - if (ops->strict && desc->mux_usecount)
> + if (ops->function_is_gpio && mux_setting)
Seems mux_setting presence is prior to the GPIO checks, I would swap
the parameters of &&.
> + func_is_gpio = ops->function_is_gpio(pctldev,
> + mux_setting->func);
One line is okay.
> + if (ops->strict && desc->mux_usecount && !func_is_gpio)
> return false;
>
> return !(ops->strict && !!desc->gpio_owner);
I think this whole if/return chain can be made slightly more readable,
but I haven't had something to provide right now. Lemme think about
it,
...
> + if (ops->function_is_gpio && mux_setting)
> + func_is_gpio = ops->function_is_gpio(pctldev,
> + mux_setting->func);
> + if ((!gpio_range || ops->strict) && !func_is_gpio &&
> desc->mux_usecount && strcmp(desc->mux_owner, owner)) {
This is very similar to the above check, I think at bare minimum here
can be a helper for both cases.
...
> +/**
> + * pinmux_generic_function_is_gpio() - returns true if given function is a GPIO
> + * @pctldev: pin controller device
> + * @selector: function number
Missing Return section. Please run kernel-doc validator against new kernel-docs.
> + */
> +bool pinmux_generic_function_is_gpio(struct pinctrl_dev *pctldev,
> + unsigned int selector)
> +{
> + struct function_desc *function;
> +
> + function = radix_tree_lookup(&pctldev->pin_function_tree,
> + selector);
One line is okay.
> + if (!function)
> + return false;
> +
> + return function->func->flags & PINFUNCTION_FLAG_GPIO;
> +}
...
> struct pinfunction {
> const char *name;
> const char * const *groups;
> size_t ngroups;
> + unsigned long flags;
Not sure we need this. If the function is GPIO, pin control already
knows about this. The pin muxing has gpio request / release callbacks
that change the state. Why do we need an additional flag(s)?
> };
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 08/15] pinctrl: keembay: use a dedicated structure for the pinfunction description
2025-07-24 11:11 ` Andy Shevchenko
@ 2025-07-29 9:23 ` Bartosz Golaszewski
0 siblings, 0 replies; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-29 9:23 UTC (permalink / raw)
To: Andy Shevchenko
Cc: 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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Thu, Jul 24, 2025 at 1:11 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Thu, Jul 24, 2025 at 11:25 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> >
> > struct function_desc is a wrapper around struct pinfunction with an
> > additional void *data pointer. We're working towards reducing the usage
> > of struct function_desc in pinctrl drivers - they should only be created
> > by pinmux core and accessed by drivers using
> > pinmux_generic_get_function().
>
> Any link to the discussion and perhaps an updated in-kernel
> documentation and/or TODO?
>
The discussions happened under v1 and v2 of this series. The "reducing
the usage ..." part refers to the need to avoid memory duplication of
struct pinfunction really but it's a prerequisite.
> > This driver uses the data pointer so in
> > order to stop using struct function_desc, we need to provide an
> > alternative that also wraps the mux mode which is passed to pinctrl core
> > as user data.
>
> ...
>
> > +struct keembay_pinfunction {
> > + struct pinfunction func;
> > + u8 mux_mode;
> > +};
>
> My gut's feeling that this type of construction will be in tons of the
> drivers, perhaps better to provide an alternative like
> struct pinfunction_with_mode {
> ...
Nah, literally only this one so far. And I bet we could rework it to
avoid it altogether. Your proposal is too specific IMO. Let's cross
that bridge when (if) we get there.
> };
>
> Or even with variadic arguments... (just saying)
>
Oh please no. :)
Bartosz
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 12/15] pinctrl: allow to mark pin functions as requestable GPIOs
2025-07-24 12:21 ` Andy Shevchenko
@ 2025-07-30 9:54 ` Bartosz Golaszewski
2025-07-30 12:49 ` Andy Shevchenko
0 siblings, 1 reply; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-30 9:54 UTC (permalink / raw)
To: Andy Shevchenko
Cc: 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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Thu, Jul 24, 2025 at 2:22 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> > struct pinfunction {
> > const char *name;
> > const char * const *groups;
> > size_t ngroups;
> > + unsigned long flags;
>
> Not sure we need this. If the function is GPIO, pin control already
> knows about this. The pin muxing has gpio request / release callbacks
> that change the state. Why do we need an additional flag(s)?
>
I'm not following, how does the pin controller know that the function
is GPIO exactly, other than by the bit set in this field?
Bartosz
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 12/15] pinctrl: allow to mark pin functions as requestable GPIOs
2025-07-30 9:54 ` Bartosz Golaszewski
@ 2025-07-30 12:49 ` Andy Shevchenko
2025-07-30 12:52 ` Andy Shevchenko
2025-07-30 12:53 ` Bartosz Golaszewski
0 siblings, 2 replies; 36+ messages in thread
From: Andy Shevchenko @ 2025-07-30 12:49 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: 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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Wed, Jul 30, 2025 at 11:54 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> On Thu, Jul 24, 2025 at 2:22 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> >
> > > struct pinfunction {
> > > const char *name;
> > > const char * const *groups;
> > > size_t ngroups;
> > > + unsigned long flags;
> >
> > Not sure we need this. If the function is GPIO, pin control already
> > knows about this. The pin muxing has gpio request / release callbacks
> > that change the state. Why do we need an additional flag(s)?
> >
>
> I'm not following, how does the pin controller know that the function
> is GPIO exactly, other than by the bit set in this field?
AFAICS the gpio_owner != NULL means that. No need to have a duplicate
of this information.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 12/15] pinctrl: allow to mark pin functions as requestable GPIOs
2025-07-30 12:49 ` Andy Shevchenko
@ 2025-07-30 12:52 ` Andy Shevchenko
2025-07-30 12:53 ` Bartosz Golaszewski
1 sibling, 0 replies; 36+ messages in thread
From: Andy Shevchenko @ 2025-07-30 12:52 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: 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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Wed, Jul 30, 2025 at 2:49 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Wed, Jul 30, 2025 at 11:54 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > On Thu, Jul 24, 2025 at 2:22 PM Andy Shevchenko
> > <andy.shevchenko@gmail.com> wrote:
> > >
> > > > struct pinfunction {
> > > > const char *name;
> > > > const char * const *groups;
> > > > size_t ngroups;
> > > > + unsigned long flags;
> > >
> > > Not sure we need this. If the function is GPIO, pin control already
> > > knows about this. The pin muxing has gpio request / release callbacks
> > > that change the state. Why do we need an additional flag(s)?
> >
> > I'm not following, how does the pin controller know that the function
> > is GPIO exactly, other than by the bit set in this field?
>
> AFAICS the gpio_owner != NULL means that. No need to have a duplicate
> of this information.
To be clear, the pin control and muxing core knows about this, if the
certain pin control driver needs that information it can request this
from the core or do some other shortcuts (as it knows the state as
well in the HW). So, I do not see any need for this flag. But again,
maybe I'm missing the subtle corner case?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 12/15] pinctrl: allow to mark pin functions as requestable GPIOs
2025-07-30 12:49 ` Andy Shevchenko
2025-07-30 12:52 ` Andy Shevchenko
@ 2025-07-30 12:53 ` Bartosz Golaszewski
2025-07-30 13:30 ` Andy Shevchenko
1 sibling, 1 reply; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-30 12:53 UTC (permalink / raw)
To: Andy Shevchenko
Cc: 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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Wed, Jul 30, 2025 at 2:50 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Wed, Jul 30, 2025 at 11:54 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> >
> > On Thu, Jul 24, 2025 at 2:22 PM Andy Shevchenko
> > <andy.shevchenko@gmail.com> wrote:
> > >
> > > > struct pinfunction {
> > > > const char *name;
> > > > const char * const *groups;
> > > > size_t ngroups;
> > > > + unsigned long flags;
> > >
> > > Not sure we need this. If the function is GPIO, pin control already
> > > knows about this. The pin muxing has gpio request / release callbacks
> > > that change the state. Why do we need an additional flag(s)?
> > >
> >
> > I'm not following, how does the pin controller know that the function
> > is GPIO exactly, other than by the bit set in this field?
>
> AFAICS the gpio_owner != NULL means that. No need to have a duplicate
> of this information.
>
No, that's not at all what this series does... gpio_owner is the
consumer label of a pin used by the GPIOLIB framework. The flag I'm
introducing it telling the pinctrl core - before GPIOLIB is ever
involved - that *this pin can be requested as a GPIO by GPIOLIB*. It's
the other way around - without knowing this, for strict pinmuxers,
GPIOLIB would never be able to request this pin if it was muxed to a
function (even if the function is called "GPIO").
Bart
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 12/15] pinctrl: allow to mark pin functions as requestable GPIOs
2025-07-30 12:53 ` Bartosz Golaszewski
@ 2025-07-30 13:30 ` Andy Shevchenko
2025-07-30 14:45 ` Bartosz Golaszewski
0 siblings, 1 reply; 36+ messages in thread
From: Andy Shevchenko @ 2025-07-30 13:30 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: 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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Wed, Jul 30, 2025 at 2:53 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> On Wed, Jul 30, 2025 at 2:50 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Wed, Jul 30, 2025 at 11:54 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > > On Thu, Jul 24, 2025 at 2:22 PM Andy Shevchenko
> > > <andy.shevchenko@gmail.com> wrote:
> > > >
> > > > > struct pinfunction {
> > > > > const char *name;
> > > > > const char * const *groups;
> > > > > size_t ngroups;
> > > > > + unsigned long flags;
> > > >
> > > > Not sure we need this. If the function is GPIO, pin control already
> > > > knows about this. The pin muxing has gpio request / release callbacks
> > > > that change the state. Why do we need an additional flag(s)?
> > >
> > > I'm not following, how does the pin controller know that the function
> > > is GPIO exactly, other than by the bit set in this field?
> >
> > AFAICS the gpio_owner != NULL means that. No need to have a duplicate
> > of this information.
>
> No, that's not at all what this series does... gpio_owner is the
> consumer label of a pin used by the GPIOLIB framework. The flag I'm
> introducing it telling the pinctrl core - before GPIOLIB is ever
> involved - that *this pin can be requested as a GPIO by GPIOLIB*.
The certain pin control driver may even not know about this. But even
though the proposed change is an overkill. If it indeed needs to be
done, the solution of valid_mask approach sounds to me much better. It
will be a single bitmask per pin control to tell this.
> It's
> the other way around - without knowing this, for strict pinmuxers,
> GPIOLIB would never be able to request this pin if it was muxed to a
> function (even if the function is called "GPIO").
I need to read the series again, but I truly believe we don't need
this new field in the struct pinfunction.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 12/15] pinctrl: allow to mark pin functions as requestable GPIOs
2025-07-30 13:30 ` Andy Shevchenko
@ 2025-07-30 14:45 ` Bartosz Golaszewski
0 siblings, 0 replies; 36+ messages in thread
From: Bartosz Golaszewski @ 2025-07-30 14:45 UTC (permalink / raw)
To: Andy Shevchenko
Cc: 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,
linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
On Wed, Jul 30, 2025 at 3:30 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Wed, Jul 30, 2025 at 2:53 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > On Wed, Jul 30, 2025 at 2:50 PM Andy Shevchenko
> > <andy.shevchenko@gmail.com> wrote:
> > > On Wed, Jul 30, 2025 at 11:54 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > > > On Thu, Jul 24, 2025 at 2:22 PM Andy Shevchenko
> > > > <andy.shevchenko@gmail.com> wrote:
> > > > >
> > > > > > struct pinfunction {
> > > > > > const char *name;
> > > > > > const char * const *groups;
> > > > > > size_t ngroups;
> > > > > > + unsigned long flags;
> > > > >
> > > > > Not sure we need this. If the function is GPIO, pin control already
> > > > > knows about this. The pin muxing has gpio request / release callbacks
> > > > > that change the state. Why do we need an additional flag(s)?
> > > >
> > > > I'm not following, how does the pin controller know that the function
> > > > is GPIO exactly, other than by the bit set in this field?
> > >
> > > AFAICS the gpio_owner != NULL means that. No need to have a duplicate
> > > of this information.
> >
> > No, that's not at all what this series does... gpio_owner is the
> > consumer label of a pin used by the GPIOLIB framework. The flag I'm
> > introducing it telling the pinctrl core - before GPIOLIB is ever
> > involved - that *this pin can be requested as a GPIO by GPIOLIB*.
>
> The certain pin control driver may even not know about this. But even
> though the proposed change is an overkill. If it indeed needs to be
> done, the solution of valid_mask approach sounds to me much better. It
> will be a single bitmask per pin control to tell this.
>
> > It's
> > the other way around - without knowing this, for strict pinmuxers,
> > GPIOLIB would never be able to request this pin if it was muxed to a
> > function (even if the function is called "GPIO").
>
> I need to read the series again, but I truly believe we don't need
> this new field in the struct pinfunction.
>
Without a code example, I can't tell what you're imagining but let me
give some more context: the flags field could only exist in the
qualcomm drivers but the problem will be the same on all existing
platforms so IMO it's better to centralize it right away. And if we're
already centralizing it, let's make it future proof by making it
possible to define more such flags if we need it. Since the GPIO
category is a function property, it only makes sense to put it in the
structure defining the function.
Bartosz
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 09/15] pinctrl: constify pinmux_generic_get_function()
2025-07-24 9:24 ` [PATCH v3 09/15] pinctrl: constify pinmux_generic_get_function() Bartosz Golaszewski
2025-07-24 11:14 ` Andy Shevchenko
@ 2025-07-30 14:53 ` Geert Uytterhoeven
1 sibling, 0 replies; 36+ messages in thread
From: Geert Uytterhoeven @ 2025-07-30 14:53 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: 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, linux-gpio,
linux-kernel, linux-arm-msm, linux-mediatek, linux-arm-kernel,
linux-mips, linux-hardening, linux-mm, imx, linux-omap,
linux-renesas-soc, Bartosz Golaszewski
On Thu, 24 Jul 2025 at 11:24, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> With all users of struct function_desc limited to only accessing it using
> the dedicated function and never modifying it, we can now constify the
> return value of pinmux_generic_get_function() treewide.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> drivers/pinctrl/renesas/pinctrl-rza1.c | 2 +-
> drivers/pinctrl/renesas/pinctrl-rza2.c | 2 +-
> drivers/pinctrl/renesas/pinctrl-rzg2l.c | 2 +-
> drivers/pinctrl/renesas/pinctrl-rzv2m.c | 2 +-
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> # renesas
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be> # renesas
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v3 02/15] pinctrl: ingenic: use struct pinfunction instead of struct function_desc
2025-07-24 9:24 ` [PATCH v3 02/15] pinctrl: ingenic: use struct pinfunction instead of struct function_desc Bartosz Golaszewski
@ 2025-07-30 15:35 ` Paul Cercueil
0 siblings, 0 replies; 36+ messages in thread
From: Paul Cercueil @ 2025-07-30 15:35 UTC (permalink / raw)
To: Bartosz Golaszewski, Linus Walleij, Bjorn Andersson,
Konrad Dybcio, Alexey Klimov, Lorenzo Bianconi, Sean Wang,
Matthias Brugger, AngeloGioacchino Del Regno, 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
Cc: linux-gpio, linux-kernel, linux-arm-msm, linux-mediatek,
linux-arm-kernel, linux-mips, linux-hardening, linux-mm, imx,
linux-omap, linux-renesas-soc, Bartosz Golaszewski
Hi Bartosz,
Le jeudi 24 juillet 2025 à 11:24 +0200, Bartosz Golaszewski a écrit :
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> struct function_desc is a wrapper around struct pinfunction with an
> additional void *data pointer. This driver doesn't use the data
> pointer.
> We're also working towards reducing the usage of struct function_desc
> in
> pinctrl drivers - they should only be created by pinmux core and
> accessed by drivers using pinmux_generic_get_function(). Replace the
> struct function_desc objects in this driver with smaller struct
> pinfunction instances.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Acked-by: Paul Cercueil <paul@crapouillou.net>
Cheers,
-Paul
> ---
> drivers/pinctrl/pinctrl-ingenic.c | 45 +++++++++++++++++------------
> ----------
> 1 file changed, 20 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-ingenic.c
> b/drivers/pinctrl/pinctrl-ingenic.c
> index
> 79119cf20efcf8cc701647d9ff979c2b71bf7589..0ee8554c5446c4167c9b0e6b939
> 7a2507ca57419 100644
> --- a/drivers/pinctrl/pinctrl-ingenic.c
> +++ b/drivers/pinctrl/pinctrl-ingenic.c
> @@ -96,11 +96,8 @@
> .data = (void
> *)func, \
> }
>
> -#define INGENIC_PIN_FUNCTION(_name_,
> id) \
> -
> { \
> - .func = PINCTRL_PINFUNCTION(_name_, id##_groups,
> ARRAY_SIZE(id##_groups)), \
> - .data =
> NULL, \
> - }
> +#define INGENIC_PIN_FUNCTION(_name_,
> id) \
> + PINCTRL_PINFUNCTION(_name_, id##_groups,
> ARRAY_SIZE(id##_groups))
>
> enum jz_version {
> ID_JZ4730,
> @@ -128,7 +125,7 @@ struct ingenic_chip_info {
> const struct group_desc *groups;
> unsigned int num_groups;
>
> - const struct function_desc *functions;
> + const struct pinfunction *functions;
> unsigned int num_functions;
>
> const u32 *pull_ups, *pull_downs;
> @@ -263,7 +260,7 @@ static const char *jz4730_pwm1_groups[] = {
> "pwm1", };
> static const char *jz4730_mii_groups[] = { "mii", };
> static const char *jz4730_i2s_groups[] = { "i2s-data", "i2s-master",
> "i2s-slave", };
>
> -static const struct function_desc jz4730_functions[] = {
> +static const struct pinfunction jz4730_functions[] = {
> INGENIC_PIN_FUNCTION("mmc", jz4730_mmc),
> INGENIC_PIN_FUNCTION("uart0", jz4730_uart0),
> INGENIC_PIN_FUNCTION("uart1", jz4730_uart1),
> @@ -370,7 +367,7 @@ static const char *jz4740_pwm5_groups[] = {
> "pwm5", };
> static const char *jz4740_pwm6_groups[] = { "pwm6", };
> static const char *jz4740_pwm7_groups[] = { "pwm7", };
>
> -static const struct function_desc jz4740_functions[] = {
> +static const struct pinfunction jz4740_functions[] = {
> INGENIC_PIN_FUNCTION("mmc", jz4740_mmc),
> INGENIC_PIN_FUNCTION("uart0", jz4740_uart0),
> INGENIC_PIN_FUNCTION("uart1", jz4740_uart1),
> @@ -474,7 +471,7 @@ static const char *jz4725b_pwm3_groups[] = {
> "pwm3", };
> static const char *jz4725b_pwm4_groups[] = { "pwm4", };
> static const char *jz4725b_pwm5_groups[] = { "pwm5", };
>
> -static const struct function_desc jz4725b_functions[] = {
> +static const struct pinfunction jz4725b_functions[] = {
> INGENIC_PIN_FUNCTION("mmc0", jz4725b_mmc0),
> INGENIC_PIN_FUNCTION("mmc1", jz4725b_mmc1),
> INGENIC_PIN_FUNCTION("uart", jz4725b_uart),
> @@ -606,7 +603,7 @@ static const char *jz4750_pwm3_groups[] = {
> "pwm3", };
> static const char *jz4750_pwm4_groups[] = { "pwm4", };
> static const char *jz4750_pwm5_groups[] = { "pwm5", };
>
> -static const struct function_desc jz4750_functions[] = {
> +static const struct pinfunction jz4750_functions[] = {
> INGENIC_PIN_FUNCTION("uart0", jz4750_uart0),
> INGENIC_PIN_FUNCTION("uart1", jz4750_uart1),
> INGENIC_PIN_FUNCTION("uart2", jz4750_uart2),
> @@ -771,7 +768,7 @@ static const char *jz4755_pwm3_groups[] = {
> "pwm3", };
> static const char *jz4755_pwm4_groups[] = { "pwm4", };
> static const char *jz4755_pwm5_groups[] = { "pwm5", };
>
> -static const struct function_desc jz4755_functions[] = {
> +static const struct pinfunction jz4755_functions[] = {
> INGENIC_PIN_FUNCTION("uart0", jz4755_uart0),
> INGENIC_PIN_FUNCTION("uart1", jz4755_uart1),
> INGENIC_PIN_FUNCTION("uart2", jz4755_uart2),
> @@ -1106,7 +1103,7 @@ static const char *jz4760_pwm6_groups[] = {
> "pwm6", };
> static const char *jz4760_pwm7_groups[] = { "pwm7", };
> static const char *jz4760_otg_groups[] = { "otg-vbus", };
>
> -static const struct function_desc jz4760_functions[] = {
> +static const struct pinfunction jz4760_functions[] = {
> INGENIC_PIN_FUNCTION("uart0", jz4760_uart0),
> INGENIC_PIN_FUNCTION("uart1", jz4760_uart1),
> INGENIC_PIN_FUNCTION("uart2", jz4760_uart2),
> @@ -1444,7 +1441,7 @@ static const char *jz4770_pwm6_groups[] = {
> "pwm6", };
> static const char *jz4770_pwm7_groups[] = { "pwm7", };
> static const char *jz4770_mac_groups[] = { "mac-rmii", "mac-mii", };
>
> -static const struct function_desc jz4770_functions[] = {
> +static const struct pinfunction jz4770_functions[] = {
> INGENIC_PIN_FUNCTION("uart0", jz4770_uart0),
> INGENIC_PIN_FUNCTION("uart1", jz4770_uart1),
> INGENIC_PIN_FUNCTION("uart2", jz4770_uart2),
> @@ -1723,7 +1720,7 @@ static const char *jz4775_mac_groups[] = {
> };
> static const char *jz4775_otg_groups[] = { "otg-vbus", };
>
> -static const struct function_desc jz4775_functions[] = {
> +static const struct pinfunction jz4775_functions[] = {
> INGENIC_PIN_FUNCTION("uart0", jz4775_uart0),
> INGENIC_PIN_FUNCTION("uart1", jz4775_uart1),
> INGENIC_PIN_FUNCTION("uart2", jz4775_uart2),
> @@ -1976,7 +1973,7 @@ static const char *jz4780_dmic_groups[] = {
> "dmic", };
> static const char *jz4780_cim_groups[] = { "cim-data", };
> static const char *jz4780_hdmi_ddc_groups[] = { "hdmi-ddc", };
>
> -static const struct function_desc jz4780_functions[] = {
> +static const struct pinfunction jz4780_functions[] = {
> INGENIC_PIN_FUNCTION("uart0", jz4770_uart0),
> INGENIC_PIN_FUNCTION("uart1", jz4770_uart1),
> INGENIC_PIN_FUNCTION("uart2", jz4780_uart2),
> @@ -2211,7 +2208,7 @@ static const char *x1000_pwm3_groups[] = {
> "pwm3", };
> static const char *x1000_pwm4_groups[] = { "pwm4", };
> static const char *x1000_mac_groups[] = { "mac", };
>
> -static const struct function_desc x1000_functions[] = {
> +static const struct pinfunction x1000_functions[] = {
> INGENIC_PIN_FUNCTION("uart0", x1000_uart0),
> INGENIC_PIN_FUNCTION("uart1", x1000_uart1),
> INGENIC_PIN_FUNCTION("uart2", x1000_uart2),
> @@ -2341,7 +2338,7 @@ static const char *x1500_pwm2_groups[] = {
> "pwm2", };
> static const char *x1500_pwm3_groups[] = { "pwm3", };
> static const char *x1500_pwm4_groups[] = { "pwm4", };
>
> -static const struct function_desc x1500_functions[] = {
> +static const struct pinfunction x1500_functions[] = {
> INGENIC_PIN_FUNCTION("uart0", x1500_uart0),
> INGENIC_PIN_FUNCTION("uart1", x1500_uart1),
> INGENIC_PIN_FUNCTION("uart2", x1500_uart2),
> @@ -2562,7 +2559,7 @@ static const char * const x1600_pwm7_groups[] =
> { "pwm7-b10", "pwm7-b21", };
>
> static const char * const x1600_mac_groups[] = { "mac", };
>
> -static const struct function_desc x1600_functions[] = {
> +static const struct pinfunction x1600_functions[] = {
> INGENIC_PIN_FUNCTION("uart0", x1600_uart0),
> INGENIC_PIN_FUNCTION("uart1", x1600_uart1),
> INGENIC_PIN_FUNCTION("uart2", x1600_uart2),
> @@ -2779,7 +2776,7 @@ static const char *x1830_pwm6_groups[] = {
> "pwm6-c-17", "pwm6-c-27", };
> static const char *x1830_pwm7_groups[] = { "pwm7-c-18", "pwm7-c-28",
> };
> static const char *x1830_mac_groups[] = { "mac", };
>
> -static const struct function_desc x1830_functions[] = {
> +static const struct pinfunction x1830_functions[] = {
> INGENIC_PIN_FUNCTION("uart0", x1830_uart0),
> INGENIC_PIN_FUNCTION("uart1", x1830_uart1),
> INGENIC_PIN_FUNCTION("sfc", x1830_sfc),
> @@ -3225,7 +3222,7 @@ static const char *x2000_mac0_groups[] = {
> "mac0-rmii", "mac0-rgmii", };
> static const char *x2000_mac1_groups[] = { "mac1-rmii", "mac1-
> rgmii", };
> static const char *x2000_otg_groups[] = { "otg-vbus", };
>
> -static const struct function_desc x2000_functions[] = {
> +static const struct pinfunction x2000_functions[] = {
> INGENIC_PIN_FUNCTION("uart0", x2000_uart0),
> INGENIC_PIN_FUNCTION("uart1", x2000_uart1),
> INGENIC_PIN_FUNCTION("uart2", x2000_uart2),
> @@ -3449,7 +3446,7 @@ static const struct group_desc x2100_groups[] =
> {
>
> static const char *x2100_mac_groups[] = { "mac", };
>
> -static const struct function_desc x2100_functions[] = {
> +static const struct pinfunction x2100_functions[] = {
> INGENIC_PIN_FUNCTION("uart0", x2000_uart0),
> INGENIC_PIN_FUNCTION("uart1", x2000_uart1),
> INGENIC_PIN_FUNCTION("uart2", x2000_uart2),
> @@ -4571,11 +4568,9 @@ static int __init ingenic_pinctrl_probe(struct
> platform_device *pdev)
> }
>
> for (i = 0; i < chip_info->num_functions; i++) {
> - const struct function_desc *function = &chip_info-
> >functions[i];
> - const struct pinfunction *func = &function->func;
> + const struct pinfunction *func = &chip_info-
> >functions[i];
>
> - err = pinmux_generic_add_pinfunction(jzpc->pctl,
> func,
> - function-
> >data);
> + err = pinmux_generic_add_pinfunction(jzpc->pctl,
> func, NULL);
> if (err < 0) {
> dev_err(dev, "Failed to register function
> %s\n", func->name);
> return err;
^ permalink raw reply [flat|nested] 36+ messages in thread
end of thread, other threads:[~2025-07-30 15:42 UTC | newest]
Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-24 9:24 [PATCH v3 00/15] pinctrl: introduce the concept of a GPIO pin function category Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 01/15] lib: provide kmemdup_const() Bartosz Golaszewski
2025-07-24 11:04 ` Andy Shevchenko
2025-07-24 11:09 ` Lorenzo Stoakes
2025-07-24 11:12 ` Andy Shevchenko
2025-07-24 11:15 ` Lorenzo Stoakes
2025-07-24 11:52 ` Andy Shevchenko
2025-07-24 11:57 ` David Hildenbrand
2025-07-24 9:24 ` [PATCH v3 02/15] pinctrl: ingenic: use struct pinfunction instead of struct function_desc Bartosz Golaszewski
2025-07-30 15:35 ` Paul Cercueil
2025-07-24 9:24 ` [PATCH v3 03/15] pinctrl: airoha: replace struct function_desc with struct pinfunction Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 04/15] pinctrl: mediatek: mt7988: use PINCTRL_PIN_FUNCTION() Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 05/15] pinctrl: mediatek: moore: replace struct function_desc with struct pinfunction Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 06/15] pinctrl: imx: don't access the pin function radix tree directly Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 07/15] pinctrl: keembay: release allocated memory in detach path Bartosz Golaszewski
2025-07-24 11:06 ` Andy Shevchenko
2025-07-24 9:24 ` [PATCH v3 08/15] pinctrl: keembay: use a dedicated structure for the pinfunction description Bartosz Golaszewski
2025-07-24 11:11 ` Andy Shevchenko
2025-07-29 9:23 ` Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 09/15] pinctrl: constify pinmux_generic_get_function() Bartosz Golaszewski
2025-07-24 11:14 ` Andy Shevchenko
2025-07-30 14:53 ` Geert Uytterhoeven
2025-07-24 9:24 ` [PATCH v3 10/15] pinctrl: make struct pinfunction a pointer in struct function_desc Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 11/15] pinctrl: qcom: use generic pin function helpers Bartosz Golaszewski
2025-07-24 10:57 ` Konrad Dybcio
2025-07-24 9:24 ` [PATCH v3 12/15] pinctrl: allow to mark pin functions as requestable GPIOs Bartosz Golaszewski
2025-07-24 12:21 ` Andy Shevchenko
2025-07-30 9:54 ` Bartosz Golaszewski
2025-07-30 12:49 ` Andy Shevchenko
2025-07-30 12:52 ` Andy Shevchenko
2025-07-30 12:53 ` Bartosz Golaszewski
2025-07-30 13:30 ` Andy Shevchenko
2025-07-30 14:45 ` Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 13/15] pinctrl: qcom: add infrastructure for marking pin functions as GPIOs Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 14/15] pinctrl: qcom: mark the `gpio` and `egpio` pins function as non-strict functions Bartosz Golaszewski
2025-07-24 9:24 ` [PATCH v3 15/15] pinctrl: qcom: make the pinmuxing strict Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).