Re: [PATCH 13/31] swim: Check for CRC errors

Laurent Vivier <[email protected]> Mon, 20 Jul 2026 21:37:27 +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:
> After reading either the sector header or sector data, examine that flag
> in the handshake register which holds the result of the CRC calculation.
> CRC validation has to take place with the last byte still in the FIFO.
> This flag can't be checked by the caller because by then all bytes will
> have been retrieved from the FIFO. Return an error code when appropriate=
.
>=20
> Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support")
> Signed-off-by: Finn Thain <[email protected]>
> ---
>   drivers/block/swim_asm.S | 16 ++++++++++++----
>   1 file changed, 12 insertions(+), 4 deletions(-)

Reviewed-by: Laurent Vivier <[email protected]>

>=20
> diff --git a/drivers/block/swim_asm.S b/drivers/block/swim_asm.S
> index 31fc63b074dc..f40e19e48021 100644
> --- a/drivers/block/swim_asm.S
> +++ b/drivers/block/swim_asm.S
> @@ -42,6 +42,8 @@
>   	.equ	max_retry, 40
>   	.equ	sector_size, 512
>  =20
> +	.equ	.Lhr_crc_error,		0x02
> +
>   	.global swim_read_sector_header
>   swim_read_sector_header:
>   	link	%a6, #0
> @@ -128,12 +130,15 @@ crc0:	tstb	%a2@
>  =20
>   	moveq	#max_retry, %d2
>  =20
> -crc1:	tstb	%a2@
> +crc1:	moveb	%a2@, %d5
>   	dbmi	%d2, crc1
>   	bpl	signal_nonyb
>  =20
>   	moveb	%a3@, %a4@(o_crc1)
>  =20
> +	andb	#.Lhr_crc_error, %d5
> +	bne	signal_nonyb
> +
>   	tstb	%a3@(read_error - read_mark)
>  =20
>   	moveq	#0, %d0
> @@ -212,17 +217,20 @@ data_crc0:
>   	dbmi	%d2, data_crc0
>   	bpl	data_exit
>  =20
> -	moveb	%a3@, %d5
> +	moveb	%a3@, %d2
>  =20
>   	moveq	#max_retry, %d2
>  =20
>   data_crc1:
>  =20
> -	tstb	%a2@
> +	moveb	%a2@, %d5
>   	dbmi	%d2, data_crc1
>   	bpl	data_exit
>  =20
> -	moveb	%a3@, %d5
> +	moveb	%a3@, %d2
> +
> +	andb	#.Lhr_crc_error, %d5
> +	bne	data_exit
>  =20
>   	tstb	%a3@(read_error - read_mark)
>  =20