From: Johan Hovold <johan+linaro@kernel.org>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: 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,
Johan Hovold <johan+linaro@kernel.org>
Subject: [PATCH 3/3] usb: typec: ps883x: fix configuration error handling
Date: Tue, 18 Feb 2025 16:29:33 +0100 [thread overview]
Message-ID: <20250218152933.22992-4-johan+linaro@kernel.org> (raw)
In-Reply-To: <20250218152933.22992-1-johan+linaro@kernel.org>
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>
---
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
next prev parent reply other threads:[~2025-02-18 15:29 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 ` Johan Hovold [this message]
2025-02-26 9:56 ` [PATCH 3/3] usb: typec: ps883x: fix configuration error handling Heikki Krogerus
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=20250218152933.22992-4-johan+linaro@kernel.org \
--to=johan+linaro@kernel.org \
--cc=abel.vesa@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--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