Commit 3b4de4f2 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

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

Equivalent transformation:
	now that all phase functions are called claimed, we can
	simplify the logics around claiming - new variable (pd_claimed)
	keeps track of claim/unclaim we'd done.  We check it in the
	beginning of the loop and do claiming if it's not set.
parent f35387f3
...@@ -213,6 +213,7 @@ static struct pd_unit *pd_current; /* current request's drive */ ...@@ -213,6 +213,7 @@ static struct pd_unit *pd_current; /* current request's drive */
static PIA *pi_current; /* current request's PIA */ static PIA *pi_current; /* current request's PIA */
static struct request *pd_req; /* current request */ static struct request *pd_req; /* current request */
static enum action do_pd_io_start(void); static enum action do_pd_io_start(void);
static int pd_claimed;
static struct request_queue *pd_queue; static struct request_queue *pd_queue;
static void run_fsm(void) static void run_fsm(void)
...@@ -226,6 +227,10 @@ static void run_fsm(void) ...@@ -226,6 +227,10 @@ static void run_fsm(void)
pd_current = pd_req->rq_disk->private_data; pd_current = pd_req->rq_disk->private_data;
pi_current = pd_current->pi; pi_current = pd_current->pi;
phase = do_pd_io_start; phase = do_pd_io_start;
}
if (!pd_claimed) {
pd_claimed = 1;
if (!pi_schedule_claimed(pi_current, run_fsm)) if (!pi_schedule_claimed(pi_current, run_fsm))
return; return;
} }
...@@ -233,6 +238,7 @@ static void run_fsm(void) ...@@ -233,6 +238,7 @@ static void run_fsm(void)
switch(res = phase()) { switch(res = phase()) {
case Ok: case Fail: case Ok: case Fail:
pi_unclaim(pi_current); pi_unclaim(pi_current);
pd_claimed = 0;
phase = NULL; phase = NULL;
spin_lock_irqsave(&pd_lock, saved_flags); spin_lock_irqsave(&pd_lock, saved_flags);
end_request(pd_req, res); end_request(pd_req, res);
...@@ -247,9 +253,7 @@ static void run_fsm(void) ...@@ -247,9 +253,7 @@ static void run_fsm(void)
return; return;
case Wait: case Wait:
pi_unclaim(pi_current); pi_unclaim(pi_current);
if (!pi_schedule_claimed(pi_current, run_fsm)) pd_claimed = 0;
return;
break;
} }
} }
} }
......
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