Skip to contentSkip to conversation

x86: tangier: pinmux: Move is_protected assignment closer to its user

PATCH In review Andy Shevchenko 3 participants 8 messages Oct 27, 2021 – Nov 1, 2021 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 x86: tangier: pinmux: Move is_protected assignment closer to its user

Move is_protected assignment closer to its user. This increases readability and makes maintenance easier.

---
 arch/x86/cpu/tangier/pinmux.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/cpu/tangier/pinmux.c +1 -2
index 8385167b2b6b..883860f75e28 100644
@@ -162,8 +162,6 @@ static int mrfld_pinctrl_cfg_pin(ofnode pin_node)
 	u32 mask;
 	int ret;
 
-	is_protected = ofnode_read_bool(pin_node, "protected");
-
 	pad_offset = ofnode_read_s32_default(pin_node, "pad-offset", -1);
 	if (pad_offset == -1)
 		return -EINVAL;
@@ -178,6 +176,7 @@ static int mrfld_pinctrl_cfg_pin(ofnode pin_node)
 	if (mode & ~mask)
 		return -ENOTSUPP;
 
+	is_protected = ofnode_read_bool(pin_node, "protected");
 	if (is_protected)
 		ret = mrfld_pinconfig_protected(pad_offset, mask, mode);
 	else
Signature · 1 line
2.33.0
#1 lore raw

PATCH 2/2 x86: tangier: pinmux: Move error message to the caller

Move error message to the caller of mrfld_pinconfig*() in order to unify them in the future.

---
 arch/x86/cpu/tangier/pinmux.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
arch/x86/cpu/tangier/pinmux.c +3 -7
index 883860f75e28..7b2c35fbf794 100644
@@ -117,13 +117,7 @@ static int mrfld_pinconfig_protected(unsigned int pin, u32 mask, u32 bits)
 	debug("scu: v: 0x%x p: 0x%x bits: %d, mask: %d bufcfg: 0x%p\n",
 	      v, (u32)bufcfg, bits, mask, bufcfg);
 
-	ret = scu_ipc_raw_command(IPCMSG_INDIRECT_WRITE, 0, &v, 4,
-				  NULL, 0, (u32)bufcfg, 0);
-	if (ret)
-		pr_err("Failed to set mode via SCU for pin %u (%d)\n",
-		       pin, ret);
-
-	return ret;
+	return scu_ipc_raw_command(IPCMSG_INDIRECT_WRITE, 0, &v, 4, NULL, 0, (u32)bufcfg, 0);
 }
 
 static int mrfld_pinconfig(unsigned int pin, u32 mask, u32 bits)
@@ -181,6 +175,8 @@ static int mrfld_pinctrl_cfg_pin(ofnode pin_node)
 		ret = mrfld_pinconfig_protected(pad_offset, mask, mode);
 	else
 		ret = mrfld_pinconfig(pad_offset, mask, mode);
+	if (ret)
+		pr_err("Failed to set mode for pin %u (%d)\n", pad_offset, ret);
 
 	return ret;
 }
Signature · 1 line
2.33.0
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH v1 2/2] x86: tangier: pinmux: Move error message to the caller

Quoted 8 lines · Andy Shevchenko

Move error message to the caller of mrfld_pinconfig*() in order to unify them in the future.

---
 arch/x86/cpu/tangier/pinmux.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
Quoted 7 lines
arch/x86/cpu/tangier/pinmux.c +0 -0
index 883860f75e28..7b2c35fbf794 100644
@@ -117,13 +117,7 @@ static int mrfld_pinconfig_protected(unsigned int pin, u32 mask, u32 bits)
        debug("scu: v: 0x%x p: 0x%x bits: %d, mask: %d bufcfg: 0x%p\n",

arch/x86/cpu/tangier/pinmux.c static int mrfld_pinconfig_protected(unsigned int pin, u32 mask, u32 bits) · line 120

Quoted 10 lines
arch/x86/cpu/tangier/pinmux.c +1 -7
              v, (u32)bufcfg, bits, mask, bufcfg);
 
-       ret = scu_ipc_raw_command(IPCMSG_INDIRECT_WRITE, 0, &v, 4,
-                                 NULL, 0, (u32)bufcfg, 0);
-       if (ret)
-               pr_err("Failed to set mode via SCU for pin %u (%d)\n",
-                      pin, ret);
-
-       return ret;
+       return scu_ipc_raw_command(IPCMSG_INDIRECT_WRITE, 0, &v, 4, NULL, 0, (u32)bufcfg, 0);

In general I like to separate out the error return so we can use something like:

ret = scu_...
if (ret)
return log_msg_ret("scu", ret);

return 0;

Quoted 15 lines
arch/x86/cpu/tangier/pinmux.c +2 -1
 }
 
 static int mrfld_pinconfig(unsigned int pin, u32 mask, u32 bits)
@@ -181,6 +175,8 @@ static int mrfld_pinctrl_cfg_pin(ofnode pin_node)
                ret = mrfld_pinconfig_protected(pad_offset, mask, mode);
        else
                ret = mrfld_pinconfig(pad_offset, mask, mode);
+       if (ret)
+               pr_err("Failed to set mode for pin %u (%d)\n", pad_offset, ret);
 
        return ret;
 }
--

2.33.0

#4 lore raw

Re: [PATCH v1 2/2] x86: tangier: pinmux: Move error message to the caller

Quoted 7 lines · Bin Meng
Quoted 4 lines · Andy Shevchenko

Move error message to the caller of mrfld_pinconfig*() in order to unify them in the future.

Quoted 7 lines
Quoted 5 lines
---
 arch/x86/cpu/tangier/pinmux.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

applied to u-boot-x86, thanks!

Reviewed-by on v1 1/2
#5 lore raw
In reply to Andy Shevchenko
Quoted 8 lines · Andy Shevchenko

Move is_protected assignment closer to its user. This increases readability and makes maintenance easier.

---
 arch/x86/cpu/tangier/pinmux.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

(with a note that normally we would read the devicetree in the of_to_plat() method)

Quoted 25 lines
arch/x86/cpu/tangier/pinmux.c +1 -3
index 8385167b2b6b..883860f75e28 100644
@@ -162,8 +162,6 @@ static int mrfld_pinctrl_cfg_pin(ofnode pin_node)
        u32 mask;
        int ret;
 
-       is_protected = ofnode_read_bool(pin_node, "protected");
-
        pad_offset = ofnode_read_s32_default(pin_node, "pad-offset", -1);
        if (pad_offset == -1)
                return -EINVAL;
@@ -178,6 +176,7 @@ static int mrfld_pinctrl_cfg_pin(ofnode pin_node)
        if (mode & ~mask)
                return -ENOTSUPP;
 
+       is_protected = ofnode_read_bool(pin_node, "protected");
        if (is_protected)
                ret = mrfld_pinconfig_protected(pad_offset, mask, mode);
        else
--

2.33.0

#7 lore raw
Quoted 7 lines · Bin Meng
Quoted 4 lines · Andy Shevchenko

Move is_protected assignment closer to its user. This increases readability and makes maintenance easier.

Quoted 7 lines
Quoted 5 lines
---
 arch/x86/cpu/tangier/pinmux.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

applied to u-boot-x86, thanks!