/* Return: 0 if request was submitted successfully, -ve on error  */
static int aux_request(struct udevice *dev, struct aux_transaction *request)
/* Return: 0 if request was submitted successfully, -ve on error  */
static int aux_request(struct udevice *dev, struct aux_transaction *request)
{
	u32 defer_count = 0;
	u32 timeout_count = 0;
	while ((defer_count < AUX_MAX_DEFER_COUNT) &&
	       (timeout_count < AUX_MAX_TIMEOUT_COUNT)) {
		int status = aux_wait_ready(dev);
		if (status) {
			timeout_count++;
			continue;
		}
		status = aux_request_send(dev, request);
		if (status == -EAGAIN) {
			defer_count++;
		} else if (status == -ETIMEDOUT) {
			timeout_count++;
		} else {
			return status;
		}
		udelay(100);
	}
	return -ETIMEDOUT;
}