firmware: arm_scmi: Refactor error logging from SCMI device creation to single helper
authorSudeep Holla <sudeep.holla@arm.com>
Mon, 17 Mar 2025 10:31:23 +0000 (10:31 +0000)
committerSudeep Holla <sudeep.holla@arm.com>
Mon, 14 Apr 2025 09:12:01 +0000 (10:12 +0100)
Refactors the error logging related to SCMI device creation. The goal
is to remove duplicated error-handling code and centralize it into a
single helper function: _scmi_device_create().

By doing so, any code redundancy around error logging is avoided, as
error logging during device creation will now be handled by a unified
helper function.

Message-Id: <20250317-b4-scmi_minor_cleanup-v2-3-f4be99bd9864@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_scmi/bus.c
drivers/firmware/arm_scmi/driver.c

index 6055e44cc3a9ab95750254c644c4aeb756d43a03..cb4f9de1ae7e2da3d226beca032bba11f681df6b 100644 (file)
@@ -454,6 +454,20 @@ put_dev:
        return NULL;
 }
 
+static struct scmi_device *
+_scmi_device_create(struct device_node *np, struct device *parent,
+                   int protocol, const char *name)
+{
+       struct scmi_device *sdev;
+
+       sdev = __scmi_device_create(np, parent, protocol, name);
+       if (!sdev)
+               pr_err("(%s) Failed to create device for protocol 0x%x (%s)\n",
+                      of_node_full_name(parent->of_node), protocol, name);
+
+       return sdev;
+}
+
 /**
  * scmi_device_create  - A method to create one or more SCMI devices
  *
@@ -486,7 +500,7 @@ struct scmi_device *scmi_device_create(struct device_node *np,
        struct scmi_device *scmi_dev = NULL;
 
        if (name)
-               return __scmi_device_create(np, parent, protocol, name);
+               return _scmi_device_create(np, parent, protocol, name);
 
        mutex_lock(&scmi_requested_devices_mtx);
        phead = idr_find(&scmi_requested_devices, protocol);
@@ -500,18 +514,13 @@ struct scmi_device *scmi_device_create(struct device_node *np,
        list_for_each_entry(rdev, phead, node) {
                struct scmi_device *sdev;
 
-               sdev = __scmi_device_create(np, parent,
-                                           rdev->id_table->protocol_id,
-                                           rdev->id_table->name);
-               /* Report errors and carry on... */
+               sdev = _scmi_device_create(np, parent,
+                                          rdev->id_table->protocol_id,
+                                          rdev->id_table->name);
                if (sdev)
                        scmi_dev = sdev;
-               else
-                       pr_err("(%s) Failed to create device for protocol 0x%x (%s)\n",
-                              of_node_full_name(parent->of_node),
-                              rdev->id_table->protocol_id,
-                              rdev->id_table->name);
        }
+
        mutex_unlock(&scmi_requested_devices_mtx);
 
        return scmi_dev;
index 1c75a4c9c3716622f6d7f1d81e794db3a45a9a4b..3ca019a5f7ef4ef2e0509c226b3e393e16750507 100644 (file)
@@ -439,14 +439,8 @@ static void scmi_create_protocol_devices(struct device_node *np,
                                         struct scmi_info *info,
                                         int prot_id, const char *name)
 {
-       struct scmi_device *sdev;
-
        mutex_lock(&info->devreq_mtx);
-       sdev = scmi_device_create(np, info->dev, prot_id, name);
-       if (name && !sdev)
-               dev_err(info->dev,
-                       "failed to create device for protocol 0x%X (%s)\n",
-                       prot_id, name);
+       scmi_device_create(np, info->dev, prot_id, name);
        mutex_unlock(&info->devreq_mtx);
 }