usb: gadget: f_midi: move some of f_midi_transmit to separate func
Move some of the f_midi_transmit to a separate f_midi_do_transmit function so the massive indention levels are not so jarring. This introduces no changes in behaviour. Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
This commit is contained in:
committed by
Felipe Balbi
parent
f297e86c7f
commit
9a71eb5634
@@ -531,34 +531,31 @@ static void f_midi_drop_out_substreams(struct f_midi *midi)
|
||||
}
|
||||
}
|
||||
|
||||
static void f_midi_transmit(struct f_midi *midi)
|
||||
static int f_midi_do_transmit(struct f_midi *midi, struct usb_ep *ep)
|
||||
{
|
||||
struct usb_ep *ep = midi->in_ep;
|
||||
bool active;
|
||||
|
||||
/* We only care about USB requests if IN endpoint is enabled */
|
||||
if (!ep || !ep->enabled)
|
||||
goto drop_out;
|
||||
|
||||
do {
|
||||
struct usb_request *req = NULL;
|
||||
unsigned int len, i;
|
||||
bool active = false;
|
||||
int err;
|
||||
|
||||
active = false;
|
||||
|
||||
/* We peek the request in order to reuse it if it fails
|
||||
* to enqueue on its endpoint */
|
||||
/*
|
||||
* We peek the request in order to reuse it if it fails to enqueue on
|
||||
* its endpoint
|
||||
*/
|
||||
len = kfifo_peek(&midi->in_req_fifo, &req);
|
||||
if (len != 1) {
|
||||
ERROR(midi, "%s: Couldn't get usb request\n", __func__);
|
||||
goto drop_out;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If buffer overrun, then we ignore this transmission.
|
||||
* IMPORTANT: This will cause the user-space rawmidi device to block until a) usb
|
||||
* requests have been completed or b) snd_rawmidi_write() times out. */
|
||||
/*
|
||||
* If buffer overrun, then we ignore this transmission.
|
||||
* IMPORTANT: This will cause the user-space rawmidi device to block
|
||||
* until a) usb requests have been completed or b) snd_rawmidi_write()
|
||||
* times out.
|
||||
*/
|
||||
if (req->length > 0)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
for (i = midi->in_last_port; i < MAX_PORTS; i++) {
|
||||
struct gmidi_in_port *port = midi->in_port[i];
|
||||
@@ -584,9 +581,11 @@ static void f_midi_transmit(struct f_midi *midi)
|
||||
}
|
||||
|
||||
active = !!port->active;
|
||||
/* Check if last port is still active, which means that
|
||||
* there is still data on that substream but this current
|
||||
* request run out of space. */
|
||||
/*
|
||||
* Check if last port is still active, which means that there is
|
||||
* still data on that substream but this current request run out
|
||||
* of space.
|
||||
*/
|
||||
if (active) {
|
||||
midi->in_last_port = i;
|
||||
/* There is no need to re-iterate though midi ports. */
|
||||
@@ -594,8 +593,8 @@ static void f_midi_transmit(struct f_midi *midi)
|
||||
}
|
||||
}
|
||||
|
||||
if (req->length > 0) {
|
||||
int err;
|
||||
if (req->length <= 0)
|
||||
return active;
|
||||
|
||||
err = usb_ep_queue(ep, req, GFP_ATOMIC);
|
||||
if (err < 0) {
|
||||
@@ -607,8 +606,24 @@ static void f_midi_transmit(struct f_midi *midi)
|
||||
kfifo_skip(&midi->in_req_fifo);
|
||||
kfifo_put(&midi->in_req_fifo, req);
|
||||
}
|
||||
}
|
||||
} while (active);
|
||||
|
||||
return active;
|
||||
}
|
||||
|
||||
static void f_midi_transmit(struct f_midi *midi)
|
||||
{
|
||||
struct usb_ep *ep = midi->in_ep;
|
||||
int ret;
|
||||
|
||||
/* We only care about USB requests if IN endpoint is enabled */
|
||||
if (!ep || !ep->enabled)
|
||||
goto drop_out;
|
||||
|
||||
do {
|
||||
ret = f_midi_do_transmit(midi, ep);
|
||||
if (ret < 0)
|
||||
goto drop_out;
|
||||
} while (ret);
|
||||
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user