Skip to content

Commit 803eae3

Browse files
sudeep-hollaSasha Levin
authored andcommitted
firmware: arm_scmi: Relax duplicate name constraint across protocol ids
[ Upstream commit 21ee965 ] Currently in scmi_protocol_device_request(), no duplicate scmi device name is allowed across any protocol. However scmi_dev_match_id() first matches the protocol id and then the name. So, there is no strict requirement to keep this scmi device name unique across all the protocols. Relax the constraint on the duplicate name across the protocols and inhibit only within the same protocol id. Message-Id: <[email protected]> Reviewed-by: Dhruva Gole <[email protected]> Reviewed-by: Peng Fan <[email protected]> Signed-off-by: Sudeep Holla <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 86d3fb9 commit 803eae3

File tree

1 file changed

+6
-13
lines changed
  • drivers/firmware/arm_scmi

1 file changed

+6
-13
lines changed

drivers/firmware/arm_scmi/bus.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static atomic_t scmi_syspower_registered = ATOMIC_INIT(0);
4242
* This helper let an SCMI driver request specific devices identified by the
4343
* @id_table to be created for each active SCMI instance.
4444
*
45-
* The requested device name MUST NOT be already existent for any protocol;
45+
* The requested device name MUST NOT be already existent for this protocol;
4646
* at first the freshly requested @id_table is annotated in the IDR table
4747
* @scmi_requested_devices and then the requested device is advertised to any
4848
* registered party via the @scmi_requested_devices_nh notification chain.
@@ -52,7 +52,6 @@ static atomic_t scmi_syspower_registered = ATOMIC_INIT(0);
5252
static int scmi_protocol_device_request(const struct scmi_device_id *id_table)
5353
{
5454
int ret = 0;
55-
unsigned int id = 0;
5655
struct list_head *head, *phead = NULL;
5756
struct scmi_requested_dev *rdev;
5857

@@ -67,19 +66,13 @@ static int scmi_protocol_device_request(const struct scmi_device_id *id_table)
6766
}
6867

6968
/*
70-
* Search for the matching protocol rdev list and then search
71-
* of any existent equally named device...fails if any duplicate found.
69+
* Find the matching protocol rdev list and then search of any
70+
* existent equally named device...fails if any duplicate found.
7271
*/
7372
mutex_lock(&scmi_requested_devices_mtx);
74-
idr_for_each_entry(&scmi_requested_devices, head, id) {
75-
if (!phead) {
76-
/* A list found registered in the IDR is never empty */
77-
rdev = list_first_entry(head, struct scmi_requested_dev,
78-
node);
79-
if (rdev->id_table->protocol_id ==
80-
id_table->protocol_id)
81-
phead = head;
82-
}
73+
phead = idr_find(&scmi_requested_devices, id_table->protocol_id);
74+
if (phead) {
75+
head = phead;
8376
list_for_each_entry(rdev, head, node) {
8477
if (!strcmp(rdev->id_table->name, id_table->name)) {
8578
pr_err("Ignoring duplicate request [%d] %s\n",

0 commit comments

Comments
 (0)