From: Kees Cook <keescook@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: Jiri Kosina <jikos@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Ming Lei <tom.leiming@gmail.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Geliang Tang <geliangtang@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH] block/floppy: Convert callback to pass timer_list
Date: Wed, 4 Oct 2017 17:49:29 -0700 [thread overview]
Message-ID: <20171005004929.GA23067@beast> (raw)
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>
---
This requires commit 686fef928bba ("timer: Prepare to change timer
callback argument type") in v4.14-rc3, but should be otherwise
stand-alone.
---
drivers/block/floppy.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 60c086a53609..9390bd078fb0 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -899,10 +899,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);
}
@@ -3043,7 +3047,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) ||
@@ -4538,7 +4542,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");
--
2.7.4
--
Kees Cook
Pixel Security
next reply other threads:[~2017-10-05 0:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-05 0:49 Kees Cook [this message]
2017-10-06 14:46 ` [PATCH] block/floppy: Convert callback to pass timer_list Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171005004929.GA23067@beast \
--to=keescook@chromium.org \
--cc=axboe@kernel.dk \
--cc=geliangtang@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=tom.leiming@gmail.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.