Re: [PATCH 09/31] swim: Recalibrate when drive is probed
Laurent Vivier <[email protected]> Mon, 20 Jul 2026 21:12:16 +0200
| Newsgroups | org.kernel.vger.linux-m68k,org.kernel.vger.linux-block,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Le 16/07/2026 =C3=A0 12:02, Finn Thain a =C3=A9crit=C2=A0:
> 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 probe=
d
> 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.
>=20
> Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support")
> Signed-off-by: Finn Thain <[email protected]>
> ---
> drivers/block/swim.c | 15 +++++----------
> 1 file changed, 5 insertions(+), 10 deletions(-)
Reviewed-by: Laurent Vivier <[email protected]>
>=20
> 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;
> =20
> + pr_err("swim: track zero recalibration failed\n");
> return -1;
> }
> =20
> @@ -456,6 +457,7 @@ static int floppy_eject(struct floppy_state *fs)
> struct swim __iomem *base =3D fs->swd->base;
> =20
> 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 =3D 1;
> fs->write_protected =3D 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 =3D swim_readbit(base, TWOMEG_MEDIA) ?
> HD_MEDIA : DD_MEDIA;
> fs->head_number =3D swim_readbit(base, SINGLE_SIDED) ? 1 : 2;
> @@ -610,7 +605,6 @@ static void setup_medium(struct floppy_state *fs)
> fs->total_secs =3D g->size;
> fs->secpercyl =3D g->head * g->sect;
> fs->secpertrack =3D g->sect;
> - fs->track =3D 0;
> } else {
> fs->disk_in =3D 0;
> }
> @@ -773,6 +767,7 @@ static int swim_add_floppy(struct swim_priv *swd, en=
um drive_location location)
> =20
> fs->ref_count =3D 0;
> fs->ejected =3D 1;
> + fs->track =3D 0;
> =20
> swd->floppy_count++;
> =20
> @@ -827,11 +822,11 @@ static int swim_floppy_init(struct platform_device=
*pdev)
> =20
> 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);
> =20