[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240210070934.2549994-13-swboyd@chromium.org>
Date: Fri, 9 Feb 2024 23:09:23 -0800
From: Stephen Boyd <swboyd@...omium.org>
To: chrome-platform@...ts.linux.dev
Cc: linux-kernel@...r.kernel.org,
patches@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org,
devicetree@...r.kernel.org,
linux-arm-msm@...r.kernel.org,
Douglas Anderson <dianders@...omium.org>,
Pin-yen Lin <treapking@...omium.org>,
Prashant Malani <pmalani@...omium.org>,
Benson Leung <bleung@...omium.org>,
Tzung-Bi Shih <tzungbi@...nel.org>
Subject: [PATCH 12/22] platform/chrome: cros_typec_switch: Use dev_err_probe()
Use dev_err_probe() helper so we can get better diagnostics when driver
probes fails for any reason.
Cc: Prashant Malani <pmalani@...omium.org>
Cc: Benson Leung <bleung@...omium.org>
Cc: Tzung-Bi Shih <tzungbi@...nel.org>
Cc: <chrome-platform@...ts.linux.dev>
Cc: Pin-yen Lin <treapking@...omium.org>
Signed-off-by: Stephen Boyd <swboyd@...omium.org>
---
drivers/platform/chrome/cros_typec_switch.c | 36 +++++++--------------
1 file changed, 12 insertions(+), 24 deletions(-)
diff --git a/drivers/platform/chrome/cros_typec_switch.c b/drivers/platform/chrome/cros_typec_switch.c
index 373e0e86ebfc..769de2889f2f 100644
--- a/drivers/platform/chrome/cros_typec_switch.c
+++ b/drivers/platform/chrome/cros_typec_switch.c
@@ -219,31 +219,23 @@ static int cros_typec_register_port(struct cros_typec_switch_data *sdata,
if (adev)
prop_name = "_ADR";
- if (!adev) {
- dev_err(fwnode->dev, "Couldn't get ACPI handle\n");
- return -ENODEV;
- }
+ if (!adev)
+ return dev_err_probe(fwnode->dev, -ENODEV, "Couldn't get ACPI handle\n");
ret = fwnode_property_read_u32(fwnode, prop_name, &index);
- if (ret) {
- dev_err(fwnode->dev, "%s property wasn't found\n", prop_name);
- return ret;
- }
+ if (ret)
+ return dev_err_probe(fwnode->dev, ret, "%s property wasn't found\n", prop_name);
- if (index >= EC_USB_PD_MAX_PORTS) {
- dev_err(fwnode->dev, "Invalid port index number: %u\n", index);
- return -EINVAL;
- }
+ if (index >= EC_USB_PD_MAX_PORTS)
+ return dev_err_probe(fwnode->dev, -EINVAL, "Invalid port index number: %u\n", index);
port->sdata = sdata;
port->port_num = index;
sdata->ports[index] = port;
if (fwnode_property_present(fwnode, "retimer-switch")) {
ret = cros_typec_register_retimer(port, fwnode);
- if (ret) {
- dev_err(dev, "Retimer switch register failed\n");
- return ret;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "Retimer switch register failed\n");
dev_dbg(dev, "Retimer switch registered for index %u\n", index);
}
@@ -252,10 +244,8 @@ static int cros_typec_register_port(struct cros_typec_switch_data *sdata,
return 0;
ret = cros_typec_register_mode_switch(port, fwnode);
- if (ret) {
- dev_err(dev, "Mode switch register failed\n");
- return ret;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "Mode switch register failed\n");
dev_dbg(dev, "Mode switch registered for index %u\n", index);
@@ -269,10 +259,8 @@ static int cros_typec_register_switches(struct cros_typec_switch_data *sdata)
int nports, ret;
nports = device_get_child_node_count(dev);
- if (nports == 0) {
- dev_err(dev, "No switch devices found.\n");
- return -ENODEV;
- }
+ if (nports == 0)
+ return dev_err_probe(dev, -ENODEV, "No switch devices found\n");
device_for_each_child_node(dev, fwnode) {
ret = cros_typec_register_port(sdata, fwnode);
--
https://chromeos.dev
Powered by blists - more mailing lists