Commit a1babdb5 authored by Bart Van Assche's avatar Bart Van Assche Committed by Leon Romanovsky
Browse files

RDMA/iwcm: Simplify cm_work_handler()



Instead of complicating the code to avoid a spin_lock_irqsave() /
spin_lock_irqrestore() pair before returning, simplify the code by removing
the local variable 'empty'.

Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20240605145117.397751-5-bvanassche@acm.org


Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
parent e1168f09
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -1017,16 +1017,13 @@ static void cm_work_handler(struct work_struct *_work)
	struct iw_cm_event levent;
	struct iwcm_id_private *cm_id_priv = work->cm_id;
	unsigned long flags;
	int empty;
	int ret = 0;

	spin_lock_irqsave(&cm_id_priv->lock, flags);
	empty = list_empty(&cm_id_priv->work_list);
	while (!empty) {
	while (!list_empty(&cm_id_priv->work_list)) {
		work = list_first_entry(&cm_id_priv->work_list,
					struct iwcm_work, list);
		list_del_init(&work->list);
		empty = list_empty(&cm_id_priv->work_list);
		levent = work->event;
		put_work(work);
		spin_unlock_irqrestore(&cm_id_priv->lock, flags);
@@ -1039,8 +1036,6 @@ static void cm_work_handler(struct work_struct *_work)
			pr_debug("dropping event %d\n", levent.event);
		if (iwcm_deref_id(cm_id_priv))
			return;
		if (empty)
			return;
		spin_lock_irqsave(&cm_id_priv->lock, flags);
	}
	spin_unlock_irqrestore(&cm_id_priv->lock, flags);