diff mbox series

[RFC,2/7] usb: typec: ucsi: Don't stop alt mode registration on busy condition

Message ID 20210607131442.20121-3-heikki.krogerus@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series usb: typec: ucsi: Polling the alt modes and PDOs | expand

Commit Message

Heikki Krogerus June 7, 2021, 1:14 p.m. UTC
If the PPM tells it's busy, we can now simply try again.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/usb/typec/ucsi/ucsi.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Sergei Shtylyov June 8, 2021, 9:31 a.m. UTC | #1
Hello!

On 07.06.2021 16:14, Heikki Krogerus wrote:

> If the PPM tells it's busy, we can now simply try again.
> 
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
>   drivers/usb/typec/ucsi/ucsi.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index 366c8a468bc18..a8e0e31dcddf5 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -437,8 +437,11 @@ static int ucsi_register_altmodes(struct ucsi_connector *con, u8 recipient)
>   		command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num);
>   		command |= UCSI_GET_ALTMODE_OFFSET(i);
>   		len = ucsi_send_command(con->ucsi, command, alt, sizeof(alt));

    Could insert your check here, to reduce the indentation...

> -		if (len <= 0)
> +		if (len <= 0) {
> +			if (len == -EBUSY)
> +				continue;
>   			return len;
> +		}
>   
>   		/*
>   		 * This code is requesting one alt mode at a time, but some PPMs

MBR, Sergei
Heikki Krogerus June 8, 2021, 1:18 p.m. UTC | #2
On Tue, Jun 08, 2021 at 12:31:45PM +0300, Sergei Shtylyov wrote:
> Hello!
> 
> On 07.06.2021 16:14, Heikki Krogerus wrote:
> 
> > If the PPM tells it's busy, we can now simply try again.
> > 
> > Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > ---
> >   drivers/usb/typec/ucsi/ucsi.c | 5 ++++-
> >   1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> > index 366c8a468bc18..a8e0e31dcddf5 100644
> > --- a/drivers/usb/typec/ucsi/ucsi.c
> > +++ b/drivers/usb/typec/ucsi/ucsi.c
> > @@ -437,8 +437,11 @@ static int ucsi_register_altmodes(struct ucsi_connector *con, u8 recipient)
> >   		command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num);
> >   		command |= UCSI_GET_ALTMODE_OFFSET(i);
> >   		len = ucsi_send_command(con->ucsi, command, alt, sizeof(alt));
> 
>    Could insert your check here, to reduce the indentation...

Sure thing.

> > -		if (len <= 0)
> > +		if (len <= 0) {
> > +			if (len == -EBUSY)
> > +				continue;
> >   			return len;
> > +		}
> >   		/*
> >   		 * This code is requesting one alt mode at a time, but some PPMs

thanks,
diff mbox series

Patch

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index 366c8a468bc18..a8e0e31dcddf5 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -437,8 +437,11 @@  static int ucsi_register_altmodes(struct ucsi_connector *con, u8 recipient)
 		command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num);
 		command |= UCSI_GET_ALTMODE_OFFSET(i);
 		len = ucsi_send_command(con->ucsi, command, alt, sizeof(alt));
-		if (len <= 0)
+		if (len <= 0) {
+			if (len == -EBUSY)
+				continue;
 			return len;
+		}
 
 		/*
 		 * This code is requesting one alt mode at a time, but some PPMs