Skip to content

Commit f3b10a3

Browse files
wtarreautorvalds
authored andcommitted
ataflop: use a statically allocated error counters
This is the last driver making use of fd_request->error_count, which is easy to get wrong as was shown in floppy.c. We don't need to keep it there, it can be moved to the atari_floppy_struct instead, so let's do this. Suggested-by: Linus Torvalds <torvalds@linuxfoundation.org> Cc: Minh Yuan <yuanmingbuaa@gmail.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f71f013 commit f3b10a3

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

drivers/block/ataflop.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ static struct atari_floppy_struct {
303303
int ref;
304304
int type;
305305
struct blk_mq_tag_set tag_set;
306+
int error_count;
306307
} unit[FD_MAX_UNITS];
307308

308309
#define UD unit[drive]
@@ -705,14 +706,14 @@ static void fd_error( void )
705706
if (!fd_request)
706707
return;
707708

708-
fd_request->error_count++;
709-
if (fd_request->error_count >= MAX_ERRORS) {
709+
unit[SelectedDrive].error_count++;
710+
if (unit[SelectedDrive].error_count >= MAX_ERRORS) {
710711
printk(KERN_ERR "fd%d: too many errors.\n", SelectedDrive );
711712
fd_end_request_cur(BLK_STS_IOERR);
712713
finish_fdc();
713714
return;
714715
}
715-
else if (fd_request->error_count == RECALIBRATE_ERRORS) {
716+
else if (unit[SelectedDrive].error_count == RECALIBRATE_ERRORS) {
716717
printk(KERN_WARNING "fd%d: recalibrating\n", SelectedDrive );
717718
if (SelectedDrive != -1)
718719
SUD.track = -1;
@@ -1491,7 +1492,7 @@ static void setup_req_params( int drive )
14911492
ReqData = ReqBuffer + 512 * ReqCnt;
14921493

14931494
if (UseTrackbuffer)
1494-
read_track = (ReqCmd == READ && fd_request->error_count == 0);
1495+
read_track = (ReqCmd == READ && unit[drive].error_count == 0);
14951496
else
14961497
read_track = 0;
14971498

@@ -1520,6 +1521,7 @@ static blk_status_t ataflop_queue_rq(struct blk_mq_hw_ctx *hctx,
15201521
return BLK_STS_RESOURCE;
15211522
}
15221523
fd_request = bd->rq;
1524+
unit[drive].error_count = 0;
15231525
blk_mq_start_request(fd_request);
15241526

15251527
atari_disable_irq( IRQ_MFP_FDC );

0 commit comments

Comments
 (0)