Skip to content

Commit 97100fc

Browse files
committed
ide: add device flags
Add 'unsigned long dev_flags' to ide_drive_t and convert bitfields to IDE_DFLAG_* flags. While at it: - IDE_DFLAG_ADDRESSING -> IDE_DFLAG_LBA48 - fixup some comments - remove needless g->flags zeroing from ide*_probe() There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent be3c096 commit 97100fc

26 files changed

Lines changed: 370 additions & 243 deletions

‎drivers/ide/ide-acpi.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static int do_drive_get_GTF(ide_drive_t *drive,
290290
DEBPRINT("ENTER: %s at %s, port#: %d, hard_port#: %d\n",
291291
hwif->name, dev->bus_id, port, hwif->channel);
292292

293-
if (!drive->present) {
293+
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) {
294294
DEBPRINT("%s drive %d:%d not present\n",
295295
hwif->name, hwif->channel, port);
296296
goto out;
@@ -420,8 +420,9 @@ static int do_drive_set_taskfiles(ide_drive_t *drive,
420420

421421
DEBPRINT("ENTER: %s, hard_port#: %d\n", drive->name, drive->dn);
422422

423-
if (!drive->present)
423+
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
424424
goto out;
425+
425426
if (!gtf_count) /* shouldn't be here */
426427
goto out;
427428

@@ -660,7 +661,8 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on)
660661
if (!drive->acpidata->obj_handle)
661662
drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive);
662663

663-
if (drive->acpidata->obj_handle && drive->present) {
664+
if (drive->acpidata->obj_handle &&
665+
(drive->dev_flags & IDE_DFLAG_PRESENT)) {
664666
acpi_bus_set_power(drive->acpidata->obj_handle,
665667
on? ACPI_STATE_D0: ACPI_STATE_D3);
666668
}
@@ -720,7 +722,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
720722

721723
memset(drive->acpidata, 0, sizeof(*drive->acpidata));
722724

723-
if (!drive->present)
725+
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
724726
continue;
725727

726728
err = taskfile_lib_get_identify(drive, drive->acpidata->idbuff);
@@ -745,7 +747,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
745747
for (i = 0; i < MAX_DRIVES; i++) {
746748
drive = &hwif->drives[i];
747749

748-
if (drive->present)
750+
if (drive->dev_flags & IDE_DFLAG_PRESENT)
749751
/* Execute ACPI startup code */
750752
ide_acpi_exec_tfs(drive);
751753
}

‎drivers/ide/ide-atapi.c‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
261261
ide_expiry_t *expiry;
262262
unsigned int timeout, temp;
263263
u16 bcount;
264-
u8 stat, ireason, scsi = drive->scsi, dsc = 0;
264+
u8 stat, ireason, scsi = !!(drive->dev_flags & IDE_DFLAG_SCSI), dsc = 0;
265265

266266
debug_log("Enter %s - interrupt handler\n", __func__);
267267

@@ -494,7 +494,8 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)
494494
}
495495

496496
ireason = ide_read_ireason(drive);
497-
if (drive->media == ide_tape && !drive->scsi)
497+
if (drive->media == ide_tape &&
498+
(drive->dev_flags & IDE_DFLAG_SCSI) == 0)
498499
ireason = ide_wait_ireason(drive, ireason);
499500

500501
if ((ireason & ATAPI_COD) == 0 || (ireason & ATAPI_IO)) {
@@ -512,7 +513,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)
512513
timeout = drive->pc_delay;
513514
expiry = &ide_delayed_transfer_pc;
514515
} else {
515-
if (drive->scsi) {
516+
if (drive->dev_flags & IDE_DFLAG_SCSI) {
516517
timeout = ide_scsi_get_timeout(pc);
517518
expiry = ide_scsi_expiry;
518519
} else {
@@ -544,14 +545,14 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,
544545
struct ide_atapi_pc *pc = drive->pc;
545546
ide_hwif_t *hwif = drive->hwif;
546547
u16 bcount;
547-
u8 dma = 0;
548+
u8 dma = 0, scsi = !!(drive->dev_flags & IDE_DFLAG_SCSI);
548549

549550
/* We haven't transferred any data yet */
550551
pc->xferred = 0;
551552
pc->cur_pos = pc->buf;
552553

553554
/* Request to transfer the entire buffer at once */
554-
if (drive->media == ide_tape && !drive->scsi)
555+
if (drive->media == ide_tape && scsi == 0)
555556
bcount = pc->req_xfer;
556557
else
557558
bcount = min(pc->req_xfer, 63 * 1024);
@@ -561,19 +562,19 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,
561562
ide_dma_off(drive);
562563
}
563564

564-
if ((pc->flags & PC_FLAG_DMA_OK) && drive->using_dma) {
565-
if (drive->scsi)
565+
if ((pc->flags & PC_FLAG_DMA_OK) &&
566+
(drive->dev_flags & IDE_DFLAG_USING_DMA)) {
567+
if (scsi)
566568
hwif->sg_mapped = 1;
567569
dma = !hwif->dma_ops->dma_setup(drive);
568-
if (drive->scsi)
570+
if (scsi)
569571
hwif->sg_mapped = 0;
570572
}
571573

572574
if (!dma)
573575
pc->flags &= ~PC_FLAG_DMA_OK;
574576

575-
ide_pktcmd_tf_load(drive, drive->scsi ? 0 : IDE_TFLAG_OUT_DEVICE,
576-
bcount, dma);
577+
ide_pktcmd_tf_load(drive, scsi ? 0 : IDE_TFLAG_OUT_DEVICE, bcount, dma);
577578

578579
/* Issue the packet command */
579580
if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) {

‎drivers/ide/ide-cd.c‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ static ide_startstop_t cdrom_seek_intr(ide_drive_t *drive)
741741

742742
if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) {
743743
if (--retry == 0)
744-
drive->dsc_overlap = 0;
744+
drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP;
745745
}
746746
return ide_stopped;
747747
}
@@ -1129,7 +1129,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
11291129
}
11301130
cd->dma = 0;
11311131
} else
1132-
cd->dma = drive->using_dma;
1132+
cd->dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
11331133

11341134
if (write)
11351135
cd->devinfo.media_written = 1;
@@ -1166,7 +1166,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
11661166
else
11671167
buf = rq->data;
11681168

1169-
info->dma = drive->using_dma;
1169+
info->dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
11701170

11711171
/*
11721172
* check if dma is safe
@@ -1211,7 +1211,7 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
12111211
if (rq_data_dir(rq) == READ &&
12121212
IDE_LARGE_SEEK(info->last_block, block,
12131213
IDECD_SEEK_THRESHOLD) &&
1214-
drive->dsc_overlap) {
1214+
(drive->dev_flags & IDE_DFLAG_DSC_OVERLAP)) {
12151215
xferlen = 0;
12161216
fn = cdrom_start_seek_continuation;
12171217

@@ -1804,7 +1804,7 @@ static ide_proc_entry_t idecd_proc[] = {
18041804
{ NULL, 0, NULL, NULL }
18051805
};
18061806

1807-
ide_devset_rw_field(dsc_overlap, dsc_overlap);
1807+
ide_devset_rw_flag(dsc_overlap, IDE_DFLAG_DSC_OVERLAP);
18081808

18091809
static const struct ide_proc_devset idecd_settings[] = {
18101810
IDE_PROC_DEVSET(dsc_overlap, 0, 1),
@@ -1910,7 +1910,10 @@ static int ide_cdrom_setup(ide_drive_t *drive)
19101910
/* set correct block size */
19111911
blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE);
19121912

1913-
drive->dsc_overlap = (drive->next != drive);
1913+
if (drive->next != drive)
1914+
drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP;
1915+
else
1916+
drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP;
19141917

19151918
if (ide_cdrom_register(drive, nslots)) {
19161919
printk(KERN_ERR "%s: %s failed to register device with the"
@@ -1944,7 +1947,7 @@ static void ide_cd_release(struct kref *kref)
19441947
kfree(info->toc);
19451948
if (devinfo->handle == drive)
19461949
unregister_cdrom(devinfo);
1947-
drive->dsc_overlap = 0;
1950+
drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP;
19481951
drive->driver_data = NULL;
19491952
blk_queue_prep_rq(drive->queue, NULL);
19501953
g->private_data = NULL;

0 commit comments

Comments
 (0)