From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752134AbdJEAtg (ORCPT ); Wed, 4 Oct 2017 20:49:36 -0400 Received: from mail-pg0-f53.google.com ([74.125.83.53]:52963 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751234AbdJEAtc (ORCPT ); Wed, 4 Oct 2017 20:49:32 -0400 X-Google-Smtp-Source: AOwi7QBKkc5UPiwRspUXepHZimADzzW3c3jte1M2vgI0k2c0rDR4JDljhOFYvremLN2IeZiM3HENnw== Date: Wed, 4 Oct 2017 17:49:29 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Jiri Kosina , Jens Axboe , Ming Lei , Al Viro , Geliang Tang , Thomas Gleixner Subject: [PATCH] block/floppy: Convert callback to pass timer_list Message-ID: <20171005004929.GA23067@beast> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Jens Axboe Cc: Ming Lei Cc: Al Viro Cc: Geliang Tang Cc: Thomas Gleixner Signed-off-by: Kees Cook --- 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