When I move the test
else if (priv->resp_len[priv->resp_idx])
shouldsleep = 0; /* We have a command response *
before
else if (priv->cur_cmd)
shouldsleep = 1; /* Can't send a command; one already running */
the the problem vanishes. I hope this is the correct fix ...