Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp445013ybb; Fri, 10 Apr 2020 03:20:18 -0700 (PDT) X-Google-Smtp-Source: APiQypJilwMDGkP0thFxk4SA2axUU/BjsQYUx0oWrhkpDIcVVuGsW6pK63yjssf36VBPoz9NIORH X-Received: by 2002:ac8:7769:: with SMTP id h9mr3719795qtu.234.1586514018079; Fri, 10 Apr 2020 03:20:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586514018; cv=none; d=google.com; s=arc-20160816; b=oisBvisAOFdBCBmehILZnJMx++cijHXyeuo5OplrJDXor1VPR+yHsPlG7jSx7cfZFQ Pjghc4eRS7lBK+3SBJP09uRB8AynRmcJWCoBZmsV0mXDEcBSPvruGBHouvt1pHQzAMvf ybAlhdy8Pw7dFpdYhuil9BabRhlmIB/54zMqOSApXsYeb7ZrivJPzwX8gG+fDDdjCSTk vYEHJhmEwVuh2tWEEigoeifBIkkIsavnCfQ6Rw8Iz5COvyusY2D8Z/A8DqwIIT0AsZne 1FMtR6Zfd0Yfy+/enyL/2NSiEFYNEy5Hl3fQfj5oUFOjD7ZrXZgiG2SLYf+j2nf0v/oQ Pm+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=7fNy0SyRJCIejzP3SFY8sFg1WmomqwZPTMP7U4l1PUA=; b=eZqy7qh/dPq7c2vP/OLQiLPSVJgvOFcAHIRJo+ipSxcA5+6Vbs7k2aI0JIjMuVKwST K59/cM8ER1utiveei0QXUGIZ2zFs+41IU5bCW/ymacdeiEZw8GzhgpeEbjQbC9yyweTb 4TCXhGRKS3WiJZRRC9Jqi3CpsgTzyUQ1OZdx3QssLKal3uls5m2wlrU3cvEbE6u5ZOP/ EqG3SaJxOUTL1FZAEDARw2h0FwoHhFcNxnSnas+agPP2vTfhnYm8RN/5UO8FoW6Xe2Rb +IwvV3mst99iGOS+hMwwhIaIbXPofqZ42dbaRSuP/Wn6ySlmWf/15HN3Xyiyt9HmDFLP 1lPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17si856053qtk.333.2020.04.10.03.20.03; Fri, 10 Apr 2020 03:20:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726594AbgDJKTR (ORCPT + 99 others); Fri, 10 Apr 2020 06:19:17 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:34485 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbgDJKTR (ORCPT ); Fri, 10 Apr 2020 06:19:17 -0400 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 03AAJ96S014696; Fri, 10 Apr 2020 12:19:09 +0200 From: Willy Tarreau To: Denis Efremov Cc: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Willy Tarreau Subject: [PATCH 27/23] floppy: cleanup: make set_fdc() always set current_drive and current_fd Date: Fri, 10 Apr 2020 12:19:04 +0200 Message-Id: <20200410101904.14652-3-w@1wt.eu> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20200410101904.14652-1-w@1wt.eu> References: <20200331094054.24441-23-w@1wt.eu> <20200410101904.14652-1-w@1wt.eu> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When called with a negative drive value, set_fdc() would stick to the current fdc (which was assumed to reflect the current_drive's FDC). We do not need this anymore as the last call place with a negative value was just addressed. Let's make this function always set both current_fdc and current_drive so that there's no more ambiguity. A few comments stating this were added to a few non-obvious places. Signed-off-by: Willy Tarreau --- drivers/block/floppy.c | 43 ++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 20646d4c5437..2817170dd403 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -851,31 +851,42 @@ static void reset_fdc_info(int fdc, int mode) drive_state[drive].track = NEED_2_RECAL; } -/* selects the fdc and drive, and enables the fdc's input/dma. */ +/* + * selects the fdc and drive, and enables the fdc's input/dma. + * Both current_drive and current_fdc are changed to match the new drive. + */ static void set_fdc(int drive) { - unsigned int new_fdc = current_fdc; + unsigned int fdc; - if (drive >= 0 && drive < N_DRIVE) { - new_fdc = FDC(drive); - current_drive = drive; + if (drive < 0 || drive >= N_DRIVE) { + pr_info("bad drive value %d\n", drive); + return; } - if (new_fdc >= N_FDC) { + + fdc = FDC(drive); + if (fdc >= N_FDC) { pr_info("bad fdc value\n"); return; } - current_fdc = new_fdc; - set_dor(current_fdc, ~0, 8); + + set_dor(fdc, ~0, 8); #if N_FDC > 1 - set_dor(1 - current_fdc, ~8, 0); + set_dor(1 - fdc, ~8, 0); #endif - if (fdc_state[current_fdc].rawcmd == 2) - reset_fdc_info(current_fdc, 1); - if (fdc_inb(current_fdc, FD_STATUS) != STATUS_READY) - fdc_state[current_fdc].reset = 1; + if (fdc_state[fdc].rawcmd == 2) + reset_fdc_info(fdc, 1); + if (fdc_inb(fdc, FD_STATUS) != STATUS_READY) + fdc_state[fdc].reset = 1; + + current_drive = drive; + current_fdc = fdc; } -/* locks the driver */ +/* + * locks the driver. + * Both current_drive and current_fdc are changed to match the new drive. + */ static int lock_fdc(int drive) { if (WARN(atomic_read(&usage_count) == 0, @@ -3000,6 +3011,10 @@ static const struct cont_t reset_cont = { .done = generic_done }; +/* + * Resets the FDC connected to drive . + * Both current_drive and current_fdc are changed to match the new drive. + */ static int user_reset_fdc(int drive, int arg, bool interruptible) { int ret; -- 2.20.1