Commit 24ae9cff authored by Martin Dalecki's avatar Martin Dalecki Committed by Linus Torvalds

[PATCH] 2.5.6-pre2 IDE cleanup 16

There is no such a thing like a ide-clean-15. Never was.  But here comes
what has been done in ide-clean-16:

- Apply a patch for the initialization of the second PIIX channel.
   Found by Daniel Quinlan <quinlan@transmeta.com>

- Apply a patch for the DMA initialization of the serverworks chip.
   Ken Brownfield <brownfld@irridia.com>

- Make the ata_operations methods immune against device type drivers,
   which donot provide them by separating the access to them out. Audit
   them all.

- Resynchronize with 2.5.6-pre1.

- Remove unused IDE_DRIVE_CMD, IDE_DRIVE_TASK, IDE_DRIVE_TASK_MASK,
   IDE_DRIVE_TASKFILE macros.

- Disable configuration of the task file stuff. It is going to go away
   and will be replaced by a truly abstract interface based on
   functionality and *not* direct mess-up of hardware.

- Resync with 2.5.6-pre2.

- Add HPT entries to the fall-back list, since otherwise the driver
   won'trecognize the drives. We will have to make this the default
   behavior for allnot recognized host chip types.

- Fix compilation with no PCI host chip support enabled.

- Apply the overflow fixes for HPT366 by Vojtech Pavlik.

- Kill the one-shoot functions ide_wait_cmd_taks() ide_wait_cmd() by
   moving them to the places where they are actually used. Fix a
   potential buffer overflow on the way.

- Fix usage of ide.c as module. Thanks to Adam J. Richter for figuring
   out what was wrong.

- Various cleanups all along as well as removal of TONS of
   unfinished/dead code.

I think it's sometimes better to remove stuff, which isn't there,
instead of hoping for a "magical day" where it will be finished.
parent 3d7af078
...@@ -237,7 +237,6 @@ CONFIG_BLK_DEV_IDECD=y ...@@ -237,7 +237,6 @@ CONFIG_BLK_DEV_IDECD=y
# CONFIG_BLK_DEV_IDETAPE is not set # CONFIG_BLK_DEV_IDETAPE is not set
# CONFIG_BLK_DEV_IDEFLOPPY is not set # CONFIG_BLK_DEV_IDEFLOPPY is not set
# CONFIG_BLK_DEV_IDESCSI is not set # CONFIG_BLK_DEV_IDESCSI is not set
# CONFIG_IDE_TASK_IOCTL is not set
# #
# IDE chipset support/bugfixes # IDE chipset support/bugfixes
......
...@@ -378,7 +378,6 @@ CONFIG_BLK_DEV_IDE=m ...@@ -378,7 +378,6 @@ CONFIG_BLK_DEV_IDE=m
# CONFIG_BLK_DEV_IDECD is not set # CONFIG_BLK_DEV_IDECD is not set
# CONFIG_BLK_DEV_IDETAPE is not set # CONFIG_BLK_DEV_IDETAPE is not set
# CONFIG_BLK_DEV_IDEFLOPPY is not set # CONFIG_BLK_DEV_IDEFLOPPY is not set
# CONFIG_IDE_TASK_IOCTL is not set
# #
# IDE chipset support/bugfixes # IDE chipset support/bugfixes
......
...@@ -239,7 +239,6 @@ CONFIG_BLK_DEV_IDECD=y ...@@ -239,7 +239,6 @@ CONFIG_BLK_DEV_IDECD=y
# CONFIG_BLK_DEV_IDETAPE is not set # CONFIG_BLK_DEV_IDETAPE is not set
# CONFIG_BLK_DEV_IDEFLOPPY is not set # CONFIG_BLK_DEV_IDEFLOPPY is not set
# CONFIG_BLK_DEV_IDESCSI is not set # CONFIG_BLK_DEV_IDESCSI is not set
CONFIG_IDE_TASK_IOCTL=y
# #
# IDE chipset support/bugfixes # IDE chipset support/bugfixes
......
...@@ -273,7 +273,6 @@ CONFIG_BLK_DEV_IDECD=y ...@@ -273,7 +273,6 @@ CONFIG_BLK_DEV_IDECD=y
# CONFIG_BLK_DEV_IDETAPE is not set # CONFIG_BLK_DEV_IDETAPE is not set
# CONFIG_BLK_DEV_IDEFLOPPY is not set # CONFIG_BLK_DEV_IDEFLOPPY is not set
# CONFIG_BLK_DEV_IDESCSI is not set # CONFIG_BLK_DEV_IDESCSI is not set
# CONFIG_IDE_TASK_IOCTL is not set
# #
# IDE chipset support/bugfixes # IDE chipset support/bugfixes
......
...@@ -188,7 +188,6 @@ CONFIG_BLK_DEV_IDEDISK=y ...@@ -188,7 +188,6 @@ CONFIG_BLK_DEV_IDEDISK=y
# CONFIG_BLK_DEV_IDETAPE is not set # CONFIG_BLK_DEV_IDETAPE is not set
# CONFIG_BLK_DEV_IDEFLOPPY is not set # CONFIG_BLK_DEV_IDEFLOPPY is not set
# CONFIG_BLK_DEV_IDESCSI is not set # CONFIG_BLK_DEV_IDESCSI is not set
# CONFIG_IDE_TASK_IOCTL is not set
# #
# IDE chipset support/bugfixes # IDE chipset support/bugfixes
......
...@@ -807,14 +807,6 @@ CONFIG_IDEDISK_STROKE ...@@ -807,14 +807,6 @@ CONFIG_IDEDISK_STROKE
If you are unsure, say N here. If you are unsure, say N here.
CONFIG_IDE_TASK_IOCTL
This is a direct raw access to the media. It is a complex but
elegant solution to test and validate the domain of the hardware and
perform below the driver data recovery if needed. This is the most
basic form of media-forensics.
If you are unsure, say N here.
CONFIG_BLK_DEV_IDEDMA_FORCED CONFIG_BLK_DEV_IDEDMA_FORCED
This is an old piece of lost code from Linux 2.0 Kernels. This is an old piece of lost code from Linux 2.0 Kernels.
......
...@@ -33,9 +33,7 @@ if [ "$CONFIG_BLK_DEV_IDE" != "n" ]; then ...@@ -33,9 +33,7 @@ if [ "$CONFIG_BLK_DEV_IDE" != "n" ]; then
dep_tristate ' Include IDE/ATAPI FLOPPY support' CONFIG_BLK_DEV_IDEFLOPPY $CONFIG_BLK_DEV_IDE dep_tristate ' Include IDE/ATAPI FLOPPY support' CONFIG_BLK_DEV_IDEFLOPPY $CONFIG_BLK_DEV_IDE
dep_tristate ' SCSI emulation support' CONFIG_BLK_DEV_IDESCSI $CONFIG_BLK_DEV_IDE $CONFIG_SCSI dep_tristate ' SCSI emulation support' CONFIG_BLK_DEV_IDESCSI $CONFIG_BLK_DEV_IDE $CONFIG_SCSI
bool ' IDE Taskfile Access' CONFIG_IDE_TASK_IOCTL comment 'IDE chipset support'
comment 'IDE chipset support/bugfixes'
if [ "$CONFIG_BLK_DEV_IDE" != "n" ]; then if [ "$CONFIG_BLK_DEV_IDE" != "n" ]; then
dep_bool ' CMD640 chipset bugfix/support' CONFIG_BLK_DEV_CMD640 $CONFIG_X86 dep_bool ' CMD640 chipset bugfix/support' CONFIG_BLK_DEV_CMD640 $CONFIG_X86
dep_bool ' CMD640 enhanced support' CONFIG_BLK_DEV_CMD640_ENHANCED $CONFIG_BLK_DEV_CMD640 dep_bool ' CMD640 enhanced support' CONFIG_BLK_DEV_CMD640_ENHANCED $CONFIG_BLK_DEV_CMD640
......
...@@ -374,7 +374,8 @@ static int hpt366_get_info (char *buffer, char **addr, off_t offset, int count) ...@@ -374,7 +374,8 @@ static int hpt366_get_info (char *buffer, char **addr, off_t offset, int count)
class_rev &= 0xff; class_rev &= 0xff;
p += sprintf(p, "\nController: %d\n", i); p += sprintf(p, "\nController: %d\n", i);
p += sprintf(p, "Chipset: HPT%s\n", chipset_nums[class_rev]); p += sprintf(p, "Chipset: HPT%s\n",
class_rev < sizeof(chipset_nums) / sizeof(char *) ? chipset_nums[class_rev] : "???");
p += sprintf(p, "--------------- Primary Channel " p += sprintf(p, "--------------- Primary Channel "
"--------------- Secondary Channel " "--------------- Secondary Channel "
"--------------\n"); "--------------\n");
...@@ -1119,12 +1120,11 @@ unsigned int __init pci_init_hpt366(struct pci_dev *dev) ...@@ -1119,12 +1120,11 @@ unsigned int __init pci_init_hpt366(struct pci_dev *dev)
if (test != 0x08) if (test != 0x08)
pci_write_config_byte(dev, PCI_MAX_LAT, 0x08); pci_write_config_byte(dev, PCI_MAX_LAT, 0x08);
if (pci_rev_check_hpt3xx(dev)) { if (pci_rev_check_hpt3xx(dev))
init_hpt370(dev); init_hpt370(dev);
if (n_hpt_devs < HPT366_MAX_DEVS)
hpt_devs[n_hpt_devs++] = dev; hpt_devs[n_hpt_devs++] = dev;
} else {
hpt_devs[n_hpt_devs++] = dev;
}
#if defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS) #if defined(DISPLAY_HPT366_TIMINGS) && defined(CONFIG_PROC_FS)
if (!hpt366_proc) { if (!hpt366_proc) {
......
...@@ -2906,69 +2906,29 @@ int ide_cdrom_cleanup(ide_drive_t *drive) ...@@ -2906,69 +2906,29 @@ int ide_cdrom_cleanup(ide_drive_t *drive)
return 0; return 0;
} }
static int ide_cdrom_reinit (ide_drive_t *drive);
static struct ata_operations ide_cdrom_driver = { static struct ata_operations ide_cdrom_driver = {
owner: THIS_MODULE, owner: THIS_MODULE,
cleanup: ide_cdrom_cleanup, cleanup: ide_cdrom_cleanup,
standby: NULL, standby: NULL,
flushcache: NULL,
do_request: ide_do_rw_cdrom, do_request: ide_do_rw_cdrom,
end_request: NULL, end_request: NULL,
ioctl: ide_cdrom_ioctl, ioctl: ide_cdrom_ioctl,
open: ide_cdrom_open, open: ide_cdrom_open,
release: ide_cdrom_release, release: ide_cdrom_release,
media_change: ide_cdrom_check_media_change, check_media_change: ide_cdrom_check_media_change,
revalidate: ide_cdrom_revalidate, revalidate: ide_cdrom_revalidate,
pre_reset: NULL, pre_reset: NULL,
capacity: ide_cdrom_capacity, capacity: ide_cdrom_capacity,
special: NULL, special: NULL,
proc: NULL, proc: NULL
driver_reinit: ide_cdrom_reinit,
}; };
/* options */ /* options */
char *ignore = NULL; static char *ignore = NULL;
MODULE_PARM(ignore, "s"); MODULE_PARM(ignore, "s");
MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
static int ide_cdrom_reinit (ide_drive_t *drive)
{
struct cdrom_info *info;
int failed = 0;
MOD_INC_USE_COUNT;
info = (struct cdrom_info *) kmalloc (sizeof (struct cdrom_info), GFP_KERNEL);
if (info == NULL) {
printk ("%s: Can't allocate a cdrom structure\n", drive->name);
return 1;
}
if (ide_register_subdriver (drive, &ide_cdrom_driver)) {
printk ("%s: Failed to register the driver with ide.c\n", drive->name);
kfree (info);
return 1;
}
memset (info, 0, sizeof (struct cdrom_info));
drive->driver_data = info;
/* ATA-PATTERN */
ata_ops(drive)->busy++;
if (ide_cdrom_setup (drive)) {
ata_ops(drive)->busy--;
if (ide_cdrom_cleanup (drive))
printk ("%s: ide_cdrom_cleanup failed in ide_cdrom_init\n", drive->name);
return 1;
}
ata_ops(drive)->busy--;
failed--;
revalidate_drives();
MOD_DEC_USE_COUNT;
return 0;
}
static void __exit ide_cdrom_exit(void) static void __exit ide_cdrom_exit(void)
{ {
ide_drive_t *drive; ide_drive_t *drive;
...@@ -2980,7 +2940,7 @@ static void __exit ide_cdrom_exit(void) ...@@ -2980,7 +2940,7 @@ static void __exit ide_cdrom_exit(void)
failed++; failed++;
} }
} }
int ide_cdrom_init(void) int ide_cdrom_init(void)
{ {
ide_drive_t *drive; ide_drive_t *drive;
......
...@@ -351,7 +351,19 @@ static int idedisk_open (struct inode *inode, struct file *filp, ide_drive_t *dr ...@@ -351,7 +351,19 @@ static int idedisk_open (struct inode *inode, struct file *filp, ide_drive_t *dr
return 0; return 0;
} }
static int do_idedisk_flushcache(ide_drive_t *drive); static int idedisk_flushcache(ide_drive_t *drive)
{
struct hd_drive_task_hdr taskfile;
struct hd_drive_hob_hdr hobfile;
memset(&taskfile, 0, sizeof(struct hd_drive_task_hdr));
memset(&hobfile, 0, sizeof(struct hd_drive_hob_hdr));
if (drive->id->cfs_enable_2 & 0x2400) {
taskfile.command = WIN_FLUSH_CACHE_EXT;
} else {
taskfile.command = WIN_FLUSH_CACHE;
}
return ide_wait_taskfile(drive, &taskfile, &hobfile, NULL);
}
static void idedisk_release (struct inode *inode, struct file *filp, ide_drive_t *drive) static void idedisk_release (struct inode *inode, struct file *filp, ide_drive_t *drive)
{ {
...@@ -367,15 +379,16 @@ static void idedisk_release (struct inode *inode, struct file *filp, ide_drive_t ...@@ -367,15 +379,16 @@ static void idedisk_release (struct inode *inode, struct file *filp, ide_drive_t
drive->doorlocking = 0; drive->doorlocking = 0;
} }
if ((drive->id->cfs_enable_2 & 0x3000) && drive->wcache) if ((drive->id->cfs_enable_2 & 0x3000) && drive->wcache)
if (do_idedisk_flushcache(drive)) if (idedisk_flushcache(drive))
printk (KERN_INFO "%s: Write Cache FAILED Flushing!\n", printk (KERN_INFO "%s: Write Cache FAILED Flushing!\n",
drive->name); drive->name);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
} }
static int idedisk_media_change (ide_drive_t *drive) static int idedisk_check_media_change (ide_drive_t *drive)
{ {
return drive->removable; /* if removable, always assume it was changed */ /* if removable, always assume it was changed */
return drive->removable;
} }
/* /*
...@@ -836,7 +849,7 @@ static int write_cache (ide_drive_t *drive, int arg) ...@@ -836,7 +849,7 @@ static int write_cache (ide_drive_t *drive, int arg)
return 0; return 0;
} }
static int do_idedisk_standby (ide_drive_t *drive) static int idedisk_standby (ide_drive_t *drive)
{ {
struct hd_drive_task_hdr taskfile; struct hd_drive_task_hdr taskfile;
struct hd_drive_hob_hdr hobfile; struct hd_drive_hob_hdr hobfile;
...@@ -846,20 +859,6 @@ static int do_idedisk_standby (ide_drive_t *drive) ...@@ -846,20 +859,6 @@ static int do_idedisk_standby (ide_drive_t *drive)
return ide_wait_taskfile(drive, &taskfile, &hobfile, NULL); return ide_wait_taskfile(drive, &taskfile, &hobfile, NULL);
} }
static int do_idedisk_flushcache (ide_drive_t *drive)
{
struct hd_drive_task_hdr taskfile;
struct hd_drive_hob_hdr hobfile;
memset(&taskfile, 0, sizeof(struct hd_drive_task_hdr));
memset(&hobfile, 0, sizeof(struct hd_drive_hob_hdr));
if (drive->id->cfs_enable_2 & 0x2400) {
taskfile.command = WIN_FLUSH_CACHE_EXT;
} else {
taskfile.command = WIN_FLUSH_CACHE;
}
return ide_wait_taskfile(drive, &taskfile, &hobfile, NULL);
}
static int set_acoustic (ide_drive_t *drive, int arg) static int set_acoustic (ide_drive_t *drive, int arg)
{ {
struct hd_drive_task_hdr taskfile; struct hd_drive_task_hdr taskfile;
...@@ -1040,72 +1039,36 @@ static void idedisk_setup(ide_drive_t *drive) ...@@ -1040,72 +1039,36 @@ static void idedisk_setup(ide_drive_t *drive)
static int idedisk_cleanup (ide_drive_t *drive) static int idedisk_cleanup (ide_drive_t *drive)
{ {
/* FIXME: we will have to think twice whatever this is the proper place
* to do it.
*/
put_device(&drive->device); put_device(&drive->device);
if ((drive->id->cfs_enable_2 & 0x3000) && drive->wcache) if ((drive->id->cfs_enable_2 & 0x3000) && drive->wcache)
if (do_idedisk_flushcache(drive)) if (idedisk_flushcache(drive))
printk (KERN_INFO "%s: Write Cache FAILED Flushing!\n", printk (KERN_INFO "%s: Write Cache FAILED Flushing!\n",
drive->name); drive->name);
return ide_unregister_subdriver(drive); return ide_unregister_subdriver(drive);
} }
static int idedisk_reinit(ide_drive_t *drive);
/* /*
* IDE subdriver functions, registered with ide.c * IDE subdriver functions, registered with ide.c
*/ */
static struct ata_operations idedisk_driver = { static struct ata_operations idedisk_driver = {
owner: THIS_MODULE, owner: THIS_MODULE,
cleanup: idedisk_cleanup, cleanup: idedisk_cleanup,
standby: do_idedisk_standby, standby: idedisk_standby,
flushcache: do_idedisk_flushcache,
do_request: do_rw_disk, do_request: do_rw_disk,
end_request: NULL, end_request: NULL,
ioctl: NULL, ioctl: NULL,
open: idedisk_open, open: idedisk_open,
release: idedisk_release, release: idedisk_release,
media_change: idedisk_media_change, check_media_change: idedisk_check_media_change,
revalidate: ide_revalidate_drive, revalidate: NULL, /* use default method */
pre_reset: idedisk_pre_reset, pre_reset: idedisk_pre_reset,
capacity: idedisk_capacity, capacity: idedisk_capacity,
special: idedisk_special, special: idedisk_special,
proc: idedisk_proc, proc: idedisk_proc
driver_reinit: idedisk_reinit,
}; };
MODULE_DESCRIPTION("ATA DISK Driver"); MODULE_DESCRIPTION("ATA DISK Driver");
static int idedisk_reinit(ide_drive_t *drive)
{
int failed = 0;
MOD_INC_USE_COUNT;
if (ide_register_subdriver (drive, &idedisk_driver)) {
printk (KERN_ERR "ide-disk: %s: Failed to register the driver with ide.c\n", drive->name);
return 1;
}
ata_ops(drive)->busy++;
idedisk_setup(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);
idedisk_cleanup(drive);
ata_ops(drive)->busy--;
return 1;
}
ata_ops(drive)->busy--;
failed--;
revalidate_drives();
MOD_DEC_USE_COUNT;
return 0;
}
static void __exit idedisk_exit (void) static void __exit idedisk_exit (void)
{ {
ide_drive_t *drive; ide_drive_t *drive;
...@@ -1136,15 +1099,12 @@ int idedisk_init (void) ...@@ -1136,15 +1099,12 @@ int idedisk_init (void)
printk (KERN_ERR "ide-disk: %s: Failed to register the driver with ide.c\n", drive->name); printk (KERN_ERR "ide-disk: %s: Failed to register the driver with ide.c\n", drive->name);
continue; continue;
} }
ata_ops(drive)->busy++;
idedisk_setup(drive); idedisk_setup(drive);
if ((!drive->head || drive->head > 16) && !drive->select.b.lba) { if ((!drive->head || drive->head > 16) && !drive->select.b.lba) {
printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n", drive->name, drive->head); printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n", drive->name, drive->head);
idedisk_cleanup(drive); idedisk_cleanup(drive);
ata_ops(drive)->busy--;
continue; continue;
} }
ata_ops(drive)->busy--;
failed--; failed--;
} }
revalidate_drives(); revalidate_drives();
......
...@@ -1819,10 +1819,10 @@ static void idefloppy_release (struct inode *inode, struct file *filp, ide_drive ...@@ -1819,10 +1819,10 @@ static void idefloppy_release (struct inode *inode, struct file *filp, ide_drive
/* /*
* Check media change. Use a simple algorithm for now. * Check media change. Use a simple algorithm for now.
*/ */
static int idefloppy_media_change (ide_drive_t *drive) static int idefloppy_check_media_change (ide_drive_t *drive)
{ {
idefloppy_floppy_t *floppy = drive->driver_data; idefloppy_floppy_t *floppy = drive->driver_data;
return test_and_clear_bit (IDEFLOPPY_MEDIA_CHANGED, &floppy->flags); return test_and_clear_bit (IDEFLOPPY_MEDIA_CHANGED, &floppy->flags);
} }
...@@ -2038,8 +2038,6 @@ static ide_proc_entry_t idefloppy_proc[] = { ...@@ -2038,8 +2038,6 @@ static ide_proc_entry_t idefloppy_proc[] = {
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
static int idefloppy_reinit(ide_drive_t *drive);
/* /*
* IDE subdriver functions, registered with ide.c * IDE subdriver functions, registered with ide.c
*/ */
...@@ -2047,58 +2045,19 @@ static struct ata_operations idefloppy_driver = { ...@@ -2047,58 +2045,19 @@ static struct ata_operations idefloppy_driver = {
owner: THIS_MODULE, owner: THIS_MODULE,
cleanup: idefloppy_cleanup, cleanup: idefloppy_cleanup,
standby: NULL, standby: NULL,
flushcache: NULL,
do_request: idefloppy_do_request, do_request: idefloppy_do_request,
end_request: idefloppy_end_request, end_request: idefloppy_end_request,
ioctl: idefloppy_ioctl, ioctl: idefloppy_ioctl,
open: idefloppy_open, open: idefloppy_open,
release: idefloppy_release, release: idefloppy_release,
media_change: idefloppy_media_change, check_media_change: idefloppy_check_media_change,
revalidate: ide_revalidate_drive, revalidate: NULL, /* use default method */
pre_reset: NULL, pre_reset: NULL,
capacity: idefloppy_capacity, capacity: idefloppy_capacity,
special: NULL, special: NULL,
proc: idefloppy_proc, proc: idefloppy_proc
driver_reinit: idefloppy_reinit,
}; };
static int idefloppy_reinit (ide_drive_t *drive)
{
idefloppy_floppy_t *floppy;
int failed = 0;
MOD_INC_USE_COUNT;
while ((drive = ide_scan_devices(ATA_FLOPPY, "ide-floppy", NULL, failed++)) != NULL) {
if (!idefloppy_identify_device (drive, drive->id)) {
printk (KERN_ERR "ide-floppy: %s: not supported by this version of ide-floppy\n", drive->name);
continue;
}
if (drive->scsi) {
printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name);
continue;
}
if ((floppy = (idefloppy_floppy_t *) kmalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) {
printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name);
continue;
}
if (ide_register_subdriver (drive, &idefloppy_driver)) {
printk (KERN_ERR "ide-floppy: %s: Failed to register the driver with ide.c\n", drive->name);
kfree (floppy);
continue;
}
/* ATA-PATTERN */
ata_ops(drive)->busy++;
idefloppy_setup (drive, floppy);
ata_ops(drive)->busy--;
failed--;
}
revalidate_drives();
MOD_DEC_USE_COUNT;
return 0;
}
MODULE_DESCRIPTION("ATAPI FLOPPY Driver"); MODULE_DESCRIPTION("ATAPI FLOPPY Driver");
static void __exit idefloppy_exit (void) static void __exit idefloppy_exit (void)
......
...@@ -14,14 +14,14 @@ ...@@ -14,14 +14,14 @@
#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
extern ide_drive_t * get_info_ptr(kdev_t); extern ide_drive_t * get_info_ptr(kdev_t);
extern unsigned long current_capacity (ide_drive_t *);
/* /*
* If heads is nonzero: find a translation with this many heads and S=63. * If heads is nonzero: find a translation with this many heads and S=63.
* Otherwise: find out how OnTrack Disk Manager would translate the disk. * Otherwise: find out how OnTrack Disk Manager would translate the disk.
*/ */
static void static void
ontrack(ide_drive_t *drive, int heads, unsigned int *c, int *h, int *s) { ontrack(ide_drive_t *drive, int heads, unsigned int *c, int *h, int *s)
{
static const byte dm_head_vals[] = {4, 8, 16, 32, 64, 128, 255, 0}; static const byte dm_head_vals[] = {4, 8, 16, 32, 64, 128, 255, 0};
const byte *headp = dm_head_vals; const byte *headp = dm_head_vals;
unsigned long total; unsigned long total;
...@@ -34,7 +34,7 @@ ontrack(ide_drive_t *drive, int heads, unsigned int *c, int *h, int *s) { ...@@ -34,7 +34,7 @@ ontrack(ide_drive_t *drive, int heads, unsigned int *c, int *h, int *s) {
* computes a geometry different from what OnTrack uses.] * computes a geometry different from what OnTrack uses.]
*/ */
total = ata_ops(drive)->capacity(drive); total = ata_capacity(drive);
*s = 63; *s = 63;
...@@ -136,7 +136,7 @@ int ide_xlate_1024 (kdev_t i_rdev, int xparm, int ptheads, const char *msg) ...@@ -136,7 +136,7 @@ int ide_xlate_1024 (kdev_t i_rdev, int xparm, int ptheads, const char *msg)
ret = 1; ret = 1;
} }
drive->part[0].nr_sects = current_capacity(drive); drive->part[0].nr_sects = ata_capacity(drive);
if (ret) if (ret)
printk("%s%s [%d/%d/%d]", msg, msg1, printk("%s%s [%d/%d/%d]", msg, msg1,
......
...@@ -303,7 +303,9 @@ static ide_pci_device_t pci_chipsets[] __initdata = { ...@@ -303,7 +303,9 @@ static ide_pci_device_t pci_chipsets[] __initdata = {
#ifdef CONFIG_BLK_DEV_IT8172 #ifdef CONFIG_BLK_DEV_IT8172
{PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_IT8172G, pci_init_it8172, NULL, ide_init_it8172, NULL, {{0x00,0x00,0x00}, {0x40,0x00,0x01}}, ON_BOARD, 0, 0 }, {PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_IT8172G, pci_init_it8172, NULL, ide_init_it8172, NULL, {{0x00,0x00,0x00}, {0x40,0x00,0x01}}, ON_BOARD, 0, 0 },
#endif #endif
/* Those are id's of chips we don't deal currently with. */ /* Those are id's of chips we don't deal currently with,
* but which still need some generic quirk handling.
*/
{PCI_VENDOR_ID_PCTECH, PCI_DEVICE_ID_PCTECH_SAMURAI_IDE, NULL, NULL, NULL, NULL, {{0x00,0x00,0x00}, {0x00,0x00,0x00}}, ON_BOARD, 0, 0 }, {PCI_VENDOR_ID_PCTECH, PCI_DEVICE_ID_PCTECH_SAMURAI_IDE, NULL, NULL, NULL, NULL, {{0x00,0x00,0x00}, {0x00,0x00,0x00}}, ON_BOARD, 0, 0 },
{PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_CMD_640, NULL, NULL, IDE_IGNORE, NULL, {{0x00,0x00,0x00}, {0x00,0x00,0x00}}, ON_BOARD, 0, 0 }, {PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_CMD_640, NULL, NULL, IDE_IGNORE, NULL, {{0x00,0x00,0x00}, {0x00,0x00,0x00}}, ON_BOARD, 0, 0 },
{PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87410, NULL, NULL, NULL, NULL, {{0x43,0x08,0x08}, {0x47,0x08,0x08}}, ON_BOARD, 0, 0 }, {PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87410, NULL, NULL, NULL, NULL, {{0x43,0x08,0x08}, {0x47,0x08,0x08}}, ON_BOARD, 0, 0 },
...@@ -313,6 +315,7 @@ static ide_pci_device_t pci_chipsets[] __initdata = { ...@@ -313,6 +315,7 @@ static ide_pci_device_t pci_chipsets[] __initdata = {
{PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8886A, NULL, NULL, NULL, NULL, {{0x00,0x00,0x00}, {0x00,0x00,0x00}}, ON_BOARD, 0, ATA_F_FIXIRQ }, {PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8886A, NULL, NULL, NULL, NULL, {{0x00,0x00,0x00}, {0x00,0x00,0x00}}, ON_BOARD, 0, ATA_F_FIXIRQ },
{PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8886BF, NULL, NULL, NULL, NULL, {{0x00,0x00,0x00}, {0x00,0x00,0x00}}, ON_BOARD, 0, ATA_F_FIXIRQ }, {PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8886BF, NULL, NULL, NULL, NULL, {{0x00,0x00,0x00}, {0x00,0x00,0x00}}, ON_BOARD, 0, ATA_F_FIXIRQ },
{PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C561, NULL, NULL, NULL, NULL, {{0x00,0x00,0x00}, {0x00,0x00,0x00}}, ON_BOARD, 0, ATA_F_NOADMA }, {PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C561, NULL, NULL, NULL, NULL, {{0x00,0x00,0x00}, {0x00,0x00,0x00}}, ON_BOARD, 0, ATA_F_NOADMA },
{PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT366, NULL, NULL, IDE_NO_DRIVER, NULL, {{0x00,0x00,0x00}, {0x00,0x00,0x00}}, OFF_BOARD, 240, ATA_F_IRQ | ATA_F_HPTHACK },
{0, 0, NULL, NULL, NULL, NULL, {{0x00,0x00,0x00}, {0x00,0x00,0x00}}, ON_BOARD, 0 }}; {0, 0, NULL, NULL, NULL, NULL, {{0x00,0x00,0x00}, {0x00,0x00,0x00}}, ON_BOARD, 0 }};
/* /*
......
...@@ -471,9 +471,11 @@ static void hwif_register (ide_hwif_t *hwif) ...@@ -471,9 +471,11 @@ static void hwif_register (ide_hwif_t *hwif)
sprintf(hwif->device.bus_id, "%04x", hwif->io_ports[IDE_DATA_OFFSET]); sprintf(hwif->device.bus_id, "%04x", hwif->io_ports[IDE_DATA_OFFSET]);
sprintf(hwif->device.name, "ide"); sprintf(hwif->device.name, "ide");
hwif->device.driver_data = hwif; hwif->device.driver_data = hwif;
#ifdef CONFIG_BLK_DEV_IDEPCI
if (hwif->pci_dev) if (hwif->pci_dev)
hwif->device.parent = &hwif->pci_dev->dev; hwif->device.parent = &hwif->pci_dev->dev;
else else
#endif
hwif->device.parent = NULL; /* Would like to do = &device_legacy */ hwif->device.parent = NULL; /* Would like to do = &device_legacy */
device_register(&hwif->device); device_register(&hwif->device);
......
...@@ -353,7 +353,7 @@ int proc_ide_read_capacity ...@@ -353,7 +353,7 @@ int proc_ide_read_capacity
if (!driver) if (!driver)
len = sprintf(page, "(none)\n"); len = sprintf(page, "(none)\n");
else else
len = sprintf(page,"%llu\n", (unsigned long long) drive->driver->capacity(drive)); len = sprintf(page,"%llu\n", (unsigned long long) ata_capacity(drive));
PROC_IDE_READ_RETURN(page,start,off,count,eof,len); PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
} }
......
...@@ -6140,7 +6140,12 @@ static ide_proc_entry_t idetape_proc[] = { ...@@ -6140,7 +6140,12 @@ static ide_proc_entry_t idetape_proc[] = {
#endif #endif
static int idetape_reinit(ide_drive_t *drive); static void idetape_revalidate(ide_drive_t *_dummy)
{
/* We don't have to handle any partition information here, which is the
* default behaviour of this method.
*/
}
/* /*
* IDE subdriver functions, registered with ide.c * IDE subdriver functions, registered with ide.c
...@@ -6149,18 +6154,16 @@ static struct ata_operations idetape_driver = { ...@@ -6149,18 +6154,16 @@ static struct ata_operations idetape_driver = {
owner: THIS_MODULE, owner: THIS_MODULE,
cleanup: idetape_cleanup, cleanup: idetape_cleanup,
standby: NULL, standby: NULL,
flushcache: NULL,
do_request: idetape_do_request, do_request: idetape_do_request,
end_request: idetape_end_request, end_request: idetape_end_request,
ioctl: idetape_blkdev_ioctl, ioctl: idetape_blkdev_ioctl,
open: idetape_blkdev_open, open: idetape_blkdev_open,
release: idetape_blkdev_release, release: idetape_blkdev_release,
media_change: NULL, check_media_change: NULL,
revalidate: NULL, revalidate: idetape_revalidate,
pre_reset: idetape_pre_reset, pre_reset: idetape_pre_reset,
capacity: NULL, capacity: NULL,
proc: idetape_proc, proc: idetape_proc
driver_reinit: idetape_reinit,
}; };
/* /*
...@@ -6175,12 +6178,6 @@ static struct file_operations idetape_fops = { ...@@ -6175,12 +6178,6 @@ static struct file_operations idetape_fops = {
release: idetape_chrdev_release, release: idetape_chrdev_release,
}; };
/* This will propably just go entierly away... */
static int idetape_reinit (ide_drive_t *drive)
{
return 1;
}
MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver"); MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -1750,6 +1750,29 @@ int ide_taskfile_ioctl (ide_drive_t *drive, struct inode *inode, struct file *fi ...@@ -1750,6 +1750,29 @@ int ide_taskfile_ioctl (ide_drive_t *drive, struct inode *inode, struct file *fi
return err; return err;
} }
/*
* Issue ATA command and wait for completion. use for implementing commands in
* kernel.
*
* The caller has to make sure buf is never NULL!
*/
static int ide_wait_cmd(ide_drive_t *drive, int cmd, int nsect, int feature, int sectors, byte *argbuf)
{
struct request rq;
/* FIXME: Do we really have to zero out the buffer?
*/
memset(argbuf, 0, 4 + SECTOR_WORDS * 4 * sectors);
ide_init_drive_cmd(&rq);
rq.buffer = argbuf;
*argbuf++ = cmd;
*argbuf++ = nsect;
*argbuf++ = feature;
*argbuf++ = sectors;
return ide_do_drive_cmd(drive, &rq, ide_wait);
}
int ide_cmd_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) int ide_cmd_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{ {
int err = 0; int err = 0;
...@@ -1806,12 +1829,20 @@ int ide_cmd_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, u ...@@ -1806,12 +1829,20 @@ int ide_cmd_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, u
int ide_task_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) int ide_task_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{ {
int err = 0; int err = 0;
byte args[7], *argbuf = args; u8 args[7];
u8 *argbuf;
int argsize = 7; int argsize = 7;
struct request rq;
argbuf = args;
if (copy_from_user(args, (void *)arg, 7)) if (copy_from_user(args, (void *)arg, 7))
return -EFAULT; return -EFAULT;
err = ide_wait_cmd_task(drive, argbuf);
ide_init_drive_cmd(&rq);
rq.flags = REQ_DRIVE_TASK;
rq.buffer = argbuf;
err = ide_do_drive_cmd(drive, &rq, ide_wait);
if (copy_to_user((void *)arg, argbuf, argsize)) if (copy_to_user((void *)arg, argbuf, argsize))
err = -EFAULT; err = -EFAULT;
return err; return err;
......
This diff is collapsed.
...@@ -214,7 +214,7 @@ static void piix_tune_drive (ide_drive_t *drive, byte pio) ...@@ -214,7 +214,7 @@ static void piix_tune_drive (ide_drive_t *drive, byte pio)
{ {
unsigned long flags; unsigned long flags;
u16 master_data; u16 master_data;
byte slave_data; u8 slave_data;
int is_slave = (&HWIF(drive)->drives[1] == drive); int is_slave = (&HWIF(drive)->drives[1] == drive);
int master_port = HWIF(drive)->index ? 0x42 : 0x40; int master_port = HWIF(drive)->index ? 0x42 : 0x40;
int slave_port = 0x44; int slave_port = 0x44;
......
...@@ -660,8 +660,10 @@ void __init ide_init_svwks (ide_hwif_t *hwif) ...@@ -660,8 +660,10 @@ void __init ide_init_svwks (ide_hwif_t *hwif)
hwif->autodma = 0; hwif->autodma = 0;
#else /* CONFIG_BLK_DEV_IDEDMA */ #else /* CONFIG_BLK_DEV_IDEDMA */
if (hwif->dma_base) { if (hwif->dma_base) {
#ifdef CONFIG_IDEDMA_AUTO
if (!noautodma) if (!noautodma)
hwif->autodma = 1; hwif->autodma = 1;
#endif
hwif->dmaproc = &svwks_dmaproc; hwif->dmaproc = &svwks_dmaproc;
hwif->highmem = 1; hwif->highmem = 1;
} else { } else {
......
...@@ -536,7 +536,11 @@ static int idescsi_cleanup (ide_drive_t *drive) ...@@ -536,7 +536,11 @@ static int idescsi_cleanup (ide_drive_t *drive)
return 0; return 0;
} }
static int idescsi_reinit(ide_drive_t *drive); static void idescsi_revalidate(ide_drive_t *_dummy)
{
/* The partition information will be handled by the SCSI layer.
*/
}
/* /*
* IDE subdriver functions, registered with ide.c * IDE subdriver functions, registered with ide.c
...@@ -545,26 +549,19 @@ static struct ata_operations idescsi_driver = { ...@@ -545,26 +549,19 @@ static struct ata_operations idescsi_driver = {
owner: THIS_MODULE, owner: THIS_MODULE,
cleanup: idescsi_cleanup, cleanup: idescsi_cleanup,
standby: NULL, standby: NULL,
flushcache: NULL,
do_request: idescsi_do_request, do_request: idescsi_do_request,
end_request: idescsi_end_request, end_request: idescsi_end_request,
ioctl: NULL, ioctl: NULL,
open: idescsi_open, open: idescsi_open,
release: idescsi_ide_release, release: idescsi_ide_release,
media_change: NULL, check_media_change: NULL,
revalidate: NULL, revalidate: idescsi_revalidate,
pre_reset: NULL, pre_reset: NULL,
capacity: NULL, capacity: NULL,
special: NULL, special: NULL,
proc: NULL, proc: NULL
driver_reinit: idescsi_reinit,
}; };
static int idescsi_reinit (ide_drive_t *drive)
{
return 0;
}
/* /*
* idescsi_init will register the driver for each scsi. * idescsi_init will register the driver for each scsi.
*/ */
......
...@@ -51,28 +51,16 @@ ...@@ -51,28 +51,16 @@
#endif #endif
#ifdef CONFIG_BLK_DEV_CMD640 #ifdef CONFIG_BLK_DEV_CMD640
#if 0 /* change to 1 when debugging cmd640 problems */ # if 0 /* change to 1 when debugging cmd640 problems */
void cmd640_dump_regs (void); void cmd640_dump_regs (void);
#define CMD640_DUMP_REGS cmd640_dump_regs() /* for debugging cmd640 chipset */ # define CMD640_DUMP_REGS cmd640_dump_regs() /* for debugging cmd640 chipset */
# endif
#endif #endif
#endif /* CONFIG_BLK_DEV_CMD640 */
#ifndef DISABLE_IRQ_NOSYNC #ifndef DISABLE_IRQ_NOSYNC
#define DISABLE_IRQ_NOSYNC 0 # define DISABLE_IRQ_NOSYNC 0
#endif #endif
/*
* IDE_DRIVE_CMD is used to implement many features of the hdparm utility
*/
#define IDE_DRIVE_CMD 99 /* (magic) undef to reduce kernel size*/
#define IDE_DRIVE_TASK 98
/*
* IDE_DRIVE_TASKFILE is used to implement many features needed for raw tasks
*/
#define IDE_DRIVE_TASKFILE 97
/* /*
* "No user-serviceable parts" beyond this point :) * "No user-serviceable parts" beyond this point :)
*****************************************************************************/ *****************************************************************************/
...@@ -95,7 +83,7 @@ typedef unsigned char byte; /* used everywhere */ ...@@ -95,7 +83,7 @@ typedef unsigned char byte; /* used everywhere */
* Ensure that various configuration flags have compatible settings * Ensure that various configuration flags have compatible settings
*/ */
#ifdef REALLY_SLOW_IO #ifdef REALLY_SLOW_IO
#undef REALLY_FAST_IO # undef REALLY_FAST_IO
#endif #endif
#define HWIF(drive) ((drive)->hwif) #define HWIF(drive) ((drive)->hwif)
...@@ -705,21 +693,19 @@ struct ata_operations { ...@@ -705,21 +693,19 @@ struct ata_operations {
unsigned busy: 1; /* FIXME: this will go soon away... */ unsigned busy: 1; /* FIXME: this will go soon away... */
int (*cleanup)(ide_drive_t *); int (*cleanup)(ide_drive_t *);
int (*standby)(ide_drive_t *); int (*standby)(ide_drive_t *);
int (*flushcache)(ide_drive_t *);
ide_startstop_t (*do_request)(ide_drive_t *, struct request *, unsigned long); ide_startstop_t (*do_request)(ide_drive_t *, struct request *, unsigned long);
int (*end_request)(ide_drive_t *drive, int uptodate); int (*end_request)(ide_drive_t *drive, int uptodate);
int (*ioctl)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long); int (*ioctl)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
int (*open)(struct inode *, struct file *, ide_drive_t *); int (*open)(struct inode *, struct file *, ide_drive_t *);
void (*release)(struct inode *, struct file *, ide_drive_t *); void (*release)(struct inode *, struct file *, ide_drive_t *);
int (*media_change)(ide_drive_t *); int (*check_media_change)(ide_drive_t *);
void (*revalidate)(ide_drive_t *); void (*revalidate)(ide_drive_t *);
void (*pre_reset)(ide_drive_t *); void (*pre_reset)(ide_drive_t *);
unsigned long (*capacity)(ide_drive_t *); unsigned long (*capacity)(ide_drive_t *);
ide_startstop_t (*special)(ide_drive_t *); ide_startstop_t (*special)(ide_drive_t *);
ide_proc_entry_t *proc; ide_proc_entry_t *proc;
int (*driver_reinit)(ide_drive_t *);
}; };
/* Alas, no aliases. Too much hassle with bringing module.h everywhere */ /* Alas, no aliases. Too much hassle with bringing module.h everywhere */
...@@ -734,6 +720,7 @@ do { \ ...@@ -734,6 +720,7 @@ do { \
__MOD_DEC_USE_COUNT((ata)->owner); \ __MOD_DEC_USE_COUNT((ata)->owner); \
} while(0) } while(0)
extern unsigned long ata_capacity(ide_drive_t *drive);
/* FIXME: Actually implement and use them as soon as possible! to make the /* FIXME: Actually implement and use them as soon as possible! to make the
* ide_scan_devices() go away! */ * ide_scan_devices() go away! */
...@@ -818,16 +805,6 @@ int ide_xlate_1024 (kdev_t, int, int, const char *); ...@@ -818,16 +805,6 @@ int ide_xlate_1024 (kdev_t, int, int, const char *);
*/ */
ide_drive_t *get_info_ptr (kdev_t i_rdev); ide_drive_t *get_info_ptr (kdev_t i_rdev);
/*
* Return the current idea about the total capacity of this drive.
*/
unsigned long current_capacity (ide_drive_t *drive);
/*
* Revalidate (read partition tables)
*/
extern void ide_revalidate_drive (ide_drive_t *drive);
/* /*
* Start a reset operation for an IDE interface. * Start a reset operation for an IDE interface.
* The caller should return immediately after invoking this. * The caller should return immediately after invoking this.
...@@ -892,18 +869,9 @@ int ide_do_drive_cmd (ide_drive_t *drive, struct request *rq, ide_action_t actio ...@@ -892,18 +869,9 @@ int ide_do_drive_cmd (ide_drive_t *drive, struct request *rq, ide_action_t actio
/* /*
* Clean up after success/failure of an explicit drive cmd. * Clean up after success/failure of an explicit drive cmd.
* stat/err are used only when (HWGROUP(drive)->rq->cmd == IDE_DRIVE_CMD).
* stat/err are used only when (HWGROUP(drive)->rq->cmd == IDE_DRIVE_TASK_MASK).
*/ */
void ide_end_drive_cmd (ide_drive_t *drive, byte stat, byte err); void ide_end_drive_cmd (ide_drive_t *drive, byte stat, byte err);
/*
* Issue ATA command and wait for completion. use for implementing commands in kernel
*/
int ide_wait_cmd (ide_drive_t *drive, int cmd, int nsect, int feature, int sectors, byte *buf);
int ide_wait_cmd_task (ide_drive_t *drive, byte *buf);
typedef struct ide_task_s { typedef struct ide_task_s {
task_ioreg_t tfRegister[8]; task_ioreg_t tfRegister[8];
task_ioreg_t hobRegister[8]; task_ioreg_t hobRegister[8];
......
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