]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
block/floppy: Convert callback to pass timer_list
authorKees Cook <keescook@chromium.org>
Thu, 5 Oct 2017 00:49:29 +0000 (17:49 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 15 Nov 2017 03:10:35 +0000 (20:10 -0700)
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to passing in the timer pointer explicitly.
Calculate the drive from the offset of the timer in the timer list.

Cc: Jiri Kosina <jikos@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Ming Lei <tom.leiming@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Geliang Tang <geliangtang@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/floppy.c

index a54183935aa1a7562e328e34be5de94ced530fb2..eae484acfbbc1d4c8228b5524b4d30070793620a 100644 (file)
@@ -903,10 +903,14 @@ static void unlock_fdc(void)
 }
 
 /* switches the motor off after a given timeout */
-static void motor_off_callback(unsigned long nr)
+static void motor_off_callback(struct timer_list *t)
 {
+       unsigned long nr = t - motor_off_timer;
        unsigned char mask = ~(0x10 << UNIT(nr));
 
+       if (WARN_ON_ONCE(nr >= N_DRIVE))
+               return;
+
        set_dor(FDC(nr), mask, 0);
 }
 
@@ -3047,7 +3051,7 @@ static void raw_cmd_done(int flag)
                else
                        raw_cmd->flags &= ~FD_RAW_DISK_CHANGE;
                if (raw_cmd->flags & FD_RAW_NO_MOTOR_AFTER)
-                       motor_off_callback(current_drive);
+                       motor_off_callback(&motor_off_timer[current_drive]);
 
                if (raw_cmd->next &&
                    (!(raw_cmd->flags & FD_RAW_FAILURE) ||
@@ -4542,7 +4546,7 @@ static int __init do_floppy_init(void)
                disks[drive]->fops = &floppy_fops;
                sprintf(disks[drive]->disk_name, "fd%d", drive);
 
-               setup_timer(&motor_off_timer[drive], motor_off_callback, drive);
+               timer_setup(&motor_off_timer[drive], motor_off_callback, 0);
        }
 
        err = register_blkdev(FLOPPY_MAJOR, "fd");