hiti: Use nanosleep() instead of usleep()

This commit is contained in:
Solomon Peachy 2020-03-24 19:33:20 -04:00
parent f79500986f
commit ebf857e8fc
1 changed files with 10 additions and 7 deletions

View File

@ -33,6 +33,9 @@
#include <config.h>
#endif
// We should use nanosleep everywhere properly.
#define __usleep(__x) { struct timespec t = { 0, (__x) * 1000 } ; nanosleep (&t, NULL); }
/* Private structures */
struct hiti_cmd {
uint8_t hdr; /* 0xa5 */
@ -424,7 +427,7 @@ static int hiti_docmd(struct hiti_ctx *ctx, uint16_t cmdid, uint8_t *buf, uint16
return ret;
}
usleep(10*1000);
__usleep(10*1000);
/* Read back command */
ret = read_data(ctx->dev, ctx->endp_up, cmdbuf, 6, &num);
@ -467,7 +470,7 @@ static int hiti_docmd_resp(struct hiti_ctx *ctx, uint16_t cmdid,
return CUPS_BACKEND_FAILED;
}
usleep(10*1000);
__usleep(10*1000);
/* Read back the data*/
ret = read_data(ctx->dev, ctx->endp_up, respbuf, *resplen, &num);
@ -508,7 +511,7 @@ static int hiti_sepd(struct hiti_ctx *ctx, uint32_t buf_len,
return ret;
}
usleep(10*1000);
__usleep(10*1000);
/* Read back command */
ret = read_data(ctx->dev, ctx->endp_up, cmdbuf, 6, &num);
@ -1137,7 +1140,7 @@ static int hiti_seht2(struct hiti_ctx *ctx, uint8_t plane,
return ret;
}
usleep(10*1000);
__usleep(10*1000);
/* Read back command */
ret = read_data(ctx->dev, ctx->endp_up, cmdbuf, 6, &num);
@ -1876,7 +1879,7 @@ resend_y:
ret = send_data(ctx->dev, ctx->endp_down, job->databuf + sent, rows * cols);
if (ret)
return CUPS_BACKEND_FAILED;
usleep(200*1000);
__usleep(200*1000);
sent += rows * cols;
ret = hiti_query_status(ctx, sts, &err);
if (ret)
@ -1903,7 +1906,7 @@ resend_m:
if (ret)
return CUPS_BACKEND_FAILED;
sent += rows * cols;
usleep(200*1000);
__usleep(200*1000);
ret = hiti_query_status(ctx, sts, &err);
if (ret)
return ret;
@ -1928,7 +1931,7 @@ resend_c:
ret = send_data(ctx->dev, ctx->endp_down, job->databuf + sent, rows * cols);
if (ret)
return CUPS_BACKEND_FAILED;
usleep(200*1000);
__usleep(200*1000);
sent += rows * cols;
ret = hiti_query_status(ctx, sts, &err);
if (ret)