From: viro@parcelfarce.linux.theplanet.co.uk Equivalent transformation: * ps_continuation renamed - it's "phase" now. * run_fsm() does what ps_tq_int() used to do * calls of pi_do_claimed(..., func) replaced with phase = func; pi_do_claimed(..., run_fsm); Now all phase functions are called from run_fsm() and we can start pulling the common code into it. --- 25-akpm/drivers/block/paride/pd.c | 32 ++++++++++++++++++++------------ 1 files changed, 20 insertions(+), 12 deletions(-) diff -puN drivers/block/paride/pd.c~PI9-run_fsm-RC1 drivers/block/paride/pd.c --- 25/drivers/block/paride/pd.c~PI9-run_fsm-RC1 Wed Jan 14 13:46:19 2004 +++ 25-akpm/drivers/block/paride/pd.c Wed Jan 14 13:46:19 2004 @@ -194,7 +194,7 @@ MODULE_PARM(drive3, "1-8i"); static void ps_tq_int( void *data); -static void (* ps_continuation)(void); +static void (*phase)(void); static unsigned long ps_timeout; static DECLARE_WORK(ps_tq, ps_tq_int, NULL); @@ -207,9 +207,14 @@ static void ps_set_intr(void) schedule_delayed_work(&ps_tq, nice-1); } +static void run_fsm(void) +{ + phase(); +} + static void ps_tq_int(void *data) { - ps_continuation(); + run_fsm(); } #define PD_BITS 4 @@ -750,7 +755,7 @@ static void do_pd_request(request_queue_ if (!pd_req) return; - ps_continuation = do_pd_io; + phase = do_pd_io; ps_set_intr(); } @@ -787,14 +792,15 @@ static inline void next_request(int succ } spin_unlock_irqrestore(&pd_lock, saved_flags); - ps_continuation = do_pd_io; + phase = do_pd_io; ps_set_intr(); } static void do_pd_io(void) { pd_current = pd_req->rq_disk->private_data; - pi_do_claimed(pd_current->pi, do_pd_io_start); + phase = do_pd_io_start; + pi_do_claimed(pd_current->pi, run_fsm); } static void do_pd_io_start(void) @@ -829,14 +835,14 @@ static void do_pd_read_start(void) pi_disconnect(pd_current->pi); if (pd_retries < PD_MAX_RETRIES) { pd_retries++; - pi_do_claimed(pd_current->pi, do_pd_read_start); + pi_do_claimed(pd_current->pi, run_fsm); return; } next_request(0); return; } pd_ide_command(pd_current, IDE_READ, pd_block, pd_run); - ps_continuation = do_pd_read_drq; + phase = do_pd_read_drq; ps_timeout = jiffies + PD_TMO; ps_set_intr(); } @@ -852,7 +858,8 @@ static void do_pd_read_drq(void) pi_disconnect(pd_current->pi); if (pd_retries < PD_MAX_RETRIES) { pd_retries++; - pi_do_claimed(pd_current->pi, do_pd_read_start); + phase = do_pd_read_start; + pi_do_claimed(pd_current->pi, run_fsm); return; } next_request(0); @@ -873,7 +880,7 @@ static void do_pd_write_start(void) pi_disconnect(pd_current->pi); if (pd_retries < PD_MAX_RETRIES) { pd_retries++; - pi_do_claimed(pd_current->pi, do_pd_write_start); + pi_do_claimed(pd_current->pi, run_fsm); return; } next_request(0); @@ -885,7 +892,7 @@ static void do_pd_write_start(void) pi_disconnect(pd_current->pi); if (pd_retries < PD_MAX_RETRIES) { pd_retries++; - pi_do_claimed(pd_current->pi, do_pd_write_start); + pi_do_claimed(pd_current->pi, run_fsm); return; } next_request(0); @@ -895,7 +902,7 @@ static void do_pd_write_start(void) if (pd_next_buf()) break; } - ps_continuation = do_pd_write_done; + phase = do_pd_write_done; ps_timeout = jiffies + PD_TMO; ps_set_intr(); } @@ -910,7 +917,8 @@ static void do_pd_write_done(void) pi_disconnect(pd_current->pi); if (pd_retries < PD_MAX_RETRIES) { pd_retries++; - pi_do_claimed(pd_current->pi, do_pd_write_start); + phase = do_pd_write_start; + pi_do_claimed(pd_current->pi, run_fsm); return; } next_request(0); _