Commit 6ea2645f authored by Andries E. Brouwer's avatar Andries E. Brouwer Committed by Linus Torvalds

[PATCH] paride fix: make timeouts unsigned long

parent 6ebc7946
...@@ -233,14 +233,14 @@ struct pg_unit { ...@@ -233,14 +233,14 @@ struct pg_unit {
int busy; /* write done, read expected */ int busy; /* write done, read expected */
int start; /* jiffies at command start */ int start; /* jiffies at command start */
int dlen; /* transfer size requested */ int dlen; /* transfer size requested */
int timeout; /* timeout requested */ unsigned long timeout; /* timeout requested */
int status; /* last sense key */ int status; /* last sense key */
int drive; /* drive */ int drive; /* drive */
unsigned long access; /* count of active opens ... */ unsigned long access; /* count of active opens ... */
int present; /* device present ? */ int present; /* device present ? */
char *bufptr; char *bufptr;
char name[PG_NAMELEN]; /* pg0, pg1, ... */ char name[PG_NAMELEN]; /* pg0, pg1, ... */
}; };
struct pg_unit pg[PG_UNITS]; struct pg_unit pg[PG_UNITS];
...@@ -292,43 +292,47 @@ static void pg_sleep( int cs ) ...@@ -292,43 +292,47 @@ static void pg_sleep( int cs )
schedule_timeout(cs); schedule_timeout(cs);
} }
static int pg_wait( int unit, int go, int stop, int tmo, char * msg ) static int pg_wait(int unit, int go, int stop, unsigned long tmo, char *msg)
{
{ int j, r, e, s, p; int j, r, e, s, p, to;
PG.status = 0; PG.status = 0;
j = 0; j = 0;
while ((((r=RR(1,6))&go)||(stop&&(!(r&stop))))&&(time_before(jiffies,tmo))) { while ((((r=RR(1,6))&go) || (stop&&(!(r&stop))))
if (j++ < PG_SPIN) udelay(PG_SPIN_DEL); && time_before(jiffies,tmo)) {
else pg_sleep(1); if (j++ < PG_SPIN)
udelay(PG_SPIN_DEL);
else
pg_sleep(1);
} }
if ((r&(STAT_ERR&stop))||time_after_eq(jiffies, tmo)) { to = time_after_eq(jiffies, tmo);
s = RR(0,7);
e = RR(0,1); if ((r&(STAT_ERR&stop)) || to) {
p = RR(0,2); s = RR(0,7);
if (verbose > 1) e = RR(0,1);
printk("%s: %s: stat=0x%x err=0x%x phase=%d%s\n", p = RR(0,2);
PG.name,msg,s,e,p,time_after_eq(jiffies, tmo)?" timeout":""); if (verbose > 1)
printk("%s: %s: stat=0x%x err=0x%x phase=%d%s\n",
PG.name, msg, s, e, p, to ? " timeout" : "");
if (time_after_eq(jiffies, tmo)) e |= 0x100; if (to)
PG.status = (e >> 4) & 0xff; e |= 0x100;
return -1; PG.status = (e >> 4) & 0xff;
return -1;
} }
return 0; return 0;
} }
static int pg_command( int unit, char * cmd, int dlen, int tmo ) static int pg_command(int unit, char *cmd, int dlen, unsigned long tmo)
{
{ int k; int k;
pi_connect(PI); pi_connect(PI);
WR(0,6,DRIVE); WR(0,6,DRIVE);
if (pg_wait(unit,STAT_BUSY|STAT_DRQ,0,tmo,"before command")) { if (pg_wait(unit, STAT_BUSY|STAT_DRQ, 0, tmo, "before command")) {
pi_disconnect(PI); pi_disconnect(PI);
return -1; return -1;
} }
...@@ -337,15 +341,15 @@ static int pg_command( int unit, char * cmd, int dlen, int tmo ) ...@@ -337,15 +341,15 @@ static int pg_command( int unit, char * cmd, int dlen, int tmo )
WR(0,5,dlen / 256); WR(0,5,dlen / 256);
WR(0,7,0xa0); /* ATAPI packet command */ WR(0,7,0xa0); /* ATAPI packet command */
if (pg_wait(unit,STAT_BUSY,STAT_DRQ,tmo,"command DRQ")) { if (pg_wait(unit, STAT_BUSY, STAT_DRQ, tmo, "command DRQ")) {
pi_disconnect(PI); pi_disconnect(PI);
return -1; return -1;
} }
if (RR(0,2) != 1) { if (RR(0,2) != 1) {
printk("%s: command phase error\n",PG.name); printk("%s: command phase error\n",PG.name);
pi_disconnect(PI); pi_disconnect(PI);
return -1; return -1;
} }
pi_write_block(PI,cmd,12); pi_write_block(PI,cmd,12);
...@@ -358,27 +362,30 @@ static int pg_command( int unit, char * cmd, int dlen, int tmo ) ...@@ -358,27 +362,30 @@ static int pg_command( int unit, char * cmd, int dlen, int tmo )
return 0; return 0;
} }
static int pg_completion( int unit, char * buf, int tmo) static int pg_completion(int unit, char *buf, unsigned long tmo)
{
{ int r, d, n, p; int r, d, n, p;
r = pg_wait(unit,STAT_BUSY,STAT_DRQ|STAT_READY|STAT_ERR, r = pg_wait(unit, STAT_BUSY, STAT_DRQ|STAT_READY|STAT_ERR,
tmo,"completion"); tmo, "completion");
PG.dlen = 0; PG.dlen = 0;
while (RR(0,7)&STAT_DRQ) { while (RR(0,7)&STAT_DRQ) {
d = (RR(0,4)+256*RR(0,5)); d = (RR(0,4)+256*RR(0,5));
n = ((d+3)&0xfffc); n = ((d+3)&0xfffc);
p = RR(0,2)&3; p = RR(0,2)&3;
if (p == 0) pi_write_block(PI,buf,n); if (p == 0)
if (p == 2) pi_read_block(PI,buf,n); pi_write_block(PI,buf,n);
if (verbose > 1) printk("%s: %s %d bytes\n",PG.name, if (p == 2)
p?"Read":"Write",n); pi_read_block(PI,buf,n);
PG.dlen += (1-p)*d; if (verbose > 1)
buf += d; printk("%s: %s %d bytes\n", PG.name,
r = pg_wait(unit,STAT_BUSY,STAT_DRQ|STAT_READY|STAT_ERR, p?"Read":"Write", n);
tmo,"completion"); PG.dlen += (1-p)*d;
buf += d;
r = pg_wait(unit, STAT_BUSY, STAT_DRQ|STAT_READY|STAT_ERR,
tmo, "completion");
} }
pi_disconnect(PI); pi_disconnect(PI);
......
...@@ -39,7 +39,7 @@ static void ps_tq_int( void *data); ...@@ -39,7 +39,7 @@ static void ps_tq_int( void *data);
static void (* ps_continuation)(void); static void (* ps_continuation)(void);
static int (* ps_ready)(void); static int (* ps_ready)(void);
static int ps_timeout; static unsigned long ps_timeout;
static int ps_tq_active = 0; static int ps_tq_active = 0;
static int ps_nice = 0; static int ps_nice = 0;
...@@ -70,7 +70,7 @@ static void ps_set_intr(void (*continuation)(void), ...@@ -70,7 +70,7 @@ static void ps_set_intr(void (*continuation)(void),
spin_unlock_irqrestore(&ps_spinlock,flags); spin_unlock_irqrestore(&ps_spinlock,flags);
} }
static void ps_tq_int( void *data ) static void ps_tq_int(void *data)
{ {
void (*con)(void); void (*con)(void);
unsigned long flags; unsigned long flags;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment