[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240210070934.2549994-12-swboyd@chromium.org>
Date: Fri, 9 Feb 2024 23:09:22 -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 11/22] platform/chrome: cros_typec_switch: Use fwnode instead of ACPI APIs
Use fwnode APIs instead of ACPI ones because this driver will soon
support devicetree firmwares. Using fwnode APIs makes it easier to
support either ACPI or DT.
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 | 24 +++++++++++----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/platform/chrome/cros_typec_switch.c b/drivers/platform/chrome/cros_typec_switch.c
index 1a718b661203..373e0e86ebfc 100644
--- a/drivers/platform/chrome/cros_typec_switch.c
+++ b/drivers/platform/chrome/cros_typec_switch.c
@@ -207,29 +207,31 @@ static int cros_typec_register_port(struct cros_typec_switch_data *sdata,
struct cros_typec_port *port;
struct device *dev = sdata->dev;
struct acpi_device *adev;
- unsigned long long index;
+ u32 index;
int ret;
+ const char *prop_name;
port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
if (!port)
return -ENOMEM;
adev = to_acpi_device_node(fwnode);
- if (adev) {
- ret = acpi_evaluate_integer(adev->handle, "_ADR", NULL, &index);
- if (ACPI_FAILURE(ret)) {
- dev_err(fwnode->dev, "_ADR wasn't evaluated\n");
- return -ENODATA;
- }
- }
+ if (adev)
+ prop_name = "_ADR";
if (!adev) {
dev_err(fwnode->dev, "Couldn't get ACPI handle\n");
return -ENODEV;
}
+ 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 (index >= EC_USB_PD_MAX_PORTS) {
- dev_err(fwnode->dev, "Invalid port index number: %llu\n", index);
+ dev_err(fwnode->dev, "Invalid port index number: %u\n", index);
return -EINVAL;
}
port->sdata = sdata;
@@ -243,7 +245,7 @@ static int cros_typec_register_port(struct cros_typec_switch_data *sdata,
return ret;
}
- dev_dbg(dev, "Retimer switch registered for index %llu\n", index);
+ dev_dbg(dev, "Retimer switch registered for index %u\n", index);
}
if (!fwnode_property_present(fwnode, "mode-switch"))
@@ -255,7 +257,7 @@ static int cros_typec_register_port(struct cros_typec_switch_data *sdata,
return ret;
}
- dev_dbg(dev, "Mode switch registered for index %llu\n", index);
+ dev_dbg(dev, "Mode switch registered for index %u\n", index);
return ret;
}
--
https://chromeos.dev
Powered by blists - more mailing lists