/* Factorization helper for the command state machine: Submit a CSW read.  */
static int __ub_state_stat(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
/* Factorization helper for the command state machine: Submit a CSW read.  */
static int __ub_state_stat(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
{
	int rc;
	UB_INIT_COMPLETION(sc->work_done);
	sc->last_pipe = sc->recv_bulk_pipe;
	usb_fill_bulk_urb(&sc->work_urb, sc->dev, sc->recv_bulk_pipe,
	    &sc->work_bcs, US_BULK_CS_WRAP_LEN, ub_urb_complete, sc);
	if ((rc = usb_submit_urb(&sc->work_urb, GFP_ATOMIC)) != 0) {
		ub_complete(&sc->work_done);
		ub_state_done(sc, cmd, rc);
		return -1;
	}
	if (cmd->timeo)
		sc->work_timer.expires = jiffies + cmd->timeo;
	else
		sc->work_timer.expires = jiffies + UB_STAT_TIMEOUT;
	add_timer(&sc->work_timer);
	return 0;
}