mirror of
https://github.com/torvalds/linux.git
synced 2026-07-30 19:21:28 +02:00
net: qrtr: Improve qrtr_node_assign
First check if the node is already assigned the requested nid, this allows an early exit for the common case. Do not allow later nodes to overwrite a node id. The first to claim a node id should get priority. Change-Id: Ie3da0c3b709de8c68f9918cd485492f9eaa41247 Signed-off-by: Chris Lew <quic_clew@quicinc.com>
This commit is contained in:
parent
8fa3203fdc
commit
e00d15abf5
|
|
@ -457,11 +457,13 @@ static void qrtr_node_assign(struct qrtr_node *node, unsigned int nid)
|
|||
{
|
||||
unsigned long flags;
|
||||
|
||||
if (nid == QRTR_EP_NID_AUTO)
|
||||
if (nid == node->nid || nid == QRTR_EP_NID_AUTO)
|
||||
return;
|
||||
|
||||
spin_lock_irqsave(&qrtr_nodes_lock, flags);
|
||||
radix_tree_insert(&qrtr_nodes, nid, node);
|
||||
if (!radix_tree_lookup(&qrtr_nodes, nid))
|
||||
radix_tree_insert(&qrtr_nodes, nid, node);
|
||||
|
||||
if (node->nid == QRTR_EP_NID_AUTO)
|
||||
node->nid = nid;
|
||||
spin_unlock_irqrestore(&qrtr_nodes_lock, flags);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user