Skip to contentSkip to conversation

platform/chrome: Minor cleanups to cros_typec_switch

PATCH Applied Stephen Boyd 3 participants 11 messages Aug 30, 2022 – Sep 8, 2022

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

cover platform/chrome: Minor cleanups to cros_typec_switch

A small cleanup patch pile for the new cros_typec_switch driver.

Stephen Boyd (4):
platform/chrome: cros_typec_switch: Add missing newline on printk platform/chrome: cros_typec_switch: Remove impossible condition platform/chrome: cros_typec_switch: Use PTR_ERR_OR_ZERO() to simplify platform/chrome: cros_typec_switch: Inline DRV_NAME

 drivers/platform/chrome/cros_typec_switch.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

base-commit: 1a8912caba02522f612d465a4849ce98915b96ad

Signature · 1 line
https://chromeos.dev
#1 lore raw

PATCH 1/4 platform/chrome: cros_typec_switch: Add missing newline on printk

We need a newline here to ensure the next printk starts fresh.

Cc Prashant Malani <[email protected]>
Cc Tzung-Bi Shih <[email protected]>
Fixes affc804c44c8 ("platform/chrome: cros_typec_switch: Add switch driver")
---
 drivers/platform/chrome/cros_typec_switch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/chrome/cros_typec_switch.c +1 -1
index f85687adb594..383daf2c66b7 100644
@@ -244,7 +244,7 @@ static int cros_typec_register_switches(struct cros_typec_switch_data *sdata)
 		}
 
 		if (index < 0 || index >= EC_USB_PD_MAX_PORTS) {
-			dev_err(fwnode->dev, "Invalid port index number: %llu", index);
+			dev_err(fwnode->dev, "Invalid port index number: %llu\n", index);
 			ret = -EINVAL;
 			goto err_switch;
 		}
Signature · 1 line
https://chromeos.dev
#3 lore raw

PATCH 2/4 platform/chrome: cros_typec_switch: Remove impossible condition

In reply to Stephen Boyd

The type of 'index' is unsigned long long, which can't possibly be less than zero. Remove the impossible check.

Cc Prashant Malani <[email protected]>
Cc Tzung-Bi Shih <[email protected]>
---
 drivers/platform/chrome/cros_typec_switch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/chrome/cros_typec_switch.c +1 -1
index 383daf2c66b7..3381d842c307 100644
@@ -243,7 +243,7 @@ static int cros_typec_register_switches(struct cros_typec_switch_data *sdata)
 			goto err_switch;
 		}
 
-		if (index < 0 || index >= EC_USB_PD_MAX_PORTS) {
+		if (index >= EC_USB_PD_MAX_PORTS) {
 			dev_err(fwnode->dev, "Invalid port index number: %llu\n", index);
 			ret = -EINVAL;
 			goto err_switch;
Signature · 1 line
https://chromeos.dev
#5 lore raw

PATCH 3/4 platform/chrome: cros_typec_switch: Use PTR_ERR_OR_ZERO() to simplify

In reply to Stephen Boyd

Use the standard error pointer macro to shorten the code and simplify.

Cc Prashant Malani <[email protected]>
Cc Tzung-Bi Shih <[email protected]>
---
 drivers/platform/chrome/cros_typec_switch.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/platform/chrome/cros_typec_switch.c +2 -6
index 3381d842c307..09ad0d268f4b 100644
@@ -185,10 +185,8 @@ static int cros_typec_register_mode_switch(struct cros_typec_port *port,
 	};
 
 	port->mode_switch = typec_mux_register(port->sdata->dev, &mode_switch_desc);
-	if (IS_ERR(port->mode_switch))
-		return PTR_ERR(port->mode_switch);
 
-	return 0;
+	return PTR_ERR_OR_ZERO(port->mode_switch);
 }
 
 static int cros_typec_register_retimer(struct cros_typec_port *port, struct fwnode_handle *fwnode)
@@ -201,10 +199,8 @@ static int cros_typec_register_retimer(struct cros_typec_port *port, struct fwno
 	};
 
 	port->retimer = typec_retimer_register(port->sdata->dev, &retimer_desc);
-	if (IS_ERR(port->retimer))
-		return PTR_ERR(port->retimer);
 
-	return 0;
+	return PTR_ERR_OR_ZERO(port->retimer);
 }
 
 static int cros_typec_register_switches(struct cros_typec_switch_data *sdata)
Signature · 1 line
https://chromeos.dev
#7 lore raw

PATCH 4/4 platform/chrome: cros_typec_switch: Inline DRV_NAME

In reply to Stephen Boyd

This macro is only used one place, let's inline it instead to save a line or two.

Cc Prashant Malani <[email protected]>
Cc Tzung-Bi Shih <[email protected]>
---
 drivers/platform/chrome/cros_typec_switch.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/platform/chrome/cros_typec_switch.c +1 -3
index 09ad0d268f4b..a26219e97c93 100644
@@ -18,8 +18,6 @@
 #include <linux/usb/typec_mux.h>
 #include <linux/usb/typec_retimer.h>
 
-#define DRV_NAME "cros-typec-switch"
-
 /* Handles and other relevant data required for each port's switches. */
 struct cros_typec_port {
 	int port_num;
@@ -309,7 +307,7 @@ MODULE_DEVICE_TABLE(acpi, cros_typec_switch_acpi_id);
 
 static struct platform_driver cros_typec_switch_driver = {
 	.driver	= {
-		.name = DRV_NAME,
+		.name = "cros-typec-switch",
 		.acpi_match_table = ACPI_PTR(cros_typec_switch_acpi_id),
 	},
 	.probe = cros_typec_switch_probe,
Signature · 1 line
https://chromeos.dev
#9 lore raw
In reply to Stephen Boyd
This series was applied to chrome-platform/linux.git (for-kernelci) by Tzung-Bi Shih <[email protected]>:

Hello:

This series was applied to chrome-platform/linux.git (for-kernelci) by Tzung-Bi Shih <[email protected]>:

Quoted 9 lines · On Tue, 30 Aug 2022 15:58:27 -0700 you wrote:

A small cleanup patch pile for the new cros_typec_switch driver.

Stephen Boyd (4):
platform/chrome: cros_typec_switch: Add missing newline on printk platform/chrome: cros_typec_switch: Remove impossible condition platform/chrome: cros_typec_switch: Use PTR_ERR_OR_ZERO() to simplify platform/chrome: cros_typec_switch: Inline DRV_NAME

[...]

Here is the summary with links:
- [1/4] platform/chrome: cros_typec_switch: Add missing newline on printk

    https://git.kernel.org/chrome-platform/c/8dab6a593919
  - [2/4] platform/chrome: cros_typec_switch: Remove impossible condition
    https://git.kernel.org/chrome-platform/c/bbb5fb85cf48
  - [3/4] platform/chrome: cros_typec_switch: Use PTR_ERR_OR_ZERO() to simplify
    https://git.kernel.org/chrome-platform/c/dc22a33e3585
  - [4/4] platform/chrome: cros_typec_switch: Inline DRV_NAME
    https://git.kernel.org/chrome-platform/c/20dfb7478309

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#10 lore raw
In reply to Stephen Boyd
This series was applied to chrome-platform/linux.git (for-next) by Tzung-Bi Shih <[email protected]>:

Hello:

This series was applied to chrome-platform/linux.git (for-next) by Tzung-Bi Shih <[email protected]>:

Quoted 9 lines · On Tue, 30 Aug 2022 15:58:27 -0700 you wrote:

A small cleanup patch pile for the new cros_typec_switch driver.

Stephen Boyd (4):
platform/chrome: cros_typec_switch: Add missing newline on printk platform/chrome: cros_typec_switch: Remove impossible condition platform/chrome: cros_typec_switch: Use PTR_ERR_OR_ZERO() to simplify platform/chrome: cros_typec_switch: Inline DRV_NAME

[...]

Here is the summary with links:
- [1/4] platform/chrome: cros_typec_switch: Add missing newline on printk

    https://git.kernel.org/chrome-platform/c/8dab6a593919
  - [2/4] platform/chrome: cros_typec_switch: Remove impossible condition
    https://git.kernel.org/chrome-platform/c/bbb5fb85cf48
  - [3/4] platform/chrome: cros_typec_switch: Use PTR_ERR_OR_ZERO() to simplify
    https://git.kernel.org/chrome-platform/c/dc22a33e3585
  - [4/4] platform/chrome: cros_typec_switch: Inline DRV_NAME
    https://git.kernel.org/chrome-platform/c/20dfb7478309

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html