return ret;
}
+static struct udevice *find_scmi_transport_device(struct udevice *dev)
+{
+ struct udevice *parent = dev;
+
+ do {
+ parent = dev_get_parent(parent);
+ } while (parent && device_get_uclass_id(parent) != UCLASS_SCMI_AGENT);
+
+ if (!parent)
+ dev_err(dev, "Invalid SCMI device, agent not found\n");
+
+ return parent;
+}
+
static const struct scmi_agent_ops *transport_dev_ops(struct udevice *dev)
{
return (const struct scmi_agent_ops *)dev->driver->ops;
struct scmi_msg *msg)
{
const struct scmi_agent_ops *ops;
- struct udevice *parent = dev;
+ struct udevice *parent;
- /* Find related SCMI agent device */
- do {
- parent = dev_get_parent(parent);
- } while (parent && device_get_uclass_id(parent) != UCLASS_SCMI_AGENT);
-
- if (!parent) {
- dev_err(dev, "Invalid SCMI device, agent not found\n");
+ parent = find_scmi_transport_device(dev);
+ if (!parent)
return -ENODEV;
- }
ops = transport_dev_ops(parent);