mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 02:53:36 +02:00
firmware: arm_scmi: Refactor error logging from SCMI device creation to single helper
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>
This commit is contained in:
parent
3da2859ee5
commit
c69a31c1ad
|
|
@ -454,6 +454,20 @@ __scmi_device_create(struct device_node *np, struct device *parent,
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user