Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d09e9a53 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "rpmsg: glink: spi: Cancel intent work in remove"

parents 5fea65c1 0f798a65
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -1501,13 +1501,12 @@ static int glink_spi_create_remote(struct glink_spi *glink,

	/*
	 * Send a close request to "undo" our open-ack. The close-ack will
	 * release the last reference.
	 * release glink_spi_send_open_req() reference and the last reference
	 * will be release after rx_close or transport unregister by calling
	 * glink_spi_remove().
	 */
	glink_spi_send_close_req(glink, channel);

	/* Release glink_spi_send_open_req() reference */
	kref_put(&channel->refcount, glink_spi_channel_release);

	return ret;
}

@@ -2467,16 +2466,27 @@ static void glink_spi_remove(struct glink_spi *glink)
	if (ret)
		dev_warn(&glink->dev, "Can't remove GLINK devices: %d\n", ret);

	spin_lock_irqsave(&glink->idr_lock, flags);
	idr_for_each_entry(&glink->lcids, channel, cid) {
		spin_unlock_irqrestore(&glink->idr_lock, flags);
		/* cancel_work_sync may sleep */
		cancel_work_sync(&channel->intent_work);
		spin_lock_irqsave(&glink->idr_lock, flags);
	}
	spin_unlock_irqrestore(&glink->idr_lock, flags);

	spin_lock_irqsave(&glink->idr_lock, flags);
	/* Release any defunct local channels, waiting for close-ack */
	idr_for_each_entry(&glink->lcids, channel, cid) {
		if (kref_put(&channel->refcount, glink_spi_channel_release))
		kref_put(&channel->refcount, glink_spi_channel_release);
		idr_remove(&glink->lcids, cid);
	}

	/* Release any defunct local channels, waiting for close-req */
	idr_for_each_entry(&glink->lcids, channel, cid)
	idr_for_each_entry(&glink->lcids, channel, cid) {
		kref_put(&channel->refcount, glink_spi_channel_release);
		idr_remove(&glink->lcids, cid);
	}

	idr_destroy(&glink->lcids);
	idr_destroy(&glink->rcids);