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

Commit 4953ef65 authored by Michal Nazarewicz's avatar Michal Nazarewicz Committed by Felipe Balbi
Browse files

usb: gadget: f_mass_storage: simplify start_transfer slightly



Flatten the start_transfer function by reversing the if condition and
returning early out of the function if everything went fine.  It makes
the function look less complicated, at least to me, and easier to
understand.

Signed-off-by: default avatarMichal Nazarewicz <mina86@mina86.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent b9a42746
Loading
Loading
Loading
Loading
+13 −14
Original line number Diff line number Diff line
@@ -566,8 +566,11 @@ static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep,
	*pbusy = 1;
	*state = BUF_STATE_BUSY;
	spin_unlock_irq(&fsg->common->lock);

	rc = usb_ep_queue(ep, req, GFP_KERNEL);
	if (rc != 0) {
	if (rc == 0)
		return;  /* All good, we're done */

	*pbusy = 0;
	*state = BUF_STATE_EMPTY;

@@ -577,11 +580,8 @@ static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep,
	 * Note: currently the net2280 driver fails zero-length
	 * submissions if DMA is enabled.
	 */
		if (rc != -ESHUTDOWN &&
		    !(rc == -EOPNOTSUPP && req->length == 0))
			WARNING(fsg, "error in submission: %s --> %d\n",
				ep->name, rc);
	}
	if (rc != -ESHUTDOWN && !(rc == -EOPNOTSUPP && req->length == 0))
		WARNING(fsg, "error in submission: %s --> %d\n", ep->name, rc);
}

static bool start_in_transfer(struct fsg_common *common, struct fsg_buffhd *bh)
@@ -3665,4 +3665,3 @@ void fsg_config_from_params(struct fsg_config *cfg,
	cfg->fsg_num_buffers = fsg_num_buffers;
}
EXPORT_SYMBOL_GPL(fsg_config_from_params);