From: viro@parcelfarce.linux.theplanet.co.uk 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. --- 25-akpm/drivers/block/paride/pd.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff -puN drivers/block/paride/pd.c~PI16-pd_claimed-RC1 drivers/block/paride/pd.c --- 25/drivers/block/paride/pd.c~PI16-pd_claimed-RC1 Wed Jan 14 13:46:20 2004 +++ 25-akpm/drivers/block/paride/pd.c Wed Jan 14 13:46:20 2004 @@ -213,6 +213,7 @@ static struct pd_unit *pd_current; /* cu static PIA *pi_current; /* current request's PIA */ static struct request *pd_req; /* current request */ static enum action do_pd_io_start(void); +static int pd_claimed; static struct request_queue *pd_queue; static void run_fsm(void) @@ -226,6 +227,10 @@ static void run_fsm(void) pd_current = pd_req->rq_disk->private_data; pi_current = pd_current->pi; phase = do_pd_io_start; + } + + if (!pd_claimed) { + pd_claimed = 1; if (!pi_schedule_claimed(pi_current, run_fsm)) return; } @@ -233,6 +238,7 @@ static void run_fsm(void) switch(res = phase()) { case Ok: case Fail: pi_unclaim(pi_current); + pd_claimed = 0; phase = NULL; spin_lock_irqsave(&pd_lock, saved_flags); end_request(pd_req, res); @@ -247,9 +253,7 @@ static void run_fsm(void) return; case Wait: pi_unclaim(pi_current); - if (!pi_schedule_claimed(pi_current, run_fsm)) - return; - break; + pd_claimed = 0; } } } _