public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Johan Hovold <johan+linaro@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Abel Vesa <abel.vesa@linaro.org>,
	Stephan Gerhold <stephan.gerhold@linaro.org>,
	linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] usb: typec: ps883x: fix configuration error handling
Date: Wed, 26 Feb 2025 11:56:09 +0200	[thread overview]
Message-ID: <Z77lOR8nUQSNafm0@kuha.fi.intel.com> (raw)
In-Reply-To: <20250218152933.22992-4-johan+linaro@kernel.org>

On Tue, Feb 18, 2025 at 04:29:33PM +0100, Johan Hovold wrote:
> Propagate errors to the consumers when configuring the retimer so that
> they can act on any failures as intended, for example:
> 
> 	ps883x_retimer 2-0008: failed to write conn_status_0: -5
> 	pmic_glink_altmode.pmic_glink_altmode pmic_glink.altmode.0: failed to setup retimer to DP: -5
> 
> Fixes: 257a087c8b52 ("usb: typec: Add support for Parade PS8830 Type-C Retimer")
> Cc: Abel Vesa <abel.vesa@linaro.org>
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>

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

> ---
>  drivers/usb/typec/mux/ps883x.c | 36 ++++++++++++++++++++++++----------
>  1 file changed, 26 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/usb/typec/mux/ps883x.c b/drivers/usb/typec/mux/ps883x.c
> index f8b47187f4cf..ad59babf7cce 100644
> --- a/drivers/usb/typec/mux/ps883x.c
> +++ b/drivers/usb/typec/mux/ps883x.c
> @@ -58,12 +58,31 @@ struct ps883x_retimer {
>  	unsigned int svid;
>  };
>  
> -static void ps883x_configure(struct ps883x_retimer *retimer, int cfg0,
> -			     int cfg1, int cfg2)
> +static int ps883x_configure(struct ps883x_retimer *retimer, int cfg0,
> +			    int cfg1, int cfg2)
>  {
> -	regmap_write(retimer->regmap, REG_USB_PORT_CONN_STATUS_0, cfg0);
> -	regmap_write(retimer->regmap, REG_USB_PORT_CONN_STATUS_1, cfg1);
> -	regmap_write(retimer->regmap, REG_USB_PORT_CONN_STATUS_2, cfg2);
> +	struct device *dev = &retimer->client->dev;
> +	int ret;
> +
> +	ret = regmap_write(retimer->regmap, REG_USB_PORT_CONN_STATUS_0, cfg0);
> +	if (ret) {
> +		dev_err(dev, "failed to write conn_status_0: %d\n", ret);
> +		return ret;
> +	}
> +
> +	ret = regmap_write(retimer->regmap, REG_USB_PORT_CONN_STATUS_1, cfg1);
> +	if (ret) {
> +		dev_err(dev, "failed to write conn_status_1: %d\n", ret);
> +		return ret;
> +	}
> +
> +	ret = regmap_write(retimer->regmap, REG_USB_PORT_CONN_STATUS_2, cfg2);
> +	if (ret) {
> +		dev_err(dev, "failed to write conn_status_2: %d\n", ret);
> +		return ret;
> +	}
> +
> +	return 0;
>  }
>  
>  static int ps883x_set(struct ps883x_retimer *retimer)
> @@ -74,8 +93,7 @@ static int ps883x_set(struct ps883x_retimer *retimer)
>  
>  	if (retimer->orientation == TYPEC_ORIENTATION_NONE ||
>  	    retimer->mode == TYPEC_STATE_SAFE) {
> -		ps883x_configure(retimer, cfg0, cfg1, cfg2);
> -		return 0;
> +		return ps883x_configure(retimer, cfg0, cfg1, cfg2);
>  	}
>  
>  	if (retimer->mode != TYPEC_STATE_USB && retimer->svid != USB_TYPEC_DP_SID)
> @@ -113,9 +131,7 @@ static int ps883x_set(struct ps883x_retimer *retimer)
>  		return -EOPNOTSUPP;
>  	}
>  
> -	ps883x_configure(retimer, cfg0, cfg1, cfg2);
> -
> -	return 0;
> +	return ps883x_configure(retimer, cfg0, cfg1, cfg2);
>  }
>  
>  static int ps883x_sw_set(struct typec_switch_dev *sw,
> -- 
> 2.45.3

-- 
heikki

      reply	other threads:[~2025-02-26  9:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18 15:29 [PATCH 0/3] usb: typec: ps883x: follow-up fixes Johan Hovold
2025-02-18 15:29 ` [PATCH 1/3] usb: typec: ps883x: fix registration race Johan Hovold
2025-02-26  9:54   ` Heikki Krogerus
2025-02-18 15:29 ` [PATCH 2/3] usb: typec: ps883x: fix missing accessibility check Johan Hovold
2025-02-26  9:55   ` Heikki Krogerus
2025-03-02 13:34   ` Jens Glathe
2025-03-03  7:07     ` Johan Hovold
2025-02-18 15:29 ` [PATCH 3/3] usb: typec: ps883x: fix configuration error handling Johan Hovold
2025-02-26  9:56   ` Heikki Krogerus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z77lOR8nUQSNafm0@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=abel.vesa@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan+linaro@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stephan.gerhold@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox