diff mbox series

[2/2] platform/chrome: cros_typec_switch: Check for retimer flag

Message ID 20230104060846.112216-2-pmalani@chromium.org (mailing list archive)
State Accepted
Commit 441529bed41cd6f368fe337ebbb4920e3519da24
Headers show
Series [1/2] platform/chrome: cros_typec_switch: Use fwnode* prop check | expand

Commit Message

Prashant Malani Jan. 4, 2023, 6:08 a.m. UTC
Not all ports have retimers. Only register a retimer switch if the
"retimer-switch" property is present for that port's mux
device.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
---
 drivers/platform/chrome/cros_typec_switch.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

Benson Leung Jan. 5, 2023, 6:46 p.m. UTC | #1
Hi Prashant,

On Tue, Jan 3, 2023 at 10:09 PM Prashant Malani <pmalani@chromium.org> wrote:
>
> Not all ports have retimers. Only register a retimer switch if the
> "retimer-switch" property is present for that port's mux
> device.
>
> Signed-off-by: Prashant Malani <pmalani@chromium.org>

Reviewed-by: Benson Leung <bleung@chromium.org>

Thanks,
Benson

> ---
>  drivers/platform/chrome/cros_typec_switch.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/platform/chrome/cros_typec_switch.c b/drivers/platform/chrome/cros_typec_switch.c
> index 2536bda03bf3..9ed1605f4071 100644
> --- a/drivers/platform/chrome/cros_typec_switch.c
> +++ b/drivers/platform/chrome/cros_typec_switch.c
> @@ -246,14 +246,16 @@ static int cros_typec_register_switches(struct cros_typec_switch_data *sdata)
>                 port->port_num = index;
>                 sdata->ports[index] = port;
>
> -               ret = cros_typec_register_retimer(port, fwnode);
> -               if (ret) {
> -                       dev_err(dev, "Retimer switch register failed\n");
> -                       goto err_switch;
> +               if (fwnode_property_present(fwnode, "retimer-switch")) {
> +                       ret = cros_typec_register_retimer(port, fwnode);
> +                       if (ret) {
> +                               dev_err(dev, "Retimer switch register failed\n");
> +                               goto err_switch;
> +                       }
> +
> +                       dev_dbg(dev, "Retimer switch registered for index %llu\n", index);
>                 }
>
> -               dev_dbg(dev, "Retimer switch registered for index %llu\n", index);
> -
>                 if (!fwnode_property_present(fwnode, "mode-switch"))
>                         continue;
>
> --
> 2.39.0.314.g84b9a713c41-goog
>
diff mbox series

Patch

diff --git a/drivers/platform/chrome/cros_typec_switch.c b/drivers/platform/chrome/cros_typec_switch.c
index 2536bda03bf3..9ed1605f4071 100644
--- a/drivers/platform/chrome/cros_typec_switch.c
+++ b/drivers/platform/chrome/cros_typec_switch.c
@@ -246,14 +246,16 @@  static int cros_typec_register_switches(struct cros_typec_switch_data *sdata)
 		port->port_num = index;
 		sdata->ports[index] = port;
 
-		ret = cros_typec_register_retimer(port, fwnode);
-		if (ret) {
-			dev_err(dev, "Retimer switch register failed\n");
-			goto err_switch;
+		if (fwnode_property_present(fwnode, "retimer-switch")) {
+			ret = cros_typec_register_retimer(port, fwnode);
+			if (ret) {
+				dev_err(dev, "Retimer switch register failed\n");
+				goto err_switch;
+			}
+
+			dev_dbg(dev, "Retimer switch registered for index %llu\n", index);
 		}
 
-		dev_dbg(dev, "Retimer switch registered for index %llu\n", index);
-
 		if (!fwnode_property_present(fwnode, "mode-switch"))
 			continue;