Skip to contentSkip to conversation

pinctrl: tegra: Correctly check the supported configuration

PATCH In review Laxman Dewangan 3 participants 3 messages May 2, 2016 – May 11, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pinctrl: tegra: Correctly check the supported configuration

The pincontrol registers of Tegra chips has multiple filed per registers. There is two type of registers mux and drive. All configurations belongs to one of these registers.

If any configurations are supported then <config>_bit is set to bit position of these registers otherwise -1 to not support it. The member is defined as

	s32 <config>_bit:6;

So if config is not supported ifor given SoC then it is set to -1 in soc pinmmux table.
In common driver code, to find out that given config is supported or not, it is checked as:

s8 bit = <config>_bit;

if (bit > 31) {
	/* Not supported config */
}

But in this case, bit is s8 and hence for non supporting it is -1.

Correct the check as:

if (bit < 0) {
	/* Not supported config */
}
Fixes e4c02dced975cb ("pinctrl: tegra: use signed bitfields for optional fields")
---
 drivers/pinctrl/tegra/pinctrl-tegra.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/tegra/pinctrl-tegra.c +1 -1
index 861baf2..6e82b29 100644
@@ -417,7 +417,7 @@ static int tegra_pinconf_reg(struct tegra_pmx *pmx,
 		return -ENOTSUPP;
 	}
 
-	if (*reg < 0 || *bit > 31) {
+	if (*reg < 0 || *bit < 0)  {
 		if (report_err) {
 			const char *prop = "unknown";
 			int i;
Signature · 1 line
2.1.4
Acked-by on v2 1/1
#1 lore raw
Quoted 21 lines · Laxman Dewangan

The pincontrol registers of Tegra chips has multiple filed per registers. There is two type of registers mux and drive. All configurations belongs to one of these registers.

If any configurations are supported then <config>_bit is set to bit position of these registers otherwise -1 to not support it. The member is defined as

	s32 <config>_bit:6;

So if config is not supported ifor given SoC then it is set to -1 in soc pinmmux table.
In common driver code, to find out that given config is supported or not, it is checked as:

s8 bit = <config>_bit;

if (bit > 31) {
	/* Not supported config */
}

But in this case, bit is s8 and hence for non supporting it is -1.

Quoted 8 lines

Correct the check as:

if (bit < 0) {
	/* Not supported config */
}
Fixes e4c02dced975cb ("pinctrl: tegra: use signed bitfields for optional fields")

Nit: There shouldn't be a blank line between the Fixes: and Signed-off-by: lines. I assume this can be fixed when the patch is applied.

#2 lore raw
In reply to Laxman Dewangan
Quoted 21 lines · Laxman Dewangan

The pincontrol registers of Tegra chips has multiple filed per registers. There is two type of registers mux and drive. All configurations belongs to one of these registers.

If any configurations are supported then <config>_bit is set to bit position of these registers otherwise -1 to not support it. The member is defined as

        s32 <config>_bit:6;

So if config is not supported ifor given SoC then it is set to -1 in soc pinmmux table.
In common driver code, to find out that given config is supported or not, it is checked as:

s8 bit = <config>_bit;

if (bit > 31) {
        /* Not supported config */
}

But in this case, bit is s8 and hence for non supporting it is -1.

Quoted 7 lines

Correct the check as:

if (bit < 0) {
        /* Not supported config */
}
Fixes e4c02dced975cb ("pinctrl: tegra: use signed bitfields for optional fields")

Patch applied with Stephen's ACK.

Yours,
Linus Walleij