Commit 0254c3b4 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] paride cleanup and fixes (12/25)

Equivalent transformation:
	* calls of pi_disconnect() in phase functions expanded.
	* since both do_pd_read_start() and do_pd_write_start()
	  are always called claimed (as the matter of fact,
	  all phase functions except do_pd_io() are), we can
	  replace call of pi_connect() with direct method call -
	  pi_claim() is no-op there.
parent bd4941ed
......@@ -210,7 +210,6 @@ static void ps_set_intr(void)
}
static struct pd_unit *pd_current; /* current request's drive */
static PIA *pi_current; /* current request's PIA */
static struct request *pd_req; /* current request */
static void run_fsm(void)
......@@ -222,7 +221,7 @@ static void run_fsm(void)
next_request(res);
break;
case Claim:
pi_do_claimed(pi_current, run_fsm);
pi_do_claimed(pd_current->pi, run_fsm);
break;
case Hold:
ps_set_intr();
......@@ -814,7 +813,6 @@ static inline void next_request(int success)
static enum action do_pd_io(void)
{
pd_current = pd_req->rq_disk->private_data;
pi_current = pd_current->pi;
phase = do_pd_io_start;
return Claim;
}
......@@ -825,7 +823,7 @@ static enum action do_pd_io_start(void)
pd_run = pd_req->nr_sectors;
pd_count = pd_req->current_nr_sectors;
if (pd_block + pd_count > get_capacity(pd_req->rq_disk)) {
pi_unclaim(pi_current);
pi_unclaim(pd_current->pi);
return Fail;
}
......@@ -838,22 +836,20 @@ static enum action do_pd_io_start(void)
} else if (pd_cmd == WRITE) {
return do_pd_write_start();
} else {
pi_unclaim(pi_current);
pi_unclaim(pd_current->pi);
return Fail;
}
}
static enum action do_pd_read_start(void)
{
pi_current->proto->connect(pi_current);
pi_connect(pd_current->pi);
if (pd_wait_for(pd_current, STAT_READY, "do_pd_read") & STAT_ERR) {
pi_current->proto->disconnect(pi_current);
pi_disconnect(pd_current->pi);
if (pd_retries < PD_MAX_RETRIES) {
pd_retries++;
pi_unclaim(pi_current);
return Claim;
}
pi_unclaim(pi_current);
return Fail;
}
pd_ide_command(pd_current, IDE_READ, pd_block, pd_run);
......@@ -869,48 +865,41 @@ static enum action do_pd_read_drq(void)
while (1) {
if (pd_wait_for(pd_current, STAT_DRQ, "do_pd_read_drq") & STAT_ERR) {
pi_current->proto->disconnect(pi_current);
pi_disconnect(pd_current->pi);
if (pd_retries < PD_MAX_RETRIES) {
pd_retries++;
phase = do_pd_read_start;
pi_unclaim(pi_current);
return Claim;
}
pi_unclaim(pi_current);
return Fail;
}
pi_read_block(pd_current->pi, pd_buf, 512);
if (pd_next_buf())
break;
}
pi_current->proto->disconnect(pi_current);
pi_unclaim(pi_current);
pi_disconnect(pd_current->pi);
return Ok;
}
static enum action do_pd_write_start(void)
{
pi_current->proto->connect(pi_current);
pi_connect(pd_current->pi);
if (pd_wait_for(pd_current, STAT_READY, "do_pd_write") & STAT_ERR) {
pi_current->proto->disconnect(pi_current);
pi_disconnect(pd_current->pi);
if (pd_retries < PD_MAX_RETRIES) {
pd_retries++;
pi_unclaim(pi_current);
return Claim;
}
pi_unclaim(pi_current);
return Fail;
}
pd_ide_command(pd_current, IDE_WRITE, pd_block, pd_run);
while (1) {
if (pd_wait_for(pd_current, STAT_DRQ, "do_pd_write_drq") & STAT_ERR) {
pi_current->proto->disconnect(pi_current);
pi_disconnect(pd_current->pi);
if (pd_retries < PD_MAX_RETRIES) {
pd_retries++;
pi_unclaim(pi_current);
return Claim;
}
pi_unclaim(pi_current);
return Fail;
}
pi_write_block(pd_current->pi, pd_buf, 512);
......@@ -928,18 +917,15 @@ static enum action do_pd_write_done(void)
return Hold;
if (pd_wait_for(pd_current, STAT_READY, "do_pd_write_done") & STAT_ERR) {
pi_current->proto->disconnect(pi_current);
pi_disconnect(pd_current->pi);
if (pd_retries < PD_MAX_RETRIES) {
pd_retries++;
phase = do_pd_write_start;
pi_unclaim(pi_current);
return Claim;
}
pi_unclaim(pi_current);
return Fail;
}
pi_current->proto->disconnect(pi_current);
pi_unclaim(pi_current);
pi_disconnect(pd_current->pi);
return Ok;
}
......
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