2023-10-06 21:04:36

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 0/2] Fix some realtek driver warnings

Signed-off-by: Linus Walleij <[email protected]>
---
Linus Walleij (2):
pinctrl: realtek: Tag unused pins as __maybe_unused
pinctrl: realtek: Fix some NULL dereference warnings

drivers/pinctrl/realtek/pinctrl-rtd.c | 10 +++++++++-
drivers/pinctrl/realtek/pinctrl-rtd1315e.c | 3 ++-
drivers/pinctrl/realtek/pinctrl-rtd1319d.c | 3 ++-
3 files changed, 13 insertions(+), 3 deletions(-)
---
base-commit: e8b4ff6a856d02ee64a6023edf45e11827badeef
change-id: 20231004-fix-realtek-warnings-c165af5e97e5

Best regards,
--
Linus Walleij <[email protected]>


2023-10-06 21:04:56

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 1/2] pinctrl: realtek: Tag unused pins as __maybe_unused

These pin definitions are helpful to have when working with the
driver in the future, so they are in a sense a bit like
documentation. They could be commented out as well, but why.

This should fix these build warnings:

drivers/pinctrl/realtek/pinctrl-rtd1315e.c:231:35: warning:
'rtd1315e_boot_sel_pins' defined but not used [-Wunused-const-variable=]
drivers/pinctrl/realtek/pinctrl-rtd1315e.c:231:35: warning:
'rtd1315e_reset_n_pins' defined but not used [-Wunused-const-variable=]
drivers/pinctrl/realtek/pinctrl-rtd1315e.c:231:35: warning:
'rtd1315e_scan_switch_pins' defined but not used [-Wunused-const-variable=]
drivers/pinctrl/realtek/pinctrl-rtd1315e.c:231:35: warning:
'rtd1315e_testmode_pins' defined but not used [-Wunused-const-variable=]
drivers/pinctrl/realtek/pinctrl-rtd1315e.c:231:35: warning:
'rtd1315e_wd_rset_pins' defined but not used [-Wunused-const-variable=]
drivers/pinctrl/realtek/pinctrl-rtd1319d.c:237:35: warning:
'rtd1319d_boot_sel_pins' defined but not used [-Wunused-const-variable=]
drivers/pinctrl/realtek/pinctrl-rtd1319d.c:237:35: warning:
'rtd1319d_reset_n_pins' defined but not used [-Wunused-const-variable=]
drivers/pinctrl/realtek/pinctrl-rtd1319d.c:237:35: warning:
'rtd1319d_scan_switch_pins' defined but not used [-Wunused-const-variable=]
drivers/pinctrl/realtek/pinctrl-rtd1319d.c:237:35: warning:
'rtd1319d_testmode_pins' defined but not used [-Wunused-const-variable=]
drivers/pinctrl/realtek/pinctrl-rtd1319d.c:237:35: warning:
'rtd1319d_wd_rset_pins' defined but not used [-Wunused-const-variable=]

Cc: Tzuyi Chang <[email protected]>
Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/pinctrl/realtek/pinctrl-rtd1315e.c | 3 ++-
drivers/pinctrl/realtek/pinctrl-rtd1319d.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/realtek/pinctrl-rtd1315e.c b/drivers/pinctrl/realtek/pinctrl-rtd1315e.c
index 5ab35d73e6f4..10afc736a52b 100644
--- a/drivers/pinctrl/realtek/pinctrl-rtd1315e.c
+++ b/drivers/pinctrl/realtek/pinctrl-rtd1315e.c
@@ -227,8 +227,9 @@ static const struct pinctrl_pin_desc rtd1315e_iso_pins[] = {
PINCTRL_PIN(RTD1315E_ISO_TESTMODE, "testmode"),
};

+/* Tagged as __maybe_unused since there are pins we may use in the future */
#define DECLARE_RTD1315E_PIN(_pin, _name) \
- static const unsigned int rtd1315e_## _name ##_pins[] = { _pin }
+ static const unsigned int rtd1315e_## _name ##_pins[] __maybe_unused = { _pin }

DECLARE_RTD1315E_PIN(RTD1315E_ISO_GPIO_0, gpio_0);
DECLARE_RTD1315E_PIN(RTD1315E_ISO_GPIO_1, gpio_1);
diff --git a/drivers/pinctrl/realtek/pinctrl-rtd1319d.c b/drivers/pinctrl/realtek/pinctrl-rtd1319d.c
index 838a447776ba..b1a654ac30dc 100644
--- a/drivers/pinctrl/realtek/pinctrl-rtd1319d.c
+++ b/drivers/pinctrl/realtek/pinctrl-rtd1319d.c
@@ -233,8 +233,9 @@ static const struct pinctrl_pin_desc rtd1319d_iso_pins[] = {
PINCTRL_PIN(RTD1319D_ISO_TESTMODE, "testmode"),
};

+/* Tagged as __maybe_unused since there are pins we may use in the future */
#define DECLARE_RTD1319D_PIN(_pin, _name) \
- static const unsigned int rtd1319d_## _name ##_pins[] = { _pin }
+ static const unsigned int rtd1319d_## _name ##_pins[] __maybe_unused = { _pin }

DECLARE_RTD1319D_PIN(RTD1319D_ISO_GPIO_0, gpio_0);
DECLARE_RTD1319D_PIN(RTD1319D_ISO_GPIO_1, gpio_1);

--
2.34.1

2023-10-06 21:05:00

by Linus Walleij

[permalink] [raw]
Subject: [PATCH 2/2] pinctrl: realtek: Fix some NULL dereference warnings

Just inspecting the code doesn't convince me that this is a real
issue, but the tools complain that it is so I will just handle it.

Cc: Tzuyi Chang <[email protected]>
Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Linus Walleij <[email protected]>
---
drivers/pinctrl/realtek/pinctrl-rtd.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/realtek/pinctrl-rtd.c b/drivers/pinctrl/realtek/pinctrl-rtd.c
index bafe27face80..fc27e4f61be1 100644
--- a/drivers/pinctrl/realtek/pinctrl-rtd.c
+++ b/drivers/pinctrl/realtek/pinctrl-rtd.c
@@ -165,7 +165,10 @@ static int rtd_pinctrl_set_one_mux(struct pinctrl_dev *pcdev,
return 0;

if (!mux->functions) {
- dev_err(pcdev->dev, "No functions available for pin %s\n", mux->name);
+ if (!mux->name)
+ dev_err(pcdev->dev, "NULL pin has no functions\n");
+ else
+ dev_err(pcdev->dev, "No functions available for pin %s\n", mux->name);
return -ENOTSUPP;
}

@@ -177,6 +180,11 @@ static int rtd_pinctrl_set_one_mux(struct pinctrl_dev *pcdev,
return ret;
}

+ if (!mux->name) {
+ dev_err(pcdev->dev, "NULL pin provided for function %s\n", func_name);
+ return -EINVAL;
+ }
+
dev_err(pcdev->dev, "No function %s available for pin %s\n", func_name, mux->name);

return -EINVAL;

--
2.34.1