|
@@ -1257,11 +1257,16 @@ static int __qcom_glink_send(struct glink_channel *channel,
|
|
|
spin_lock_irqsave(&channel->intent_lock, flags);
|
|
|
idr_for_each_entry(&channel->riids, tmp, iid) {
|
|
|
if (tmp->size >= len && !tmp->in_use) {
|
|
|
- tmp->in_use = true;
|
|
|
- intent = tmp;
|
|
|
- break;
|
|
|
+ if (!intent)
|
|
|
+ intent = tmp;
|
|
|
+ else if (intent->size > tmp->size)
|
|
|
+ intent = tmp;
|
|
|
+ if (intent->size == len)
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+ if (intent)
|
|
|
+ intent->in_use = true;
|
|
|
spin_unlock_irqrestore(&channel->intent_lock, flags);
|
|
|
|
|
|
/* We found an available intent */
|