}
/*
- * ide_build_dmatable() prepares a dma request.
- * Returns 0 if all went okay, returns 1 otherwise.
- * May also be invoked from trm290.c
+ * This prepares a dma request. Returns 0 if all went okay, returns 1
+ * otherwise. May also be invoked from trm290.c
*/
-int ide_build_dmatable (ide_drive_t *drive, ide_dma_action_t func)
+int ide_build_dmatable(struct ata_device *drive, ide_dma_action_t func)
{
- struct ata_channel *hwif = drive->channel;
- unsigned int *table = hwif->dmatable_cpu;
+ struct ata_channel *ch = drive->channel;
+ unsigned int *table = ch->dmatable_cpu;
#ifdef CONFIG_BLK_DEV_TRM290
- unsigned int is_trm290_chipset = (hwif->chipset == ide_trm290);
+ unsigned int is_trm290_chipset = (ch->chipset == ide_trm290);
#else
const int is_trm290_chipset = 0;
#endif
int i;
struct scatterlist *sg;
- hwif->sg_nents = i = build_sglist(hwif, HWGROUP(drive)->rq);
+ ch->sg_nents = i = build_sglist(ch, HWGROUP(drive)->rq);
if (!i)
return 0;
- sg = hwif->sg_table;
+ sg = ch->sg_table;
while (i) {
u32 cur_addr;
u32 cur_len;
u32 xcount, bcount = 0x10000 - (cur_addr & 0xffff);
if (count++ >= PRD_ENTRIES) {
- printk("ide-dma: req %p\n", HWGROUP(drive)->rq);
- printk("count %d, sg_nents %d, cur_len %d, cur_addr %u\n", count, hwif->sg_nents, cur_len, cur_addr);
+ printk("ide-dma: count %d, sg_nents %d, cur_len %d, cur_addr %u\n",
+ count, ch->sg_nents, cur_len, cur_addr);
BUG();
}
* the 64KB entry into two 32KB entries instead.
*/
if (count++ >= PRD_ENTRIES) {
- pci_unmap_sg(hwif->pci_dev, sg,
- hwif->sg_nents,
- hwif->sg_dma_direction);
+ pci_unmap_sg(ch->pci_dev, sg,
+ ch->sg_nents,
+ ch->sg_dma_direction);
return 0;
}
{
if (timeout > WAIT_WORSTCASE)
timeout = WAIT_WORSTCASE;
- drive->PADAM_sleep = timeout + jiffies;
+ drive->sleep = timeout + jiffies;
}
/*
- * Determine the longes sleep time for the devices in our hwgroup.
+ * Determine the longest sleep time for the devices at this channel.
*/
static unsigned long longest_sleep(struct ata_channel *channel)
{
/* This device is sleeping and waiting to be serviced
* later than any other device we checked thus far.
*/
- if (drive->PADAM_sleep && (!sleep || time_after(sleep, drive->PADAM_sleep)))
- sleep = drive->PADAM_sleep;
+ if (drive->sleep && (!sleep || time_after(sleep, drive->sleep)))
+ sleep = drive->sleep;
}
}
if (list_empty(&drive->queue.queue_head))
continue;
- /* This device still want's to remain idle.
+ /* This device still wants to remain idle.
*/
- if (drive->PADAM_sleep && time_after(jiffies, drive->PADAM_sleep))
+ if (drive->sleep && time_after(jiffies, drive->sleep))
continue;
/* Take this device, if there is no device choosen thus far or
* it's more urgent.
*/
- if (!choice || (drive->PADAM_sleep && (!choice->PADAM_sleep || time_after(choice->PADAM_sleep, drive->PADAM_sleep))))
- {
+ if (!choice || (drive->sleep && (!choice->sleep || time_after(choice->sleep, drive->sleep)))) {
if (!blk_queue_plugged(&drive->queue))
choice = drive;
}
* Feed commands to a drive until it barfs. Called with ide_lock/DRIVE_LOCK
* held and busy channel.
*/
-
static void queue_commands(struct ata_device *drive, int masked_irq)
{
ide_hwgroup_t *hwgroup = drive->channel->hwgroup;
struct request *rq = NULL;
if (!test_bit(IDE_BUSY, &hwgroup->flags))
- printk(KERN_ERR"%s: hwgroup not busy while queueing\n", drive->name);
+ printk(KERN_ERR"%s: error: not busy while queueing!\n", drive->name);
/* Abort early if we can't queue another command. for non
* tcq, ata_can_queue is always 1 since we never get here
break;
}
- drive->PADAM_sleep = 0;
+ drive->sleep = 0;
if (test_bit(IDE_DMA, &hwgroup->flags)) {
printk("ide_do_request: DMA in progress...\n");
* completed. This is again intended for careful use by the ATAPI tape/cdrom
* driver code.
*/
-int ide_do_drive_cmd(ide_drive_t *drive, struct request *rq, ide_action_t action)
+int ide_do_drive_cmd(struct ata_device *drive, struct request *rq, ide_action_t action)
{
unsigned long flags;
- ide_hwgroup_t *hwgroup = HWGROUP(drive);
unsigned int major = drive->channel->major;
request_queue_t *q = &drive->queue;
struct list_head *queue_head = &q->queue_head;
spin_lock_irqsave(&ide_lock, flags);
if (blk_queue_empty(&drive->queue) || action == ide_preempt) {
if (action == ide_preempt)
- hwgroup->rq = NULL;
+ HWGROUP(drive)->rq = NULL;
} else {
if (action == ide_wait || action == ide_end)
queue_head = queue_head->prev;
* usage == 1 (we need an open channel to use an ioctl :-), so this
* is our limit.
*/
-int ide_revalidate_disk (kdev_t i_rdev)
+int ide_revalidate_disk(kdev_t i_rdev)
{
- ide_drive_t *drive;
- ide_hwgroup_t *hwgroup;
+ struct ata_device *drive;
unsigned long flags;
int res;
if ((drive = get_info_ptr(i_rdev)) == NULL)
return -ENODEV;
- hwgroup = HWGROUP(drive);
+
spin_lock_irqsave(&ide_lock, flags);
+
if (drive->busy || (drive->usage > 1)) {
spin_unlock_irqrestore(&ide_lock, flags);
return -EBUSY;
}
+
drive->busy = 1;
MOD_INC_USE_COUNT;
spin_unlock_irqrestore(&ide_lock, flags);
};
#endif
-/*
- * Note that we only release the standard ports, and do not even try to handle
- * any extra ports allocated for weird IDE interface chipsets.
- */
-static void hwif_unregister(struct ata_channel *ch)
-{
- int i;
- ide_hwgroup_t *hwgroup = ch->hwgroup;
-
- /*
- * Free the irq if we were the only channel using it.
- */
- int n = 0;
-
- for (i = 0; i < MAX_HWIFS; ++i) {
- struct ata_channel *tmp = &ide_hwifs[i];
-
- if (!tmp->present)
- continue;
-
- if (tmp->irq == ch->irq)
- ++n;
- }
- if (n == 1)
- free_irq(ch->irq, hwgroup);
-
-
- if (ch->straight8) {
- release_region(ch->io_ports[IDE_DATA_OFFSET], 8);
- } else {
- if (ch->io_ports[IDE_DATA_OFFSET])
- release_region(ch->io_ports[IDE_DATA_OFFSET], 1);
- if (ch->io_ports[IDE_ERROR_OFFSET])
- release_region(ch->io_ports[IDE_ERROR_OFFSET], 1);
- if (ch->io_ports[IDE_NSECTOR_OFFSET])
- release_region(ch->io_ports[IDE_NSECTOR_OFFSET], 1);
- if (ch->io_ports[IDE_SECTOR_OFFSET])
- release_region(ch->io_ports[IDE_SECTOR_OFFSET], 1);
- if (ch->io_ports[IDE_LCYL_OFFSET])
- release_region(ch->io_ports[IDE_LCYL_OFFSET], 1);
- if (ch->io_ports[IDE_HCYL_OFFSET])
- release_region(ch->io_ports[IDE_HCYL_OFFSET], 1);
- if (ch->io_ports[IDE_SELECT_OFFSET])
- release_region(ch->io_ports[IDE_SELECT_OFFSET], 1);
- if (ch->io_ports[IDE_STATUS_OFFSET])
- release_region(ch->io_ports[IDE_STATUS_OFFSET], 1);
- }
- if (ch->io_ports[IDE_CONTROL_OFFSET])
- release_region(ch->io_ports[IDE_CONTROL_OFFSET], 1);
-#if defined(CONFIG_AMIGA) || defined(CONFIG_MAC)
- if (ch->io_ports[IDE_IRQ_OFFSET])
- release_region(ch->io_ports[IDE_IRQ_OFFSET], 1);
-#endif
-}
-
void ide_unregister(struct ata_channel *ch)
{
struct gendisk *gd;
struct ata_device *d;
ide_hwgroup_t *hwgroup;
- int unit, i;
+ int unit;
+ int i;
unsigned long flags;
unsigned int p, minor;
struct ata_channel old;
- int n = 0;
+ int n_irq;
+ int n_ch;
spin_lock_irqsave(&ide_lock, flags);
#endif
spin_lock_irqsave(&ide_lock, flags);
- hwif_unregister(ch);
+ /*
+ * Note that we only release the standard ports, and do not even try to
+ * handle any extra ports allocated for weird IDE interface chipsets.
+ */
+
+ if (ch->straight8) {
+ release_region(ch->io_ports[IDE_DATA_OFFSET], 8);
+ } else {
+ if (ch->io_ports[IDE_DATA_OFFSET])
+ release_region(ch->io_ports[IDE_DATA_OFFSET], 1);
+ if (ch->io_ports[IDE_ERROR_OFFSET])
+ release_region(ch->io_ports[IDE_ERROR_OFFSET], 1);
+ if (ch->io_ports[IDE_NSECTOR_OFFSET])
+ release_region(ch->io_ports[IDE_NSECTOR_OFFSET], 1);
+ if (ch->io_ports[IDE_SECTOR_OFFSET])
+ release_region(ch->io_ports[IDE_SECTOR_OFFSET], 1);
+ if (ch->io_ports[IDE_LCYL_OFFSET])
+ release_region(ch->io_ports[IDE_LCYL_OFFSET], 1);
+ if (ch->io_ports[IDE_HCYL_OFFSET])
+ release_region(ch->io_ports[IDE_HCYL_OFFSET], 1);
+ if (ch->io_ports[IDE_SELECT_OFFSET])
+ release_region(ch->io_ports[IDE_SELECT_OFFSET], 1);
+ if (ch->io_ports[IDE_STATUS_OFFSET])
+ release_region(ch->io_ports[IDE_STATUS_OFFSET], 1);
+ }
+ if (ch->io_ports[IDE_CONTROL_OFFSET])
+ release_region(ch->io_ports[IDE_CONTROL_OFFSET], 1);
+#if defined(CONFIG_AMIGA) || defined(CONFIG_MAC)
+ if (ch->io_ports[IDE_IRQ_OFFSET])
+ release_region(ch->io_ports[IDE_IRQ_OFFSET], 1);
+#endif
/*
- * Remove us from the hwgroup
+ * Remove us from the hwgroup.
*/
hwgroup = ch->hwgroup;
if (d->present)
hwgroup->XXX_drive = d;
- /* Free the hwgroup if we were the only member.
+
+ /*
+ * Free the irq if we were the only channel using it.
+ *
+ * Free the hwgroup if we were the only member.
*/
- n = 0;
+ n_irq = n_ch = 0;
for (i = 0; i < MAX_HWIFS; ++i) {
struct ata_channel *tmp = &ide_hwifs[i];
if (!tmp->present)
continue;
+ if (tmp->irq == ch->irq)
+ ++n_irq;
if (tmp->hwgroup == ch->hwgroup)
- ++n;
+ ++n_ch;
}
- if (n == 1)
+ if (n_irq == 1)
+ free_irq(ch->irq, ch->hwgroup);
+ if (n_ch == 1) {
kfree(ch->hwgroup);
+ ch->hwgroup = NULL;
+ }
#if defined(CONFIG_BLK_DEV_IDEDMA) && !defined(CONFIG_DMA_NONPCI)
ide_release_dma(ch);