Commit a19a4921 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] floppy driver cleanup

From: "Randy.Dunlap" <rddunlap@osdl.org>

- use kernel.h min() and max();

- C99 initializers;

- Tidy up the scheule_work() callbacks (none of them take an arg)
parent 77aae21d
...@@ -695,23 +695,9 @@ static void reschedule_timeout(int drive, const char *message, int marg) ...@@ -695,23 +695,9 @@ static void reschedule_timeout(int drive, const char *message, int marg)
spin_unlock_irqrestore(&floppy_lock, flags); spin_unlock_irqrestore(&floppy_lock, flags);
} }
static int maximum(int a, int b) #define INFBOUND(a,b) (a)=max_t(int, a, b)
{
if (a > b)
return a;
else
return b;
}
#define INFBOUND(a,b) (a)=maximum((a),(b));
static int minimum(int a, int b) #define SUPBOUND(a,b) (a)=min_t(int, a, b)
{
if (a < b)
return a;
else
return b;
}
#define SUPBOUND(a,b) (a)=minimum((a),(b));
/* /*
...@@ -1021,9 +1007,9 @@ static void empty(void) ...@@ -1021,9 +1007,9 @@ static void empty(void)
static DECLARE_WORK(floppy_work, NULL, NULL); static DECLARE_WORK(floppy_work, NULL, NULL);
static void schedule_bh( void (*handler)(void*) ) static void schedule_bh(void (*handler) (void))
{ {
PREPARE_WORK(&floppy_work, handler, NULL); PREPARE_WORK(&floppy_work, (void (*)(void *))handler, NULL);
schedule_work(&floppy_work); schedule_work(&floppy_work);
} }
...@@ -1035,7 +1021,7 @@ static void cancel_activity(void) ...@@ -1035,7 +1021,7 @@ static void cancel_activity(void)
spin_lock_irqsave(&floppy_lock, flags); spin_lock_irqsave(&floppy_lock, flags);
do_floppy = NULL; do_floppy = NULL;
PREPARE_WORK(&floppy_work, (void*)(void*)empty, NULL); PREPARE_WORK(&floppy_work, (void*)empty, NULL);
del_timer(&fd_timer); del_timer(&fd_timer);
spin_unlock_irqrestore(&floppy_lock, flags); spin_unlock_irqrestore(&floppy_lock, flags);
} }
...@@ -1813,9 +1799,9 @@ irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs * regs) ...@@ -1813,9 +1799,9 @@ irqreturn_t floppy_interrupt(int irq, void *dev_id, struct pt_regs * regs)
max_sensei--; max_sensei--;
} while ((ST0 & 0x83) != UNIT(current_drive) && inr == 2 && max_sensei); } while ((ST0 & 0x83) != UNIT(current_drive) && inr == 2 && max_sensei);
} }
if (handler) { if (handler)
schedule_bh( (void *)(void *) handler); schedule_bh(handler);
} else else
FDCS->reset = 1; FDCS->reset = 1;
is_alive("normal interrupt end"); is_alive("normal interrupt end");
...@@ -2058,26 +2044,26 @@ static void do_wakeup(void) ...@@ -2058,26 +2044,26 @@ static void do_wakeup(void)
wake_up(&command_done); wake_up(&command_done);
} }
static struct cont_t wakeup_cont={ static struct cont_t wakeup_cont = {
empty, .interrupt = empty,
do_wakeup, .redo = do_wakeup,
empty, .error = empty,
(done_f)empty .done = (done_f) empty
}; };
static struct cont_t intr_cont={ static struct cont_t intr_cont = {
empty, .interrupt = empty,
process_fd_request, .redo = process_fd_request,
empty, .error = empty,
(done_f) empty .done = (done_f) empty
}; };
static int wait_til_done(void (*handler)(void), int interruptible) static int wait_til_done(void (*handler)(void), int interruptible)
{ {
int ret; int ret;
schedule_bh((void *)(void *)handler); schedule_bh(handler);
if (command_status < 2 && NO_SIGNAL) { if (command_status < 2 && NO_SIGNAL) {
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
...@@ -2281,11 +2267,12 @@ static void redo_format(void) ...@@ -2281,11 +2267,12 @@ static void redo_format(void)
#endif #endif
} }
static struct cont_t format_cont={ static struct cont_t format_cont = {
format_interrupt, .interrupt = format_interrupt,
redo_format, .redo = redo_format,
bad_flp_intr, .error = bad_flp_intr,
generic_done }; .done = generic_done
};
static int do_format(int drive, struct format_descr *tmp_format_req) static int do_format(int drive, struct format_descr *tmp_format_req)
{ {
...@@ -2523,12 +2510,12 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2) ...@@ -2523,12 +2510,12 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2)
int size, i; int size, i;
max_sector = transfer_size(ssize, max_sector = transfer_size(ssize,
minimum(max_sector, max_sector_2), min(max_sector, max_sector_2),
current_req->nr_sectors); current_req->nr_sectors);
if (current_count_sectors <= 0 && CT(COMMAND) == FD_WRITE && if (current_count_sectors <= 0 && CT(COMMAND) == FD_WRITE &&
buffer_max > fsector_t + current_req->nr_sectors) buffer_max > fsector_t + current_req->nr_sectors)
current_count_sectors = minimum(buffer_max - fsector_t, current_count_sectors = min_t(int, buffer_max - fsector_t,
current_req->nr_sectors); current_req->nr_sectors);
remaining = current_count_sectors << 9; remaining = current_count_sectors << 9;
...@@ -2546,7 +2533,7 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2) ...@@ -2546,7 +2533,7 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2)
} }
#endif #endif
buffer_max = maximum(max_sector, buffer_max); buffer_max = max(max_sector, buffer_max);
dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9); dma_buffer = floppy_track_buffer + ((fsector_t - buffer_min) << 9);
...@@ -2697,7 +2684,7 @@ static int make_raw_rw_request(void) ...@@ -2697,7 +2684,7 @@ static int make_raw_rw_request(void)
if ((_floppy->rate & FD_2M) && (!TRACK) && (!HEAD)){ if ((_floppy->rate & FD_2M) && (!TRACK) && (!HEAD)){
max_sector = 2 * _floppy->sect / 3; max_sector = 2 * _floppy->sect / 3;
if (fsector_t >= max_sector){ if (fsector_t >= max_sector){
current_count_sectors = minimum(_floppy->sect - fsector_t, current_count_sectors = min_t(int, _floppy->sect - fsector_t,
current_req->nr_sectors); current_req->nr_sectors);
return 1; return 1;
} }
...@@ -2987,7 +2974,7 @@ static void redo_fd_request(void) ...@@ -2987,7 +2974,7 @@ static void redo_fd_request(void)
if (TESTF(FD_NEED_TWADDLE)) if (TESTF(FD_NEED_TWADDLE))
twaddle(); twaddle();
schedule_bh( (void *)(void *) floppy_start); schedule_bh(floppy_start);
#ifdef DEBUGT #ifdef DEBUGT
debugt("queue fd request"); debugt("queue fd request");
#endif #endif
...@@ -2996,16 +2983,17 @@ static void redo_fd_request(void) ...@@ -2996,16 +2983,17 @@ static void redo_fd_request(void)
#undef REPEAT #undef REPEAT
} }
static struct cont_t rw_cont={ static struct cont_t rw_cont = {
rw_interrupt, .interrupt = rw_interrupt,
redo_fd_request, .redo = redo_fd_request,
bad_flp_intr, .error = bad_flp_intr,
request_done }; .done = request_done
};
static void process_fd_request(void) static void process_fd_request(void)
{ {
cont = &rw_cont; cont = &rw_cont;
schedule_bh( (void *)(void *) redo_fd_request); schedule_bh(redo_fd_request);
} }
static void do_fd_request(request_queue_t * q) static void do_fd_request(request_queue_t * q)
...@@ -3031,11 +3019,12 @@ static void do_fd_request(request_queue_t * q) ...@@ -3031,11 +3019,12 @@ static void do_fd_request(request_queue_t * q)
is_alive("do fd request"); is_alive("do fd request");
} }
static struct cont_t poll_cont={ static struct cont_t poll_cont = {
success_and_wakeup, .interrupt = success_and_wakeup,
floppy_ready, .redo = floppy_ready,
generic_failure, .error = generic_failure,
generic_done }; .done = generic_done
};
static int poll_drive(int interruptible, int flag) static int poll_drive(int interruptible, int flag)
{ {
...@@ -3066,11 +3055,12 @@ static void reset_intr(void) ...@@ -3066,11 +3055,12 @@ static void reset_intr(void)
printk("weird, reset interrupt called\n"); printk("weird, reset interrupt called\n");
} }
static struct cont_t reset_cont={ static struct cont_t reset_cont = {
reset_intr, .interrupt = reset_intr,
success_and_wakeup, .redo = success_and_wakeup,
generic_failure, .error = generic_failure,
generic_done }; .done = generic_done
};
static int user_reset_fdc(int drive, int arg, int interruptible) static int user_reset_fdc(int drive, int arg, int interruptible)
{ {
...@@ -3174,11 +3164,11 @@ static void raw_cmd_done(int flag) ...@@ -3174,11 +3164,11 @@ static void raw_cmd_done(int flag)
} }
static struct cont_t raw_cmd_cont={ static struct cont_t raw_cmd_cont = {
success_and_wakeup, .interrupt = success_and_wakeup,
floppy_start, .redo = floppy_start,
generic_failure, .error = generic_failure,
raw_cmd_done .done = raw_cmd_done
}; };
static inline int raw_cmd_copyout(int cmd, char *param, static inline int raw_cmd_copyout(int cmd, char *param,
......
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