From 64a56a01159442c59c56dc5bea3f73eb914dd8a7 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 24 Jan 2015 16:01:26 +0000 Subject: [PATCH] devlpr: use need_resched --- Kernel/platform-msx1/devlpr.c | 10 ++-------- Kernel/platform-nc100/devlpr.c | 10 ++-------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/Kernel/platform-msx1/devlpr.c b/Kernel/platform-msx1/devlpr.c index 6ca6cef9..4b5c37b7 100644 --- a/Kernel/platform-msx1/devlpr.c +++ b/Kernel/platform-msx1/devlpr.c @@ -23,32 +23,26 @@ int lpr_write(uint8_t minor, uint8_t rawflag, uint8_t flag) { int c = udata.u_count; char *p = udata.u_base; - uint16_t ct; minor; rawflag; flag; // shut up compiler while (c-- > 0) { - ct = 0; - - /* Try and balance polling and sleeping */ while (lpstat & 2) { - ct++; - if (ct == 10000) { - udata.u_ptab->p_timeout = 3; + if (need_resched()) { if (psleep_flags(NULL, flag)) { if (udata.u_count) udata.u_error = 0; return udata.u_count; } - ct = 0; } } /* Data */ lpdata = ugetc(p++); /* Strobe */ lpstat |= 1; + /* FIXME: delay needed */ lpstat &= ~1; } return udata.u_count; diff --git a/Kernel/platform-nc100/devlpr.c b/Kernel/platform-nc100/devlpr.c index 5b363eec..d9362acd 100644 --- a/Kernel/platform-nc100/devlpr.c +++ b/Kernel/platform-nc100/devlpr.c @@ -25,36 +25,30 @@ int lpr_write(uint8_t minor, uint8_t rawflag, uint8_t flag) { int c = udata.u_count; char *p = udata.u_base; - uint16_t ct; minor; rawflag; flag; // shut up compiler while (c-- > 0) { - ct = 0; - - /* Try and balance polling and sleeping */ #ifdef CONFIG_NC200 while (lpstat200 & 1) { #else while (lpstat & 2) { #endif - ct++; - if (ct == 10000) { - udata.u_ptab->p_timeout = 3; + if (need_resched()) { if (psleep_flags(NULL, flag)) { if (udata.u_count) udata.u_error = 0; return udata.u_count; } - ct = 0; } } /* Data */ lpdata = ugetc(p++); /* Strobe */ mod_control(0, 0x40); + /* Delay a bit more ??? */ mod_control(0x40, 0); } return udata.u_count; -- 2.34.1