Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97100fc8 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

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: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent be3c096e
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -290,7 +290,7 @@ static int do_drive_get_GTF(ide_drive_t *drive,
	DEBPRINT("ENTER: %s at %s, port#: %d, hard_port#: %d\n",
		 hwif->name, dev->bus_id, port, hwif->channel);

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

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

	if (!drive->present)
	if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
		goto out;

	if (!gtf_count)		/* shouldn't be here */
		goto out;

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

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

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

		if (!drive->present)
		if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
			continue;

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

		if (drive->present)
		if (drive->dev_flags & IDE_DFLAG_PRESENT)
			/* Execute ACPI startup code */
			ide_acpi_exec_tfs(drive);
	}
+11 −10
Original line number Diff line number Diff line
@@ -261,7 +261,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
	ide_expiry_t *expiry;
	unsigned int timeout, temp;
	u16 bcount;
	u8 stat, ireason, scsi = drive->scsi, dsc = 0;
	u8 stat, ireason, scsi = !!(drive->dev_flags & IDE_DFLAG_SCSI), dsc = 0;

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

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

	ireason = ide_read_ireason(drive);
	if (drive->media == ide_tape && !drive->scsi)
	if (drive->media == ide_tape &&
	    (drive->dev_flags & IDE_DFLAG_SCSI) == 0)
		ireason = ide_wait_ireason(drive, ireason);

	if ((ireason & ATAPI_COD) == 0 || (ireason & ATAPI_IO)) {
@@ -512,7 +513,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)
		timeout = drive->pc_delay;
		expiry = &ide_delayed_transfer_pc;
	} else {
		if (drive->scsi) {
		if (drive->dev_flags & IDE_DFLAG_SCSI) {
			timeout = ide_scsi_get_timeout(pc);
			expiry = ide_scsi_expiry;
		} else {
@@ -544,14 +545,14 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,
	struct ide_atapi_pc *pc = drive->pc;
	ide_hwif_t *hwif = drive->hwif;
	u16 bcount;
	u8 dma = 0;
	u8 dma = 0, scsi = !!(drive->dev_flags & IDE_DFLAG_SCSI);

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

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

	if ((pc->flags & PC_FLAG_DMA_OK) && drive->using_dma) {
		if (drive->scsi)
	if ((pc->flags & PC_FLAG_DMA_OK) &&
	    (drive->dev_flags & IDE_DFLAG_USING_DMA)) {
		if (scsi)
			hwif->sg_mapped = 1;
		dma = !hwif->dma_ops->dma_setup(drive);
		if (drive->scsi)
		if (scsi)
			hwif->sg_mapped = 0;
	}

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

	ide_pktcmd_tf_load(drive, drive->scsi ? 0 : IDE_TFLAG_OUT_DEVICE,
			   bcount, dma);
	ide_pktcmd_tf_load(drive, scsi ? 0 : IDE_TFLAG_OUT_DEVICE, bcount, dma);

	/* Issue the packet command */
	if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) {
+10 −7
Original line number Diff line number Diff line
@@ -741,7 +741,7 @@ static ide_startstop_t cdrom_seek_intr(ide_drive_t *drive)

	if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) {
		if (--retry == 0)
			drive->dsc_overlap = 0;
			drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP;
	}
	return ide_stopped;
}
@@ -1129,7 +1129,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
		}
		cd->dma = 0;
	} else
		cd->dma = drive->using_dma;
		cd->dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA);

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

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

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

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

ide_devset_rw_field(dsc_overlap, dsc_overlap);
ide_devset_rw_flag(dsc_overlap, IDE_DFLAG_DSC_OVERLAP);

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

	drive->dsc_overlap = (drive->next != drive);
	if (drive->next != drive)
		drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP;
	else
		drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP;

	if (ide_cdrom_register(drive, nslots)) {
		printk(KERN_ERR "%s: %s failed to register device with the"
@@ -1944,7 +1947,7 @@ static void ide_cd_release(struct kref *kref)
	kfree(info->toc);
	if (devinfo->handle == drive)
		unregister_cdrom(devinfo);
	drive->dsc_overlap = 0;
	drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP;
	drive->driver_data = NULL;
	blk_queue_prep_rq(drive->queue, NULL);
	g->private_data = NULL;
+57 −37
Original line number Diff line number Diff line
@@ -140,9 +140,9 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
					sector_t block)
{
	ide_hwif_t *hwif	= HWIF(drive);
	unsigned int dma	= drive->using_dma;
	u16 nsectors		= (u16)rq->nr_sectors;
	u8 lba48		= (drive->addressing == 1) ? 1 : 0;
	u8 lba48		= !!(drive->dev_flags & IDE_DFLAG_LBA48);
	u8 dma			= !!(drive->dev_flags & IDE_DFLAG_USING_DMA);
	ide_task_t		task;
	struct ide_taskfile	*tf = &task.tf;
	ide_startstop_t		rc;
@@ -237,7 +237,7 @@ static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
{
	ide_hwif_t *hwif = HWIF(drive);

	BUG_ON(drive->blocked);
	BUG_ON(drive->dev_flags & IDE_DFLAG_BLOCKED);

	if (!blk_fs_request(rq)) {
		blk_dump_rq_flags(rq, "ide_do_rw_disk - bad command");
@@ -452,7 +452,7 @@ static int proc_idedisk_read_cache
	char		*out = page;
	int		len;

	if (drive->id_read)
	if (drive->dev_flags & IDE_DFLAG_ID_READ)
		len = sprintf(out, "%i\n", drive->id[ATA_ID_BUF_SIZE] / 2);
	else
		len = sprintf(out, "(none)\n");
@@ -568,15 +568,20 @@ static int set_multcount(ide_drive_t *drive, int arg)
	return (drive->mult_count == arg) ? 0 : -EIO;
}

ide_devset_get(nowerr, nowerr);
ide_devset_get_flag(nowerr, IDE_DFLAG_NOWERR);

static int set_nowerr(ide_drive_t *drive, int arg)
{
	if (arg < 0 || arg > 1)
		return -EINVAL;

	drive->nowerr = arg;
	if (arg)
		drive->dev_flags |= IDE_DFLAG_NOWERR;
	else
		drive->dev_flags &= ~IDE_DFLAG_NOWERR;

	drive->bad_wstat = arg ? BAD_R_STAT : BAD_W_STAT;

	return 0;
}

@@ -599,7 +604,7 @@ static void update_ordered(ide_drive_t *drive)
	unsigned ordered = QUEUE_ORDERED_NONE;
	prepare_flush_fn *prep_fn = NULL;

	if (drive->wcache) {
	if (drive->dev_flags & IDE_DFLAG_WCACHE) {
		unsigned long long capacity;
		int barrier;
		/*
@@ -611,8 +616,10 @@ static void update_ordered(ide_drive_t *drive)
		 * not available so we don't need to recheck that.
		 */
		capacity = idedisk_capacity(drive);
		barrier = ata_id_flush_enabled(id) && !drive->noflush &&
			(drive->addressing == 0 || capacity <= (1ULL << 28) ||
		barrier = ata_id_flush_enabled(id) &&
			(drive->dev_flags & IDE_DFLAG_NOFLUSH) == 0 &&
			((drive->dev_flags & IDE_DFLAG_LBA48) == 0 ||
			 capacity <= (1ULL << 28) ||
			 ata_id_flush_ext_enabled(id));

		printk(KERN_INFO "%s: cache flushes %ssupported\n",
@@ -628,7 +635,7 @@ static void update_ordered(ide_drive_t *drive)
	blk_queue_ordered(drive->queue, ordered, prep_fn);
}

ide_devset_get(wcache, wcache);
ide_devset_get_flag(wcache, IDE_DFLAG_WCACHE);

static int set_wcache(ide_drive_t *drive, int arg)
{
@@ -640,8 +647,12 @@ static int set_wcache(ide_drive_t *drive, int arg)
	if (ata_id_flush_enabled(drive->id)) {
		err = ide_do_setfeature(drive,
			arg ? SETFEATURES_WC_ON : SETFEATURES_WC_OFF, 0);
		if (err == 0)
			drive->wcache = arg;
		if (err == 0) {
			if (arg)
				drive->dev_flags |= IDE_DFLAG_WCACHE;
			else
				drive->dev_flags &= ~IDE_DFLAG_WCACHE;
		}
	}

	update_ordered(drive);
@@ -677,7 +688,7 @@ static int set_acoustic(ide_drive_t *drive, int arg)
	return 0;
}

ide_devset_get(addressing, addressing);
ide_devset_get_flag(addressing, IDE_DFLAG_LBA48);

/*
 * drive->addressing:
@@ -697,7 +708,10 @@ static int set_addressing(ide_drive_t *drive, int arg)
	if (arg == 2)
		arg = 0;

	drive->addressing = arg;
	if (arg)
		drive->dev_flags |= IDE_DFLAG_LBA48;
	else
		drive->dev_flags &= ~IDE_DFLAG_LBA48;

	return 0;
}
@@ -743,20 +757,20 @@ static void idedisk_setup(ide_drive_t *drive)

	ide_proc_register_driver(drive, idkp->driver);

	if (drive->id_read == 0)
	if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0)
		return;

	if (drive->removable) {
	if (drive->dev_flags & IDE_DFLAG_REMOVABLE) {
		/*
		 * Removable disks (eg. SYQUEST); ignore 'WD' drives
		 */
		if (m[0] != 'W' || m[1] != 'D')
			drive->doorlocking = 1;
			drive->dev_flags |= IDE_DFLAG_DOORLOCKING;
	}

	(void)set_addressing(drive, 1);

	if (drive->addressing == 1) {
	if (drive->dev_flags & IDE_DFLAG_LBA48) {
		int max_s = 2048;

		if (max_s > hwif->rqsize)
@@ -772,7 +786,8 @@ static void idedisk_setup(ide_drive_t *drive)
	init_idedisk_capacity(drive);

	/* limit drive capacity to 137GB if LBA48 cannot be used */
	if (drive->addressing == 0 && drive->capacity64 > 1ULL << 28) {
	if ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 &&
	    drive->capacity64 > 1ULL << 28) {
		printk(KERN_WARNING "%s: cannot use LBA48 - full capacity "
		       "%llu sectors (%llu MB)\n",
		       drive->name, (unsigned long long)drive->capacity64,
@@ -780,13 +795,14 @@ static void idedisk_setup(ide_drive_t *drive)
		drive->capacity64 = 1ULL << 28;
	}

	if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && drive->addressing) {
	if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) &&
	    (drive->dev_flags & IDE_DFLAG_LBA48)) {
		if (drive->capacity64 > 1ULL << 28) {
			printk(KERN_INFO "%s: cannot use LBA48 DMA - PIO mode"
					 " will be used for accessing sectors "
					 "> %u\n", drive->name, 1 << 28);
		} else
			drive->addressing = 0;
			drive->dev_flags &= ~IDE_DFLAG_LBA48;
	}

	/*
@@ -795,7 +811,7 @@ static void idedisk_setup(ide_drive_t *drive)
	 */
	capacity = idedisk_capacity(drive);

	if (!drive->forced_geom) {
	if ((drive->dev_flags & IDE_DFLAG_FORCED_GEOM) == 0) {
		if (ata_id_lba48_enabled(drive->id)) {
			/* compatibility */
			drive->bios_sect = 63;
@@ -830,14 +846,15 @@ static void idedisk_setup(ide_drive_t *drive)

	/* write cache enabled? */
	if ((id[ATA_ID_CSFO] & 1) || ata_id_wcache_enabled(id))
		drive->wcache = 1;
		drive->dev_flags |= IDE_DFLAG_WCACHE;

	set_wcache(drive, 1);
}

static void ide_cacheflush_p(ide_drive_t *drive)
{
	if (!drive->wcache || ata_id_flush_enabled(drive->id) == 0)
	if (ata_id_flush_enabled(drive->id) == 0 ||
	    (drive->dev_flags & IDE_DFLAG_WCACHE) == 0)
		return;

	if (do_idedisk_flushcache(drive))
@@ -956,15 +973,16 @@ static int idedisk_open(struct inode *inode, struct file *filp)

	idkp->openers++;

	if (drive->removable && idkp->openers == 1) {
	if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) {
		check_disk_change(inode->i_bdev);
		/*
		 * Ignore the return code from door_lock,
		 * since the open() has already succeeded,
		 * and the door_lock is irrelevant at this point.
		 */
		if (drive->doorlocking && idedisk_set_doorlock(drive, 1))
			drive->doorlocking = 0;
		if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) &&
		    idedisk_set_doorlock(drive, 1))
			drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
	}
	return 0;
}
@@ -978,9 +996,10 @@ static int idedisk_release(struct inode *inode, struct file *filp)
	if (idkp->openers == 1)
		ide_cacheflush_p(drive);

	if (drive->removable && idkp->openers == 1) {
		if (drive->doorlocking && idedisk_set_doorlock(drive, 0))
			drive->doorlocking = 0;
	if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) {
		if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) &&
		    idedisk_set_doorlock(drive, 0))
			drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
	}

	idkp->openers--;
@@ -1031,12 +1050,13 @@ static int idedisk_media_changed(struct gendisk *disk)
	ide_drive_t *drive = idkp->drive;

	/* do not scan partitions twice if this is a removable device */
	if (drive->attach) {
		drive->attach = 0;
	if (drive->dev_flags & IDE_DFLAG_ATTACH) {
		drive->dev_flags &= ~IDE_DFLAG_ATTACH;
		return 0;
	}

	/* if removable, always assume it was changed */
	return drive->removable;
	return !!(drive->dev_flags & IDE_DFLAG_REMOVABLE);
}

static int idedisk_revalidate_disk(struct gendisk *disk)
@@ -1094,15 +1114,15 @@ static int ide_disk_probe(ide_drive_t *drive)
	if ((!drive->head || drive->head > 16) && !drive->select.b.lba) {
		printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n",
			drive->name, drive->head);
		drive->attach = 0;
		drive->dev_flags &= ~IDE_DFLAG_ATTACH;
	} else
		drive->attach = 1;
		drive->dev_flags |= IDE_DFLAG_ATTACH;

	g->minors = IDE_DISK_MINORS;
	g->driverfs_dev = &drive->gendev;
	g->flags |= GENHD_FL_EXT_DEVT;
	if (drive->removable)
		g->flags |= GENHD_FL_REMOVABLE;
	if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
		g->flags = GENHD_FL_REMOVABLE;
	set_capacity(g, idedisk_capacity(drive));
	g->fops = &idedisk_ops;
	add_disk(g);
+4 −3
Original line number Diff line number Diff line
@@ -397,7 +397,7 @@ EXPORT_SYMBOL_GPL(ide_dma_host_set);

void ide_dma_off_quietly(ide_drive_t *drive)
{
	drive->using_dma = 0;
	drive->dev_flags &= ~IDE_DFLAG_USING_DMA;
	ide_toggle_bounce(drive, 0);

	drive->hwif->dma_ops->dma_host_set(drive, 0);
@@ -430,7 +430,7 @@ EXPORT_SYMBOL(ide_dma_off);

void ide_dma_on(ide_drive_t *drive)
{
	drive->using_dma = 1;
	drive->dev_flags |= IDE_DFLAG_USING_DMA;
	ide_toggle_bounce(drive, 1);

	drive->hwif->dma_ops->dma_host_set(drive, 1);
@@ -727,7 +727,8 @@ static int ide_tune_dma(ide_drive_t *drive)
	ide_hwif_t *hwif = drive->hwif;
	u8 speed;

	if (drive->nodma || ata_id_has_dma(drive->id) == 0)
	if (ata_id_has_dma(drive->id) == 0 ||
	    (drive->dev_flags & IDE_DFLAG_NODMA))
		return 0;

	/* consult the list of known "bad" drives */
Loading