Skip to content

Commit baf08f0

Browse files
committed
ide: make ide_transfer_pc() static
* Move ->ticks field from struct ide_floppy_obj to ide_drive_t. * Move idefloppy_transfer_pc() to ide-atapi.c and make ide_transfer_pc() use it. * Always use ide_transfer_pc as a handler in ide_issue_pc(). * Remove no longer used idefloppy_start_pc_transfer(), ide*_transfer_pc() and 'handler' argument from ide_issue_pc(). * Make ide_transfer_pc() static. While at it: * idefloppy_transfer_pc() -> ide_delayed_transfer_pc() * IDEFLOPPY_TICKS_DELAY -> IDEFLOPPY_PC_DELAY * ->ticks -> ->pc_delay There should be no functional changes caused by this patch. Cc: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent aa5d2de commit baf08f0

6 files changed

Lines changed: 49 additions & 89 deletions

File tree

‎drivers/ide/ide-atapi.c‎

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,12 +468,22 @@ static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason)
468468
return ireason;
469469
}
470470

471-
ide_startstop_t ide_transfer_pc(ide_drive_t *drive, unsigned int timeout,
472-
ide_expiry_t *expiry)
471+
static int ide_delayed_transfer_pc(ide_drive_t *drive)
472+
{
473+
/* Send the actual packet */
474+
drive->hwif->tp_ops->output_data(drive, NULL, drive->pc->c, 12);
475+
476+
/* Timeout for the packet command */
477+
return WAIT_FLOPPY_CMD;
478+
}
479+
480+
static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)
473481
{
474482
struct ide_atapi_pc *pc = drive->pc;
475483
ide_hwif_t *hwif = drive->hwif;
476484
struct request *rq = hwif->hwgroup->rq;
485+
ide_expiry_t *expiry;
486+
unsigned int timeout;
477487
ide_startstop_t startstop;
478488
u8 ireason;
479489

@@ -493,6 +503,25 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, unsigned int timeout,
493503
return ide_do_reset(drive);
494504
}
495505

506+
/*
507+
* If necessary schedule the packet transfer to occur 'timeout'
508+
* miliseconds later in ide_delayed_transfer_pc() after the device
509+
* says it's ready for a packet.
510+
*/
511+
if (drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) {
512+
timeout = drive->pc_delay;
513+
expiry = &ide_delayed_transfer_pc;
514+
} else {
515+
if (drive->scsi) {
516+
timeout = ide_scsi_get_timeout(pc);
517+
expiry = ide_scsi_expiry;
518+
} else {
519+
timeout = (drive->media == ide_floppy) ? WAIT_FLOPPY_CMD
520+
: WAIT_TAPE_CMD;
521+
expiry = NULL;
522+
}
523+
}
524+
496525
/* Set the interrupt routine */
497526
ide_set_handler(drive, ide_pc_intr, timeout, expiry);
498527

@@ -508,10 +537,8 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, unsigned int timeout,
508537

509538
return ide_started;
510539
}
511-
EXPORT_SYMBOL_GPL(ide_transfer_pc);
512540

513-
ide_startstop_t ide_issue_pc(ide_drive_t *drive,
514-
ide_handler_t *handler, unsigned int timeout,
541+
ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,
515542
ide_expiry_t *expiry)
516543
{
517544
struct ide_atapi_pc *pc = drive->pc;
@@ -550,12 +577,12 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive,
550577

551578
/* Issue the packet command */
552579
if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) {
553-
ide_execute_command(drive, ATA_CMD_PACKET, handler,
580+
ide_execute_command(drive, ATA_CMD_PACKET, ide_transfer_pc,
554581
timeout, NULL);
555582
return ide_started;
556583
} else {
557584
ide_execute_pkt_cmd(drive);
558-
return (*handler)(drive);
585+
return ide_transfer_pc(drive);
559586
}
560587
}
561588
EXPORT_SYMBOL_GPL(ide_issue_pc);

‎drivers/ide/ide-floppy.c‎

Lines changed: 8 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@
7373
#define CAPACITY_CURRENT 0x02
7474
#define CAPACITY_NO_CARTRIDGE 0x03
7575

76-
#define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */
76+
/*
77+
* The following delay solves a problem with ATAPI Zip 100 drive where BSY bit
78+
* was apparently being deasserted before the unit was ready to receive data.
79+
*/
80+
#define IDEFLOPPY_PC_DELAY (HZ/20) /* default delay for ZIP 100 (50ms) */
7781

7882
/* Error code returned in rq->errors to the higher part of the driver. */
7983
#define IDEFLOPPY_ERROR_GENERAL 101
@@ -193,51 +197,6 @@ static void ide_floppy_callback(ide_drive_t *drive, int dsc)
193197
idefloppy_end_request(drive, uptodate, 0);
194198
}
195199

196-
/*
197-
* What we have here is a classic case of a top half / bottom half interrupt
198-
* service routine. In interrupt mode, the device sends an interrupt to signal
199-
* that it is ready to receive a packet. However, we need to delay about 2-3
200-
* ticks before issuing the packet or we gets in trouble.
201-
*/
202-
static int idefloppy_transfer_pc(ide_drive_t *drive)
203-
{
204-
/* Send the actual packet */
205-
drive->hwif->tp_ops->output_data(drive, NULL, drive->pc->c, 12);
206-
207-
/* Timeout for the packet command */
208-
return WAIT_FLOPPY_CMD;
209-
}
210-
211-
/*
212-
* Called as an interrupt (or directly). When the device says it's ready for a
213-
* packet, we schedule the packet transfer to occur about 2-3 ticks later in
214-
* transfer_pc.
215-
*/
216-
static ide_startstop_t idefloppy_start_pc_transfer(ide_drive_t *drive)
217-
{
218-
idefloppy_floppy_t *floppy = drive->driver_data;
219-
ide_expiry_t *expiry;
220-
unsigned int timeout;
221-
222-
/*
223-
* The following delay solves a problem with ATAPI Zip 100 drives
224-
* where the Busy flag was apparently being deasserted before the
225-
* unit was ready to receive data. This was happening on a
226-
* 1200 MHz Athlon system. 10/26/01 25msec is too short,
227-
* 40 and 50msec work well. ide_pc_intr will not be actually
228-
* used until after the packet is moved in about 50 msec.
229-
*/
230-
if (drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) {
231-
timeout = floppy->ticks;
232-
expiry = &idefloppy_transfer_pc;
233-
} else {
234-
timeout = WAIT_FLOPPY_CMD;
235-
expiry = NULL;
236-
}
237-
238-
return ide_transfer_pc(drive, timeout, expiry);
239-
}
240-
241200
static void ide_floppy_report_error(idefloppy_floppy_t *floppy,
242201
struct ide_atapi_pc *pc)
243202
{
@@ -281,8 +240,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
281240

282241
pc->retries++;
283242

284-
return ide_issue_pc(drive, idefloppy_start_pc_transfer,
285-
WAIT_FLOPPY_CMD, NULL);
243+
return ide_issue_pc(drive, WAIT_FLOPPY_CMD, NULL);
286244
}
287245

288246
void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *pc)
@@ -597,21 +555,7 @@ static sector_t idefloppy_capacity(ide_drive_t *drive)
597555
ide_devset_rw_field(bios_cyl, bios_cyl);
598556
ide_devset_rw_field(bios_head, bios_head);
599557
ide_devset_rw_field(bios_sect, bios_sect);
600-
601-
static int get_ticks(ide_drive_t *drive)
602-
{
603-
idefloppy_floppy_t *floppy = drive->driver_data;
604-
return floppy->ticks;
605-
}
606-
607-
static int set_ticks(ide_drive_t *drive, int arg)
608-
{
609-
idefloppy_floppy_t *floppy = drive->driver_data;
610-
floppy->ticks = arg;
611-
return 0;
612-
}
613-
614-
IDE_DEVSET(ticks, DS_SYNC, get_ticks, set_ticks);
558+
ide_devset_rw_field(ticks, pc_delay);
615559

616560
static const struct ide_proc_devset idefloppy_settings[] = {
617561
IDE_PROC_DEVSET(bios_cyl, 0, 1023),
@@ -647,7 +591,7 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
647591
if (!strncmp((char *)&id[ATA_ID_PROD], "IOMEGA ZIP 100 ATAPI", 20)) {
648592
drive->atapi_flags |= IDE_AFLAG_ZIP_DRIVE;
649593
/* This value will be visible in the /proc/ide/hdx/settings */
650-
floppy->ticks = IDEFLOPPY_TICKS_DELAY;
594+
drive->pc_delay = IDEFLOPPY_PC_DELAY;
651595
blk_queue_max_sectors(drive->queue, 64);
652596
}
653597

‎drivers/ide/ide-floppy.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ typedef struct ide_floppy_obj {
2020

2121
/* Last error information */
2222
u8 sense_key, asc, ascq;
23-
/* delay this long before sending packet command */
24-
u8 ticks;
23+
2524
int progress_indication;
2625

2726
/* Device information */

‎drivers/ide/ide-tape.c‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -654,10 +654,6 @@ static int ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
654654
* again, the callback function will be called and then we will handle the next
655655
* request.
656656
*/
657-
static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive)
658-
{
659-
return ide_transfer_pc(drive, WAIT_TAPE_CMD, NULL);
660-
}
661657

662658
static ide_startstop_t idetape_issue_pc(ide_drive_t *drive,
663659
struct ide_atapi_pc *pc)
@@ -705,7 +701,7 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive,
705701

706702
pc->retries++;
707703

708-
return ide_issue_pc(drive, idetape_transfer_pc, WAIT_TAPE_CMD, NULL);
704+
return ide_issue_pc(drive, WAIT_TAPE_CMD, NULL);
709705
}
710706

711707
/* A mode sense command is used to "sense" tape parameters. */

‎drivers/scsi/ide-scsi.c‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,6 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs)
270270
return 0;
271271
}
272272

273-
static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive)
274-
{
275-
return ide_transfer_pc(drive, ide_scsi_get_timeout(drive->pc),
276-
ide_scsi_expiry);
277-
}
278-
279273
static inline int idescsi_set_direction(struct ide_atapi_pc *pc)
280274
{
281275
switch (pc->c[0]) {
@@ -321,8 +315,7 @@ static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive,
321315
/* Set the current packet command */
322316
drive->pc = pc;
323317

324-
return ide_issue_pc(drive, idescsi_transfer_pc,
325-
ide_scsi_get_timeout(pc), ide_scsi_expiry);
318+
return ide_issue_pc(drive, ide_scsi_get_timeout(pc), ide_scsi_expiry);
326319
}
327320

328321
/*

‎include/linux/ide.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,9 @@ struct ide_drive_s {
531531
u8 bios_head; /* BIOS/fdisk/LILO number of heads */
532532
u8 bios_sect; /* BIOS/fdisk/LILO sectors per track */
533533

534+
/* delay this long before sending packet command */
535+
u8 pc_delay;
536+
534537
unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */
535538
unsigned int cyl; /* "real" number of cyls */
536539
unsigned int drive_data; /* used by set_pio_mode/selectproc */
@@ -1188,9 +1191,7 @@ static inline unsigned long ide_scsi_get_timeout(struct ide_atapi_pc *pc)
11881191

11891192
int ide_scsi_expiry(ide_drive_t *);
11901193

1191-
ide_startstop_t ide_transfer_pc(ide_drive_t *, unsigned int, ide_expiry_t *);
1192-
ide_startstop_t ide_issue_pc(ide_drive_t *,
1193-
ide_handler_t *, unsigned int, ide_expiry_t *);
1194+
ide_startstop_t ide_issue_pc(ide_drive_t *, unsigned int, ide_expiry_t *);
11941195

11951196
ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);
11961197

0 commit comments

Comments
 (0)