All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] platform/chrome: cros_ec_typec: allow deferred probe of switch handles
@ 2023-01-24  7:56 Victor Ding
  2023-01-24 13:20 ` Guenter Roeck
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Victor Ding @ 2023-01-24  7:56 UTC (permalink / raw)
  To: linux-kernel, chrome-platform
  Cc: heikki.krogerus, lee.jones, groeck, enric.balletbo, tzungbi,
	sebastian.reichel, gregkh, gustavoars, bleung, dustin, dnojiri,
	tinghan.shen, pmalani, Victor Ding

`fwnode_typec_{retimer,mux,switch}_get()` could return `-EPROBE_DEFER`,
which is called from `cros_typec_get_switch_handles`. When this happens,
it does not indicate absence of switches; instead, it only hints that
probing of switches should occur at a later time.

Progagate `-EPROBE_DEFER` to upper layer logic so that they can re-try
probing switches as a better time.

Signed-off-by: Victor Ding <victording@chromium.org>
---

Changes in v3:
- Reverted unnecessary change.

Changes in v2:
- Coverted switch-block to nested if-blocks.

 drivers/platform/chrome/cros_ec_typec.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 59de4ce01fab..de480ab10488 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -145,27 +145,33 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port,
 					 struct fwnode_handle *fwnode,
 					 struct device *dev)
 {
+	int ret = 0;
+
 	port->mux = fwnode_typec_mux_get(fwnode, NULL);
 	if (IS_ERR(port->mux)) {
-		dev_dbg(dev, "Mux handle not found.\n");
+		ret = PTR_ERR(port->mux);
+		dev_dbg(dev, "Mux handle not found: %d.\n", ret);
 		goto mux_err;
 	}
 
 	port->retimer = fwnode_typec_retimer_get(fwnode);
 	if (IS_ERR(port->retimer)) {
-		dev_dbg(dev, "Retimer handle not found.\n");
+		ret = PTR_ERR(port->retimer);
+		dev_dbg(dev, "Retimer handle not found: %d.\n", ret);
 		goto retimer_sw_err;
 	}
 
 	port->ori_sw = fwnode_typec_switch_get(fwnode);
 	if (IS_ERR(port->ori_sw)) {
-		dev_dbg(dev, "Orientation switch handle not found.\n");
+		ret = PTR_ERR(port->ori_sw);
+		dev_dbg(dev, "Orientation switch handle not found: %d\n", ret);
 		goto ori_sw_err;
 	}
 
 	port->role_sw = fwnode_usb_role_switch_get(fwnode);
 	if (IS_ERR(port->role_sw)) {
-		dev_dbg(dev, "USB role switch handle not found.\n");
+		ret = PTR_ERR(port->role_sw);
+		dev_dbg(dev, "USB role switch handle not found: %d\n", ret);
 		goto role_sw_err;
 	}
 
@@ -181,7 +187,7 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port,
 	typec_mux_put(port->mux);
 	port->mux = NULL;
 mux_err:
-	return -ENODEV;
+	return ret;
 }
 
 static int cros_typec_add_partner(struct cros_typec_data *typec, int port_num,
@@ -423,9 +429,11 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
 		}
 
 		ret = cros_typec_get_switch_handles(cros_port, fwnode, dev);
-		if (ret)
-			dev_dbg(dev, "No switch control for port %d\n",
-				port_num);
+		if (ret) {
+			dev_dbg(dev, "No switch control for port %d, err: %d\n", port_num, ret);
+			if (ret == -EPROBE_DEFER)
+				goto unregister_ports;
+		}
 
 		ret = cros_typec_register_port_altmodes(typec, port_num);
 		if (ret) {
-- 
2.39.1.405.gd4c25cc71f-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] platform/chrome: cros_ec_typec: allow deferred probe of switch handles
  2023-01-24  7:56 [PATCH v3] platform/chrome: cros_ec_typec: allow deferred probe of switch handles Victor Ding
@ 2023-01-24 13:20 ` Guenter Roeck
  2023-01-24 14:09 ` Heikki Krogerus
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2023-01-24 13:20 UTC (permalink / raw)
  To: Victor Ding
  Cc: linux-kernel, chrome-platform, heikki.krogerus, lee.jones,
	groeck, enric.balletbo, tzungbi, sebastian.reichel, gregkh,
	gustavoars, bleung, dustin, dnojiri, tinghan.shen, pmalani

On Mon, Jan 23, 2023 at 11:56 PM Victor Ding <victording@chromium.org> wrote:
>
> `fwnode_typec_{retimer,mux,switch}_get()` could return `-EPROBE_DEFER`,
> which is called from `cros_typec_get_switch_handles`. When this happens,
> it does not indicate absence of switches; instead, it only hints that
> probing of switches should occur at a later time.
>
> Progagate `-EPROBE_DEFER` to upper layer logic so that they can re-try
> probing switches as a better time.
>
> Signed-off-by: Victor Ding <victording@chromium.org>

Reviewed-by: Guenter Roeck <groeck@chromium.org>

> ---
>
> Changes in v3:
> - Reverted unnecessary change.
>
> Changes in v2:
> - Coverted switch-block to nested if-blocks.
>
>  drivers/platform/chrome/cros_ec_typec.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 59de4ce01fab..de480ab10488 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -145,27 +145,33 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port,
>                                          struct fwnode_handle *fwnode,
>                                          struct device *dev)
>  {
> +       int ret = 0;
> +
>         port->mux = fwnode_typec_mux_get(fwnode, NULL);
>         if (IS_ERR(port->mux)) {
> -               dev_dbg(dev, "Mux handle not found.\n");
> +               ret = PTR_ERR(port->mux);
> +               dev_dbg(dev, "Mux handle not found: %d.\n", ret);
>                 goto mux_err;
>         }
>
>         port->retimer = fwnode_typec_retimer_get(fwnode);
>         if (IS_ERR(port->retimer)) {
> -               dev_dbg(dev, "Retimer handle not found.\n");
> +               ret = PTR_ERR(port->retimer);
> +               dev_dbg(dev, "Retimer handle not found: %d.\n", ret);
>                 goto retimer_sw_err;
>         }
>
>         port->ori_sw = fwnode_typec_switch_get(fwnode);
>         if (IS_ERR(port->ori_sw)) {
> -               dev_dbg(dev, "Orientation switch handle not found.\n");
> +               ret = PTR_ERR(port->ori_sw);
> +               dev_dbg(dev, "Orientation switch handle not found: %d\n", ret);
>                 goto ori_sw_err;
>         }
>
>         port->role_sw = fwnode_usb_role_switch_get(fwnode);
>         if (IS_ERR(port->role_sw)) {
> -               dev_dbg(dev, "USB role switch handle not found.\n");
> +               ret = PTR_ERR(port->role_sw);
> +               dev_dbg(dev, "USB role switch handle not found: %d\n", ret);
>                 goto role_sw_err;
>         }
>
> @@ -181,7 +187,7 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port,
>         typec_mux_put(port->mux);
>         port->mux = NULL;
>  mux_err:
> -       return -ENODEV;
> +       return ret;
>  }
>
>  static int cros_typec_add_partner(struct cros_typec_data *typec, int port_num,
> @@ -423,9 +429,11 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
>                 }
>
>                 ret = cros_typec_get_switch_handles(cros_port, fwnode, dev);
> -               if (ret)
> -                       dev_dbg(dev, "No switch control for port %d\n",
> -                               port_num);
> +               if (ret) {
> +                       dev_dbg(dev, "No switch control for port %d, err: %d\n", port_num, ret);
> +                       if (ret == -EPROBE_DEFER)
> +                               goto unregister_ports;
> +               }
>
>                 ret = cros_typec_register_port_altmodes(typec, port_num);
>                 if (ret) {
> --
> 2.39.1.405.gd4c25cc71f-goog
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] platform/chrome: cros_ec_typec: allow deferred probe of switch handles
  2023-01-24  7:56 [PATCH v3] platform/chrome: cros_ec_typec: allow deferred probe of switch handles Victor Ding
  2023-01-24 13:20 ` Guenter Roeck
@ 2023-01-24 14:09 ` Heikki Krogerus
  2023-01-24 15:14 ` Benson Leung
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Heikki Krogerus @ 2023-01-24 14:09 UTC (permalink / raw)
  To: Victor Ding
  Cc: linux-kernel, chrome-platform, lee.jones, groeck, enric.balletbo,
	tzungbi, sebastian.reichel, gregkh, gustavoars, bleung, dustin,
	dnojiri, tinghan.shen, pmalani

On Tue, Jan 24, 2023 at 07:56:32AM +0000, Victor Ding wrote:
> `fwnode_typec_{retimer,mux,switch}_get()` could return `-EPROBE_DEFER`,
> which is called from `cros_typec_get_switch_handles`. When this happens,
> it does not indicate absence of switches; instead, it only hints that
> probing of switches should occur at a later time.
> 
> Progagate `-EPROBE_DEFER` to upper layer logic so that they can re-try
> probing switches as a better time.
> 
> Signed-off-by: Victor Ding <victording@chromium.org>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
> 
> Changes in v3:
> - Reverted unnecessary change.
> 
> Changes in v2:
> - Coverted switch-block to nested if-blocks.
> 
>  drivers/platform/chrome/cros_ec_typec.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 59de4ce01fab..de480ab10488 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -145,27 +145,33 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port,
>  					 struct fwnode_handle *fwnode,
>  					 struct device *dev)
>  {
> +	int ret = 0;
> +
>  	port->mux = fwnode_typec_mux_get(fwnode, NULL);
>  	if (IS_ERR(port->mux)) {
> -		dev_dbg(dev, "Mux handle not found.\n");
> +		ret = PTR_ERR(port->mux);
> +		dev_dbg(dev, "Mux handle not found: %d.\n", ret);
>  		goto mux_err;
>  	}
>  
>  	port->retimer = fwnode_typec_retimer_get(fwnode);
>  	if (IS_ERR(port->retimer)) {
> -		dev_dbg(dev, "Retimer handle not found.\n");
> +		ret = PTR_ERR(port->retimer);
> +		dev_dbg(dev, "Retimer handle not found: %d.\n", ret);
>  		goto retimer_sw_err;
>  	}
>  
>  	port->ori_sw = fwnode_typec_switch_get(fwnode);
>  	if (IS_ERR(port->ori_sw)) {
> -		dev_dbg(dev, "Orientation switch handle not found.\n");
> +		ret = PTR_ERR(port->ori_sw);
> +		dev_dbg(dev, "Orientation switch handle not found: %d\n", ret);
>  		goto ori_sw_err;
>  	}
>  
>  	port->role_sw = fwnode_usb_role_switch_get(fwnode);
>  	if (IS_ERR(port->role_sw)) {
> -		dev_dbg(dev, "USB role switch handle not found.\n");
> +		ret = PTR_ERR(port->role_sw);
> +		dev_dbg(dev, "USB role switch handle not found: %d\n", ret);
>  		goto role_sw_err;
>  	}
>  
> @@ -181,7 +187,7 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port,
>  	typec_mux_put(port->mux);
>  	port->mux = NULL;
>  mux_err:
> -	return -ENODEV;
> +	return ret;
>  }
>  
>  static int cros_typec_add_partner(struct cros_typec_data *typec, int port_num,
> @@ -423,9 +429,11 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
>  		}
>  
>  		ret = cros_typec_get_switch_handles(cros_port, fwnode, dev);
> -		if (ret)
> -			dev_dbg(dev, "No switch control for port %d\n",
> -				port_num);
> +		if (ret) {
> +			dev_dbg(dev, "No switch control for port %d, err: %d\n", port_num, ret);
> +			if (ret == -EPROBE_DEFER)
> +				goto unregister_ports;
> +		}
>  
>  		ret = cros_typec_register_port_altmodes(typec, port_num);
>  		if (ret) {
> -- 
> 2.39.1.405.gd4c25cc71f-goog

-- 
heikki

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] platform/chrome: cros_ec_typec: allow deferred probe of switch handles
  2023-01-24  7:56 [PATCH v3] platform/chrome: cros_ec_typec: allow deferred probe of switch handles Victor Ding
  2023-01-24 13:20 ` Guenter Roeck
  2023-01-24 14:09 ` Heikki Krogerus
@ 2023-01-24 15:14 ` Benson Leung
  2023-01-24 19:10 ` patchwork-bot+chrome-platform
  2023-01-26 19:50 ` patchwork-bot+chrome-platform
  4 siblings, 0 replies; 6+ messages in thread
From: Benson Leung @ 2023-01-24 15:14 UTC (permalink / raw)
  To: Victor Ding
  Cc: linux-kernel, chrome-platform, heikki.krogerus, lee.jones,
	groeck, enric.balletbo, tzungbi, sebastian.reichel, gregkh,
	gustavoars, dustin, dnojiri, tinghan.shen, pmalani

On Mon, Jan 23, 2023 at 11:56 PM Victor Ding <victording@chromium.org> wrote:
>
> `fwnode_typec_{retimer,mux,switch}_get()` could return `-EPROBE_DEFER`,
> which is called from `cros_typec_get_switch_handles`. When this happens,
> it does not indicate absence of switches; instead, it only hints that
> probing of switches should occur at a later time.
>
> Progagate `-EPROBE_DEFER` to upper layer logic so that they can re-try
> probing switches as a better time.
>
> Signed-off-by: Victor Ding <victording@chromium.org>

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

> ---
>
> Changes in v3:
> - Reverted unnecessary change.
>
> Changes in v2:
> - Coverted switch-block to nested if-blocks.
>
>  drivers/platform/chrome/cros_ec_typec.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 59de4ce01fab..de480ab10488 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -145,27 +145,33 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port,
>                                          struct fwnode_handle *fwnode,
>                                          struct device *dev)
>  {
> +       int ret = 0;
> +
>         port->mux = fwnode_typec_mux_get(fwnode, NULL);
>         if (IS_ERR(port->mux)) {
> -               dev_dbg(dev, "Mux handle not found.\n");
> +               ret = PTR_ERR(port->mux);
> +               dev_dbg(dev, "Mux handle not found: %d.\n", ret);
>                 goto mux_err;
>         }
>
>         port->retimer = fwnode_typec_retimer_get(fwnode);
>         if (IS_ERR(port->retimer)) {
> -               dev_dbg(dev, "Retimer handle not found.\n");
> +               ret = PTR_ERR(port->retimer);
> +               dev_dbg(dev, "Retimer handle not found: %d.\n", ret);
>                 goto retimer_sw_err;
>         }
>
>         port->ori_sw = fwnode_typec_switch_get(fwnode);
>         if (IS_ERR(port->ori_sw)) {
> -               dev_dbg(dev, "Orientation switch handle not found.\n");
> +               ret = PTR_ERR(port->ori_sw);
> +               dev_dbg(dev, "Orientation switch handle not found: %d\n", ret);
>                 goto ori_sw_err;
>         }
>
>         port->role_sw = fwnode_usb_role_switch_get(fwnode);
>         if (IS_ERR(port->role_sw)) {
> -               dev_dbg(dev, "USB role switch handle not found.\n");
> +               ret = PTR_ERR(port->role_sw);
> +               dev_dbg(dev, "USB role switch handle not found: %d\n", ret);
>                 goto role_sw_err;
>         }
>
> @@ -181,7 +187,7 @@ static int cros_typec_get_switch_handles(struct cros_typec_port *port,
>         typec_mux_put(port->mux);
>         port->mux = NULL;
>  mux_err:
> -       return -ENODEV;
> +       return ret;
>  }
>
>  static int cros_typec_add_partner(struct cros_typec_data *typec, int port_num,
> @@ -423,9 +429,11 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
>                 }
>
>                 ret = cros_typec_get_switch_handles(cros_port, fwnode, dev);
> -               if (ret)
> -                       dev_dbg(dev, "No switch control for port %d\n",
> -                               port_num);
> +               if (ret) {
> +                       dev_dbg(dev, "No switch control for port %d, err: %d\n", port_num, ret);
> +                       if (ret == -EPROBE_DEFER)
> +                               goto unregister_ports;
> +               }
>
>                 ret = cros_typec_register_port_altmodes(typec, port_num);
>                 if (ret) {
> --
> 2.39.1.405.gd4c25cc71f-goog
>
>


-- 
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
bleung@google.com
Chromium OS Project
bleung@chromium.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] platform/chrome: cros_ec_typec: allow deferred probe of switch handles
  2023-01-24  7:56 [PATCH v3] platform/chrome: cros_ec_typec: allow deferred probe of switch handles Victor Ding
                   ` (2 preceding siblings ...)
  2023-01-24 15:14 ` Benson Leung
@ 2023-01-24 19:10 ` patchwork-bot+chrome-platform
  2023-01-26 19:50 ` patchwork-bot+chrome-platform
  4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+chrome-platform @ 2023-01-24 19:10 UTC (permalink / raw)
  To: Victor Ding
  Cc: linux-kernel, chrome-platform, heikki.krogerus, lee.jones,
	groeck, enric.balletbo, tzungbi, sebastian.reichel, gregkh,
	gustavoars, bleung, dustin, dnojiri, tinghan.shen, pmalani

Hello:

This patch was applied to chrome-platform/linux.git (for-kernelci)
by Prashant Malani <pmalani@chromium.org>:

On Tue, 24 Jan 2023 07:56:32 +0000 you wrote:
> `fwnode_typec_{retimer,mux,switch}_get()` could return `-EPROBE_DEFER`,
> which is called from `cros_typec_get_switch_handles`. When this happens,
> it does not indicate absence of switches; instead, it only hints that
> probing of switches should occur at a later time.
> 
> Progagate `-EPROBE_DEFER` to upper layer logic so that they can re-try
> probing switches as a better time.
> 
> [...]

Here is the summary with links:
  - [v3] platform/chrome: cros_ec_typec: allow deferred probe of switch handles
    https://git.kernel.org/chrome-platform/c/13aba1e532f0

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] platform/chrome: cros_ec_typec: allow deferred probe of switch handles
  2023-01-24  7:56 [PATCH v3] platform/chrome: cros_ec_typec: allow deferred probe of switch handles Victor Ding
                   ` (3 preceding siblings ...)
  2023-01-24 19:10 ` patchwork-bot+chrome-platform
@ 2023-01-26 19:50 ` patchwork-bot+chrome-platform
  4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+chrome-platform @ 2023-01-26 19:50 UTC (permalink / raw)
  To: Victor Ding
  Cc: linux-kernel, chrome-platform, heikki.krogerus, lee.jones,
	groeck, enric.balletbo, tzungbi, sebastian.reichel, gregkh,
	gustavoars, bleung, dustin, dnojiri, tinghan.shen, pmalani

Hello:

This patch was applied to chrome-platform/linux.git (for-next)
by Prashant Malani <pmalani@chromium.org>:

On Tue, 24 Jan 2023 07:56:32 +0000 you wrote:
> `fwnode_typec_{retimer,mux,switch}_get()` could return `-EPROBE_DEFER`,
> which is called from `cros_typec_get_switch_handles`. When this happens,
> it does not indicate absence of switches; instead, it only hints that
> probing of switches should occur at a later time.
> 
> Progagate `-EPROBE_DEFER` to upper layer logic so that they can re-try
> probing switches as a better time.
> 
> [...]

Here is the summary with links:
  - [v3] platform/chrome: cros_ec_typec: allow deferred probe of switch handles
    https://git.kernel.org/chrome-platform/c/13aba1e532f0

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-01-26 19:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-24  7:56 [PATCH v3] platform/chrome: cros_ec_typec: allow deferred probe of switch handles Victor Ding
2023-01-24 13:20 ` Guenter Roeck
2023-01-24 14:09 ` Heikki Krogerus
2023-01-24 15:14 ` Benson Leung
2023-01-24 19:10 ` patchwork-bot+chrome-platform
2023-01-26 19:50 ` patchwork-bot+chrome-platform

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.