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

Commit 7dfd2bd7 authored by Shubhrajyoti D's avatar Shubhrajyoti D Committed by Grant Likely
Browse files

spi: Dont call prepare/unprepare transfer if not populated



Currently the prepare/unprepare transfer are called unconditionally.
The assumption is that every driver using the spi core queue infrastructure
has to populate the prepare and unprepare functions. This encourages
drivers to populate empty functions to prevent crashing.
This patch prevents the call to prepare/unprepare if not populated.

Signed-off-by: default avatarShubhrajyoti D <shubhrajyoti@ti.com>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
[grant.likely: fix whitespace defect]
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent 6d6467ee
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -532,7 +532,7 @@ static void spi_pump_messages(struct kthread_work *work)
	/* Lock queue and check for queue work */
	/* Lock queue and check for queue work */
	spin_lock_irqsave(&master->queue_lock, flags);
	spin_lock_irqsave(&master->queue_lock, flags);
	if (list_empty(&master->queue) || !master->running) {
	if (list_empty(&master->queue) || !master->running) {
		if (master->busy) {
		if (master->busy && master->unprepare_transfer_hardware) {
			ret = master->unprepare_transfer_hardware(master);
			ret = master->unprepare_transfer_hardware(master);
			if (ret) {
			if (ret) {
				spin_unlock_irqrestore(&master->queue_lock, flags);
				spin_unlock_irqrestore(&master->queue_lock, flags);
@@ -562,7 +562,7 @@ static void spi_pump_messages(struct kthread_work *work)
		master->busy = true;
		master->busy = true;
	spin_unlock_irqrestore(&master->queue_lock, flags);
	spin_unlock_irqrestore(&master->queue_lock, flags);


	if (!was_busy) {
	if (!was_busy && master->prepare_transfer_hardware) {
		ret = master->prepare_transfer_hardware(master);
		ret = master->prepare_transfer_hardware(master);
		if (ret) {
		if (ret) {
			dev_err(&master->dev,
			dev_err(&master->dev,