Received: by 10.213.65.68 with SMTP id h4csp1078773imn; Sat, 31 Mar 2018 18:43:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/YG96WQlS/AisbOWe1Kvd0Sbvdohay8vyRu6p4d2L0DqlEG54yHSQrO444JZ4lESm7n5xJ X-Received: by 2002:a17:902:8304:: with SMTP id bd4-v6mr4788917plb.70.1522547007685; Sat, 31 Mar 2018 18:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522547007; cv=none; d=google.com; s=arc-20160816; b=yqkB0Elnanc305Aq2CBKWInclxUpCk1TQJJhn63f2ijVZytgLXY3CiFlPw6klpYbx4 2L1lTCkFwQq4nV5mn9Sf5dKe+A0j/sP4JuaMYEhSweOF6jwKiGxLD/xPz+AStX4ouVHN RgAu7sm/rgTXcsyD8tZtkFjihTkIXSF5rlm6vI2x3ZVsOnfENj8dePfNM6/9vyZ5oJjt lmBX4JjjZ1uBfGU47D+t6nxOvzzP7RdaSupbIzTPBNi/F0XFWnPmeAryo7l67CsuRdiv 8AtNrObIrPfpU8e26s9rfugdnJ18FsC2BqrXjyjChpsU1Eu4HGTtGCSe4WeY3JnTAQ3L GJaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:from:references:in-reply-to :message-id:cc:to:arc-authentication-results; bh=88n+yQmC86h7I4fdK/8Dt9HGxoO7TF++kCOyBtXH8rE=; b=LRYaqmEprbpDgX0K5SKihH3DCnmehxDfiEW925AQ/p2rNsHEKMhIoREoWF4t2+NOby 0c6jq7x5xV8FKn+q3q9TNgmUXt08mD8NzL58bq6356uRR6FQfGn73eU2g78f8PFth0+t wXvgz3Mu7mo3RrHkJce8KHfHQDQOCbUaMWtGZedqKRdiQB58UBLFfjgXa3EQNWSKvhhN a0uZ/vy5Zt3PEHTbQGoC8uSJsqet1t22YcaTeV+6ayCfT/obpH0qG52UYYt9Ov7IxSku OhzCKjiMUKhIgYY8auPD3gBdCJ69PpetM2MhHsQBUBFrCa2zd7WdNPlFrkAQYK8rDeCr Lukw== 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 f78si8654977pfa.79.2018.03.31.18.43.14; Sat, 31 Mar 2018 18:43:27 -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 S1753294AbeDABld (ORCPT + 99 others); Sat, 31 Mar 2018 21:41:33 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:47454 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753203AbeDABlK (ORCPT ); Sat, 31 Mar 2018 21:41:10 -0400 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 622F222989; Sat, 31 Mar 2018 21:41:05 -0400 (EDT) To: Geert Uytterhoeven Cc: Laurent Vivier , Jens Axboe , linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-Id: In-Reply-To: References: From: Finn Thain Subject: [PATCH 11/12] block/swim: Fix IO error at end of medium Date: Sat, 31 Mar 2018 21:41:05 -0400 (EDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Reading to the end of a 720K disk results in an IO error instead of EOF because the block layer thinks the disk has 2880 sectors. (Partly this is a result of inverted logic of the ONEMEG_MEDIA bit that's now fixed.) Initialize the density and head count in swim_add_floppy() to agree with the device size passed to set_capacity() during drive probe. Call set_capacity() again upon device open, after refreshing the density and head count values. Cc: Laurent Vivier Cc: Jens Axboe Tested-by: Stan Johnson Signed-off-by: Finn Thain --- drivers/block/swim.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 6e3ebf5519e3..c4eb54575574 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -619,7 +619,6 @@ static void setup_medium(struct floppy_state *fs) struct floppy_struct *g; fs->disk_in = 1; fs->write_protected = swim_readbit(base, WRITE_PROT); - fs->type = swim_readbit(base, TWOMEG_MEDIA); if (swim_track00(base)) printk(KERN_ERR @@ -627,6 +626,9 @@ static void setup_medium(struct floppy_state *fs) swim_track00(base); + fs->type = swim_readbit(base, TWOMEG_MEDIA) ? + HD_MEDIA : DD_MEDIA; + fs->head_number = swim_readbit(base, SINGLE_SIDED) ? 1 : 2; get_floppy_geometry(fs, 0, &g); fs->total_secs = g->size; fs->secpercyl = g->head * g->sect; @@ -668,6 +670,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) goto out; } + set_capacity(fs->disk, fs->total_secs); + if (mode & FMODE_NDELAY) return 0; @@ -820,10 +824,9 @@ static int swim_add_floppy(struct swim_priv *swd, enum drive_location location) swim_motor(base, OFF); - if (swim_readbit(base, SINGLE_SIDED)) - fs->head_number = 1; - else - fs->head_number = 2; + fs->type = HD_MEDIA; + fs->head_number = 2; + fs->ref_count = 0; fs->ejected = 1; -- 2.16.1