[PATCH 09/31] swim: Recalibrate when drive is probed
From: Finn Thain
Date: Thu Jul 16 2026 - 06:24:50 EST
Track zero recalibration can be slow and is normally done only once i.e.
during system POST or boot-up. Recalibrate once after the drive is probed
rather than every time the device is opened. Don't register the drive if
recalibration fails. Move the heads to the edge of the disk before
ejecting so that recalibration happens quickly.
Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support")
Signed-off-by: Finn Thain <fthain@xxxxxxxxxxxxxx>
---
drivers/block/swim.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/block/swim.c b/drivers/block/swim.c
index 03a89916d4ed..76f6cfa68432 100644
--- a/drivers/block/swim.c
+++ b/drivers/block/swim.c
@@ -412,6 +412,7 @@ static inline int swim_track00(struct swim __iomem *base)
if (swim_readbit(base, TRACK_ZERO))
return 0;
+ pr_err("swim: track zero recalibration failed\n");
return -1;
}
@@ -456,6 +457,7 @@ static int floppy_eject(struct floppy_state *fs)
struct swim __iomem *base = fs->swd->base;
swim_drive(base, fs->location);
+ swim_track(fs, 1);
swim_motor(base, OFF);
swim_eject(base);
swim_drive(base, NO_DRIVE);
@@ -596,13 +598,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);
-
- if (swim_track00(base))
- printk(KERN_ERR
- "SWIM: cannot move floppy head to track 0\n");
-
- swim_track00(base);
-
fs->type = swim_readbit(base, TWOMEG_MEDIA) ?
HD_MEDIA : DD_MEDIA;
fs->head_number = swim_readbit(base, SINGLE_SIDED) ? 1 : 2;
@@ -610,7 +605,6 @@ static void setup_medium(struct floppy_state *fs)
fs->total_secs = g->size;
fs->secpercyl = g->head * g->sect;
fs->secpertrack = g->sect;
- fs->track = 0;
} else {
fs->disk_in = 0;
}
@@ -773,6 +767,7 @@ static int swim_add_floppy(struct swim_priv *swd, enum drive_location location)
fs->ref_count = 0;
fs->ejected = 1;
+ fs->track = 0;
swd->floppy_count++;
@@ -827,11 +822,11 @@ static int swim_floppy_init(struct platform_device *pdev)
swim_drive(base, INTERNAL_DRIVE);
if (swim_readbit(base, DRIVE_PRESENT) &&
- !swim_readbit(base, ONEMEG_DRIVE))
+ !swim_readbit(base, ONEMEG_DRIVE) && !swim_track00(base))
swim_add_floppy(swd, INTERNAL_DRIVE);
swim_drive(base, EXTERNAL_DRIVE);
if (swim_readbit(base, DRIVE_PRESENT) &&
- !swim_readbit(base, ONEMEG_DRIVE))
+ !swim_readbit(base, ONEMEG_DRIVE) && !swim_track00(base))
swim_add_floppy(swd, EXTERNAL_DRIVE);
swim_drive(base, NO_DRIVE);
--
2.52.0