Commit a925c40f authored by Martin Dalecki's avatar Martin Dalecki Committed by Linus Torvalds

[PATCH] IDE 17 (not just cleanup)

This is actually an attempt to remove some stall code from
this driver. However if some *real* users complain (Not just
the usuall: "Hey - if someone!" but the "Hey I'm using this!")
I'm all open to reenable it. Since I prepared this patch
yerstoday it doesn't contain the ide_module.h fixup. This will
follow later.

- Don't use the convoluted byte type in ide-pci.c. Just use the proper
   u8instead.

- Move ide_get_or_set_dma_base to the only place where it's used and
   reorganize the code there by killing the unnecessary
   CONFIG_BLK_DEV_IDEDMA_FORCED configuration option.

- Remove unfunctional CONFIG_PKT_TASK_IOCTL code.

- Kill unused ALTSTAT_SCREW_UP code.

- Tons of dead code removed from ide-taskfile.c (#if 0 #endif and
   friends)

- Remove unused IDE_DEBUG macro as well as lots of other name space
   pollution from ide.h.

- Start using the ide_lock spin-lock for protecting access to data
   structures instead of the excessive interrupt disabling games.

- Shorten the proc ouput of the piix initialization module.

- Remove special /proc tape "name" output from ide-tape.c. This was
   redundant data which should only show up on syslog anyway.

- Kill the REALLY_FAST_IO undef from the ide.h. This was a mistake
   present since far too many years in this driver. The proper way to
   deal with broken systems is to define REALLY_SLOW_IO in system
   dependent headers or particular driver files.  We can always
   reintroduce it easy if real users will complain, since OUT_BYTE() and
   similar can be used as hooks. But I don't expect anybody reporting
   about this. Even on the most broken IDE chip in the world (cmd640
   at VLB) undefining this *always* worked for me. Nearly all the code
   pieces in the ide driver code *reverted* it's effects explicitly
   anyway.

- Remove the obsolete CONFIG_BLK_DEV_4DRIVES support. This was supposed
   to support 4 drivers attached at one channel on some older chipsets,
   in esp. Tekram 690CD, in the last century. They where all supposed to
   work at a register set starting at the base address 0x1f0.  Before
   complaining that this is removing functionality, please note that this
   must have been broken for already quite a long time, since the ide
   driver didn't contain the special device selection methods implicated
   by this any longer.  It didn't scan   this port too if PCI host chip
   support was enabled (as it is in all those distributions around
   there).  On the other hand this is the most prominent case of
   incoherent use of the mate member in the struct hwif_s. And please
   think about how big the probability is, that there are systems out
   there, where there are actually 4 drivers on such a channel?

- Streamline module initialization code by removing one shoot functions.

- Make the WAIT_READY value used in case of CONFIG_APM or
   CONFIG_APM_MODULE the default, since this is what really reflects the
   behavior of modern drives. It won't hurt any other case and finally
   removing it is reducing the necessary coverage for overall driver code
   testing/analysis.

- Move the IDE_LARGE_SEEK macro to the only place where it's actually
   used. Replace the IDE_MIN() and IDE_MAX() drivers with the obvious.
   Remove unused SPLIT_WORD and MAKE WORD from the local header.

- Remove CMD640_DUMP_REGS from global scope, since there is no
   development done on this any longer. Finally, the way the host chip
   initialization routines are called changed in the time between allows
   this to remain fully local to the host chip driver in question.

- Some spell checking of comments in the code. (Yeep I have extended my
   Vim to do this the "Word" way with nice undercurl lines... mozilla
   remains to be fixed...)
parent 6aa0c79e
......@@ -249,7 +249,6 @@ CONFIG_BLK_DEV_IDEPCI=y
# CONFIG_IDEPCI_SHARE_IRQ is not set
CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_BLK_DEV_OFFBOARD is not set
# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
CONFIG_IDEDMA_PCI_AUTO=y
# CONFIG_IDEDMA_ONLYDISK is not set
CONFIG_BLK_DEV_IDEDMA=y
......
......@@ -94,8 +94,6 @@
* device can't do DMA handshaking for some stupid reason. We don't need to do that.
*/
#undef REALLY_SLOW_IO /* most systems can safely undef this */
#include <linux/config.h>
#include <linux/types.h>
#include <linux/kernel.h>
......
......@@ -252,7 +252,6 @@ CONFIG_BLK_DEV_IDEPCI=y
CONFIG_IDEPCI_SHARE_IRQ=y
CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_BLK_DEV_OFFBOARD is not set
# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
CONFIG_IDEDMA_PCI_AUTO=y
# CONFIG_IDEDMA_ONLYDISK is not set
CONFIG_BLK_DEV_IDEDMA=y
......
......@@ -285,7 +285,6 @@ CONFIG_BLK_DEV_IDEPCI=y
# CONFIG_IDEPCI_SHARE_IRQ is not set
CONFIG_BLK_DEV_IDEDMA_PCI=y
# CONFIG_BLK_DEV_OFFBOARD is not set
# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
CONFIG_IDEDMA_PCI_AUTO=y
CONFIG_IDEDMA_ONLYDISK=y
CONFIG_BLK_DEV_IDEDMA=y
......
......@@ -581,13 +581,6 @@ CONFIG_IDE_CHIPSETS
People with SCSI-only systems can say N here.
CONFIG_BLK_DEV_4DRIVES
Certain older chipsets, including the Tekram 690CD, use a single set
of I/O ports at 0x1f0 to control up to four drives, instead of the
customary two drives per port. Support for this can be enabled at
runtime using the "ide0=four" kernel boot parameter if you say Y
here.
CONFIG_BLK_DEV_ALI14XX
This driver is enabled at runtime using the "ide0=ali14xx" kernel
boot parameter. It enables support for the secondary IDE interface
......@@ -807,11 +800,6 @@ CONFIG_IDEDISK_STROKE
If you are unsure, say N here.
CONFIG_BLK_DEV_IDEDMA_FORCED
This is an old piece of lost code from Linux 2.0 Kernels.
Generally say N here.
CONFIG_IDEDMA_ONLYDISK
This is used if you know your ATAPI Devices are going to fail DMA
Transfers.
......
......@@ -45,7 +45,6 @@ if [ "$CONFIG_BLK_DEV_IDE" != "n" ]; then
bool ' Sharing PCI IDE interrupts support' CONFIG_IDEPCI_SHARE_IRQ
bool ' Generic PCI bus-master DMA support' CONFIG_BLK_DEV_IDEDMA_PCI
bool ' Boot off-board chipsets first support' CONFIG_BLK_DEV_OFFBOARD
dep_bool ' Force enable legacy 2.0.X HOSTS to use DMA' CONFIG_BLK_DEV_IDEDMA_FORCED $CONFIG_BLK_DEV_IDEDMA_PCI
dep_bool ' Use PCI DMA by default when available' CONFIG_IDEDMA_PCI_AUTO $CONFIG_BLK_DEV_IDEDMA_PCI
dep_bool ' Enable DMA only for disks ' CONFIG_IDEDMA_ONLYDISK $CONFIG_IDEDMA_PCI_AUTO
define_bool CONFIG_BLK_DEV_IDEDMA $CONFIG_BLK_DEV_IDEDMA_PCI
......@@ -141,7 +140,6 @@ if [ "$CONFIG_BLK_DEV_IDE" != "n" ]; then
bool ' Other IDE chipset support' CONFIG_IDE_CHIPSETS
if [ "$CONFIG_IDE_CHIPSETS" = "y" ]; then
comment 'Note: most of these also require special kernel boot parameters'
bool ' Generic 4 drives/port support' CONFIG_BLK_DEV_4DRIVES
bool ' ALI M14xx support' CONFIG_BLK_DEV_ALI14XX
bool ' DTC-2278 support' CONFIG_BLK_DEV_DTC2278
bool ' Holtek HT6560B support' CONFIG_BLK_DEV_HT6560B
......
/*
* linux/drivers/ide/ali14xx.c Version 0.03 Feb 09, 1996
*
* Copyright (C) 1996 Linus Torvalds & author (see below)
*/
......@@ -37,8 +35,6 @@
* mode 4 for a while now with no trouble.) -Derek
*/
#undef REALLY_SLOW_IO /* most systems can safely undef this */
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/delay.h>
......
/*
* linux/drivers/ide/cmd640.c Version 1.02 Sep 01, 1996
*
* Copyright (C) 1995-1996 Linus Torvalds & authors (see below)
*/
/*
* Original authors: abramov@cecmow.enet.dec.com (Igor Abramov)
* mlord@pobox.com (Mark Lord)
* mlord@pobox.com (Mark Lord)
*
* See linux/MAINTAINERS for address of current maintainer.
*
......@@ -98,7 +96,6 @@
* (patch courtesy of Zoltan Hidvegi)
*/
#undef REALLY_SLOW_IO /* most systems can safely undef this */
#define CMD640_PREFETCH_MASKS 1
#include <linux/config.h>
......
......@@ -238,7 +238,7 @@ static void program_drive_counts (ide_drive_t *drive, int setup_count, int activ
*/
if (channel) {
drive->drive_data = setup_count;
setup_count = IDE_MAX(drives[0].drive_data, drives[1].drive_data);
setup_count = max(drives[0].drive_data, drives[1].drive_data);
cmdprintk("Secondary interface, setup_count = %d\n", setup_count);
}
......
/*
* linux/drivers/ide/dtc2278.c Version 0.02 Feb 10, 1996
*
* Copyright (C) 1996 Linus Torvalds & author (see below)
*/
#undef REALLY_SLOW_IO /* most systems can safely undef this */
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/delay.h>
......
/*
* linux/drivers/ide/ht6560b.c Version 0.07 Feb 1, 2000
*
* Copyright (C) 1995-2000 Linus Torvalds & author (see below)
*/
/*
*
* Version 0.01 Initial version hacked out of ide.c
*
......@@ -36,8 +31,6 @@
#define HT6560B_VERSION "v0.07"
#undef REALLY_SLOW_IO /* most systems can safely undef this */
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/delay.h>
......
......@@ -1633,6 +1633,7 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
return startstop;
}
#define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t)))
/****************************************************************************
* cdrom driver request routine.
......
/*
* linux/drivers/ide/ide-disk.c Version 1.13 Nov 28, 2001
*
* Copyright (C) 1994-1998 Linus Torvalds & authors (see below)
*/
/*
*
* Mostly written by Mark Lord <mlord@pobox.com>
* and Gadi Oxman <gadio@netvision.net.il>
* and Andre Hedrick <andre@linux-ide.org>
......@@ -34,8 +30,6 @@
#define IDEDISK_VERSION "1.13"
#undef REALLY_SLOW_IO /* most systems can safely undef this */
#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
......@@ -720,7 +714,7 @@ static int get_smart_values(ide_drive_t *drive, byte *buf)
taskfile.low_cylinder = SMART_LCYL_PASS;
taskfile.high_cylinder = SMART_HCYL_PASS;
taskfile.command = WIN_SMART;
(void) smart_enable(drive);
smart_enable(drive);
return ide_wait_taskfile(drive, &taskfile, &hobfile, buf);
}
......@@ -735,7 +729,7 @@ static int get_smart_thresholds(ide_drive_t *drive, byte *buf)
taskfile.low_cylinder = SMART_LCYL_PASS;
taskfile.high_cylinder = SMART_HCYL_PASS;
taskfile.command = WIN_SMART;
(void) smart_enable(drive);
smart_enable(drive);
return ide_wait_taskfile(drive, &taskfile, &hobfile, buf);
}
......@@ -844,7 +838,7 @@ static int write_cache (ide_drive_t *drive, int arg)
if (!(drive->id->cfs_enable_2 & 0x3000))
return 1;
(void) ide_wait_taskfile(drive, &taskfile, &hobfile, NULL);
ide_wait_taskfile(drive, &taskfile, &hobfile, NULL);
drive->wcache = arg;
return 0;
}
......@@ -870,7 +864,7 @@ static int set_acoustic (ide_drive_t *drive, int arg)
taskfile.sector_count = arg;
taskfile.command = WIN_SETFEATURES;
(void) ide_wait_taskfile(drive, &taskfile, &hobfile, NULL);
ide_wait_taskfile(drive, &taskfile, &hobfile, NULL);
drive->acoustic = arg;
return 0;
}
......
/*
* linux/drivers/ide/ide-dma.c Version 4.10 June 9, 2000
*
* Copyright (c) 1999-2000 Andre Hedrick <andre@linux-ide.org>
* May be copied or modified under the terms of the GNU General Public License
*/
......@@ -15,7 +13,7 @@
/*
* This module provides support for the bus-master IDE DMA functions
* of various PCI chipsets, including the Intel PIIX (i82371FB for
* the 430 FX chipset), the PIIX3 (i82371SB for the 430 HX/VX and
* the 430 FX chipset), the PIIX3 (i82371SB for the 430 HX/VX and
* 440 chipsets), and the PIIX4 (i82371AB for the 430 TX chipset)
* ("PIIX" stands for "PCI ISA IDE Xcellerator").
*
......@@ -73,8 +71,6 @@
* check_drive_lists(ide_drive_t *drive, int good_bad)
*
* ATA-66/100 and recovery functions, I forgot the rest......
* SELECT_READ_WRITE(hwif,drive,func) for active tuning based on IO direction.
*
*/
#include <linux/config.h>
......@@ -426,7 +422,7 @@ int check_drive_lists (ide_drive_t *drive, int good_bad)
return 0;
}
int report_drive_dmaing (ide_drive_t *drive)
static int report_drive_dmaing (ide_drive_t *drive)
{
struct hd_driveid *id = drive->id;
......@@ -606,7 +602,10 @@ int ide_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
case ide_dma_read:
reading = 1 << 3;
case ide_dma_write:
SELECT_READ_WRITE(hwif,drive,func);
/* active tuning based on IO direction */
if (hwif->rwproc)
hwif->rwproc(drive, func);
if (!(count = ide_build_dmatable(drive, func)))
return 1; /* try PIO instead of DMA */
outl(hwif->dmatable_dma, dma_base + 4); /* PRD table */
......@@ -617,9 +616,9 @@ int ide_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
return 0;
#ifdef CONFIG_BLK_DEV_IDEDMA_TIMEOUT
ide_set_handler(drive, &ide_dma_intr, 2*WAIT_CMD, NULL); /* issue cmd to drive */
#else /* !CONFIG_BLK_DEV_IDEDMA_TIMEOUT */
#else
ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, dma_timer_expiry); /* issue cmd to drive */
#endif /* CONFIG_BLK_DEV_IDEDMA_TIMEOUT */
#endif
if ((HWGROUP(drive)->rq->flags & REQ_DRIVE_TASKFILE) &&
(drive->addressing == 1)) {
ide_task_t *args = HWGROUP(drive)->rq->special;
......@@ -728,9 +727,8 @@ int ide_release_dma (ide_hwif_t *hwif)
}
/*
* This can be called for a dynamically installed interface. Don't __init it
* This can be called for a dynamically installed interface. Don't __init it
*/
void ide_setup_dma (ide_hwif_t *hwif, unsigned long dma_base, unsigned int num_ports)
{
printk(" %s: BM-DMA at 0x%04lx-0x%04lx", hwif->name, dma_base, dma_base + num_ports - 1);
......@@ -768,81 +766,3 @@ void ide_setup_dma (ide_hwif_t *hwif, unsigned long dma_base, unsigned int num_p
dma_alloc_failure:
printk(" -- ERROR, UNABLE TO ALLOCATE DMA TABLES\n");
}
/*
* Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space:
*/
unsigned long __init ide_get_or_set_dma_base (ide_hwif_t *hwif, int extra, const char *name)
{
unsigned long dma_base = 0;
struct pci_dev *dev = hwif->pci_dev;
#ifdef CONFIG_BLK_DEV_IDEDMA_FORCED
int second_chance = 0;
second_chance_to_dma:
#endif /* CONFIG_BLK_DEV_IDEDMA_FORCED */
if (hwif->mate && hwif->mate->dma_base) {
dma_base = hwif->mate->dma_base - (hwif->channel ? 0 : 8);
} else {
dma_base = pci_resource_start(dev, 4);
if (!dma_base) {
printk("%s: dma_base is invalid (0x%04lx)\n", name, dma_base);
dma_base = 0;
}
}
#ifdef CONFIG_BLK_DEV_IDEDMA_FORCED
if ((!dma_base) && (!second_chance)) {
unsigned long set_bmiba = 0;
second_chance++;
switch(dev->vendor) {
case PCI_VENDOR_ID_AL:
set_bmiba = DEFAULT_BMALIBA; break;
case PCI_VENDOR_ID_VIA:
set_bmiba = DEFAULT_BMCRBA; break;
case PCI_VENDOR_ID_INTEL:
set_bmiba = DEFAULT_BMIBA; break;
default:
return dma_base;
}
pci_write_config_dword(dev, 0x20, set_bmiba|1);
goto second_chance_to_dma;
}
#endif /* CONFIG_BLK_DEV_IDEDMA_FORCED */
if (dma_base) {
if (extra) /* PDC20246, PDC20262, HPT343, & HPT366 */
request_region(dma_base+16, extra, name);
dma_base += hwif->channel ? 8 : 0;
hwif->dma_extra = extra;
switch(dev->device) {
case PCI_DEVICE_ID_AL_M5219:
case PCI_DEVICE_ID_AMD_VIPER_7409:
case PCI_DEVICE_ID_CMD_643:
outb(inb(dma_base+2) & 0x60, dma_base+2);
if (inb(dma_base+2) & 0x80) {
printk("%s: simplex device: DMA forced\n", name);
}
break;
default:
/*
* If the device claims "simplex" DMA,
* this means only one of the two interfaces
* can be trusted with DMA at any point in time.
* So we should enable DMA only on one of the
* two interfaces.
*/
if ((inb(dma_base+2) & 0x80)) { /* simplex device? */
if ((!hwif->drives[0].present && !hwif->drives[1].present) ||
(hwif->mate && hwif->mate->dma_base)) {
printk("%s: simplex device: DMA disabled\n", name);
dma_base = 0;
}
}
}
}
return dma_base;
}
......@@ -1113,7 +1113,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p
pc->retries++;
pc->actually_transferred=0; /* We haven't transferred any data yet */
pc->current_position=pc->buffer;
bcount.all = IDE_MIN(pc->request_transfer, 63 * 1024);
bcount.all = min(pc->request_transfer, 63 * 1024);
#ifdef CONFIG_BLK_DEV_IDEDMA
if (test_and_clear_bit (PC_DMA_ERROR, &pc->flags)) {
......
This diff is collapsed.
/*
* linux/drivers/ide/ide-probe.c Version 1.07 March 18, 2001
*
* Copyright (C) 1994-1998 Linus Torvalds & authors (see below)
*/
/*
*
* Mostly written by Mark Lord <mlord@pobox.com>
* and Gadi Oxman <gadio@netvision.net.il>
* and Andre Hedrick <andre@linux-ide.org>
......@@ -26,11 +22,9 @@
* with new flag : drive->ata_flash : 1;
* Version 1.06 stream line request queue and prep for cascade project.
* Version 1.07 max_sect <= 255; slower disks would get behind and
* then fall over when they get to 256. Paul G.
* then fall over when they get to 256. Paul G.
*/
#undef REALLY_SLOW_IO /* most systems can safely undef this */
#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
......@@ -94,7 +88,7 @@ static inline void do_identify (ide_drive_t *drive, byte cmd)
printk("%s: EATA SCSI HBA %.10s\n", drive->name, id->model);
goto err_misc;
}
#endif /* CONFIG_SCSI_EATA_DMA || CONFIG_SCSI_EATA_PIO */
#endif
/*
* WIN_IDENTIFY returns little-endian info,
......@@ -128,7 +122,7 @@ static inline void do_identify (ide_drive_t *drive, byte cmd)
printk(" -- not supported on 2nd Promise port\n");
goto err_misc;
}
#endif /* CONFIG_BLK_DEV_PDC4030 */
#endif
switch (type) {
case ATA_FLOPPY:
if (!strstr(id->model, "CD-ROM")) {
......@@ -186,7 +180,11 @@ static inline void do_identify (ide_drive_t *drive, byte cmd)
}
drive->type = ATA_DISK;
printk("ATA DISK drive\n");
QUIRK_LIST(HWIF(drive),drive);
/* Initialize our quirk list. */
if (HWIF(drive)->quirkproc)
drive->quirk_list = HWIF(drive)->quirkproc(drive);
return;
err_misc:
......@@ -282,24 +280,15 @@ static int try_to_identify (ide_drive_t *drive, byte cmd)
if (autoprobe) {
int irq;
OUT_BYTE(drive->ctl|2,IDE_CONTROL_REG); /* mask device irq */
(void) GET_STAT(); /* clear drive IRQ */
OUT_BYTE(drive->ctl | 0x02, IDE_CONTROL_REG); /* mask device irq */
GET_STAT(); /* clear drive IRQ */
udelay(5);
irq = probe_irq_off(cookie);
if (!HWIF(drive)->irq) {
if (irq > 0) {
if (irq > 0)
HWIF(drive)->irq = irq;
} else { /* Mmmm.. multiple IRQs.. don't know which was ours */
else /* Mmmm.. multiple IRQs.. don't know which was ours */
printk("%s: IRQ probe failed (0x%lx)\n", drive->name, cookie);
#ifdef CONFIG_BLK_DEV_CMD640
#ifdef CMD640_DUMP_REGS
if (HWIF(drive)->chipset == ide_cmd640) {
printk("%s: Hmmm.. probably a driver problem.\n", drive->name);
CMD640_DUMP_REGS;
}
#endif /* CMD640_DUMP_REGS */
#endif /* CONFIG_BLK_DEV_CMD640 */
}
}
}
return retval;
......@@ -522,11 +511,11 @@ static void probe_hwif (ide_hwif_t *hwif)
if (hwif->noprobe)
return;
if ((hwif->chipset != ide_4drives || !hwif->mate->present) &&
if (
#if CONFIG_BLK_DEV_PDC4030
(hwif->chipset != ide_pdc4030 || hwif->channel == 0) &&
#endif /* CONFIG_BLK_DEV_PDC4030 */
(hwif_check_regions(hwif))) {
#endif
hwif_check_regions(hwif)) {
int msgout = 0;
for (unit = 0; unit < MAX_DRIVES; ++unit) {
ide_drive_t *drive = &hwif->drives[unit];
......@@ -552,9 +541,7 @@ static void probe_hwif (ide_hwif_t *hwif)
probe_for_drive (drive);
if (drive->present && !hwif->present) {
hwif->present = 1;
if (hwif->chipset != ide_4drives || !hwif->mate->present) {
hwif_register(hwif);
}
hwif_register(hwif);
}
}
if (hwif->io_ports[IDE_CONTROL_OFFSET] && hwif->reset) {
......@@ -582,32 +569,6 @@ static void probe_hwif (ide_hwif_t *hwif)
}
}
#if MAX_HWIFS > 1
/*
* save_match() is used to simplify logic in init_irq() below.
*
* A loophole here is that we may not know about a particular
* hwif's irq until after that hwif is actually probed/initialized..
* This could be a problem for the case where an hwif is on a
* dual interface that requires serialization (eg. cmd640) and another
* hwif using one of the same irqs is initialized beforehand.
*
* This routine detects and reports such situations, but does not fix them.
*/
static void save_match (ide_hwif_t *hwif, ide_hwif_t *new, ide_hwif_t **match)
{
ide_hwif_t *m = *match;
if (m && m->hwgroup && m->hwgroup != new->hwgroup) {
if (!new->hwgroup)
return;
printk("%s: potential irq problem with %s and %s\n", hwif->name, new->name, m->name);
}
if (!m || m->irq != hwif->irq) /* don't undo a prior perfect match */
*match = new;
}
#endif /* MAX_HWIFS > 1 */
/*
* init request queue
*/
......@@ -636,6 +597,33 @@ static void ide_init_queue(ide_drive_t *drive)
blk_queue_max_phys_segments(q, PRD_ENTRIES);
}
#if MAX_HWIFS > 1
/*
* This is used to simplify logic in init_irq() below.
*
* A loophole here is that we may not know about a particular hwif's irq until
* after that hwif is actually probed/initialized.. This could be a problem
* for the case where an hwif is on a dual interface that requires
* serialization (eg. cmd640) and another hwif using one of the same irqs is
* initialized beforehand.
*
* This routine detects and reports such situations, but does not fix them.
*/
static void save_match(ide_hwif_t *hwif, ide_hwif_t *new, ide_hwif_t **match)
{
ide_hwif_t *m = *match;
if (m && m->hwgroup && m->hwgroup != new->hwgroup) {
if (!new->hwgroup)
return;
printk("%s: potential irq problem with %s and %s\n", hwif->name, new->name, m->name);
}
if (!m || m->irq != hwif->irq) /* don't undo a prior perfect match */
*match = new;
}
#endif
/*
* This routine sets up the irq for an ide interface, and creates a new
* hwgroup for the irq/hwif if none was previously assigned.
......@@ -656,15 +644,14 @@ static int init_irq (ide_hwif_t *hwif)
ide_hwgroup_t *hwgroup, *new_hwgroup;
ide_hwif_t *match = NULL;
/* Allocate the buffer and potentially sleep first */
new_hwgroup = kmalloc(sizeof(ide_hwgroup_t),GFP_KERNEL);
save_flags(flags); /* all CPUs */
cli(); /* all CPUs */
spin_lock_irqsave(&ide_lock, flags);
hwif->hwgroup = NULL;
#if MAX_HWIFS > 1
/*
* Group up with any other hwifs that share our irq(s).
......@@ -674,9 +661,8 @@ static int init_irq (ide_hwif_t *hwif)
if (h->hwgroup) { /* scan only initialized hwif's */
if (hwif->irq == h->irq) {
hwif->sharing_irq = h->sharing_irq = 1;
if (hwif->chipset != ide_pci || h->chipset != ide_pci) {
if (hwif->chipset != ide_pci || h->chipset != ide_pci)
save_match(hwif, h, &match);
}
}
if (hwif->serialized) {
if (hwif->mate && hwif->mate->irq == h->irq)
......@@ -688,7 +674,7 @@ static int init_irq (ide_hwif_t *hwif)
}
}
}
#endif /* MAX_HWIFS > 1 */
#endif
/*
* If we are still without a hwgroup, then form a new one
*/
......@@ -699,7 +685,7 @@ static int init_irq (ide_hwif_t *hwif)
} else {
hwgroup = new_hwgroup;
if (!hwgroup) {
restore_flags(flags); /* all CPUs */
spin_unlock_irqrestore(&ide_lock, flags);
return 1;
}
memset(hwgroup, 0, sizeof(ide_hwgroup_t));
......@@ -719,9 +705,9 @@ static int init_irq (ide_hwif_t *hwif)
if (!match || match->irq != hwif->irq) {
#ifdef CONFIG_IDEPCI_SHARE_IRQ
int sa = IDE_CHIPSET_IS_PCI(hwif->chipset) ? SA_SHIRQ : SA_INTERRUPT;
#else /* !CONFIG_IDEPCI_SHARE_IRQ */
#else
int sa = IDE_CHIPSET_IS_PCI(hwif->chipset) ? SA_INTERRUPT|SA_SHIRQ : SA_INTERRUPT;
#endif /* CONFIG_IDEPCI_SHARE_IRQ */
#endif
if (hwif->io_ports[IDE_CONTROL_OFFSET])
OUT_BYTE(0x08, hwif->io_ports[IDE_CONTROL_OFFSET]); /* clear nIEN */
......@@ -729,13 +715,13 @@ static int init_irq (ide_hwif_t *hwif)
if (ide_request_irq(hwif->irq, &ide_intr, sa, hwif->name, hwgroup)) {
if (!match)
kfree(hwgroup);
restore_flags(flags); /* all CPUs */
spin_unlock_irqrestore(&ide_lock, flags);
return 1;
}
}
/*
* Everything is okay, so link us into the hwgroup
* Everything is okay, so link us into the hwgroup.
*/
hwif->hwgroup = hwgroup;
hwif->next = hwgroup->hwif->next;
......@@ -757,7 +743,7 @@ static int init_irq (ide_hwif_t *hwif)
printk("%s : Adding missed hwif to hwgroup!!\n", hwif->name);
#endif
}
restore_flags(flags); /* all CPUs; safe now that hwif->hwgroup is set up */
spin_unlock_irqrestore(&ide_lock, flags);
#if !defined(__mc68000__) && !defined(CONFIG_APUS) && !defined(__sparc__)
printk("%s at 0x%03x-0x%03x,0x%03x on irq %d", hwif->name,
......
......@@ -161,7 +161,6 @@ static int proc_ide_read_imodel
case ide_trm290: name = "trm290"; break;
case ide_cmd646: name = "cmd646"; break;
case ide_cy82c693: name = "cy82c693"; break;
case ide_4drives: name = "4drives"; break;
case ide_pmac: name = "mac-io"; break;
default: name = "(unknown)"; break;
}
......@@ -298,8 +297,8 @@ static int proc_ide_write_settings
}
if (*p != ':')
goto parse_error;
len = IDE_MIN(p - start, MAX_LEN);
strncpy(name, start, IDE_MIN(len, MAX_LEN));
len = min(p - start, MAX_LEN);
strncpy(name, start, min(len, MAX_LEN));
name[len] = 0;
if (n > 0) {
......@@ -307,7 +306,7 @@ static int proc_ide_write_settings
p++;
} else
goto parse_error;
digits = 0;
while (n > 0 && (d = ide_getdigit(*p)) >= 0) {
val = (val * 10) + d;
......
......@@ -1504,7 +1504,7 @@ static void idetape_input_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsigne
return;
}
#endif /* IDETAPE_DEBUG_BUGS */
count = IDE_MIN (bio->bi_size - pc->b_count, bcount);
count = min(bio->bi_size - pc->b_count, bcount);
atapi_input_bytes (drive, bio_data(bio) + pc->b_count, count);
bcount -= count;
pc->b_count += bio->bi_size;
......@@ -1529,7 +1529,7 @@ static void idetape_output_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsign
return;
}
#endif /* IDETAPE_DEBUG_BUGS */
count = IDE_MIN (pc->b_count, bcount);
count = min(pc->b_count, bcount);
atapi_output_bytes (drive, bio_data(bio), count);
bcount -= count;
pc->b_data += count;
......@@ -1559,7 +1559,7 @@ static void idetape_update_buffers (idetape_pc_t *pc)
return;
}
#endif /* IDETAPE_DEBUG_BUGS */
count = IDE_MIN (bio->bi_size, bcount);
count = min(bio->bi_size, bcount);
pc->b_count = count;
if (pc->b_count == bio->bi_size)
bio = bio->bi_next;
......@@ -1759,8 +1759,8 @@ static void idetape_increase_max_pipeline_stages (ide_drive_t *drive)
#endif /* IDETAPE_DEBUG_LOG */
tape->max_stages += increase;
tape->max_stages = IDE_MAX(tape->max_stages, tape->min_pipeline);
tape->max_stages = IDE_MIN(tape->max_stages, tape->max_pipeline);
tape->max_stages = max(tape->max_stages, tape->min_pipeline);
tape->max_stages = min(tape->max_stages, tape->max_pipeline);
}
/*
......@@ -2084,7 +2084,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
if (!status.b.drq) { /* No more interrupts */
cmd_time = (jiffies - tape->cmd_start_time) * 1000 / HZ;
tape->max_cmd_time = IDE_MAX(cmd_time, tape->max_cmd_time);
tape->max_cmd_time = max(cmd_time, tape->max_cmd_time);
#if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 2)
printk (KERN_INFO "ide-tape: Packet command completed, %d bytes transferred\n", pc->actually_transferred);
......@@ -2442,7 +2442,7 @@ static void calculate_speeds(ide_drive_t *drive)
tape->uncontrolled_pipeline_head_time = jiffies;
}
}
tape->pipeline_head_speed = IDE_MAX(tape->uncontrolled_pipeline_head_speed, tape->controlled_pipeline_head_speed);
tape->pipeline_head_speed = max(tape->uncontrolled_pipeline_head_speed, tape->controlled_pipeline_head_speed);
if (tape->speed_control == 0) {
tape->max_insert_speed = 5000;
} else if (tape->speed_control == 1) {
......@@ -2459,7 +2459,7 @@ static void calculate_speeds(ide_drive_t *drive)
(tape->pipeline_head_speed * full / 100 - tape->pipeline_head_speed * empty / 100) * tape->nr_pending_stages / tape->max_stages;
} else
tape->max_insert_speed = tape->speed_control;
tape->max_insert_speed = IDE_MAX(tape->max_insert_speed, 500);
tape->max_insert_speed = max(tape->max_insert_speed, 500);
}
static ide_startstop_t idetape_media_access_finished (ide_drive_t *drive)
......@@ -2920,7 +2920,7 @@ static void idetape_copy_stage_from_user (idetape_tape_t *tape, idetape_stage_t
return;
}
#endif /* IDETAPE_DEBUG_BUGS */
count = IDE_MIN (bio->bi_size - tape->b_count, n);
count = min(bio->bi_size - tape->b_count, n);
copy_from_user (bio_data(bio) + tape->b_count, buf, count);
n -= count;
bio->bi_size += count;
......@@ -2946,7 +2946,7 @@ static void idetape_copy_stage_to_user (idetape_tape_t *tape, char *buf, idetape
return;
}
#endif /* IDETAPE_DEBUG_BUGS */
count = IDE_MIN (tape->b_count, n);
count = min(tape->b_count, n);
copy_to_user (buf, tape->b_data, count);
n -= count;
tape->b_data += count;
......@@ -3878,7 +3878,7 @@ static void idetape_empty_write_pipeline (ide_drive_t *drive)
printk(KERN_INFO "ide-tape: bug, bio NULL\n");
break;
}
min = IDE_MIN(i, bio->bi_size - atomic_read(&bio->bi_cnt));
min = min(i, bio->bi_size - atomic_read(&bio->bi_cnt));
memset(bio_data(bio) + bio->bi_size, 0, min);
atomic_add(min, &bio->bi_cnt);
i -= min;
......@@ -4149,11 +4149,11 @@ static void idetape_pad_zeros (ide_drive_t *drive, int bcount)
while (bcount) {
bio = tape->merge_stage->bio;
count = IDE_MIN (tape->stage_size, bcount);
count = min(tape->stage_size, bcount);
bcount -= count;
blocks = count / tape->tape_block_size;
while (count) {
atomic_set(&bio->bi_cnt, IDE_MIN (count, bio->bi_size));
atomic_set(&bio->bi_cnt, min(count, bio->bi_size));
memset (bio_data(bio), 0, bio->bi_size);
count -= atomic_read(&bio->bi_cnt);
bio = bio->bi_next;
......@@ -4596,7 +4596,7 @@ static ssize_t idetape_chrdev_read (struct file *file, char *buf,
if (count == 0)
return (0);
if (tape->merge_stage_size) {
actually_read = IDE_MIN (tape->merge_stage_size, count);
actually_read = min(tape->merge_stage_size, count);
idetape_copy_stage_to_user (tape, buf, tape->merge_stage, actually_read);
buf += actually_read;
tape->merge_stage_size -= actually_read;
......@@ -4615,7 +4615,7 @@ static ssize_t idetape_chrdev_read (struct file *file, char *buf,
bytes_read=idetape_add_chrdev_read_request (drive, tape->capabilities.ctl);
if (bytes_read <= 0)
goto finish;
temp = IDE_MIN (count, bytes_read);
temp = min(count, bytes_read);
idetape_copy_stage_to_user (tape, buf, tape->merge_stage, temp);
actually_read += temp;
tape->merge_stage_size = bytes_read-temp;
......@@ -4890,7 +4890,7 @@ static ssize_t idetape_chrdev_write (struct file *file, const char *buf,
tape->merge_stage_size = 0;
}
#endif /* IDETAPE_DEBUG_BUGS */
actually_written = IDE_MIN (tape->stage_size - tape->merge_stage_size, count);
actually_written = min(tape->stage_size - tape->merge_stage_size, count);
idetape_copy_stage_from_user (tape, tape->merge_stage, buf, actually_written);
buf += actually_written;
tape->merge_stage_size += actually_written;
......@@ -6049,7 +6049,7 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor)
* Select the "best" DSC read/write polling frequency
* and pipeline size.
*/
speed = IDE_MAX (tape->capabilities.speed, tape->capabilities.max_speed);
speed = max(tape->capabilities.speed, tape->capabilities.max_speed);
tape->max_stages = speed * 1000 * 10 / tape->stage_size;
......@@ -6075,7 +6075,7 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor)
* Ensure that the number we got makes sense; limit
* it within IDETAPE_DSC_RW_MIN and IDETAPE_DSC_RW_MAX.
*/
tape->best_dsc_rw_frequency = IDE_MAX (IDE_MIN (t, IDETAPE_DSC_RW_MAX), IDETAPE_DSC_RW_MIN);
tape->best_dsc_rw_frequency = max(min(t, IDETAPE_DSC_RW_MAX), IDETAPE_DSC_RW_MIN);
printk (KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, %dkB pipeline, %lums tDSC%s\n",
drive->name, tape->name, tape->capabilities.speed, (tape->capabilities.buffer_size * 512) / tape->stage_size,
tape->stage_size / 1024, tape->max_stages * tape->stage_size / 1024,
......
This diff is collapsed.
This diff is collapsed.
/*
* linux/drivers/ide/opti621.c Version 0.6 Jan 02, 1999
*
* Copyright (C) 1996-1998 Linus Torvalds & authors (see below)
*/
/*
*
* Authors:
* Jaromir Koutek <miri@punknet.cz>,
* Jan Harkes <jaharkes@cwi.nl>,
......@@ -62,9 +58,9 @@
* by hdparm.
*
* Version 0.1, Nov 8, 1996
* by Jaromir Koutek, for 2.1.8.
* by Jaromir Koutek, for 2.1.8.
* Initial version of driver.
*
*
* Version 0.2
* Number 0.2 skipped.
*
......@@ -80,14 +76,13 @@
* by Jaromir Koutek
* Updates for use with (again) new IDE block driver.
* Update of documentation.
*
*
* Version 0.6, Jan 2, 1999
* by Jaromir Koutek
* Reversed to version 0.3 of the driver, because
* 0.5 doesn't work.
*/
#undef REALLY_SLOW_IO /* most systems can safely undef this */
#define OPTI621_DEBUG /* define for debug messages */
#include <linux/types.h>
......
/*
* linux/drivers/ide/qd65xx.c Version 0.07 Sep 30, 2001
*
* Copyright (C) 1996-2001 Linus Torvalds & author (see below)
*/
......@@ -9,24 +7,20 @@
* Version 0.04 Added second channel tuning
* Version 0.05 Enhanced tuning ; added qd6500 support
* Version 0.06 Added dos driver's list
* Version 0.07 Second channel bug fix
* Version 0.07 Second channel bug fix
*
* QDI QD6500/QD6580 EIDE controller fast support
*
* Please set local bus speed using kernel parameter idebus
* for example, "idebus=33" stands for 33Mhz VLbus
* for example, "idebus=33" stands for 33Mhz VLbus
* To activate controller support, use "ide0=qd65xx"
* To enable tuning, use "ide0=autotune"
* To enable second channel tuning (qd6580 only), use "ide1=autotune"
*/
/*
*
* Rewritten from the work of Colten Edwards <pje120@cs.usask.ca> by
* Samuel Thibault <samuel.thibault@fnac.net>
*/
#undef REALLY_SLOW_IO /* most systems can safely undef this */
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/delay.h>
......@@ -262,7 +256,7 @@ static void qd6580_tune_drive (ide_drive_t *drive, byte pio)
if (drive->id && !qd_find_disk_type(drive,&active_time,&recovery_time)) {
pio = ide_get_best_pio_mode(drive, pio, 255, &d);
pio = IDE_MIN(pio,4);
pio = min(pio,4);
switch (pio) {
case 0: break;
......
/*
* linux/drivers/ide/rz1000.c Version 0.05 December 8, 1997
*
* Copyright (C) 1995-1998 Linus Torvalds & author (see below)
*/
/*
*
* Principal Author: mlord@pobox.com (Mark Lord)
*
* See linux/MAINTAINERS for address of current maintainer.
......@@ -15,8 +11,6 @@
* Dunno if this fixes both ports, or only the primary port (?).
*/
#undef REALLY_SLOW_IO /* most systems can safely undef this */
#include <linux/config.h> /* for CONFIG_BLK_DEV_IDEPCI */
#include <linux/types.h>
#include <linux/kernel.h>
......
......@@ -138,7 +138,7 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne
idescsi_discard_data (drive, bcount);
return;
}
count = IDE_MIN (pc->sg->length - pc->b_count, bcount);
count = min(pc->sg->length - pc->b_count, bcount);
buf = page_address(pc->sg->page) + pc->sg->offset;
atapi_input_bytes (drive, buf + pc->b_count, count);
bcount -= count; pc->b_count += count;
......@@ -160,7 +160,7 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
idescsi_output_zeros (drive, bcount);
return;
}
count = IDE_MIN (pc->sg->length - pc->b_count, bcount);
count = min(pc->sg->length - pc->b_count, bcount);
buf = page_address(pc->sg->page) + pc->sg->offset;
atapi_output_bytes (drive, buf + pc->b_count, count);
bcount -= count; pc->b_count += count;
......@@ -290,7 +290,7 @@ static int idescsi_end_request(ide_drive_t *drive, int uptodate)
if (!test_bit(PC_WRITING, &pc->flags) && pc->actually_transferred && pc->actually_transferred <= 1024 && pc->buffer) {
printk(", rst = ");
scsi_buf = pc->scsi_cmd->request_buffer;
hexdump(scsi_buf, IDE_MIN(16, pc->scsi_cmd->request_bufflen));
hexdump(scsi_buf, min(16, pc->scsi_cmd->request_bufflen));
} else printk("\n");
}
}
......@@ -307,7 +307,7 @@ static int idescsi_end_request(ide_drive_t *drive, int uptodate)
static inline unsigned long get_timeout(idescsi_pc_t *pc)
{
return IDE_MAX(WAIT_CMD, pc->timeout - jiffies);
return max(WAIT_CMD, pc->timeout - jiffies);
}
/*
......@@ -431,7 +431,7 @@ static ide_startstop_t idescsi_issue_pc (ide_drive_t *drive, idescsi_pc_t *pc)
scsi->pc=pc; /* Set the current packet command */
pc->actually_transferred=0; /* We haven't transferred any data yet */
pc->current_position=pc->buffer;
bcount = IDE_MIN (pc->request_transfer, 63 * 1024); /* Request to transfer the entire buffer at once */
bcount = min(pc->request_transfer, 63 * 1024); /* Request to transfer the entire buffer at once */
if (drive->using_dma && rq->bio)
dma_ok=!HWIF(drive)->dmaproc(test_bit (PC_WRITING, &pc->flags) ? ide_dma_write : ide_dma_read, drive);
......@@ -613,9 +613,9 @@ int idescsi_detect (Scsi_Host_Template *host_template)
host = scsi_register(host_template, 0);
if(host == NULL)
return 0;
for (id = 0; id < MAX_HWIFS * MAX_DRIVES && idescsi_drives[id]; id++)
last_lun = IDE_MAX(last_lun, idescsi_drives[id]->last_lun);
last_lun = max(last_lun, idescsi_drives[id]->last_lun);
host->max_id = id;
host->max_lun = last_lun + 1;
host->can_queue = host->cmd_per_lun * id;
......
......@@ -146,8 +146,7 @@ void OUT_BYTE(unsigned char data, ide_ioreg_t reg);
unsigned char IN_BYTE(ide_ioreg_t reg);
/* this tells ide.h not to define the standard macros */
#define HAVE_ARCH_OUT_BYTE
#define HAVE_ARCH_IN_BYTE
#define HAVE_ARCH_IN_OUT 1
#endif /* __KERNEL__ */
......
......@@ -51,7 +51,7 @@
/*
* Command Header sizes for IOCTL commands
* HDIO_DRIVE_CMD, HDIO_DRIVE_TASK, and HDIO_DRIVE_TASKFILE
* HDIO_DRIVE_CMD and HDIO_DRIVE_TASK
*/
#if 0
......@@ -355,7 +355,6 @@ struct hd_big_geometry {
#define HDIO_GET_BUSSTATE 0x031a /* get the bus state of the hwif */
#define HDIO_TRISTATE_HWIF 0x031b /* execute a channel tristate */
#define HDIO_DRIVE_RESET 0x031c /* execute a device reset */
#define HDIO_DRIVE_TASKFILE 0x031d /* execute raw taskfile */
#define HDIO_DRIVE_TASK 0x031e /* execute task and special drive command */
#define HDIO_DRIVE_CMD 0x031f /* execute a special drive command */
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment