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

Commit e67cc079 authored by Ajay Agarwal's avatar Ajay Agarwal Committed by Gerrit - the friendly Code Review server
Browse files

usb: diag_bridge: Modify kref_put handling in case of transfers



Make the code more readable by doing kref_put in the completion
callback if the URB is submitted successfully. Else do so from
the error handling in read/write functions.

Change-Id: I50645cac757293dd0b1df9afb356281b2922401b
Signed-off-by: default avatarAjay Agarwal <ajaya@codeaurora.org>
parent 08cce56f
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -249,11 +249,14 @@ int diag_bridge_read(int id, char *data, int size)
	}

	usb_autopm_put_interface(dev->ifc);
	usb_free_urb(urb);
	mutex_unlock(&dev->ifc_mutex);
	return ret;

free_error:
	usb_free_urb(urb);
put_error:
	if (ret) /* otherwise this is done in the completion handler */
	/* If URB submit successful, this is done in the completion handler */
	kref_put(&dev->kref, diag_bridge_delete);
error:
	mutex_unlock(&dev->ifc_mutex);
@@ -360,10 +363,14 @@ int diag_bridge_write(int id, char *data, int size)
		goto free_error;
	}

	usb_free_urb(urb);
	mutex_unlock(&dev->ifc_mutex);
	return ret;

free_error:
	usb_free_urb(urb);
put_error:
	if (ret) /* otherwise this is done in the completion handler */
	/* If URB submit successful, this is done in the completion handler */
	kref_put(&dev->kref, diag_bridge_delete);
error:
	mutex_unlock(&dev->ifc_mutex);