History log of /include/linux/ide.h
Revision Date Author Comments
8b48463f89429af408ff695244dc627e1acff4f7 03-Dec-2013 Lv Zheng <lv.zheng@intel.com> ACPI: Clean up inclusions of ACPI header files

Replace direct inclusions of <acpi/acpi.h>, <acpi/acpi_bus.h> and
<acpi/acpi_drivers.h>, which are incorrect, with <linux/acpi.h>
inclusions and remove some inclusions of those files that aren't
necessary.

First of all, <acpi/acpi.h>, <acpi/acpi_bus.h> and <acpi/acpi_drivers.h>
should not be included directly from any files that are built for
CONFIG_ACPI unset, because that generally leads to build warnings about
undefined symbols in !CONFIG_ACPI builds. For CONFIG_ACPI set,
<linux/acpi.h> includes those files and for CONFIG_ACPI unset it
provides stub ACPI symbols to be used in that case.

Second, there are ordering dependencies between those files that always
have to be met. Namely, it is required that <acpi/acpi_bus.h> be included
prior to <acpi/acpi_drivers.h> so that the acpi_pci_root declarations the
latter depends on are always there. And <acpi/acpi.h> which provides
basic ACPICA type declarations should always be included prior to any other
ACPI headers in CONFIG_ACPI builds. That also is taken care of including
<linux/acpi.h> as appropriate.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Matthew Garrett <mjg59@srcf.ucam.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com> (drivers/pci stuff)
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> (Xen stuff)
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
fb3fed7926545e44ce36574e1b1c5cdeb018db5c 08-Oct-2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org> ide: convert bus code to use dev_groups

The dev_attrs field of struct bus_type is going away soon, dev_groups
should be used instead. This converts the ide bus code to use the
correct field.

Acked-by: David S. Miller <davem@davemloft.net>
Cc: <linux-ide@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9ffc93f203c18a70623f21950f1dd473c9ec48cd 28-Mar-2012 David Howells <dhowells@redhat.com> Remove all #inclusions of asm/system.h

Remove all #inclusions of asm/system.h preparatory to splitting and killing
it. Performed with the following command:

perl -p -i -e 's!^#\s*include\s*<asm/system[.]h>.*\n!!' `grep -Irl '^#\s*include\s*<asm/system[.]h>' *`

Signed-off-by: David Howells <dhowells@redhat.com>
313162d0b83836e2f57e51b9b8650fb4b9c396ea 30-Jan-2012 Paul Gortmaker <paul.gortmaker@windriver.com> device.h: audit and cleanup users in main include dir

The <linux/device.h> header includes a lot of stuff, and
it in turn gets a lot of use just for the basic "struct device"
which appears so often.

Clean up the users as follows:

1) For those headers only needing "struct device" as a pointer
in fcn args, replace the include with exactly that.

2) For headers not really using anything from device.h, simply
delete the include altogether.

3) For headers relying on getting device.h implicitly before
being included themselves, now explicitly include device.h

4) For files in which doing #1 or #2 uncovers an implicit
dependency on some other header, fix by explicitly adding
the required header(s).

Any C files that were implicitly relying on device.h to be
present have already been dealt with in advance.

Total removals from #1 and #2: 51. Total additions coming
from #3: 9. Total other implicit dependencies from #4: 7.

As of 3.3-rc1, there were 110, so a net removal of 42 gives
about a 38% reduction in device.h presence in include/*

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
d161a13f974c72fd7ff0069d39a3ae57cb5694ff 24-Jul-2011 Al Viro <viro@zeniv.linux.org.uk> switch procfs to umode_t use

both proc_dir_entry ->mode and populating functions

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
245e37182b7dead255bdc9e333e0bcc128360675 09-May-2011 Anton Blanchard <anton@samba.org> ide: Use linux/mutex.h

The IDE code is still including asm/mutex.h instead of linux/mutex.h

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
65155b3708137fabee865dc4da822763c0c41208 11-Jun-2010 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> fix typos concerning "management"

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
c3e33e043f5e9c583aa59d5591a614b2a8243d3a 15-May-2010 Tejun Heo <tj@kernel.org> block,ide: simplify bdops->set_capacity() to ->unlock_native_capacity()

bdops->set_capacity() is unnecessarily generic. All that's required
is a simple one way notification to lower level driver telling it to
try to unlock native capacity. There's no reason to pass in target
capacity or return the new capacity. The former is always the
inherent native capacity and the latter can be handled via the usual
device resize / revalidation path. In fact, the current API is always
used that way.

Replace ->set_capacity() with ->unlock_native_capacity() which take
only @disk and doesn't return anything. IDE which is the only current
user of the API is converted accordingly.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
54a4ec469dd6067f0b604bef8ca01a2b1fdb4dcd 15-Apr-2010 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: fix comment typo in ide.h

Fix typo in the comment to the 'dma_mode' field of the 'struct ide_drive_s'
introduced by the commit 3fccaa192b9501e79a57e02e62b6bf420d2b461e (ide: add
drive->dma_mode field).

Whilt at it, convert spaces to a tab in the declaration of the neighbouring
'dn' field...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6072f7491f5ef391a575e18a1165e72a3eef1601 31-Mar-2010 Herbert Xu <herbert@gondor.apana.org.au> ide: Requeue request after DMA timeout

I noticed that my KVM virtual machines were experiencing IDE
issues resulting in processes stuck on waiting for buffers to
complete.

The root cause is of course race conditions in the ancient qemu
backend that I'm using. However, the fact that the guest isn't
recovering is a bug.

I've tracked it down to the change made last year to dequeue
requests at the start rather than at the end in the IDE layer.

commit 8f6205cd572fece673da0255d74843680f67f879
Author: Tejun Heo <tj@kernel.org>
Date: Fri May 8 11:53:59 2009 +0900

ide: dequeue in-flight request

The problem is that the function ide_dma_timeout_retry does not
requeue the current request, causing one request to be lost for
each DMA timeout.

This patch fixes this by requeueing the request.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
220c58bc6d1198c4c4e69a385d364602c38b6b1c 18-Jan-2010 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make ide_get_best_pio_mode() static

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8776168ca2151850164af1de5565d01f7b8b2c53 19-Jan-2010 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: change ->set_dma_mode method parameters

Change ->set_dma_mode method parameters to match ->set_dmamode method
used in struct ata_port_operations.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e085b3cae85af47eb0a3eda3186bd898310fb322 19-Jan-2010 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: change ->set_pio_mode method parameters

Change ->set_pio_mode method parameters to match ->set_piomode method
used in struct ata_port_operations.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3fccaa192b9501e79a57e02e62b6bf420d2b461e 18-Jan-2010 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add drive->dma_mode field

Add dma_mode field to ide_drive_t matching dma_mode field used in
struct ata_device.

The validity of the field is restricted to ->dma_pio_mode method
only currently in IDE subsystem.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
d2d4e780aff2fab46a792ebc89f80d1a6872b325 18-Jan-2010 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add drive->pio_mode field

Add pio_mode field to ide_drive_t matching pio_mode field used in
struct ata_device.

The validity of the field is restricted to ->set_pio_mode method
only currently in IDE subsystem.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
602da297e293eb2cbd28dcdbbe247593a46a853a 03-Dec-2009 David S. Miller <davem@davemloft.net> ide: Increase WAIT_DRQ to accomodate some CF cards and SSD drives.

Based upon a patch by Philippe De Muyter, and feedback from Mark
Lord and Robert Hancock.

As noted by Mark Lord, the outdated ATA1 spec specifies a 20msec
timeout for setting DRQ but lots of common devices overshoot this.

Signed-off-by: David S. Miller <davem@davemloft.net>
6d703a81ad5fdd102334751ddacb053ecc6ff046 02-Sep-2009 Alexey Dobriyan <adobriyan@gmail.com> ide: convert to ->proc_fops

->read_proc, ->write_proc are going away, ->proc_fops should be used instead.

The only tricky place is IDENTIFY handling: if for some reason
taskfile_lib_get_identify() fails, buffer _is_ changed and at least
first byte is overwritten. Emulate old behaviour with returning
that first byte to userspace and reporting length=1 despite overall -E.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
665d66e8fad60a5a162c4615f27f916ad1a6d567 23-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix races in handling of user-space SET XFER commands

* Make cmd->tf_flags field 'u16' and add IDE_TFLAG_SET_XFER taskfile flag.

* Update ide_finish_cmd() to set xfer / re-read id if the new flag is set.

* Convert set_xfer_rate() (write handler for /proc/ide/hd?/current_speed)
and ide_cmd_ioctl() (HDIO_DRIVE_CMD ioctl handler) to use the new flag.

* Remove no longer needed disable_irq_nosync() + enable_irq() from
ide_config_drive_speed().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
fa56d4cb4022c8b313c3b99236e1b87effc3655b 23-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: allow ide_dev_read_id() to be called from the IRQ context

* Un-static __ide_wait_stat().

* Allow ide_dev_read_id() helper to be called from the IRQ context by
adding irq_ctx flag and using mdelay()/__ide_wait_stat() when needed.

* Switch ide_driveid_update() to set irq_ctx flag.

This change is needed for the consecutive patch which fixes races in
handling of user-space SET XFER commands but for improved bisectability
and clarity it is better to do it in a separate patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2bf427b25b79eb7cea27963a66c3d4684cae0e0c 30-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix resume for CONFIG_BLK_DEV_IDEACPI=y

commit 2f0d0fd2a605666d38e290c5c0d2907484352dc4 ("ide-acpi: cleanup
do_drive_get_GTF()") didn't account for the lack of hwif->acpidata
check in generic_ide_suspend() [ indirect user of do_drive_get_GTF()
through ide_acpi_exec_tfs() ] resulting in broken resume when ACPI
support is enabled but ACPI data is unavailable.

Fix it by adding ide_port_acpi() helper for checking if port needs
ACPI handling and cleaning generic_ide_{suspend,resume}() to use it
instead of hiding hwif->acpidata and ide_noacpi checks in IDE ACPI
helpers (this should help in preventing similar bugs in the future).

While at it:
- kill superfluous debugging printks in ide_acpi_{get,push}_timing()

Reported-and-tested-by: Etienne Basset <etienne.basset@numericable.fr>
Also-reported-and-tested-by: Jeff Chua <jeff.chua.linux@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5e955245d6cf49c5ed26c7add7392ff5a6762bf4 23-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: always kill the whole request on error

* Use blk_rq_bytes() instead of obsolete ide_rq_bytes() in ide_kill_rq()
and ide_floppy_do_request() for failed requests.
[ bugfix part ]

* Use blk_rq_bytes() instead of obsolete ide_rq_bytes() in ide_do_devset()
and ide_complete_drive_reset(). Then remove ide_rq_bytes().
[ cleanup part ]

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
346c17a6cf60375323adfaa4b8a9d841049f890e 22-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: relax DMA info validity checking

There are some broken devices that report multiple DMA xfer modes
enabled at once (ATA spec doesn't allow it) but otherwise work fine
with DMA so just delete ide_id_dma_bug().

[ As discovered by detective work by Frans and Bart, due to how
handling of the ID block was handled before commit c419993
("ide-iops: only clear DMA words on setting DMA mode") this
check was always seeing zeros in the fields or other similar
garbage. Therefore this check wasn't actually checking anything.
Now that the tests actually check the real bits, all we see are
devices that trigger the check yet work perfectly fine, therefore
killing this useless check is the best thing to do. -DaveM ]

Reported-by: Frans Pop <elendil@planet.nl>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5bfb151f1f565e6082304a30e8c81dfb6ed0b0c8 15-Jun-2009 Joao Ramos <joao.ramos@inov.pt> ide: do not access ide_drive_t 'drive_data' field directly

Change ide_drive_t 'drive_data' field from 'unsigned int' type to 'void *'
type, allowing a wider range of values/types to be stored in this field.

Added 'ide_get_drivedata' and 'ide_set_drivedata' helpers to get and set
the 'drive_data' field.

Fixed all host drivers to maintain coherency with the change in the
'drive_data' field type.

Signed-off-by: Joao Ramos <joao.ramos@inov.pt>
[bart: fix qd65xx build, cast to 'unsigned long', minor Coding Style fixups]
Acked-by: Sergei Shtylyov <sshtylyov@ru.montavista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f4d3ffa52a402ec9e8699571cf3811763d284459 15-Jun-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: move ack_intr() method into 'struct ide_port_ops' (take 2)

Move the ack_intr() method into 'struct ide_port_ops', also renaming it to
test_irq() while at it...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5880b5de7101cc123778c5d17d4f3986351f3122 15-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: don't enable IORDY at a probe time

* Add 'unsigned long port_flags' field to ide_hwif_t.

* Add IDE_PFLAG_PROBING port flag and keep it set during probing.

* Fix ide_pio_need_iordy() to not enable IORDY at a probe time
(IORDY may lead to controller lock up on certain controllers
if the port is not occupied).

Loosely based on the recent libata's fix by Tejun, thanks to Alan
for the hint that IDE may also need it.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c9ef59ff01b6bd1c7360a64fcc8556a1193c2ed0 15-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: IORDY handling fixes

Add ide_pio_need_iordy() helper and convert host drivers to use it.

This fixes it8172, it8213, pdc202xx_old, piix, slc90e66 and siimage
host drivers to handle IORDY correctly.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
734affdcae20af4fec95e46a64fb29f063a15c19 07-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_DFLAG_NIEN_QUIRK device flag

Add IDE_DFLAG_NIEN_QUIRK device flag and use it instead of
drive->quirk_list.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
8bc1e5aa06a2a9a425c4a6795fc564cba1521487 07-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: respect quirk_drives[] list on all controllers

* Add ide_check_nien_quirk_list() helper to the core code
and then use it in ide_port_tune_devices().

* Remove no longer needed ->quirkproc methods from hpt366.c
and pdc202xx_{new,old}.c.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
075affcbe01d4d7cefcd0e30a98df1253bcf8d92 07-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: preserve Host Protected Area by default (v2)

From the perspective of most users of recent systems, disabling Host
Protected Area (HPA) can break vendor RAID formats, GPT partitions and
risks corrupting firmware or overwriting vendor system recovery tools.

Unfortunately the original (kernels < 2.6.30) behavior (unconditionally
disabling HPA and using full disk capacity) was introduced at the time
when the main use of HPA was to make the drive look small enough for the
BIOS to allow the system to boot with large capacity drives.

Thus to allow the maximum compatibility with the existing setups (using
HPA and partitioned with HPA disabled) we automically disable HPA if
any partitions overlapping HPA are detected. Additionally HPA can also
be disabled using the "nohpa" module parameter (i.e. "ide_core.nohpa=0.0"
to disable HPA on /dev/hda).

v2:
Fix ->resume HPA support.

While at it:
- remove stale "idebus=" entry from Documentation/kernel-parameters.txt

Cc: Robert Hancock <hancockrwd@gmail.com>
Cc: Frans Pop <elendil@planet.nl>
Cc: "Andries E. Brouwer" <Andries.Brouwer@cwi.nl>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
[patch description was based on input from Alan Cox and Frans Pop]
Emphatically-Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e957b60d1583022a0f7c03267d37fcae2ddb78b1 07-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-gd: implement block device ->set_capacity method (v2)

* Use ->probed_capacity to store native device capacity for ATA disks.

* Add ->set_capacity method to struct ide_disk_ops.

* Implement disk device ->set_capacity method for ATA disks.

* Implement block device ->set_capacity method.

v2:
* Check if LBA and HPA are supported in ide_disk_set_capacity().

* According to the spec the SET MAX ADDRESS command shall be
immediately preceded by a READ NATIVE MAX ADDRESS command.

* Add ide_disk_hpa_{get_native,set}_capacity() helpers.

Together with the previous patch adding ->set_capacity block device
method this allows automatic disabling of Host Protected Area (HPA)
if any partitions overlapping HPA are detected.

Cc: Robert Hancock <hancockrwd@gmail.com>
Cc: Frans Pop <elendil@planet.nl>
Cc: "Andries E. Brouwer" <Andries.Brouwer@cwi.nl>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Emphatically-Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
28ee9bc5cc42776e0364399b401a64906ac1ac8e 22-May-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: report timeouts in ide_busy_sleep()

* change 'hwif' argument to 'drive'
* report an error on timeout

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9f36d31437922354d104a2db407f397e79e4027e 17-May-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove hw_regs_t typedef

Remove hw_regs_t typedef and rename struct hw_regs_s to struct ide_hw.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
dca3983059a4481e4ae97bbf0ac4b4c21429e1a5 17-May-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: pass number of ports to ide_host_{alloc,add}() (v2)

Pass number of ports to ide_host_{alloc,add}() and then update
all users accordingly.

v2:
- drop no longer needed NULL initializers in buddha.c, cmd640.c and gayle.c
(noticed by Sergei)

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
29e52cf793ded6bece50de50e738596f94f07d9f 17-May-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove chipset field from hw_regs_t

* Convert host drivers that still use hw_regs_t's chipset field to use
the one in struct ide_port_info instead.

* Move special handling of ide_pci chipset type from ide_hw_configure()
to ide_init_port().

* Remove chipset field from hw_regs_t.

While at it:
- remove stale comment in delkin_cb.c

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ca1b96e00ab5d1b0838965834469a0284c81a517 17-May-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: replace special_t typedef by IDE_SFLAG_* flags

Replace:
- special_t typedef by IDE_SFLAG_* flags
- 'special_t special' ide_drive_t's field by 'u8 special_flags' one

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
103f7033bd0f7b65ff3e0a5ea72449d08010b031 26-Apr-2009 Borislav Petkov <petkovbb@gmail.com> ide: unify interrupt reason checking

Add ide_check_ireason() function that handles all ATAPI devices.
Reorganize all unlikely cases in ireason checking further down in the
code path.

In addition, add PFX for printks originating from ide-atapi. Finally,
remove ide_cd_check_ireason.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
19f52a784f7ecb5b51cd73cc4514614b600b995a 04-May-2009 Borislav Petkov <petkovbb@gmail.com> ide-atapi: remove pc->buf

Now after all users of pc->buf have been converted, remove the 64B buffer
embedded in each packet command.

There should be no functional change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
b13345f39dadbabdabaf8819cf6df26913da9e8d 02-May-2009 Borislav Petkov <petkovbb@gmail.com> ide-atapi: add a buffer-arg to ide_queue_pc_tail

This is in preparation of removing ide_atapi_pc. Expose the buffer as an
argument to ide_queue_pc_tail with later replacing it with local buffer
or even kmalloc'ed one if needed due to stack usage constraints.

Also, add the possibility of passing a NULL-ptr buffer for cmds which
don't transfer data besides the cdb. While at it, switch to local buffer
in idetape_get_mode_sense_results().

There should be no functional change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
5a0e43b5e2ee9a295f864c38f0e853b1a4fc3892 01-May-2009 Borislav Petkov <petkovbb@gmail.com> ide-atapi: add a len-parameter to ide_queue_pc_tail

This is in preparation for removing ide_atapi_pc.

There should be no functional change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
077e6dba20e74a455a0452379d2a965c7e1b01ad 01-May-2009 Borislav Petkov <petkovbb@gmail.com> ide-atapi: switch to rq->resid_len

Now that we have rq->resid_len, use it to account partial completion
amount during the lifetime of an rq, decrementing it on each successful
transfer. As a result, get rid of now unused pc->xferred.

While at it, remove noisy debug call in ide_prep_sense.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
29d1a4371035e01b0d079bc5aa88b50f5af7a566 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-atapi: kill unused fields and callbacks

Impact: remove fields and code paths which are no longer necessary

Now that ide-tape uses standard mechanisms to transfer data, special
case handling for bh handling can be dropped from ide-atapi. Drop the
followings.

* pc->cur_pos, b_count, bh and b_data
* drive->pc_update_buffers() and pc_io_buffers().

Signed-off-by: Tejun Heo <tj@kernel.org>
02e7cf8f848841ca21864ccd019e480b73c323b7 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-cd,atapi: use bio for internal commands

Impact: unify request data buffer handling

rq->data is used mostly to pass kernel buffer through request queue
without using bio. There are only a couple of places which still do
this in kernel and converting to bio isn't difficult.

This patch converts ide-cd and atapi to use bio instead of rq->data
for request sense and internal pc commands. With previous change to
unify sense request handling, this is relatively easily achieved by
adding blk_rq_map_kern() during sense_rq prep and PC issue.

If blk_rq_map_kern() fails for sense, the error is deferred till sense
issue and aborts the failed command which triggered the sense. Note
that this is a slim possibility as sense prep is done on each command
issue, so for the above condition to actually trigger, all preps since
the last sense issue till the issue of the request which would require
a sense should fail.

* do_request functions might sleep now. This should be okay as ide
request_fn - do_ide_request() - is invoked only from make_request
and plug work. Make sure this is the case by adding might_sleep()
to do_ide_request().

* Functions which access the read sense data before the sense request
is complete now should access bio_data(sense_rq->bio) as the sense
buffer might have been copied during blk_rq_map_kern().

* ide-tape updated to map sg.

* cdrom_do_block_pc() now doesn't have to deal with REQ_TYPE_ATA_PC
special case. Simplified.

* tp_ops->output/input_data path dropped from ide_pc_intr().

Signed-off-by: Tejun Heo <tj@kernel.org>
068753203e6cd085664a62e0fc0636e19b148a12 19-Apr-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: convert ide-{floppy,tape} to using preallocated sense buffer

Since we're issuing REQ_TYPE_SENSE now we need to allow those types of
rqs in the ->do_request callbacks. As a future improvement, sense_len
assignment might be unified across all ATAPI devices. Borislav to
check with specs and test.

As a result, get rid of ide_queue_pc_head() and
drive->request_sense_rq.

tj: * Init request sense ide_atapi_pc from sense request. In the
longer timer, it would probably better to fold
ide_create_request_sense_cmd() into its only current user -
ide_floppy_get_format_progress().

* ide_retry_pc() no longer takes @disk.

CC: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
CC: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
e69d800f7e8797a8e3423380ee9d8ca1cb90c388 19-Apr-2009 Borislav Petkov <petkovbb@googlemail.com> ide: add helpers for preparing sense requests

This is in preparation of removing the queueing of a sense request out
of the IRQ handler path.

Use struct request_sense as a general sense buffer for all ATAPI
devices ide-{floppy,tape,cd}.

tj: * blk_get_request(__GFP_WAIT) can't be called from do_request() as
it can cause deadlock. Converted to use inline struct request
and blk_rq_init().

* Added xfer / cdb len selection depending on device type.

* All sense prep logics folded into ide_prep_sense() which never
fails.

* hwif->rq clearing and sense_rq used handling moved into
ide_queue_sense_rq().

* blk_rq_map_kern() conversion is moved to later patch.

CC: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
CC: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
214ae19104141404f18ad6651752eb38e3dd584e 19-Apr-2009 Tejun Heo <tj@kernel.org> ide kill unused ide_cmd->special

Impact: removal of unused field

No one uses ide_cmd->special anymore. Kill it.

Signed-off-by: Tejun Heo <tj@kernel.org>
6d7003877c2f0578f1c08f66d05c3f72ef4ae596 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-atapi: kill unused fields and callbacks

Impact: remove fields and code paths which are no longer necessary

Now that ide-tape uses standard mechanisms to transfer data, special
case handling for bh handling can be dropped from ide-atapi. Drop the
followings.

* pc->cur_pos, b_count, bh and b_data
* drive->pc_update_buffers() and pc_io_buffers().

Signed-off-by: Tejun Heo <tj@kernel.org>
5c4be57249e2e09136446597d2fe2a967c6ffef0 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-cd,atapi: use bio for internal commands

Impact: unify request data buffer handling

rq->data is used mostly to pass kernel buffer through request queue
without using bio. There are only a couple of places which still do
this in kernel and converting to bio isn't difficult.

This patch converts ide-cd and atapi to use bio instead of rq->data
for request sense and internal pc commands. With previous change to
unify sense request handling, this is relatively easily achieved by
adding blk_rq_map_kern() during sense_rq prep and PC issue.

If blk_rq_map_kern() fails for sense, the error is deferred till sense
issue and aborts the failed command which triggered the sense. Note
that this is a slim possibility as sense prep is done on each command
issue, so for the above condition to actually trigger, all preps since
the last sense issue till the issue of the request which would require
a sense should fail.

* do_request functions might sleep now. This should be okay as ide
request_fn - do_ide_request() - is invoked only from make_request
and plug work. Make sure this is the case by adding might_sleep()
to do_ide_request().

* Functions which access the read sense data before the sense request
is complete now should access bio_data(sense_rq->bio) as the sense
buffer might have been copied during blk_rq_map_kern().

* ide-tape updated to map sg.

* cdrom_do_block_pc() now doesn't have to deal with REQ_TYPE_ATA_PC
special case. Simplified.

* tp_ops->output/input_data path dropped from ide_pc_intr().

Signed-off-by: Tejun Heo <tj@kernel.org>
6b544fcc8cd0a04eb42de9d1ecdd345e979d6ada 19-Apr-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: convert ide-{floppy,tape} to using preallocated sense buffer

Since we're issuing REQ_TYPE_SENSE now we need to allow those types of
rqs in the ->do_request callbacks. As a future improvement, sense_len
assignment might be unified across all ATAPI devices. Borislav to
check with specs and test.

As a result, get rid of ide_queue_pc_head() and
drive->request_sense_rq.

tj: * Init request sense ide_atapi_pc from sense request. In the
longer timer, it would probably better to fold
ide_create_request_sense_cmd() into its only current user -
ide_floppy_get_format_progress().

* ide_retry_pc() no longer takes @disk.

CC: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
CC: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
a1df5169f9bf08f6067029bfb840a05e282b1b97 19-Apr-2009 Borislav Petkov <petkovbb@googlemail.com> ide: add helpers for preparing sense requests

This is in preparation of removing the queueing of a sense request out
of the IRQ handler path.

Use struct request_sense as a general sense buffer for all ATAPI
devices ide-{floppy,tape,cd}.

tj: * blk_get_request(__GFP_WAIT) can't be called from do_request() as
it can cause deadlock. Converted to use inline struct request
and blk_rq_init().

* Added xfer / cdb len selection depending on device type.

* All sense prep logics folded into ide_prep_sense() which never
fails.

* hwif->rq clearing and sense_rq used handling moved into
ide_queue_sense_rq().

* blk_rq_map_kern() conversion is moved to later patch.

CC: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
CC: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
46a802e852c2106d755f697819ea80cd3ffdc222 19-Apr-2009 Tejun Heo <tj@kernel.org> ide kill unused ide_cmd->special

Impact: removal of unused field

No one uses ide_cmd->special anymore. Kill it.

Signed-off-by: Tejun Heo <tj@kernel.org>
3153c26b54230d025c6d536e8d3015def4524906 08-Apr-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: refactor tf_read() method

Simplify tf_read() method, making it deal only with 'struct ide_taskfile' and
the validity flags that the upper layer passes, and factoring out the code that
deals with the high order bytes into ide_tf_readback() to be called from the
only two functions interested, ide_complete_cmd() and ide_dump_sector().

This should stop the needless code duplication in this method and so make
it about twice smaller than it was; along with simplifying the setup for
the method call, this should save both time and space...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c9ff9e7b64138d87023b733e618f29a1d58543f7 08-Apr-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: refactor tf_load() method

Simplify tf_load() method, making it deal only with 'struct ide_taskfile' and
the validity flags that the upper layer passes, and moving the code that deals
with the high order bytes into the only function interested, do_rw_taskfile().

This should stop the needless code duplication in this method and so make
it about twice smaller than it was; along with simplifying the setup for the
method call, this should save both time and space...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
745483f10c6cefb303007c6873e2bfce54efa8ed 08-Apr-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: simplify 'struct ide_taskfile'

Make 'struct ide_taskfile' cover only 8 register values and thus put two such
fields ('tf' and 'hob') into 'struct ide_cmd', dropping unnecessary 'tf_array'
field from it.

This required changing the prototype of ide_get_lba_addr() and ide_tf_dump().

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
[bart: fix setting of ATA_LBA bit for LBA48 commands in __ide_do_rw_disk()]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
60f85019c6c8c1aebf3485a313e0da094bc95d07 08-Apr-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: replace IDE_TFLAG_* flags by IDE_VALID_*

Replace IDE_TFLAG_{IN|OUT}_* flags meaning to the taskfile register validity on
input/output by the IDE_VALID_* flags and introduce 4 symmetric 8-bit register
validity indicator subfields, 'valid.{input/output}.{tf|hob}', into the 'struct
ide_cmd' instead of using the 'tf_flags' field for that purpose (this field can
then be turned from 32-bit into 8-bit one).

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
fdd88f0af616db59a6a36bdf0185181d2b779f53 31-Mar-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: inline SELECT_DRIVE()

Since SELECT_DRIVE() has boiled down to a mere dev_select() method call, it now
makes sense to just inline it...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
abb596b25edac1ec1acc4ef53df190771661c3d2 31-Mar-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: turn selectproc() method into dev_select() method (take 5)

Turn selectproc() method into dev_select() method by teaching it to write to the
device register and moving it from 'struct ide_port_ops' to 'struct ide_tp_ops'.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: benh@kernel.crashing.org
Cc: petkovbb@gmail.com
[bart: add ->dev_select to at91_ide.c and tx4939.c (__BIG_ENDIAN case)]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6762511934e6e7287ce3c8baac0d52ef64e3787b 31-Mar-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: rename IDE_TFLAG_IN_[HOB_]FEATURE

The feature register has never been readable -- when its location is read, one
gets the error register value; hence rename IDE_TFLAG_IN_[HOB_]FEATURE into
IDE_TFLAG_IN_[HOB_]ERROR and introduce the 'hob_error' field into the 'struct
ide_taskfile' (despite the error register not really depending on the HOB bit).

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ecf3a31d2a08a419bdf919456f1724f5b72bde2c 31-Mar-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: turn set_irq() method into write_devctl() method

Turn set_irq() method with its software reset hack into write_devctl() method
(for just writing a value into the device control register) at last...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
349d12a1fe57d49287a539909cf14f362634342d 31-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-floppy: use ide_pio_bytes()

* Fix ide_init_sg_cmd() setup for non-fs requests.

* Convert ide_pc_intr() to use ide_pio_bytes() for floppy media.

* Remove no longer needed ide_io_buffers() and sg/sg_cnt fields
from struct ide_atapi_pc.

* Remove partial completions; kill idefloppy_update_buffers(), as a
result.

* Add some more debugging statements.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
41fa9f863baacd32dd049daf8050d55a0c9e6f1a 31-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: decrease size of ->pc_buf field in struct ide_atapi_pc

struct ide_atapi_pc is often allocated on the stack and size of ->pc_buf
size is 256 bytes. However since only ide_floppy_create_read_capacity_cmd()
and idetape_create_inquiry_cmd() require such size allocate buffers for
these pc-s explicitely and decrease ->pc_buf size to 64 bytes.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f094d4d83bccee9277ddb6aadccf35747889426b 31-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: sanitize ide_build_sglist() and ide_destroy_dmatable()

* Move ide_map_sg() calls out from ide_build_sglist()
to ide_dma_prepare().

* Pass command to ide_destroy_dmatable().

* Rename ide_build_sglist() to ide_dma_map_sg()
and ide_destroy_dmatable() to ide_dma_unmap_sg().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
8a4a5738ba499083cf4c5668895efe220b1946d3 31-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->dma_check method

* Add (an optional) ->dma_check method for checking if DMA can be
used for a given command and fail DMA setup in ide_dma_prepare()
if necessary.

* Convert alim15x3 and trm290 host drivers to use ->dma_check.

* Rename ali15x3_dma_setup() to ali_dma_check() while at it.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5ae5412d9a23b05ab08461b202bad21ad8f6b66d 31-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_dma_prepare() helper

* Add ide_dma_prepare() helper.

* Convert ide_issue_pc() and do_rw_taskfile() to use it.

* Make ide_build_sglist() static.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4453011f959a5f5c6c7a33aea54fe17f5e43a867 31-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: destroy DMA mappings after ending DMA (v2)

Move ide_destroy_dmatable() call out from ->dma_end method to
{ide_pc,cdrom_newpc,ide_dma}_intr(), ide_dma_timeout_retry()
and sgiioc4_resetproc().

This causes minor/safe behavior changes w.r.t.:
* cmd64x.c::cmd64{8,x}_dma_end()
* cs5536.c::cs5536_dma_end()
* icside.c::icside_dma_end()
* it821x.c::it821x_dma_end()
* scc_pata.c::__scc_dma_end()
* sl82c105.c::sl82c105_dma_end()
* tx4939ide.c::tx4939ide_dma_end()

v2:
* Fix build for CONFIG_BLK_DEV_IDEDMA=n (reported by Randy Dunlap).

Cc: Randy Dunlap <randy.dunlap@oracle.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
35c9b4daf4c94b30e5cede597d98016ebf31b5ad 31-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->dma_clear method and remove ->dma_timeout one

All custom ->dma_timeout implementations call the generic one thus it is
possible to have only an optional method for resetting DMA engine instead:

* Add ->dma_clear method and convert hpt366, pdc202xx_old and sl82c105
host drivers to use it.

* Always use ide_dma_timeout() in ide_dma_timeout_retry() and remove
->dma_timeout method.

* Make ide_dma_timeout() static.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
06a449e30135aabb6686c95bf0c42b46d169a3b3 31-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-cd: fix non-SECTOR_SIZE-multiples PIO transfers for fs requests

We now support arbitrary number of bytes per-IRQ also for fs requests
so remove ide_cd_check_transfer_size() and IDE_AFLAG_LIMIT_NFRAMES.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
a08915ba594da66145f33a972db578a58b9135f1 31-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-cd: use scatterlists for PIO transfers (fs requests)

* Export ide_pio_bytes().

* Add ->last_xfer_len field to struct ide_cmd.

* Add ide_cd_error_cmd() helper to ide-cd.

* Convert ide-cd to use scatterlists also for PIO transfers (fs requests
only for now) and get rid of partial completions (except when the error
happens -- which is still subject to change later because looking at
ATAPI spec it seems that the device is free to error the whole transfer
with setting the Error bit only on the last transfer chunk).

* Update ide_cd_{prepare_rw,restore_request,do_request}() accordingly.

* Inline ide_cd_restore_request() into cdrom_start_rw().

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
bf717c0a2e18dbe82eeb28e57b0abede3cdf45d6 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: keep track of number of bytes instead of sectors in struct ide_cmd

* Pass number of bytes instead of sectors to ide_init_sg_cmd().

* Pass number of bytes to process to ide_pio_sector() and rename
it to ide_pio_bytes().

* Rename ->nsect field to ->nbytes in struct ide_cmd and use
->nbytes, ->nleft and ->cursg_ofs to keep track of number of
bytes instead of sectors.

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
35b5d0be3d8de9a5ac51471c12029fb115200cdc 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_execute_pkt_cmd() (v2)

* Pass command structure to ide_execute_command() and skip
__ide_set_handler() for ATAPI protocols on non-DRQ devices.

* Convert ide_issue_pc() to always use ide_execute_command()
and remove no longer needed ide_execute_pkt_cmd().

v2:
* Fix for non-DRQ devices (based on report from Borislav).

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
22117d6eaac50d366d9013c88318a869ea4d8739 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->dma_timer_expiry method and remove ->dma_exec_cmd one (v2)

* Rename dma_timer_expiry() to ide_dma_sff_timer_expiry() and export it.

* Add ->dma_timer_expiry method and use it to set hwif->expiry for
ATA_PROT_DMA protocol in do_rw_taskfile().

* Initialize ->dma_timer_expiry to ide_dma_sff_timer_expiry() for SFF hosts.

* Move setting hwif->expiry from ide_execute_command() to its users and drop
'expiry' argument.

* Use ide_execute_command() instead of ->dma_exec_cmd in do_rw_taskfile().

* Remove ->dma_exec_cmd method and its implementations.

* Unexport ide_execute_command() and ide_dma_intr().

v2:
* Fix CONFIG_BLK_DEV_IDEDMA=n build (noticed by Randy Dunlap).

* Fix *dma_expiry naming (suggested by Sergei Shtylyov).

There should be no functional changes caused by this patch.

Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
60c0cd02b254805691cdc61101ada6af7bd56fde 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: set hwif->expiry prior to calling [__]ide_set_handler()

* Set hwif->expiry prior to calling [__]ide_set_handler()
and drop 'expiry' argument.

* Set hwif->expiry to NULL in ide_{timer_expiry,intr}()
and remove 'hwif->expiry = NULL' assignments.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b788ee9c6561fd9219a503216284d61036a0dc0b 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use do_rw_taskfile() for ATA_CMD_PACKET commands

* Pass command to ide_issue_pc() and update ->do_request methods
in ide-{cd,floppy,tape}.c accordingly.

* Convert ide_pktcmd_tf_load() to ide_init_packet_cmd() which
just initializes command structure and use do_rw_taskfile()
to load ATA_CMD_PACKET commands.

While at it:

* Rename ide{floppy,tape}_issue_pc() to ide_{floppy,tape}_issue_pc().

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2298169418f43ba5e0919762a4bab95a1227872a 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: pass command to ide_map_sg()

* Set IDE_TFLAG_WRITE flag and ->rq also for ATA_CMD_PACKET
commands.

* Pass command to ->dma_setup method and update all its
implementations accordingly.

* Pass command instead of request to ide_build_sglist(),
*_build_dmatable() and ide_map_sg().

While at it:

* Fix scc_dma_setup() documentation + use ATA_DMA_WR define.

* Rename sgiioc4_build_dma_table() to sgiioc4_build_dmatable(),
change return value type to 'int' and drop unused 'ddir'
argument.

* Do some minor cleanups in [tx4939]ide_dma_setup().

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
130e886708d6e11f3d54e5d27c266578de56f343 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_end_request()

* Add ide_rq_bytes() helper.

* Add blk_noretry_request() quirk to ide_complete_rq() (currently only fs
requests can be marked as "noretry" so there is no change in behavior).

* Switch current ide_end_request() users to use ide_complete_rq().

[ No need to check for rq->nr_sectors == 0 in {ide_dma,task_pio}_intr(),
nsectors == 0 in cdrom_end_request() and err == 0 in ide_do_devset(). ]

* Remove no longer needed ide_end_request().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f974b196f58fe042c7b2b4c0ee15d5a6112dbf40 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: pass number of bytes to complete to ide_complete_rq()

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
a9587fd8c48415cc93fef7f4ba7748a5d3477e7b 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove BUG() from ide_complete_rq()

It is no longer needed so remove it, also while at it dequeue the request
only on blk_end_request() success and make ide_complete_rq() return an error
value.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6902a5331256e1b9f4cef95a1e3622252113b260 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: pass error value to ide_complete_rq()

Set rq->errors at ide_complete_rq() call sites and then pass
error value to ide_complete_rq().

[ Some rq->errors assignments look really wrong but this patch
leaves them alone to not introduce too many changes at once. ]

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1caf236dafb7291f9fdfe54b12dd945aec0dca03 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_end_rq() (v2)

* Move request dequeuing from __ide_end_request() to ide_end_request().

* Rename __ide_end_request() to ide_end_rq() and export it.

* Fix ide_end_rq() to pass original blk_end_request() return value.

* ide_end_dequeued_request() is used only in cdrom_end_request()
so inline it there and then remove the function.

v2:
* Remove needless BUG_ON() while at it (start_request()'s one is enough).

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
0dfb991c6943c810175376b58d1c29cfe532541b 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ata_tf_protocols enums

* Add IDE_TFLAG_MULTI_PIO taskfile flag and set it for commands
using multi-PIO protocol.

* Use ata_tf_protocols enums instead of TASKFILE_* defines to
denote command's protocol and then rename ->data_phase field
to ->protocol.

* Remove no longer needed <linux/hdreg.h> includes.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b6308ee0c55acd2e943d849773c9f0a49c516317 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move command related fields from ide_hwif_t to struct ide_cmd

* Move command related fields from ide_hwif_t to struct ide_cmd.

* Make ide_init_sg_cmd() take command and sectors number as arguments.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
adb1af9803d167091c2cb4de14014185054bfe2c 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: pass command instead of request to ide_pio_datablock()

* Add IDE_TFLAG_FS taskfile flag and set it for REQ_TYPE_FS requests.

* Convert ->{in,out}put_data methods to take command instead of request
as an argument. Then convert pre_task_out_intr(), task_end_request(),
task_error(), task_in_unexpected(), ide_pio_sector(), ide_pio_multi()
and ide_pio_datablock() in similar way.

* Rename task_end_request() to ide_finish_cmd().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
22aa4b32a19b1f231d4ce7e9af6354b577a22a35 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_task_t typedef

While at it:
- rename struct ide_task_s to struct ide_cmd
- remove stale comments from idedisk_{read_native,set}_max_address()
- drop unused 'cmd' argument from ide_{cmd,task}_ioctl()
- drop unused 'task' argument from tx4939ide_tf_load_fixup()
- rename ide_complete_task() to ide_complete_cmd()
- use consistent naming for struct ide_cmd variables

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e6830a86c260d73c6f370aa7ed17ee6c71e5ee05 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: call ide_build_sglist() prior to ->dma_setup (v2)

* Re-map sg table if needed in ide_build_sglist().

* Move ide_build_sglist() call from ->dma_setup to its users.

* Un-export ide_build_sglist().

v2:
* Build fix for CONFIG_BLK_DEV_IDEDMA=n (noticed by Randy Dunlap).

There should be no functional changes caused by this patch.

Cc: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
03a2faaea8f44edfe583ddf1240948019becfbe4 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: return request status from ->pc_callback method

Make ->pc_callback method return request status and then move
the request completion from ->pc_callback to ide_pc_intr().

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
3ee38302ffc63da93eb0313053a990bb3466e275 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->end_request method

* Handle completion of private driver requests explicitly
for ide_floppy and ide_tape media in ide_kill_rq().

* Remove no longer needed ->end_request method.

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c152cc1a90f9680cefa74d9ff9ce36038081ba72 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ->end_request only for private device driver requests

* Move IDE{FLOPPY,TAPE}_ERROR_* defines to <linux/ide.h> and rename them
to IDE_DRV_ERROR_*.

* Handle ->end_request special cases for floppy/tape media in ide_kill_rq().

* Call ->end_request only for private device driver requests.

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5e2040fd0a97888952b37243b5868872bbe0f6ac 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move ->failed_pc to ide_drive_t

Move ->failed_pc from struct ide_{disk,tape}_obj to ide_drive_t.

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c7016e95a556098db6dc4d9096a6189be9e18266 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove no longer needed PC_FLAG_TIMEDOUT packet command flag

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e3d9a73a83d98fc466dabdcfe4f4e7e4419e3f8e 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->data_phase field from ide_hwif_t

* Always use hwif->task->data_phase and remove ->data_phase
field from ide_hwif_t.

* Remove superfluous REQ_TYPE_ATA_TASKFILE check from
ide_pio_datablock() while at it.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
a09485df9cda49fbde2766c86eb18a9cae585162 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move request type specific code from ide_end_drive_cmd() to callers (v3)

* Move request type specific code from ide_end_drive_cmd() to callers.

* Remove stale ide_end_drive_cmd() documentation and drop no longer
used 'stat' argument. Then rename the function to ide_complete_rq().

v2:
* Fix handling of blk_pm_request() requests in task_no_data_intr().

v3:
* Some ide_no_data_taskfile() users (HPA code and HDIO_DRIVE_* ioctls
handlers) access original command later so we need to update it in
ide_complete_task().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
3616b6536a74ff1c56029c17cbb3575c69c0a574 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: complete power step in ide_complete_pm_request()

* Complete power step in ide_complete_pm_request().

* Rename ide_complete_pm_request() to ide_complete_pm_rq().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
19710d25d50ae0be05eebe4231ed8918b1092d82 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add "flagged" taskfile flags to struct ide_taskfile (v2)

* Add ->ftf_flags field to struct ide_taskfile
and convert flags for TASKFILE ioctl to use it.

* Rename "flagged" taskfile flags:
- IDE_TFLAG_FLAGGED -> IDE_FTFLAG_FLAGGED
- IDE_TFLAG_FLAGGED_SET_IN_FLAGS -> IDE_FTFLAG_SET_IN_FLAGS
- IDE_TFLAG_{OUT,IN}_DATA -> IDE_FTFLAG_{OUT,IN}_DATA

v2:
* Remember to fully update ide-h8300.c, scc_pata.c and tx493{8,9}ide.c
(thanks to Stephen Rothwell for noticing).

There should be no functional changes caused by this patch.

Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c094ea0774d6881598da430ea0916a597162f8df 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_4DRIVES host flag

Add IDE_HFLAG_4DRIVES host flag and use it instead of ide_4drives
chipset type in ide_init_port().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2787cb8ae5c68a6945eb82ccf96b5f2c4f238323 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_DTC2278 host flag

Add IDE_HFLAG_DTC2278 host flag and use it instead of ide_dtc2278
chipset type in ide_init_port().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
255115fb35f80735c21a1cbe9809e9795a3af26e 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: allow host drivers to specify IRQ flags

* Add ->irq_flags field to struct ide_port_info and struct ide_host.

* Update host drivers and IDE PCI code to use ->irq_flags field.

* Convert init_irq() and ide_intr() to use host->irq_flags.

This fixes handling of shared IRQs for non-PCI hosts
and removes ugly ifdeffery from core IDE code.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
69197ad70ef6b854988299c1377864f9755cd03d 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix memleak on failure in probe_for_drive()

Always free drive->id in probe_for_drive() if device is not present.

While at it:
- remove dead IDE_DFLAG_DEAD flag
- remove superfluous IDE_DFLAG_PRESENT check

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
15a453a955f89f6545118770c669b52e925368bd 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: include <asm/ide.h> only when needed

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e354c1d8033d97a97a38a1b2cffa1bc285b92ad4 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove IDE_ARCH_LOCK (v2)

* Add ->{get,release}_lock methods to struct ide_port_info
and struct ide_host.

* Convert core IDE code, m68k IDE code and falconide support to use
->{get,release}_lock methods instead of ide_{get,release}_lock().

* Remove IDE_ARCH_LOCK.

v2:
* Build fix from Geert updating ide_{get,release}_lock() callers in
falconide.c.

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Michael Schmitz <schmitz@debian.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
d15a613ba01ff2b209ecad7a38ccbb23b3b06c92 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove IDE_ARCH_INTR (v2)

This micro-optimization is not worth it. Just always check for
existence of ->ack_intr method in ide_intr() and ide_timer_expiry().

v2:
Fix brown-paper-bag bug spotted by David D. Kilzer.

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Michael Schmitz <schmitz@debian.org>
Cc: "David D. Kilzer" <ddkilzer@kilzer.net>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
088b1b88609ce89b6ab19d114cdbec94a44aa22c 02-Jan-2009 Borislav Petkov <petkovbb@gmail.com> ide: improve debugging scheme

and more specifically, push __func__ into debug
macro thus making ide_debug_log() calls shorter and more readable.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
2ebe1d9efed5f232afc8d00901d0959c9814bce3 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use try_to_identify() in ide_driveid_update()

* Pass pointer to buffer for IDENTIFY data to do_identify()
and try_to_identify().

* Un-static try_to_identify() and use it in ide_driveid_update().

* Rename try_to_identify() to ide_dev_read_id().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
d45b70ab9bbf1a46ae52972d532f9e267b8d39d9 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> mn10300: remove <asm/ide.h>

* Remove superfluous <asm/intctl-regs.h> include.

* Remove no longer used SUPPORT_SLOW_DATA_PORTS define.

* Move defining SUPPORT_VLB_SYNC to <linux/ide.h>.

* Use __ide_mm_*() macros from <asm-generic/ide_iops.h>
(MN10300 uses only memory-mapped I/O).

* Remove <asm/ide.h>.

While at it:

* Remove superfluous SPARC64 #ifdef from <linux/ide.h>.

Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
662641d98b4396b48f513726d141c5f646c08259 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> frv: remove <asm/ide.h>

* Remove superfluous <asm/{setup,io,irq}.h> includes.

* Remove <asm/ide.h>.

Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
86ccf37c6acd74cf7e4b7751ee045de19943c5a0 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove pciirq argument from ide_pci_setup_ports()

* Set ->irq explicitly in cs5520.c.

* Remove irq argument from ide_hw_configure().

* Remove pciirq argument from ide_pci_setup_ports().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2ed0ef543ae3f3ea4f8bd0433fb1fed22625a309 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix ->init_chipset method to return 'int' value

* Return 0 instead of dev->irq in ->init_chipset implementations.

* Fix ->init_chipset method to return 'int' value instead of
'unsigned int' one.

This fixes ->init_chipset handling for host drivers (cs5530, hpt366
and pdc202xx_new) for which it is possible for this method to fail.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
8b07ed26f8eb73d4f55a9d852712cd588c45ff51 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove no longer needed IRQ fallback code from hwif_init()

Then remove no longer used __ide_default_irq().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2467922a560bb7e6eb4635435760ad0a2197ffcc 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove no longer needed IDE_HFLAG[_FORCE]_LEGACY_IRQS

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
327fa1c29466b8fe471a91fc11e9c6171163c81a 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move error handling code to ide-eh.c (v2)

Do some CodingStyle fixups in <linux/ide.h> while at it.

v2:
Add missing <linux/delay.h> include (reported by Stephen Rothwell).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7eeaaaa52285d5e6cb79f515e99c591dcb9d04fe 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move xfer mode tuning code to ide-xfer-mode.c

* Move xfer mode tuning code to ide-xfer-mode.c.

* Add CONFIG_IDE_XFER_MODE config option to be selected by host drivers
that support xfer mode tuning.

* Add CONFIG_IDE_XFER_MODE=n static inline versions of ide_set_pio()
and ide_set_xfer_rate().

* Make IDE_TIMINGS and BLK_DEV_IDEDMA config options select IDE_XFER_MODE,
also add explicit selects for few host drivers that need it.

* Build/link ide-xfer-mode.o and ide-pio-blacklist.o (it is needed only
by ide-xfer-mode.o) only if CONFIG_IDE_XFER_MODE=y.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
11938c929022bb92b1a42f5e1289524a1e465dc0 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move device settings code to ide-devsets.c

Remove stale comment from ide.c while at it.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c4e66c36cce3f23d68013c4112013123ffe80bdb 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move ide_do_park_unpark() to ide-park.c

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1866082339597930c5b77aad8de34ab4fbb5724f 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_do_drive_cmd()

* Use elv_add_request() instead of __elv_add_request() in ide_do_drive_cmd().

* ide_do_drive_cmd() is used only in ide-{atapi,cd}.c so inline it there.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
65ca5377322c7543163066f373ae9e6b0ad8de8a 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move ide_dma_timeout_retry() to ide-dma.c

Move ide_dma_timeout_retry() to ide-dma.c and add static inline
version for CONFIG_BLK_DEV_IDEDMA=n.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b6a45a0b1e9a358b81201659cf87b023e3ec73e0 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move drive_is_ready() to ide-io.c

Move drive_is_ready() to ide-io.c, then make it static.

Also make some minor CodingStyle fixups while at it.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
8b803bd184e3f6892284d4b50801b9ec85cd9b96 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: sanitize ACPI initialization

* ide_acpi_init() -> ide_acpi_init_port()

* ide_acpi_blacklist() -> ide_acpi_init()

* Call ide_acpi_init() only once (do it during IDE core
initialization) and cleanup the function accordingly.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7ed5b157d9dff55bf477b4c8b4708d5d45476677 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_for_each_present_dev() iterator

* Add ide_for_each_present_dev() iterator and convert IDE code to use it.

* Do some drive-by CodingStyle fixups in ide-acpi.c while at it.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7a254df007b3db88bd430474030fec92e7bab22a 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move ide_pktcmd_tf_load() to ide-atapi.c

Then make it static and remove 'dma' argument.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5d82720a7f41f0c877e026c7d17e3bf20ccdbae0 13-Mar-2009 FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> ide: save the returned value of dma_map_sg

dma_map_sg could return a value different to 'nents' argument of
dma_map_sg so the ide stack needs to save it for the later usage
(e.g. for_each_sg).

The ide stack also needs to save the original sg_nents value for
pci_unmap_sg.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
[bart: backport to Linus' tree]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
849d7130001ab740a5a4778a561049841fdd77c9 05-Mar-2009 Stanislaw Gruszka <stf_xl@wp.pl> ide: allow to wrap interrupt handler

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
Cc: Andrew Victor <linux@maxim.org.za>
[bart: minor checkpatch.pl / CodingStyle fixups]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
8fed43684174b68f04d01d1210fd00536af790df 25-Feb-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix refcounting in device drivers

During host driver module removal del_gendisk() results in a final
put on drive->gendev and freeing the drive by drive_release_dev().

Convert device drivers from using struct kref to use struct device
so device driver's object holds reference on ->gendev and prevents
drive from prematurely going away.

Also fix ->remove methods to not erroneously drop reference on a
host driver by using only put_device() instead of ide*_put().

Reported-by: Stanislaw Gruszka <stf_xl@wp.pl>
Tested-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e720b9e498b6bbb1b4f3b3d2f8e9a78578aafef7 14-Jan-2009 Ben Dooks <ben-linux@fluff.org> IDE: fix sparse signed-ness errors with host->host_busy

The host_busy field in struct ide_host defaults to a
signed-long, where most arch's test_and_set_bit_*
macros use an unsigned long.

Change to using an unsigned long, which on ARM removes
the following sparse errors:

drivers/ide/ide-io.c:681:8: warning: incorrect type in argument 2 (different signedness)
drivers/ide/ide-io.c:681:8: expected unsigned long volatile *p
drivers/ide/ide-io.c:681:8: got long volatile *<noident>
drivers/ide/ide-io.c:681:8: warning: incorrect type in argument 2 (different signedness)
drivers/ide/ide-io.c:681:8: expected unsigned long volatile *p
drivers/ide/ide-io.c:681:8: got long volatile *<noident>
drivers/ide/ide-io.c:695:3: warning: incorrect type in argument 2 (different signedness)
drivers/ide/ide-io.c:695:3: expected unsigned long volatile *p
drivers/ide/ide-io.c:695:3: got long volatile *<noident>
drivers/ide/ide-io.c:695:3: warning: incorrect type in argument 2 (different signedness)
drivers/ide/ide-io.c:695:3: expected unsigned long volatile *p
drivers/ide/ide-io.c:695:3: got long volatile *<noident>
drivers/ide/ide-io.c:695:3: warning: incorrect type in argument 2 (different signedness)
drivers/ide/ide-io.c:695:3: expected unsigned long volatile *p
drivers/ide/ide-io.c:695:3: got long volatile *<noident>
drivers/ide/ide-io.c:695:3: warning: incorrect type in argument 2 (different signedness)
drivers/ide/ide-io.c:695:3: expected unsigned long volatile *p
drivers/ide/ide-io.c:695:3: got long volatile *<noident>
drivers/ide/ide-io.c:695:3: warning: incorrect type in argument 2 (different signedness)
drivers/ide/ide-io.c:695:3: expected unsigned long volatile *p
drivers/ide/ide-io.c:695:3: got long volatile *<noident>
drivers/ide/ide-io.c:695:3: warning: incorrect type in argument 2 (different signedness)
drivers/ide/ide-io.c:695:3: expected unsigned long volatile *p
drivers/ide/ide-io.c:695:3: got long volatile *<noident>
drivers/ide/ide-io.c:695:3: warning: incorrect type in argument 2 (different signedness)
drivers/ide/ide-io.c:695:3: expected unsigned long volatile *p
drivers/ide/ide-io.c:695:3: got long volatile *<noident>
drivers/ide/ide-io.c:695:3: warning: incorrect type in argument 2 (different signedness)
drivers/ide/ide-io.c:695:3: expected unsigned long volatile *p
drivers/ide/ide-io.c:695:3: got long volatile *<noident>

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
592b5315219881c6c0af4785f96456ad2043193a 06-Jan-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: move read_sff_dma_status() method to 'struct ide_dma_ops'

Move apparently misplaced read_sff_dma_status() method from 'struct ide_tp_ops'
to 'struct ide_dma_ops', renaming it to dma_sff_read_status() and making only
required for SFF-8038i compatible IDE controller drivers (greatly cutting down
the number of initializers) as its only user (outside ide-dma-sff.c and such
drivers) appears to be ide_pci_check_simplex() which is only called for such
controllers...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
94c96445f32c16cfdc398b20b7e78945ab7e35f9 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove unused ide_hwif_t.sg_mapped field

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
906ef986a71d541a726550fa40dcbc5c356f810e 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: struct ide_atapi_pc - remove unused fields and update documentation

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
d6251d4488a361c93da2398818e1ec69cffb6073 06-Jan-2009 Borislav Petkov <petkovbb@gmail.com> ide-cd: convert to ide-atapi facilities

... and remove no longer needed cdrom_start_packet_command and
cdrom_transfer_packet_command.

Tested lightly with ide-cd and ide-floppy.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2bd24a1cfc99d242c2cff9a6b74ca49fcaac3fb6 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add port and host iterators

Add ide_port_for_each_dev() / ide_host_for_each_port() iterators
and update IDE code to use them.

While at it:
- s/unit/i/ variable in ide_port_wait_ready(), ide_probe_port(),
ide_port_tune_devices(), ide_port_init_devices_data(), do_reset1(),
ide_acpi_set_state() and scc_dma_end()
- s/d/i/ variable in ide_proc_port_register_devices()

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5e7f3a46690f7f6c9f2781c700ab4370874aa0e8 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: dynamic allocation of device structures

Allocate device structures dynamically instead of having them embedded
in ide_hwif_t:

* Remove needless zeroing of port structure from ide_init_port_data().

* Add ide_hwif_t.devices[MAX_DRIVES] (table of pointers to the devices).

* Add ide_port_{alloc,free}_devices() helpers and use them respectively
in ide_{host,free}_alloc().

* Convert all users of ->drives[] to use ->devices[] instead.

While at it:

* Use drive->dn for the slave device check in scc_pata.c.

As a nice side-effect this patch cuts ~1kB (x86-32) from the resulting
code size:

text data bss dec hex filename
53963 1244 237 55444 d894 drivers/ide/ide-core.o.before
52981 1244 237 54462 d4be drivers/ide/ide-core.o.after

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
627e05daa10896a8f012fa78e8434c07e9e55ea7 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->error method from struct ide_driver

* Remove (now superfluous) ->error method from struct ide_driver.

* Unexport __ide_error() and make it static.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7f3c868ba78e486bd9d7569f884dd46d8f59bb18 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_driver_t typedef

While at it:
- s/struct ide_driver_s/struct ide_driver/
- use to_ide_driver() macro in ide-proc.c

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9892ec5497af1ec38c46974b5a370ba11c636b19 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove 'byte' typedef

Just use u8 instead, also s/__u8/u8/ in ide-cd.h while at it.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c0ae50234771684ae0cbac5dfb70e1a09c22aa89 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_pci_enablebit_t typedef

Remove needless parens while at it.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
54cc1428cfa619e16d75baae8cb041a2eff015f0 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove local_irq_set() macro

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
898ec223fea2a2df88035e58dbf50f493577e225 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove HWIF() macro

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b40d1b88f1001f0224c63fa2c008914514bcef33 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move ide_init_port_data() and friends to ide-probe.c

* Move IDE_DEFAULT_MAX_FAILURES to <linux/ide.h>.

* Move ide_cfg_mtx, ide_hwif_to_major[], ide_port_init_devices_data(),
ide_init_port_data(), ide_init_port_hw() and ide_unregister() to
ide-probe.c from ide.c.

* Make ide_unregister(), ide_init_port_data(), ide_init_port_hw()
and ide_cfg_mtx static.

While at it:

* Remove stale ide_init_port_data() documentation and ide_lock extern.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b65fac32cfe3b2f98cd472fef400bd1c1340de23 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: merge ide_hwgroup_t with ide_hwif_t (v2)

* Merge ide_hwgroup_t with ide_hwif_t.

* Cleanup init_irq() accordingly, then remove no longer needed
ide_remove_port_from_hwgroup() and ide_ports[].

* Remove now unused HWGROUP() macro.

While at it:

* ide_dump_ata_error() fixups

v2:
* Fix ->quirk_list check in do_ide_request()
(s/hwif->cur_dev/prev_port->cur_dev).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5b31f855f10d0053e738baa6d91fb6a3fad35119 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use lock bitops for ports serialization (v2)

* Add ->host_busy field to struct ide_host and use it's first bit
together with lock bitops to provide new ports serialization method.

* Convert core IDE code to use new ide_[un]lock_host() helpers.

This removes the need for taking hwgroup->lock if host is already
busy on serialized hosts and makes it possible to merge ide_hwgroup_t
into ide_hwif_t (done in the later patch).

* Remove no longer needed ide_hwgroup_t.busy and ide_[un]lock_hwgroup().

* Update do_ide_request() documentation.

v2:
* ide_release_lock() should be called inside IDE_HFLAG_SERIALIZE check.

* Add ide_hwif_t.busy flag and ide_[un]lock_port() for serializing
devices on a port.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
efe0397eef544ac4bcca23d39aa8d5db154952e0 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove hwgroup->hwif and {drive,hwif}->next

* Add 'int port_count' field to ide_hwgroup_t to keep the track
of the number of ports in the hwgroup. Then update init_irq()
and ide_remove_port_from_hwgroup() to use it.

* Remove no longer needed hwgroup->hwif, {drive,hwif}->next,
ide_add_drive_to_hwgroup() and ide_remove_drive_from_hwgroup()
(hwgroup->drive now only denotes the currently active device
in the hwgroup).

* Update locking documentation in <linux/ide.h>.

While at it:

* Rename ->drive field in ide_hwgroup_t to ->cur_dev.

* Use __func__ in ide_timer_expiry().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ae86afaee6a1c77c7a06d81dcc3bf872204d3bec 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use per-port IRQ handlers

Use hwif instead of hwgroup as {request,free}_irq()'s cookie,
teach ide_intr() to return early for non-active serialized ports,
modify unexpected_intr() accordingly and then use per-port IRQ
handlers instead of per-hwgroup ones.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
bd53cbcce501b61921a1af2dddfa87c5b9923dfd 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->cur_port to struct ide_host and use it for serialized hosts

* Pass 'ide_hwif_t *' instead of 'ide_hwgroup_t *' to unexpected_intr().

* Cache pointer to the port currently being serviced in ->cur_port
and use it instead of hwif->hwgroup on serialized hosts.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
28ad91db77755f1c49d79652de11b28ee2cfbf03 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: remove timeout arg to ide_issue_pc

There should be no functionality change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5317464dccd0c03026d60f1e9968de4f9cd23f69 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide: remove the last ide-scsi remnants

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5d655a03b847fbe5353a8a74bbeb75e18708dca3 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: remove ide-scsi remnants from ide_pc_intr()

As a result, remove now unused ide_scsi_get_timeout and ide_scsi_expiry.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4cad085efbce8dcc5006b0d1034089758b4fc7ba 02-Jan-2009 Borislav Petkov <petkovbb@gmail.com> ide-cd: move cdrom_timer_expiry to ide-atapi.c

- cdrom_timer_expiry -> ide_cd_expiry
- remove expiry-arg to ide_issue_pc as it is redundant now
- ide_debug_log -> debug_log

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
392de1d53dd40e2eebee3a0a26aa647a3865ca78 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: accomodate transfer length calculation for ide-cd

... by factoring it out of ide_cd_do_request() into a helper, as suggested by
Bart.

There should be no functionality change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
[bart: BLK_DEV_IDECD needs to select IDE_ATAPI now]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
bf64741fe89280bd81a9e3a1beadec1570861848 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide: make IDE_AFLAG_.. numbering continuous again

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
201bffa46466b4afdf7d29db8eca3fa5decb39c8 02-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use per-device request queue locks (v2)

* Move hack for flush requests from choose_drive() to do_ide_request().

* Add ide_plug_device() helper and convert core IDE code from using
per-hwgroup lock as a request lock to use the ->queue_lock instead.

* Remove no longer needed:
- choose_drive() function
- WAKEUP() macro
- 'sleeping' flag from ide_hwif_t
- 'service_{start,time}' fields from ide_drive_t

This patch results in much simpler and more maintainable code
(besides being a scalability improvement).

v2:
* Fixes/improvements based on review from Elias:
- take as many requests off the queue as possible
- remove now redundant BUG_ON()

Cc: Elias Oltmanns <eo@nebensachen.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
631de3708d595d153e8a510a3608689290f4c0ed 02-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_[un]lock_hwgroup() helpers

Add ide_[un]lock_hwgroup() inline helpers for obtaining exclusive
access to the given hwgroup and update the core code accordingly.

[ This change besides making code saner results in more efficient
use of ide_{get,release}_lock(). ]

Cc: Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Elias Oltmanns <eo@nebensachen.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
295f00042aaf6b553b5f37348f89bab463d4a469 02-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: don't execute the next queued command from the hard-IRQ context (v2)

* Tell the block layer that we are not done handling requests by using
blk_plug_device() in ide_do_request() (request handling function)
and ide_timer_expiry() (timeout handler) if the queue is not empty.

* Remove optimization which directly calls ide_do_request() for the next
queued command from the ide_intr() (IRQ handler) and ide_timer_expiry().

* Remove no longer needed IRQ masking from ide_do_request() - in case of
IDE ports needing serialization disable_irq_nosync()/enable_irq() was
used for the (possibly shared) IRQ of the other IDE port.

* Put the misplaced comment in the right place in ide_do_request().

* Drop no longer needed 'int masked_irq' argument from ide_do_request().

* Merge ide_do_request() into do_ide_request().

* Remove no longer needed IDE_NO_IRQ define.

While at it:

* Don't use HWGROUP() macro in do_ide_request().

* Use __func__ in ide_intr().

This patch reduces IRQ hadling latency for IDE and improves the system-wide
handling of shared IRQs (which should result in more timeout resistant and
stable IDE systems). It also makes it possible to do some further changes
later (i.e. replace some busy-waiting delays with sleeping equivalents).

v2:
Changes per review from Elias Oltmanns:
- fix wrong goto statement in 'if (startstop == ide_stopped)' block
- use spin_unlock_irq()
- don't use obsolete HWIF() macro

Cc: Elias Oltmanns <eo@nebensachen.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ebdab07dad3d3a008e519b0a028e1e1ad5ecaef0 02-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move sysfs support to ide-sysfs.c

While at it:
- media_string() -> ide_media_string()

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e2984c628c924442132304ae662da433f41c05c9 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move Power Management support to ide-pm.c

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
702c026be87ef8374ae58122969a4b0b081ce6f2 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: rework handling of serialized ports (v2)

* hpt366: set IDE_HFLAG_SERIALIZE in ->host_flags if needed
in init_hwif_hpt366(). Remove HPT_SERIALIZE_IO while at it.

* Set IDE_HFLAG_SERIALIZE in ->host_flags if needed in
ide_init_port().

* Convert init_irq() to use IDE_HFLAG_SERIALIZE together with
hwif->host to find out ports which need to be serialized.

* Remove no longer needed save_match() and ide_hwif_t.serialized.

v2:
* Set host's ->host_flags field instead of port's copy.

This patch should fix the incorrect grouping of port(s) from
host(s) that need serialization with port(s) that happen to use
the same IRQ(s) but are from the host(s) that don't need it.

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b7876a6fb6e9bf6cbcf7b40cf034aa4138d7978f 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> cy82c693: remove superfluous ide_cy82c693 chipset type

Since CY82C693 doesn't require serialization we may as well
use the default ide_pci chipset type.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1f66019bdf902cb59adf959e462bcd3f4c01f683 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> trm290: add IDE_HFLAG_TRM290 host flag

* Add IDE_HFLAG_TRM290 host flag and use it in ide_build_dmatable().

* Remove no longer needed ide_trm290 chipset type.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6b4924962c49655494d2c8e9d3faab0e349a3062 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->max_sectors field to struct ide_port_info

* Add ->max_sectors field to struct ide_port_info to allow host drivers
to specify value used for hwif->rqsize (if smaller than the default).

* Convert pdc202xx_old to use ->max_sectors and remove no longer needed
IDE_HFLAG_RQSIZE_256 flag.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtyltov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7f1ac8c4b9dadc55ec656b368f5f470f2cbe3083 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> rz1000: apply chipset quirks early (v2)

* Use pci_name(dev) instead of hwif->name in init_hwif_rz1000().

* init_hwif_rz1000() -> rz1000_init_chipset(). Update rz1000_init_one()
to use rz1000_init_chipset() and add now required rz1000_remove().

* Remove superfluous ide_rz1000 chipset type.

v2:
* unsigned int rz1000_init_chipset() -> int rz1000_disable_readahead()
per Sergei's suggestion.

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f58c1ab8deebc2360cef998f169a6727c288210f 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: always set nIEN on idle devices

* Set nIEN for previous port/device in ide_do_request()
also if port uses a non-shared IRQ.

* Remove no longer needed ide_hwif_t.sharing_irq.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6b5cde3629701258004b94cde75dd1089b556b02 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> cmd64x: set IDE_HFLAG_SERIALIZE explictly for CMD646

* Set IDE_HFLAG_SERIALIZE explictly for CMD646.

* Remove no longer needed ide_cmd646 chipset type (which has
a nice side-effect of fixing handling of unexpected IRQs).

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
27c01c2db05c3cf8824975e50403cd4fd9356dca 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-cd: remove obsolete seek optimization

It doesn't make much sense nowadays and is problematic on some drives.

Cc: Borislav Petkov <petkovbb@googlemail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2a2ca6a96194c4744a2adeefbc09ce881f3c5abe 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: replace the global ide_lock spinlock by per-hwgroup spinlocks (v2)

Now that (almost) all host drivers have been fixed not to abuse ide_lock
and core code usage of ide_lock has been sanitized we may safely replace
ide_lock by per-hwgroup locks.

This patch is partially based on earlier patch from Ravikiran G Thirumalai.

While at it:
- don't use deprecated HWIF() and HWGROUP() macros
- update locking documentation in ide.h

v2:
Add missing spin_lock_init(&hwgroup->lock). (Noticed by Elias Oltmanns)

Cc: Vaibhav V. Nivargi <vaibhav.nivargi@gmail.com>
Cc: Alok N. Kataria <alokk@calsoftinc.com>
Cc: Shai Fultheim <shai@scalex86.org>
Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Cc: Elias Oltmanns <eo@nebensachen.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6636487e8dc49a1c43fed336bdc4a2f3d7ce6881 02-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> amd74xx: workaround unreliable AltStatus register for nVidia controllers

It seems that on some nVidia controllers using AltStatus register
can be unreliable so default to Status register if the PCI device
is in Compatibility Mode. In order to achieve this:

* Add ide_pci_is_in_compatibility_mode() inline helper to <linux/ide.h>.

* Add IDE_HFLAG_BROKEN_ALTSTATUS host flag and set it in amd74xx host
driver for nVidia controllers in Compatibility Mode.

* Teach actual_try_to_identify() and drive_is_ready() about the new flag.

This fixes the regression caused by removal of CONFIG_IDEPCI_SHARE_IRQ
config option in 2.6.25 and using AltStatus register unconditionally when
available (kernel.org bugs #11659 and #10216).

[ Moreover for CONFIG_IDEPCI_SHARE_IRQ=y (which is what most people
and distributions use) it never worked correctly. ]

Thanks to Remy LABENE and Lars Winterfeld for help with debugging the problem.

More info at:
http://bugzilla.kernel.org/show_bug.cgi?id=11659
http://bugzilla.kernel.org/show_bug.cgi?id=10216

Reported-by: Remy LABENE <remy.labene@free.fr>
Tested-by: Remy LABENE <remy.labene@free.fr>
Tested-by: Lars Winterfeld <lars.winterfeld@tu-ilmenau.de>
Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
badf8082c33d18b118d3a6f1b32d5ea6b97d3839 16-Oct-2008 Al Viro <viro@zeniv.linux.org.uk> [PATCH] switch ide_disk_ops ->ioctl() to sane prototype

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1bddd9e6453ef1c7bc5b6f4ddbf7d31f4aee7a44 02-Sep-2008 Al Viro <viro@zeniv.linux.org.uk> [PATCH] lose the unused file argument in generic_ide_ioctl()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
806f80a6fc203ad0bde84e5a9e94572617d2ae45 17-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add generic ATA/ATAPI disk driver

* Add struct ide_disk_ops containing protocol specific methods.

* Add 'struct ide_disk_ops *' to ide_drive_t.

* Convert ide-{disk,floppy} drivers to use struct ide_disk_ops.

* Merge ide-{disk,floppy} drivers into generic ide-gd driver.

While at it:
- ide_disk_init_capacity() -> ide_disk_get_capacity()

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
79cb380397c834a35952d8497651d93b543ef968 17-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: allow device drivers to specify per-device type /proc settings

Turn ide_driver_t's 'proc' field into ->proc_entries method
(and also 'settings' field into ->proc_devsets method). Then
update all device drivers accordingly.

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
42619d35c7af2f88cad56425fe3981f1f65ff0bd 17-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove IDE_AFLAG_NO_DOORLOCKING

Just use IDE_DFLAG_DOORLOCKING instead.

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e01286282eef85e4783b06fb2e0ed84fc111eb32 17-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: IDE_AFLAG_FORMAT_IN_PROGRESS -> IDE_DFLAG_FORMAT_IN_PROGRESS

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
da167876bd0f71f1c646e5dd98997544d8d90e8e 17-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: IDE_AFLAG_WP -> IDE_DFLAG_WP

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
fe11edfaabf1787c05d782a7b33e6497d1118b1d 17-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: IDE_AFLAG_MEDIA_CHANGED -> IDE_DFLAG_MEDIA_CHANGED

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4abdc6ee7c47a1a6e12f95717e461baeebee5df7 13-Oct-2008 Elias Oltmanns <eo@nebensachen.de> ide: Implement disk shock protection support (v4)

On user request (through sysfs), the IDLE IMMEDIATE command with UNLOAD
FEATURE as specified in ATA-7 is issued to the device and processing of
the request queue is stopped thereafter until the specified timeout
expires or user space asks to resume normal operation. This is supposed
to prevent the heads of a hard drive from accidentally crashing onto the
platter when a heavy shock is anticipated (like a falling laptop expected
to hit the floor). Port resets are deferred whenever a device on that
port is in the parked state.

v3:
Elias Oltmanns <eo@nebensachen.de> wrote:
[...]
> >> 1. Make sure that no negative value is being passed to
> >> jiffies_to_msecs() in ide_park_show().
> >> 2. Drop the superfluous variable hwif in ide_special_rq().
> >> 3. Skip initialisation of task and tf in ide_special_rq() if we are not
> >> handling a (un)park request.
> >
> > Well, #3 should have been done differently because we donn't want to
> > check for REQ_(UN)?PARK_HEADS more often than is necessary.
>
> While preparing the backport to 2.6.27, it has just occurred to me that
> we need to clear the IDE_DFLAG_PARKED flag in ide_disk_pre_reset()
> because this flag must not be set after *any* sort of access to the
> device.

v4:
Fix a memory leak due to a missing blk_put_request() in
issue_park_cmd(). Additionally, we should plug the queue when enqueueing
the unpark request because there is no guarantee that the park timeout
has not expired by then. Even though the chance for that to happen is
very slim, the request might end up hanging in the queue until the next
I/O operation is queued up. While at it, clean up the code a little:
- make issue_park_cmd() a function of type void since nobody cares for
the return value anyway;
- use blk_start_queueing() instead of __blk_run_queue() since we don't
have to worry about recursion;
- remove a superfluous pointer deference in task_no_data_intr().

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
Cc: Jeff Garzik <jeff@garzik.org>,
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Tejun Heo <htejun@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
0a9b6f8864362e31e348b12922a92b48b1b8cc94 13-Oct-2008 Borislav Petkov <petkovbb@googlemail.com> ide: add ide_drive_t.dma flag

This flag is to accomodate ide-cd functionality into ide atapi.

There should be no functionality change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2dbe7e919eb696c86790797f8a814bef19a0d50a 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move SFF DMA code to ide-dma-sff.c

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2bbd57cad3d72334c9fcc4e229a5a5b04dc6aebc 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: switch to DMA-mapping API part #2

Follow-up to commit 5c05ff68b9a9b40a9be949497e0aa980185565cf
("ide: switch to DMA-mapping API"):

* pci_{alloc,free}_consistent() -> dma_{alloc,free}_coherent()
in ide_{allocate,release}_dma_engine().

* Add ->prd_max_nents and ->prd_ent_size fields to ide_hwif_t
(+ set default values in ide_allocate_dma_engine()).

* Make ide_{allocate,release}_dma_engine() available also
for CONFIG_BLK_DEV_IDEDMA_SFF=n. Then convert au1xxx-ide.c,
scc_pata.c and sgiioc4.c to use them.

* Add missing ->init_dma method to scc_pata.

This patch also fixes:
- ->dmatable_cpu leak for au1xxx-ide
- too early realease of ->dmatable_cpu for scc_pata
- wrong amount of ->dmatable_cpu memory being freed for sgiioc4

While at it:
- remove superfluous ->dma_base check from ide_unregister()
- return -ENOMEM on error in ide_release_dma_engine()
- beautify error message in ide_release_dma_engine()

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ffa15a6915b7f6f6f69b4a66e1100a9c68d11250 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make ide_dma_timeout() available also for CONFIG_BLK_DEV_IDEDMA_SFF=n

Make ide_dma_timeout() available also for CONFIG_BLK_DEV_IDEDMA_SFF=n
and convert {ics,au1xxx-}ide.c to use it.

While at it:
- dump ATA Status register content on error
- use EXPORT_SYMBOL_GPL() to match the rest of SFF DMA functions

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
de23ec9ca82357e6d337a2263befb1a65cf19c83 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make ide_dma_lost_irq() available also for CONFIG_BLK_DEV_IDEDMA_SFF=n

Make ide_dma_lost_irq() available also for CONFIG_BLK_DEV_IDEDMA_SFF=n
and convert {ics,au1xxx-}ide.c to use it.

While at it:
- use EXPORT_SYMBOL_GPL() to match the rest of SFF DMA functions

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
653bcf5292a9ac4ffc07315198f0ef995e0646a8 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: __ide_dma_end() -> ide_dma_end()

While at it:
- use EXPORT_SYMBOL_GPL() to match the rest of SFF DMA functions

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f87904898e91923a91b925078ac933f05076c7fd 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-disk: move all ioctl handling to ide-disk_ioctl.c

While at it:
- idedisk_ioctl() -> ide_disk_ioctl()

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
a36223b0dc14606b5c80aacbbe6288133693a841 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_host_alloc_all()

* Remove no longer used ide_host_alloc_all().

* Add MAX_HOST_PORTS define and use it instead of MAX_HWIFS
as the maximum number of host ports possible.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
bfa7d8e55f0c5ae22ef57eb22942c74fdde7b9bd 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: ->ide_dma_clear_irq() -> ->clear_irq()

* Rename ->ide_dma_clear_irq method to ->clear_irq
and move it from ide_hwif_t to struct ide_port_ops.

* Move ->waiting_for_dma check inside ->clear_irq method.

* Move ->dma_base check inside ->clear_irq method.

piix.c:
* Add ich_port_ops and remove init_hwif_ich() wrapper.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
d6ff9f64e68d23feab44efa07cc6aee01f3ef32b 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: merge all TASKFILE_NO_DATA data phase handlers into taskfile_no_intr()

* Add 'struct task_s' to ide_hwif_t and init it to the current command
in do_rw_taskfile().

* Merge all TASKFILE_NO_DATA data phase handlers into taskfile_no_intr().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6982daf71ca9a0b0c36043315e1968b3cb709b7c 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: convert 'pio_mode' device setting to use DS_SYNC flag

* Convert 'pio_mode' device setting to use DS_SYNC flag.

* Remove unused special_t.b.{set_tune,serviced} and ide_drive_t.tune_req.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7f612f272ad8abe82411f368bfacf793b466e1b3 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove [ata_]select_t

* Use 'drive->dn & 1' in ide_init_disk().

* remove [ata_]select_t.

While at it:

* Use ATA_DEVICE_OBS define in ide_port_init_devices_data().

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
0d346ba0730d84f04022f9f984d3f606f69cef37 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: sanitize ide*_pm_* enums

* Move ide*_pm_* enums from ide-io.c to <linux/ide.h>.

* idedisk_pm_* -> ide_pm_*

* ide_pm_state_* -> ide_pm_*

* No need to set ide_pm_* enums to the fixed values.

* Uppercase ide_pm_* enums.

* Fix/update comments.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
d1d76714e2f0c520b6c2a84ab5b050d0b3244949 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix HDIO_DRIVE_TASK[FILE] ioctls for CHS commands on LBA devices

Add IDE_DFLAG_LBA device flag and use it instead of ->select.b.lba.

Since ->tf_load uses ->select.all for ATA Device/Head register this
fixes HDIO_DRIVE_TASK[FILE] ioctls for CHS commands on LBA devices.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e4634d4ef04fe6d7b114b612e5b71a84187ce76a 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove superfluous ->dma field from ide_hwif_t

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
0ae4b3199ab1b6d511c6e0948e92049c272a346a 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove superfluous ->media field from ide_driver_t

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c39220483ebe6871fb129d4b2236cd95290c41fc 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: DMA_PIO_RETRY -> IDE_DFLAG_DMA_PIO_RETRY

Add IDE_DFLAG_DMA_PIO_RETRY and use it instead of
ide_drive_t.state + DMA_PIO_RETRY.

There should be no functional changes cause by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
97100fc816badbbc162644cfde7ad39ae9211fb4 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add device flags

Add 'unsigned long dev_flags' to ide_drive_t and convert bitfields
to IDE_DFLAG_* flags.

While at it:
- IDE_DFLAG_ADDRESSING -> IDE_DFLAG_LBA48
- fixup some comments
- remove needless g->flags zeroing from ide*_probe()

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
35c137531245118962eb40a550661afe317bec03 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-disk: set_addressing() fixes

* Return -EIO if arg > 0 and LBA48 is unsupported.

* No need to reset ->addressing.

* Make ->addressing a single bit flag.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e1c7c4641aae8d278fca62b3b5cffad3a8dcb0a4 13-Oct-2008 Borislav Petkov <petkovbb@googlemail.com> ide: add a driver-wide debugging macro

Add __ide_debug_log() debugging macro which is controlled by drive->debug_mask.
The macro has to have the macro DRV_NAME defined in each driver before use.
Also, add different debugging levels depending on the functionality debugged.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b22b2ca4ff0730b14d14bcc36bd1b84873557512 13-Oct-2008 Borislav Petkov <petkovbb@googlemail.com> ide: add drive->debug_mask switch

Add a debugging on/off switch for controlling driver debugging
messages dynamically.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5aeddf907f149cae7e19b7c23ccea3823d00698c 13-Oct-2008 Borislav Petkov <petkovbb@googlemail.com> ide: unify conversion macros

Introduce to_ide_drv() and ide_drv_g() macros and replace the respective
definitions of similar ones in each driver.

There should be no functionality change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
baf08f0be6d986521bb2fbdc7af51fc4847da734 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make ide_transfer_pc() static

* Move ->ticks field from struct ide_floppy_obj to ide_drive_t.

* Move idefloppy_transfer_pc() to ide-atapi.c and make
ide_transfer_pc() use it.

* Always use ide_transfer_pc as a handler in ide_issue_pc().

* Remove no longer used idefloppy_start_pc_transfer(),
ide*_transfer_pc() and 'handler' argument from ide_issue_pc().

* Make ide_transfer_pc() static.

While at it:

* idefloppy_transfer_pc() -> ide_delayed_transfer_pc()

* IDEFLOPPY_TICKS_DELAY -> IDEFLOPPY_PC_DELAY

* ->ticks -> ->pc_delay

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
aa5d2de7b080873f6d9ac3aede423c9713bf0caa 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make ide_pc_intr() static

* Always use ide_pc_intr as a handler in ide_pc_intr().

* Remove no longer used ide*_pc_intr() and 'handler'
argument from ide_{transfer_pc,pc_intr}().

* Make ide_pc_intr() static.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
85e39035ca381846b031690f4d1ac1f0660da0a2 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->pc_{update,io}_buffers methods

Add ->pc_{update,io}_buffers methods to ide_drive_t and use
them instead of {update,io}_buffers ide_pc_intr() arguments.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6b0da28b2d0f4f4e2c55689fc062db569075ff60 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_retry_pc() helper

* Add ide_create_request_sense_cmd() and ide_retry_pc() helpers
and convert ide-{atapi,floppy,tape}.c to use them.

* Remove no longer used ide*_create_request_sense_cmd(),
ide*_retry_pc() and 'retry_pc' argument from ide_pc_intr().

* Make ide_queue_pc_head() static.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
67c56364df843fb9e3ed1af014b8fbe4b22ff25d 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add request_sense_{pc,rq} to ide_drive_t

Add 'struct ide_atapi_pc request_sense_pc' and 'request request_sense_rq' to
ide_drive_t and use them instead of fields in struct ide_{floppy,tape}_obj.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
844b9468523c8c2c45b90df4efcabcbe4926b5ab 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: drop 'timeout' and 'expiry' arguments from ide_pc_intr()

* Move idescsi_expiry() to ide-atapi.c.

* Move get_timeout() to <linux/ide.h>.

* Drop 'timeout' and 'expiry' arguments from ide_pc_intr().

While at it:

* idescsi_expiry() -> ide_scsi_expiry()

* get_timeout() -> ide_scsi_get_timeout()

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2b9efba48283f34083df6bc53f6752fba4e4d409 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add pointer to the current packet command to ide_drive_t

* Add pointer to the current packet command (struct ide_atapi_pc *pc)
to ide_drive_t and use it instead of the pointer in struct ide_*_obj.

* Use drive->pc in ide_{issue,transfer}_pc() and ide_pc_intr()
instead of 'pc' argument.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b14c72127fbe8f97e49de7437520175673f7306a 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: drop dsc_handle argument from ide_pc_intr()

* Add 'int dsc' argument to ->pc_callback method.

* Call ide_tape_handle_dsc() internally in ide_tape_callback()
if dsc argument is set and update ide_pc_intr() accordingly.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
92f1f8fd8040e7b50a67a850a935509bb01201bb 10-Oct-2008 Elias Oltmanns <eo@nebensachen.de> ide: Remove ide_spin_wait_hwgroup() and use special requests instead

Use a special request for serialisation purposes and get rid of the
awkward ide_spin_wait_hwgroup(). This also involves converting the
ide_devset structure so it can be shared by the /proc and the ioctl code.

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
[bart: use rq->cmd[] directly]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
d6e2955a6b82d2312b5ff885ce13c8ab54d59d96 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move IDE{FLOPPY,TAPE}_WAIT_CMD defines to <linux/ide.h>

While at it:

* IDE{FLOPPY,TAPE}_WAIT_CMD -> WAIT_{FLOPPY,TAPE}_CMD

* Use enum for WAIT_* defines.

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
de699ad595fb45022d1b049ed91ffd06fdd16c13 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_do_test_unit_ready() helper

* Add ide_do_test_unit_ready() helper and convert ide-{floppy,tape}.c
to use it.

* Remove no longer used idetape_create_test_unit_ready_cmd().

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
0c8a6c7aead1d3be85ce53e3aaacd52e38ede03e 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_do_start_stop() helper

* Add ide_do_start_stop() helper and convert ide-{floppy,tape}.c
to use it.

* Remove no longer used idefloppy_create_start_stop_cmd()
and idetape_create_load_unload_cmd().

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
0578042db3191e1ac76b53d213f2a691c3e1eaed 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_set_media_lock() helper

* Set IDE_AFLAG_NO_DOORLOCK in idetape_get_mode_sense_result(), check it
in ide_tape_set_media_lock() and cleanup idetape_create_prevent_cmd().

* Set IDE_AFLAG_NO_DOORLOCK in ide_floppy_create_read_capacity_cmd() and
check it instead of IDE_AFLAG_CLIK_DRIVE in ide_floppy_set_media_lock().

* Add ide_set_media_lock() helper and convert ide-{floppy,tape}.c to use it.

* Remove no longer used ide*_create_prevent_cmd()/ide*_set_media_lock().

* Update comment in <linux/ide.h> accordingly.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
49cac39e71bd6bbcf934c6ba837e21503902c088 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-floppy: ->{srfp,wp} -> IDE_AFLAG_{SRFP,WP}

Add IDE_AFLAG_{SRFP,WP} drive->atapi_flags and use them
instead of ->{srfp,wp} struct ide_floppy_obj fields.

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2ac07d920604eeee8966d52e70161f9b31fe90a3 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_queue_pc_tail() helper

* Add ide_queue_pc_tail() and convert ide-{floppy,tape}.c to use it
instead of ide*_queue_pc_tail().

* Remove no longer used ide*_queue_pc_tail().

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7645c1514c7d34ebdf3ea0e8ee3a935c08abceb2 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_queue_pc_head() helper

* Move REQ_IDETAPE_* enums to <linux/ide.h>.

* Add ide_queue_pc_head() and convert ide-{floppy,tape}.c to use it
instead of ide*_queue_pc_head().

* Remove no longer used ide*_queue_pc_head().

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7bf7420a318978cd6042e5a5da34b7cfa18ae559 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_init_pc() helper

* Add IDE_PC_BUFFER_SIZE define.

* Add ide_init_pc() and convert ide-{floppy,tape}.c to use it
instead of ide*_init_pc().

* Remove no longer used IDE*_PC_BUFFER_SIZE and ide*_init_pc().

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
acaa0f5f675ccf6b8a3a11a933419068b1ea1f46 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_io_buffers() helper

* Make ->io_buffers method return number of bytes transferred.

* Use ide_end_request() instead of idefloppy_end_request()
in ide_floppy_io_buffers() and then move the call out to
ide_pc_intr().

* Add ide_io_buffers() helper and convert ide-{floppy,scsi}.c
to use it instead of ide*_io_buffers().

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
51509eec34debffec3c6f481f7371c9aeb6c63c1 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_check_atapi_device() helper

* Add ide_check_atapi_device() to ide-atapi.c and convert
ide-{floppy,tape}.c to use it instead of ide*_identify_device().

While at it:

* Add DRV_NAME defines to ide-{floppy,tape}.c.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
05236ea6df7419f0f37cf9603cfee265cfce5832 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move ioctls handling to ide-ioctls.c

* Move ioctls handling to ide-ioctls.c
(except HDIO_DRIVE_TASKFILE for now).

* Make ide_{cmd,task}() static.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
aa7687738af3332470e02ac1060f6c046d83c9a3 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_setting_ioctl() helper

* Add struct ide_ioctl_devset representing ioctl device setting.

* Add ide_setting_ioctl() helper for matching given ioctl
and its parameters against table of ioctl device settings.

* Convert ide_setting_ioctl() and idedisk_ioctl() to use
ide_setting_ioctl().

* Un-export ide_setting_mtx.

While at it:

* {get,set}_lba_addressing() -> {get,set}_addressing()

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9232c14bff36d65de254f34386c00b732c5b6099 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->bus_state field from ide_hwif_t

It is always set to BUSSTATE_ON.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
feb22b7f8e62b1b987a3a1dbad95af767a1df832 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add proper PCI PM support (v2)

* Keep pointer to ->init_chipset method also in
struct ide_host and set it in ide_host_alloc_all().

* Add ide_pci_suspend() and ide_pci_resume() helpers
(default ->suspend and ->resume implementations).

* ->init_chipset can no longer be marked __devinit.

* Add proper PCI PM support to IDE PCI host drivers
(rz1000.c and tc86c001.c are skipped for now since
they need to be converted from using ->init_hwif
to use ->init_chipset instead).

v2:
* Cleanup CONFIG_PM #ifdef-s per akpm's suggestion.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ff2779b568e70822e0ef2cc7afeeefbe7c607652 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: ide_id_has_flush_cache_ext() -> ata_id_flush_ext_enabled()

* Add ata_id_flush_ext_enabled() inline helper to <linux/ata.h>.

* ide_id_has_flush_cache_ext() -> ata_id_flush_ext_enabled()

The latter one also checks if the command is marked as
supported in word 83 and validity of words 83 & 86.

Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4b58f17d7c45a8e5f4acda641bec388398b9c0fa 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: ide_id_has_flush_cache() -> ata_id_flush_enabled()

* Add ata_id_flush_enabled() inline helper to <linux/ata.h>.

* ide_id_has_flush_cache() -> ata_id_flush_enabled()

The latter one also checks if the command is marked as
supported in word 83 and validity of words 83 & 86.

Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1a4e4d4d2cceb72be70526a485914abd638c7de1 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: check only for CACHE FLUSH command support in ide_id_has_flush_cache()

All devices supporting CACHE FLUSH EXT command should also support
CACHE FLUSH command so it is sufficient to check only for CACHE FLUSH
in ide_id_has_flush_cache().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
367d7e78dd48cf6ad35182a99d97abb5486e040e 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: ide_dev_is_sata() -> ata_id_is_sata()

* Use optimized ATA version check from Sergei in ata_id_is_sata().

* ide_dev_is_sata() -> ata_id_is_sata()

Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5d5870f0a26e2304c4a82592870c5bc88017f7c9 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: ide_dev_has_iordy() -> ata_id_has_iordy()

* Remove (id[ATA_ID_FIELD_VALID] & 2) check from ide_dev_has_iordy()
(it is for validity of words 64-70, IORDY is in word 49).

* ide_dev_has_iordy() -> ata_id_has_iordy()

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
02d599a365d04658bc9ea71762ed17c895079927 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->supports_dsc_overlap field from ide_driver_t

* Use drive->media and drive->scsi to check if ->dsc_overlap
can be set by HDIO_SET_NICE ioctl in generic_ide_ioctl().

* Remove unused ->supports_dsc_overlap field from ide_driver_t.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ebc6be520673f65aef188abde43972f9cd2162e9 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove read-only ->atapi_overlap field from ide_drive_t

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
151a670186a0f8441798f90c8701647adb7a1589 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove SECTOR_WORDS define

Just use SECTOR_SIZE instead.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
8185d5aa93e0a5c111adc4952a5b87193a68ae5b 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: /proc/ide/hd*/settings rework

* Add struct ide_devset, S_* flags, *DEVSET() & ide*_devset_*() macros.

* Add 'const struct ide_devset **settings' to ide_driver_t.

* Use 'const struct ide_devset **settings' in ide_drive_t instead of
'struct ide_settings_s *settings'. Then convert core code and device
drivers to use struct ide_devset and co.:

- device settings are no longer allocated dynamically for each device
but instead there is an unique struct ide_devset instance per setting

- device driver keeps the pointer to the table of pointers to its
settings in ide_driver_t.settings

- generic settings are kept in ide_generic_setting[]

- ide_proc_[un]register_driver(), ide_find_setting_by_name(),
ide_{read,write}_setting() and proc_ide_{read,write}_settings()
are updated accordingly

- ide*_add_settings() are removed

* Remove no longer used __ide_add_setting(), ide_add_setting(),
__ide_remove_setting() and auto_remove_settings().

* Remove no longer used TYPE_*, SETTING_*, ide_procset_t
and ide_settings_t.

* ->keep_settings, ->using_dma, ->unmask, ->noflush, ->dsc_overlap,
->nice1, ->addressing, ->wcache and ->nowerr ide_drive_t fields
can now be bitfield flags.

While at it:

* Rename ide_find_setting_by_name() to ide_find_setting().

* Rename write_wcache() to set_wcache().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
263138a0ad6e38de7f6526b7de037ed4511308ef 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: preparations for /proc/ide/hd*/settings rework

After rework settings will be no longer created dynamically
for each device so we need to make some fixups first.

* Use set_[ksettings,unmaskirq]() as a set function for
["keepsettings","unmaskirq"] setting.

* Allow writes to ["io_32bit","unmaskirq"] settings also when
drive->no_[io_32bit,unmask] is set (this is checked later inside
set_[io_32bit,unmaskirq]() anywyay and keeps consistency with
the corresponding HDIO_SET_[32BIT,UNMASKINTR] ioctls).

* Use max possible multi sectors value (16) as an allowed max for
"multcount" setting. set_multcount() set function checks against
device's max possbile value anyway and it makes the proc setting
consistent with the corresponding HDIO_SET_MULTCOUNT ioctl.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
3ceca727fe3a38dd8d7a3adf938fefda83eee8af 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: include <linux/hdreg.h> only when needed

* Include <linux/ata.h> directly in <linux/ide.h>
instead of through <linux/hdreg.h>.

* Include <linux/hdreg.h> only when needed.

Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7e59ea21aab1a91ca31bc64c7d3035ebdbd336d1 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: check drive->present in ide_get_paired_drive()

* Change ide_get_paired_drive() to return NULL if peer device
is not present and update all users accordingly.

While at it:

* ide_get_paired_drive() -> ide_get_pair_dev()

* Use ide_get_pair_dev() in cs5530.c, sc1200.c and via82cxxx.c.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
a2cdee5a9a93360165d0576bbc7e9ccb3127afee 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove IDE_CHIPSET_* macros

They just obfuscate the code.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b163f46d5ecf48d883ce156e5e5a21a1a9a125c7 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: enhance ide_busy_sleep()

* Make ide_busy_sleep() take timeout value as a parameter
and also allow use of AltStatus Register if requested with
altstatus parameter. Update existing users accordingly.

* Convert ide_driveid_update() and actual_try_to_identify()
to use ide_busy_sleep().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
3c619ffd48d7fdb3b17f0df67c4eb4b0bd80e253 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove no longer needed ide_drive_t fields

Remove ->remap_0_to_1 and ->sect0 (they are always zero now).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
3a7d24841ad794ae64c90d7d00d62a83741912aa 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ATA_* defines instead of *_STAT and *_ERR ones

* ERR_STAT -> ATA_ERR
* INDEX_STAT -> ATA_IDX
* ECC_STAT -> ATA_CORR
* DRQ_STAT -> ATA_DRQ
* SEEK_STAT -> ATA_DSC
* WRERR_STAT -> ATA_DF
* READY_STAT -> ATA_DRDY
* BUSY_STAT -> ATA_BUSY

* MARK_ERR -> ATA_AMNF
* TRK0_ERR -> ATA_TRK0NF
* ABRT_ERR -> ATA_ABORTED
* MCR_ERR -> ATA_MCR
* ID_ERR -> ATA_IDNF
* MC_ERR -> ATA_MC
* ECC_ERR -> ATA_UNC
* ICRC_ERR -> ATA_ICRC

* BBD_ERR -> ATA_BBK

Also:

* ILI_ERR -> ATAPI_ILI
* EOM_ERR -> ATAPI_EOM
* LFS_ERR -> ATAPI_LFS

* CD -> ATAPI_COD
* IO -> ATAPI_IO

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
48fb2688aa67baba373531cc4ed2d9e695983c3f 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove drive->driveid

* Factor out HDIO_[OBSOLETE,GET]_IDENTITY ioctls handling
to ide_get_identity_ioctl().

* Use temporary buffer in ide_get_identity_ioctl() instead
of accessing drive->id directly.

* Add ide_id_to_hd_driveid() inline to convert raw id into
struct hd_driveid format (needed on big-endian).

* Use ide_id_to_hd_driveid() in ide_get_identity_ioctl(),
cleanup ide_fix_driveid() and switch ide to use use raw id.

* Remove no longer needed drive->driveid.

This leaves us with 3 users of struct hd_driveid in tree:
- arch/um/drivers/ubd_kern.c
- drivers/block/xsysace.c
- drivers/usb/storage/isd200.c

While at it:

* Use ata_id_u{32,64}() and ata_id_has_{dma,lba,iordy}() macros.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4dde4492d850a4c9bcaa92e5bd7f4eebe3e2f5ab 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make drive->id an union (take 2)

Make drive->id an unnamed union so id can be accessed either by using
'u16 *id' or 'struct hd_driveid *driveid'. Then convert all existing
drive->id users accordingly (using 'u16 *id' when possible).

This is an intermediate step to make ide 'struct hd_driveid'-free.

While at it:

- Add missing KERN_CONTs in it821x.c.

- Use ATA_ID_WORDS and ATA_ID_*_LEN defines.

- Remove unnecessary checks for drive->id.

- s/drive_table/table/ in ide_in_drive_list().

- Cleanup ide_config_drive_speed() a bit.

- s/drive1/dev1/ & s/drive0/dev0/ in ide_undecoded_slave().

v2:
Fix typo in drivers/ide/ppc/pmac.c. (From Stephen Rothwell)

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f20f258603ebc5da91e76884cf0c0d7ac9804b1c 05-Oct-2008 Borislav Petkov <petkovbb@gmail.com> ide-cd: temporary tray close fix

This one fixes http://bugzilla.kernel.org/show_bug.cgi?id=11602.

A more generic fix for drives which cannot autoclose tray will follow.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
[bart: add an extra parentheses for consistency with the rest of kernel code]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
96f80219b738f84f90e449385bdede90f2910521 02-Sep-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix hwif_to_node()

hwif_to_node() incorrectly assumes that hwif->dev always belongs to
a PCI device. This results in ide-cs oopsing in init_irq() after
commit c56c5648a3bd15ff14c50f284b261140cd5b5472 accidentally fixed
device tree registration for ide-cs. Fix it by using dev_to_node().

Thanks to Martin Michlmayr and Larry Finger for help with debugging
the issue.

Reported-by: Martin Michlmayr <tbm@cyrius.com>
Tested-by: Martin Michlmayr <tbm@cyrius.com>
Cc: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
71fc9fcc70e6ad96215510c1dbcbade05cd95e41 02-Sep-2008 Kevin Hilman <khilman@deeprootsystems.com> IDE: compile fix for sff_dma_ops

The sff_dma_ops struct should be wrapped by BLK_DEV_IDEDMA_SFF instead
of BLK_DEV_IDEDMA_PCI.

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c5bfc3757f1d843a8e1261840c1f53c5062f8e92 05-Aug-2008 Adrian Bunk <bunk@kernel.org> ide: remove CONFIG_IDE_MAX_HWIFS

The benefits of a user settable CONFIG_IDE_MAX_HWIFS have become pretty
tiny and are no longer considered worth the trouble of an own option.

Simply always #define MAX_HWIFS to 10.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
39b986a6c73434d122967dc86efb295ab9a28437 05-Aug-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: sanitize struct ide_port_ops documentation (take 2)

v2:
Add missing '@'-s. (Noticed by Randy Dunlap)

Cc: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
a326b02b0c576001353dbc489154959b0889c6bf 24-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: drop 'name' parameter from ->init_chipset method

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2a8f7450f828eaee49d66f41f99ac2e54f1160a6 24-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove <asm/ide.h> for some archs

* Remove <linux/irq.h> include from <asm-ia64.h> (<linux/ide.h> includes
<linux/interrupt.h> which is enough).

* Remove <asm/ide.h> for alpha/blackfin/h8300/ia64/m32r/sh/x86/xtensa
(this leaves us with arm/frv/m68k/mips/mn10300/parisc/powerpc/sparc[64]).

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
d83b8b85cd56a083d30df73f3fd5e4714591b910 24-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: define MAX_HWIFS in <linux/ide.h>

* Now that ide_hwif_t instances are allocated dynamically
the difference between MAX_HWIFS == 2 and MAX_HWIFS == 10
is ~100 bytes (x86-32) so use MAX_HWIFS == 10 on all archs
except these ones that use MAX_HWIFS == 1.

* Define MAX_HWIFS in <linux/ide.h> instead of <asm/ide.h>.

[ Please note that avr32/cris/v850 have no <asm/ide.h>
and alpha/ia64/sh always define CONFIG_IDE_MAX_HWIFS. ]

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ef0b04276d8f719d754c092434fbd62c2aeb5307 24-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_pci_remove() helper

* Add 'unsigned long host_flags' field to struct ide_host.

* Set ->host_flags in ide_host_alloc_all().

* Always set PCI dev's ->driver_data in ide_pci_init_{one,two}().

* Add ide_pci_remove() helper (the default implementation for
struct pci_driver's ->remove method).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
08da591e14cf87247ec09b17c350235157a92fc3 24-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_device_{get,put}() helpers

* Add 'struct ide_host *host' field to ide_hwif_t and set it
in ide_host_alloc_all().

* Add ide_device_{get,put}() helpers loosely based on SCSI's
scsi_device_{get,put}() ones.

* Convert IDE device drivers to use ide_device_{get,put}().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6cdf6eb357c2681596b7b1672b92396ba82333d4 24-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->dev and ->host_priv fields to struct ide_host

* Add 'struct device *dev[2]' and 'void *host_priv' fields
to struct ide_host.

* Set ->dev[] in ide_host_alloc_all()/ide_setup_pci_device[s]().

* Pass 'void *priv' argument to ide_setup_pci_device[s]()
and use it to set ->host_priv.

* Set PCI dev's ->driver_data to point to the struct ide_host
instance if PCI host driver wants to use ->host_priv.

* Rename ide_setup_pci_device[s]() to ide_pci_init_{one,two}().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ac77ef8b03677c8ae8afe77bccc5f6a969193a79 23-Jul-2008 Borislav Petkov <petkovbb@googlemail.com> ide: remove unused PC_FLAG_DRQ_INTERRUPT

There should be no functionality change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ea68d270ff55bcdfa5d07697eb68103b5b02c7bb 23-Jul-2008 Borislav Petkov <petkovbb@googlemail.com> ide-floppy: convert to using the new atapi_flags (take 2)

while at it, remove PC_FLAG_ZIP_DRIVE from the packed command flags altogether
and query the drive type through drive->atapi_flags.

v2:
ide-floppy fix.

There should be no functionality change resulting from this patch.

[bart: IDE_FLAG_* -> IDE_AFLAG_*, dev_flags -> atapi_flags]

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
3b8ac5398ca8137b41aa5da4d9fad89153450aaa 23-Jul-2008 Borislav Petkov <petkovbb@googlemail.com> ide: add per-device flags

Push device flags up into ide_drive_t.

There should be no functionality change resulting from this patch.

[bart: IDE_FLAG_* -> IDE_AFLAG_*, dev_flags -> atapi_flags]

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
8bcda3bc492c56abed33a8cbf824c410d7ce69f0 23-Jul-2008 Borislav Petkov <petkovbb@googlemail.com> ide: remove pc->callback member from ide_atapi_pc

There should be no functionality change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
d7c26ebb5bca284ece9db7311a9e180aabae1922 23-Jul-2008 Borislav Petkov <petkovbb@googlemail.com> ide: push pc callback pointer into the ide_drive_t structure

Refrain from carrying the callback ptr with every packet command since the
callback function is only one anyways. ide_drive_t is probably not the most
suitable place for it right now but is the more sane solution. Besides, these
structs are going to be reorganized anyways during the generic ide rewrite.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
8a69580e1ea9516caada5eed202afd39546e9809 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_host_free() helper (take 2)

* Add ide_host_free() helper and convert ide_host_remove() to use it.

* Fix handling of ide_host_register() failure in ide_host_add(),
icside.c, ide-generic.c, falconide.c and sgiioc4.c.

While at it:

* Fix handling of ide_host_alloc_all() failure in ide-generic.c.

* Fix handling of ide_host_alloc() failure in falconide.c
(also return the correct error value if no device is found).

v2:
* falconide build fix. (From Stephen Rothwell)

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6f904d015262dfa43eb1cecc00b0998b4c3543f2 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_host_add() helper

Add ide_host_add() helper which does ide_host_alloc()+ide_host_register(),
then convert ide_setup_pci_device[s](), ide_legacy_device_add() and some
host drivers to use it.

While at it:

* Fix ide_setup_pci_device[s](), ide_arm.c, gayle.c, ide-4drives.c,
macide.c, q40ide.c, cmd640.c and cs5520.c to return correct error value.

* -ENOENT -> -ENOMEM in rapide.c, ide-h8300.c, ide-generic.c, au1xxx-ide.c
and pmac.c

* -ENODEV -> -ENOMEM in palm_bk3710.c, ide_platform.c and delkin_cb.c

* -1 -> -ENOMEM in ide-pnp.c

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
48c3c1072651922ed153bcf0a33ea82cf20df390 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add struct ide_host (take 3)

* Add struct ide_host which keeps pointers to host's ports.

* Add ide_host_alloc[_all]() and ide_host_remove() helpers.

* Pass 'struct ide_host *host' instead of 'u8 *idx' to
ide_device_add[_all]() and rename it to ide_host_register[_all]().

* Convert host drivers and core code to use struct ide_host.

* Remove no longer needed ide_find_port().

* Make ide_find_port_slot() static.

* Unexport ide_unregister().

v2:
* Add missing 'struct ide_host *host' to macide.c.

v3:
* Fix build problem in pmac.c (s/ide_alloc_host/ide_host_alloc/)
(Noticed by Stephen Rothwell).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
374e042c3e767ac2e5a40b78529220e0b3de793c 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add struct ide_tp_ops (take 2)

* Add struct ide_tp_ops for transport methods.

* Add 'const struct ide_tp_ops *tp_ops' to struct ide_port_info
and ide_hwif_t.

* Set the default hwif->tp_ops in ide_init_port_data().

* Set host driver specific hwif->tp_ops in ide_init_port().

* Export ide_exec_command(), ide_read_status(), ide_read_altstatus(),
ide_read_sff_dma_status(), ide_set_irq(), ide_tf_{load,read}()
and ata_{in,out}put_data().

* Convert host drivers and core code to use struct ide_tp_ops.

* Remove no longer needed default_hwif_transport().

* Cleanup ide_hwif_t from methods that are now in struct ide_tp_ops.

While at it:

* Use struct ide_port_info in falconide.c and q40ide.c.

* Rename ata_{in,out}put_data() to ide_{in,out}put_data().

v2:

* Fix missing convertion in ns87415.c.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
d6276b5f5cc7508124de291f3ed59c6945c17ae7 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add 'config' field to hw_regs_t

Add 'config' field to hw_regs_t and use it to set hwif->config_data in
ide_init_port_hw(), then convert ide_legacy_init_one() to use hw->config.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
3b2a5c7149ee4af4aff8fee953f66fc846d92cea 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: filter out "default" transfer mode values in set_xfer_rate()

* Filter out "default" transfer mode values (0x00 - default PIO mode,
0x01 - default PIO mode w/ IORDY disabled) in write handler for obsoleted
/proc/ide/hd?/settings:current_speed setting.

Allowing "default" transfer mode values is a dangerous thing to do as
we don't support programming controller to the "default" transfer mode
and devices often use different values for the default and maximum PIO
mode (i.e. PIO2 default and PIO4 maximum) so the controller will stay
programmed for higher PIO mode while device will use the lower PIO mode.

There is no functionality loss as by using special IOCTLs device can
still be programmed to "default" transfer modes (it is only useful for
debugging/testing purposes anyway).

* Remove no longer needed IDE_HFLAG_ABUSE_SET_DMA_MODE host flag, it was
previously used by few host drivers to program the controller to PIO0
timings for "default" transfer mode == 0x01 (although some host drivers
would program invalid PIO timings instead).

* Cleanup ide_set_xfer_rate() and add BUG_ON().

Suggested-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ba4b2e607e4e9eaa929935325dafd5c86d3b5262 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove dead Virtual DMA support

Lets remove dead Virtual DMA support for now so it doesn't clutter
core IDE code (it can be bring back when there is a need for it):

* Remove IDE_HFLAG_VDMA host flag.

* Remove ide_drive_t.vdma flag.

* cs5520.c: remove stale FIXMEs, cs5520_dma_host_set() and cs5520_dma_ops
(also there is no longer a need to set IDE_HFLAG_NO_ATAPI_DMA).

There should be no functional changes caused by this patch.

Cc: TAKADA Yoshihito <takada@mbf.nifty.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
761052e676372465fdeb97c148d5a4b0790fa8a0 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->INB, ->OUTB and ->OUTBSYNC methods

* Remove no longer needed ->INB, ->OUTB and ->OUTBSYNC methods.

Then:

* Remove no longer used default_hwif_[mm]iops() and ide_[mm_]outbsync().

* Cleanup SuperIO handling in ns87415.c.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1823649b5abb77ffe638178bc5253249d3ecd17d 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_read_bcount_and_ireason() helper

Add ide_read_bcount_and_ireason() helper and use it instead of ->INB
in {cdrom_newpc,ide_pc}_intr().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
92eb43800a3c1300bd5cb8a2a27e6f2a84f7042e 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ->tf_read in ide_read_error()

* Add IDE_TFLAG_IN_FEATURE taskfile flag for reading Feature
register and handle it in ->tf_read.

* Convert ide_read_error() to use ->tf_read instead of ->INB,
then uninline and export it.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6e6afb3b7401f0181da74a1add57f126946b43e6 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->set_irq method

Add ->set_irq method for setting nIEN bit of ATA Device Control
register and use it instead of ide_set_irq().

While at it:

* Use ->set_irq in init_irq() and do_reset1().

* Don't use HWIF() macro in ide_check_pm_state().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1f6d8a0fd8f6cc5ee2219a8cf9b2da16dfd67397 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->read_altstatus method

* Remove ide_read_altstatus() inline helper.

* Add ->read_altstatus method for reading ATA Alternate Status
register and use it instead of ->INB.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b73c7ee25da6133f97f47ffd3557288417da7c76 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->read_status method

* Remove ide_read_status() inline helper.

* Add ->read_status method for reading ATA Status register
and use it instead of ->INB.

While at it:

* Don't use HWGROUP() macro.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c6dfa867bb45f4bff2e48f3bc89ab1d6a7ab4c21 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->exec_command method

Add ->exec_command method for writing ATA Command register
and use it instead of ->OUTBSYNC.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ebb00fb55d0566bb3e81518122a57b4b3bedf1e4 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: factor out simplex handling from ide_pci_dma_base()

* Factor out simplex handling from ide_pci_dma_base() to
ide_pci_check_simplex().

* Set hwif->dma_base early in ->init_dma method / ide_hwif_setup_dma()
and reset it in ide_init_port() if DMA initialization fails.

* Use ->read_sff_dma_status instead of ->INB in ide_pci_dma_base().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
81e8d5a34f7d2a2acbe309cfa5810a9699a63239 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_setup_dma()

Export sff_dma_ops and then remove ide_setup_dma().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
cab7f8eda40d3e3e16b137c67cdddc2cf893c5d7 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->dma_{status,command} fields from ide_hwif_t

* Use ->dma_base + offset instead of ->dma_{status,command}
and remove no longer needed ->dma_{status,command}.

While at it:

* Use ATA_DMA_* defines.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b2f951aabc9cc7d5fb987aeec9aef96ccce618a5 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->read_sff_dma_status method

Add ->read_sff_dma_status method for reading DMA Status register
and use it instead of ->INB.

While at it:

* Use inb() directly in ns87415.c::ns87415_dma_end().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c97c6aca75fd5f718056fde7cff798b8cbdb07c0 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: pass hw_regs_t-s to ide_device_add[_all]() (take 3)

* Add 'hw_regs_t **hws' argument to ide_device_add[_all]() and convert
host drivers + ide_legacy_init_one() + ide_setup_pci_device[s]() to use
it instead of calling ide_init_port_hw() directly.

[ However if host has > 1 port we must still set hwif->chipset to hint
consecutive ide_find_port() call that the previous slot is occupied. ]

* Unexport ide_init_port_hw().

v2:
* Use defines instead of hard-coded values in buddha.c, gayle.c and q40ide.c.
(Suggested by Geert Uytterhoeven)

* Better patch description.

v3:
* Fix build problem in ide-cs.c. (Noticed by Stephen Rothwell)

There should be no functional changes caused by this patch.

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
3ef5eb424ebf0cd981192a416358fd707a9f959b 16-Jul-2008 Elias Oltmanns <eo@nebensachen.de> IDE: Remove unused code

Remove some code which has been made obsolete and hasn't worked properly
before anyway. Part of the infrastructure may be reintroduced in a
follow up patch to implement a working command aborting facility.

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
Cc: "Alan Cox" <alan@lxorguk.ukuu.org.uk>
Cc: "Randy Dunlap" <randy.dunlap@oracle.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
79e36a9f54aaf4a52eb2d9520953aa3960e99294 16-Jul-2008 Elias Oltmanns <eo@nebensachen.de> IDE: Fix HDIO_DRIVE_RESET handling

Currently, the code path executing an HDIO_DRIVE_RESET ioctl is broken
in various ways. Most importantly, it is treated as an out of band
request in an illegal way which may very likely lead to system lock ups.
Use the drive's request queue to avoid this problem (and fix a locking
issue for free along the way).

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
Cc: "Alan Cox" <alan@lxorguk.ukuu.org.uk>
Cc: "Randy Dunlap" <randy.dunlap@oracle.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e6d95bd14928926d6658b5e4ace905e8b83ed27a 16-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: ->port_init_devs -> ->init_dev

Change ->port_init_devs method to take 'ide_drive_t *' as an argument
instead of 'ide_hwif_t *' and rename it to ->init_dev.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c56c5648a3bd15ff14c50f284b261140cd5b5472 16-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: set hwif->dev in ide_init_port_hw() (take 2)

* Add 'parent' field to hw_regs_t for optional parent device pointer (needed
by macio PMAC IDE controllers) and set hwif->dev in ide_init_port_hw().

* Update au1xxx-ide.c, sgiioc4.c, pmac.c and setup-pci.c accordingly.

v2:

* Update scc_pata.c.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
63b51c6d1d63276fd320615c042f1ff5d94ebab8 16-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make ide_hwifs[] static

Move ide_hwifs[] from ide.c to ide-probe.c and make it static.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9ad540937554a3779c5fe7af13aa390b1d2aeb3e 16-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move PIO blacklist to ide-pio-blacklist.c

Move PIO blacklist to ide-pio-blacklist.c.

While at it:

- fix comment

- fix whitespace damage

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
3e153cfb5e38ae237ff27a10a833946ac95db8a4 16-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove no longer used ide_pio_timings[]

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c9d6c1a2379373219bb3271bdcbdc0ab2edf349d 16-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move ide_pio_cycle_time() to ide-timings.c

All ide_pio_cycle_time() users already select CONFIG_IDE_TIMINGS
so move the function from ide-lib.c to ide-timings.c.

While at it:

- convert ide_pio_cycle_time() to use ide_timing_find_mode()

- cleanup ide_pio_cycle_time() a bit

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f06ab3402aa2d6de060442c1053ea10b24b65076 16-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: convert ide-timing.h to ide-timings.c library (take 2)

* Don't include ide-timing.h in cs5535 and sis5513 host drivers
(they don't need it currently).

* Convert ide-timing.h to ide-timings.c library and add CONFIG_IDE_TIMINGS
config option to be selected by host drivers using the library.

While at it:

- fix ide_timing_find_mode() placement

v2:
* Add missing EXPORT_SYMBOLs. (Stephen Rothwell <sfr@canb.auug.org.au>)

There should be no functional changes caused by this patch.

Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
3be53f3f213223f50d8e29b5e1869685bf040a1e 16-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move some bits from ide-timing.h to <linux/ide.h>

Move struct ide_timing and IDE_TIMING_* defines to <linux/ide.h>
from drivers/ide/ide-timing.h.

While at it:

- use u8/u16 instead of short for struct ide_timing fields

- use enum for IDE_TIMING_*

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
646c0cb6c430f8d3ad3769dd1518fe664ff0ce27 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_pc_intr() helper

* ide-tape.c: add 'drive' argument to idetape_update_buffers().

* Add generic ide_pc_intr() helper to ide-atapi.c and then
convert ide-{floppy,tape,scsi} device drivers to use it.

* ide-tape.c: remove no longer needed DBG_PC_INTR.

There should be no functional changes caused by this patch
(unless the debugging is explicitely compiled in).

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6bf1641ca1c7554f0da54aaf89788731b541bacc 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_issue_pc() helper

Add generic ide_issue_pc() helper to ide-atapi.c and then
convert ide-{floppy,tape,scsi} device drivers to use it.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
28c7214bd8c2bbd4873b8f1e7f58d86d3731124f 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add PC_FLAG_DRQ_INTERRUPT pc flag

Add PC_FLAG_DRQ_INTERRUPT pc flag, set it in ide*_do_request()
and check for it (instead of checking for IDE*_FLAG_DRQ_INTERRUPT)
in ide*_issue_pc(). This is a preparation for adding generic
ide_issue_pc() helper.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
594c16d8dd54cd7b1c5ef1ec3ac0f6bf34301dad 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_transfer_pc() helper

* Add ide-atapi.c file for generic ATAPI support together with
CONFIG_IDE_ATAPI config option.

* Add generic ide_transfer_pc() helper to ide-atapi.c and then
convert ide-{floppy,tape,scsi} device drivers to use it.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5d41893c0f9caf94b449eada0279a08c86f0212e 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add PC_FLAG_ZIP_DRIVE pc flag

Add PC_FLAG_ZIP_DRIVE pc flag, set it in idefloppy_do_request()
and check for it (instead of checking for IDEFLOPPY_FLAG_ZIP_DRIVE)
in idefloppy_transfer_pc(). This is a preparation for adding
generic ide_transfer_pc() helper.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5e3310958204912f3f00be2592c945fbc37db6ae 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-{floppy,tape}: PC_FLAG_DMA_RECOMMENDED -> PC_FLAG_DMA_OK

* Use PC_FLAG_DMA_OK flag instead of PC_FLAG_DMA_RECOMMENDED one.

* Remove no longer used PC_FLAG_DMA_RECOMMENDED flag.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1b06e92aa03018e4b3ba281e03a7711d9b71a998 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-{floppy,tape}: merge pc->idefloppy_callback and pc->idetape_callback

Merge pc->idefloppy_callback and pc->idetape_callback into pc->callback.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
92f5daff2b8439fa4c57c57f47823ffc459c3bd9 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-tape: make pc->idetape_callback void

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
63f5abb0959337db0d5bece9cefba03cdcadec51 15-Jul-2008 FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> ide: remove action argument in ide_do_drive_cmd

ide_do_drive_cmd is called only with ide_preempt action argument. So
we can remove the action argument in ide_do_drive_cmd and ide_action_t
typedef.

This patch also includes two minor cleanups: 1) ide_do_drive_cmd
always succeeds so we don't need the return value; 2) the callers use
blk_rq_init before ide_do_drive_cmd so there is no need to initialize
rq->errors.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ff07488346702f554aaeb6aae982540aa0302373 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove drive->ctl

Remove drive->ctl (it is always equal to 0x08 after init time).

While at it:

* Use ATA_DEVCTL_OBS define.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
0fd04dcc2ebb6ec9088c24b368b0ce1f42a98ef5 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ->OUTBSYNC in ide_set_irq()

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f8c4bd0ab2b8783c0f080957781e9f70bee48eaa 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: pass 'hwif *' instead of 'drive *' to ->OUTBSYNC method

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
135721446144af005109c25eeacca4fdddcd9a66 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->mmio flag from ide_hwif_t

Since scc_pata host driver no longer uses IDE PCI layer / ide_dma_setup()
and all other ->mmio users set also IDE_HFLAG_MMIO host flag we can safely
remove ->mmio flag.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ed4af48fd660176680da905817f6e40d51436e4c 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move IRQ unmasking out from ->tf_load method

Move IRQ unmasking out from ->tf_load method to its users.

There should be no functional changes caused by this patch
(SELECT_MASK() is NOP except for hpt366, icside and sgiioc4).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9a410e79b552bacb4481f85618aa7333b7776ed7 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove IDE_TFLAG_NO_SELECT_MASK taskfile flag

Always call SELECT_MASK(..., 0) in ide_tf_load() (needs to be done
to match ide_set_irq(..., 1)) and then remove IDE_TFLAG_NO_SELECT_MASK
taskfile flag.

This change should only affect hpt366 and icside host drivers since
->maskproc(..., 0) for sgiioc4 is equivalent to ide_set_irq(..., 1).

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
931ee0dc5c69e8113233d21942681ab8fecde7f9 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove obsoleted "ide=" kernel parameters

* Remove obsoleted "ide=" kernel parameters.

* Remove no longer needed:
- ide_setup()
- parse_options()
- __setup("", ...)
- module_param(options, ...)

* Use module_{init,exit}() for MODULE=y case and remove MODULE ifdef.

* Make ide_*acpi* and ide_doubler variables static.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
30e5ee4d1a651a0c66e86c6612c003034bd20ba2 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove obsoleted "idebus=" kernel parameter

* Remove obsoleted "idebus=" kernel parameter.

* Remove no longer needed ide_system_bus_speed() and system_bus_clock()
(together with idebus_parameter and system_bus_speed variables).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
124cafc5eb973e748c4ce3dc1caad29274e64613 15-Jul-2008 FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> ide: remove ide_init_drive_cmd

ide_init_drive_cmd just calls blk_rq_init. This converts the users of
ide_init_drive_cmd to use blk_rq_init directly and removes
ide_init_drive_cmd.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Borislav Petkov <petkovbb@gmail.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
a861beb1401d65e3f095fee074c13645ab06490e 08-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add __ide_default_irq() inline helper

Add __ide_default_irq() inline helper and use it instead of
ide_default_irq() in ide-probe.c and ns87415.c (all host drivers
except IDE PCI ones always setup hwif->irq so it is enough to
check only for I/O bases 0x1f0 and 0x170).

This fixes post-2.6.25 regression since ide_default_irq()
define could shadow ide_default_irq() inline.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b76916462d990751882eaeadc75ac8c487d6de1d 10-Jun-2008 Adrian Bunk <bunk@kernel.org> ide: remove the ide_etrax100 chipset type

I forgot to remove the ide_etrax100 chipset type when removing the
ETRAX_IDE driver.

Reported-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
cafa027b8cc6f605ccebc43a960644307a12d8dd 14-May-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> cs5520: disable VDMA

Disable Virtual DMA support for now (it causes system hangs).

Thanks to TAKADA Yoshihito for the help with debugging the problem.

Reported-by: TAKADA Yoshihito <takada@mbf.nifty.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e0b4eb5193fed5c63413b0c137be29b0477d15ca 14-May-2008 Adrian Bunk <bunk@kernel.org> make ide-iops.c:SELECT_MASK() static

SELECT_MASK() can now become static.

[bart: remove space between function name and open parenthesis]

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
55224bc86a39409d55e47fd45573642ac709bb8f 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->dma_prdtable field from ide_hwif_t

* Use 'hwif->dma_base + {4,8}' instead of hwif->dma_prdtable in
{ide,scc}_dma_setup().

* Remove no longer needed ->dma_prdtable field from ide_hwif_t.

While at it:

* Use ATA_DMA_TABLE_OFS define.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
41051a141dcc67f4c5011a2ab2b547e80b9ac509 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->dma_vendor{1,3} fields from ide_hwif_t

* Use 'hwif->dma_base + {1,3}' instead of hwif->dma_vendor{1,3} in
pdc202xx_new host driver.

* Remove no longer needed ->dma_vendor{1,3} fields from ide_hwif_t.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9f87abe892f899f19df8d472f937ee955cd6264b 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_pad_transfer() helper

* Add ide_pad_transfer() helper (which uses ->{in,out}put_data methods
internally so the transfer is also padded to drive+host requirements)
and use it instead of ide_atapi_{write_zeros,discard_data}().

* Remove no longer needed ide_atapi_{write_zeros,discard_data}().

Cc: Borislav Petkov <petkovbb@gmail.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7c0daf2681f140dd9f39cd95966f471b5c904d8a 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->INW and ->OUTW methods

* Remove no longer used ->INW and ->OUTW methods.

While at it:

* scc_pata.c: scc_ide_{out,in}w() is called only in scc_tf_{load,read}()
so inline it there.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
94cd5b62ff9bb07ef065333eb97438f115a75890 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->tf_load and ->tf_read methods

* Add ->tf_load and ->tf_read methods to ide_hwif_t and set the default
methods in default_hwif_transport().

* Use ->tf_{load,read} instead o calling ide_tf_{load,read}() directly.

* Make ide_tf_{load,read}() static.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
089c5c7e0089c3461545be936bcd236cbf16b79a 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: factor out debugging code from ide_tf_load()

Factor out debugging code from ide_tf_load() to ide_tf_dump() helper
and update ide_tf_load() users accordingly.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1fc142589e58b20a67582974b8848595a2c7432e 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_execute_pkt_cmd() helper

Add ide_execute_pkt_cmd() helper for executing PACKET command,
then convert ATAPI device drivers to use it.

As a nice side-effect this fixes ide-{floppy,tape,scsi} w.r.t.
ide_lock taking (ide-cd was OK).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
16bb69c14a42e64faef1ec5c724ffaca916347a1 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->INS{W,L} and ->OUTS{W,L} methods

* Use ins{w,l}()/outs{w,l}() and __ide_mm_ins{w,l}()/__ide_mm_outs{w,l}()
directly in ata_{in,out}put_data() (by using IDE_HFLAG_MMIO host flag to
decide which I/O ops are required).

* Remove no longer needed ->INS{W,L} and ->OUTS{W,L} methods (ide-h8300,
au1xxx-ide and scc_pata implement their own ->{in,out}put_data methods).

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c5dd43ec65c1e1e378df043d517d40ed70a32cbe 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_MMIO host flag (take 2)

* Add IDE_HFLAG_MMIO host flag and set it for hosts which use
default_hwif_mmiops().

v2:
* Fix kernel panic in pmac host driver (',' should be '|').

Thanks to Kamalesh for reporting it + testing the fix
and to Andrew for hinting me about the source of the issue.

Cc: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9567b349f7e7dd7e2483db99ee8e4a6fe0caca38 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: merge ->atapi_*put_bytes and ->ata_*put_data methods

* Merge ->atapi_{in,out}put_bytes and ->ata_{in,out}put_data methods
into new ->{in,out}put_data methods which take number of bytes to
transfer as an argument and always do padding.

While at it:

* Use 'hwif' or 'drive->hwif' instead of 'HWIF(drive)'.

There should be no functional changes caused by this patch (all users
of ->ata_{in,out}put_data methods were using multiply-of-4 word counts).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
92d3ab27e8fd23d1a9dc3b69d17b2afb83e5c6f5 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> falconide/q40ide: add ->atapi_*put_bytes and ->ata_*put_data methods (take 2)

* Add ->atapi_{in,out}put_bytes and ->ata_{in,out}put_data methods to
falconide and q40ide host drivers (->ata_* methods are implemented on
top of ->atapi_* methods so they also do byte-swapping now).

* Cleanup atapi_{in,out}put_bytes().

v2:
* Add 'struct request *rq' argument to ->ata_{in,out}put_data methods
and don't byte-swap disk fs requests (we shouldn't un-swap fs requests
because fs itself is stored byte-swapped on the disk) - this is how
things were done before the patch (ideally device mapper should be
used instead but it would break existing setups and would have some
performance impact).

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Michael Schmitz <schmitz@debian.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Richard Zidlicky <rz@linux-m68k.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
fd0949e6e84e4e1649d8ea7367e78e72f59bb19f 27-Apr-2008 Alexey Dobriyan <adobriyan@sw.ru> ide: remove now unused ide_pci_create_host_proc()

It creates files in proc with obsoleted ->get_info interface.

Signed-off-by: Alexey Dobriyan <adobriyan@openvz.org>
Cc: Andrew Morton <akpm@osdl.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4c3032d8a4d6c97bd6e02bcab524ef2428d89561 27-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add struct ide_io_ports (take 3)

* Add struct ide_io_ports and use it instead of `unsigned long io_ports[]`
in ide_hwif_t.

* Rename io_ports[] in hw_regs_t to io_ports_array[].

* Use un-named union for 'unsigned long io_ports_array[]' and 'struct
ide_io_ports io_ports' in hw_regs_t.

* Remove IDE_*_OFFSET defines.

v2:
* scc_pata.c build fix from Stephen Rothwell.

v3:
* Fix ctl_adrr typo in Sparc-specific part of ns87415.c.
(Noticed by Andrew Morton)

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
387750c3bf49c22f6189436032145e2131985076 27-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make ide_unregister() take 'ide_hwif_t *' as an argument (take 2)

* Make ide_unregister() take 'ide_hwif_t *hwif' instead of 'unsigned int
index' (hwif->index) as an argument and update all users accordingly.

While at it:

* Remove unnecessary checks for hwif != NULL from ide-pnp.c::idepnp_remove()
and delkin_cb.c::delkin_cb_remove().

* Remove needless hwif->chipset assignment from scc_pata.c::scc_remove().

v2:
* Fixup ide_unregister() documentation.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1dbfeb4bc8fd0276750e5d1d454420f6c2da80e3 27-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add "noacpi" / "acpigtf" / "acpionboot" parameters

* Rename ide_noacpi{tfs,onboot} to ide_acpi{gtf,onboot} (+ reverse logic).

* Move ide_*acpi* variables to ide-acpi.c and remove unnecessary initializers.

* Add "noacpi" / "acpigtf" / "acpionboot" parameters.

* Obsolete "ide=noacpi" / "ide=acpigtf" / "ide=acpionboot" kernel parameters.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
207daeaabb5396995ebac63415fab71476b64ca3 27-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove obsoleted "hdx=autotune" kernel parameter

* Remove obsoleted "hdx=autotune" kernel parameter
(we always auto-tune PIO if possible nowadays).

* Remove no longer needed ide_drive_t.autotune flag.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e160124ff6868e53511b16412d2ea91f87936be0 27-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove IDE_HFLAG_NO_AUTOTUNE host flag

* Don't set IDE_HFLAG_NO_AUTOTUNE host flag in sgiioc4 and icside
host drivers - there is no need for it as they don't implement
->set_pio_mode method.

* Remove no longer needed IDE_HFLAG_NO_AUTOTUNE host flag.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ebae41a5a0583fb732c41445df4ac2c41016df74 27-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add "vlb|pci_clock=" parameter

* Add "vlb_clock=" parameter for specifying VLB clock frequency (in MHz).

* Add "pci_clock=" parameter for specifying PCI bus clock frequency (in MHz).

While at it:

* qd65xx.c: rename {active,recovery}_cycle variables to {act,rec}_cyc.

Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
cc12175ff2eadb0918d573169af88429440a21ae 27-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove obsoleted "hdx=noautotune" kernel parameter

Remove obsoleted "hdx=noautotune" kernel parameter
(it has been obsoleted since 1 Nov 2004).

Then make ide_hwif_t.autotune a single bit flag
and remove no longer needed IDE_TUNE_* defines.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e460a59751a7e53b549c63d4d308ba73582c8def 27-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove obsoleted "idex=reset" kernel parameter

Remove obsoleted "idex=reset" kernel parameter
(it has been obsoleted since 1 Nov 2004).

Then remove corresponding code from ide_probe_port()
and no longer used ->reset field from ide_hwif_t.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9fd91d959f1a19d1bfa46d97cbbbb55641ce26a6 27-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add "ignore_cable" parameter (take 2)

Add "ignore_cable" parameter:

* "ide_core.ignore_cable=[interface_number]" boot option if IDE is built-in
(i.e. "ide_core.ignore_cable=1" to force ignoring cable for "ide1")

* "ignore_cable=[interface_number]" module parameter (for ide_core module)
if IDE is compiled as module

v2:
* Add ide_port_apply_params() helper
- use it in ide_device_add_all() and ide_scan_port().

* Make it possible to later disable ignoring cable detection by passing
"[interface_number]:0" to /sys/module/ide_core/parameters/ignore_cable
(however sysfs interface is not enabled yet since it needs some other
IDE changes to make it work reliable).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f37afdaca711838b50ecd89b9c15fc745270d77c 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: constify struct ide_dma_ops

* Export ide_dma_exec_cmd() and __ide_dma_test_irq().

* Constify struct ide_dma_ops.

* Always set hwif->dma_ops to &sff_dma_ops in ide_setup_dma()
(it is later overriden by ide_init_port() if needed) and drop
'const struct ide_port_info *d' argument.

While at it:

* Rename __ide_dma_test_irq() to ide_dma_test_irq().

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5e37bdc081a980dd0d669e6387bcf15ca9666f81 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add struct ide_dma_ops (take 3)

Add struct ide_dma_ops and convert core code + drivers to use it.

While at it:

* Drop "ide_" prefix from ->ide_dma_end and ->ide_dma_test_irq methods.

* Drop "ide_" "infixes" from DMA methods.

* au1xxx-ide.c:
- use auide_dma_{test_irq,end}() directly in auide_dma_timeout()

* pdc202xx_old.c:
- drop "old_" "infixes" from DMA methods

* siimage.c:
- add siimage_dma_test_irq() helper
- print SATA warning in siimage_init_one()

* Remove no longer needed ->init_hwif implementations.

v2:
* Changes based on review from Sergei:
- s/siimage_ide_dma_test_irq/siimage_dma_test_irq/
- s/drive->hwif/hwif/ in idefloppy_pc_intr().
- fix patch description w.r.t. au1xxx-ide changes
- fix au1xxx-ide build
- fix naming for cmd64*_dma_ops
- drop "ide_" and "old_" infixes
- s/hpt3xxx_dma_ops/hpt37x_dma_ops/
- s/hpt370x_dma_ops/hpt370_dma_ops/
- use correct DMA ops for HPT302/N, HPT371/N and HPT374
- s/it821x_smart_dma_ops/it821x_pass_through_dma_ops/

v3:
* Two bugs slipped in v2 (noticed by Sergei):
- use correct DMA ops for HPT374 (for real this time)
- handle HPT370/HPT370A properly

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1fd1890594bd355a4217f5658a34763e77decee3 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_SERIALIZE_DMA host flag

* Add IDE_HFLAG_SERIALIZE_DMA host flag to serialize ports
if DMA is available and handle it in ide_init_port().

* Convert sl82c105 host driver to use this new flag.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b123f56e04c7c112f754f948198d1ea5a80e649d 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: do complete DMA setup in ->init_dma method (take 2)

* Make ide_hwif_setup_dma() return an error value.

* Pass 'const struct ide_port_info *d' instead of 'unsigned long dmabase'
to ->init_dma method and make it return an error value.

* Rename ide_get_or_set_dma_base() to ide_pci_dma_base(),
change ordering of its arguments and then export it.

* Export ide_pci_set_master().

* Do complete DMA setup inside ->init_dma method and update ->init_dma
users accordingly.

* Sanitize code for DMA setup in ide_init_port().

v2:
* Fix for CONFIG_BLK_DEV_IDEDMA_PCI=n configs
(from Jiri Slaby <jirislaby@gmail.com>):

Fix following compiler warning by returning EINVAL:

In file included from ANYTHING-INCLUDING-IDE.H:45:
include/linux/ide.h: In function ‘ide_hwif_setup_dma’:
include/linux/ide.h:1022: warning: no return statement in function returning non-void

Cc: Jiri Slaby <jirislaby@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b8e73fba60414e161d8fd2429b6fb268e34502e2 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: export ide_allocate_dma_engine()

Export ide_allocate_dma_engine() and use it in trm290 host driver.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5e59c236846df444860ffc8b852117f9ff65c101 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->cds field from ide_hwif_t (take 2)

* Use hwif->name instead of cds->name in ide_allocate_dma_engine().

* Use pci_name(dev) instead of cds->name in init_dma_pdc202xx().

* Remove no longer needed ->cds field from ide_hwif_t.

v2:

* scc_pata.c also needs to be updated now (noticed by Stephen Rothwell).

There should be no functional changes caused by this patch.

Cc: Kou Ishizaki <kou.ishizaki@toshiba.co.jp>
Cc: Akira Iguchi <akira2.iguchi@toshiba.co.jp>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
21a3387ddd9eedcf6d4f47e591ffa90128b9f560 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->extra field from struct ide_port_info

Always setup hwif->extra_base in ide_iomio_dma() and remove
no longer needed ->extra field from struct ide_port_info.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5add22241752a3c689bea2a9d0e71c2a5909ed8a 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_hwif_request_regions()

Remove no longer used ide_hwif_request_regions() and hwif_request_region().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
0d1bad216c43bcee84cc24d1ed003c19134d2645 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: manage resources for PCI devices in ide_pci_enable() (take 3)

* Reserve PCI BARs 0-3 (0-1 for single port controllers) in
ide_pci_enable() and remove ide_hwif_request_regions() call
from ide_device_add_all() (also cleanup resource management
in scc_pata host driver).

* Fix handling of PCI BAR 4 in ide_pci_enable(), then cleanup
ide_iomio_dma() (+ init_hwif_trm290() in trm290 host driver)
and remove ide_release[_iomio]_dma().

v2:
* Fixup trm290 host driver.

v3:
* Because of scc_pata host driver changes we need to call
pci_request_selected_regions() also in setup_mmio_scc().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
d083c03f2524af699a6b85cf4d2f8090242b1b84 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_hwif_release_regions()

All host drivers using ide_unregister()/module_exit() have been fixed
to manage resources themselves so this function can be removed now.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
0bfeee7d4190938291a76536c7f6cd8f4e2dc30c 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ide_legacy_device_add() for qd65xx (take 2)

* Add 'unsigned long config' argument to ide_legacy_device_add()
for setting hwif->config_data.

* Use ide_find_port_slot() instead of ide_find_port() in
ide_legacy_device_add().

* Handle IDE_HFLAG_QD_2ND_PORT and IDE_HFLAG_SINGLE host flags in
ide_legacy_device_add().

* Convert qd65xx host driver to use ide_legacy_device_add().

v2:
* Update ali14xx, dtc2278, ht6560b and umc8672 host drivers.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
3b36f66b81bc0d69ec7dfa736592224f6ca366b7 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_legacy_device_add() helper

Add ide_legacy_device_add() helper for use by legacy VLB host drivers
(+ convert them to use it).

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e53cd458d593c88247b8a7b2754d0e8055869670 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->noprobe field from ide_hwif_t

Update IDE PMAC host driver to use drive->noprobe instead of hwif->noprobe
and remove hwif->noprobe completely (it is always set to zero now).

There should be no functional changes caused by this patch.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ac95beedf8bc97b24f9540d4da9952f07221c023 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add struct ide_port_ops (take 2)

* Move hooks for port/host specific methods from ide_hwif_t to
'struct ide_port_ops'.

* Add 'const struct ide_port_ops *port_ops' to 'struct ide_port_info'
and ide_hwif_t.

* Update host drivers and core code accordingly.

While at it:

* Rename ata66_*() cable detect functions to *_cable_detect() to match
the standard naming. (Suggested by Sergei Shtylyov)

v2:
* Fix build for bast-ide. (Noticed by Andrew Morton)

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
05230e23cf02d939865a902f6ec4c1b2c82faf33 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove hwif->straight8 flag

All host drivers now either set hwif->mmio or reserve continuous
I/O resources so remove no longer needed hwif->straight8 flag
and never reached code for 'hwif->straight8 == 0' case.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
951784b667d78dad52ffea0a958fdbe14da97972 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove IDE_HFLAG_CY82C693 host flag

Sergei suggested that it shouldn't be necessary + it had no effect
anyway since ide_id_dma_bug() is called earlier in ide_tune_dma().

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e277f91fef8a0ff7726ad33eb79c6f0d0c6229a8 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ide_find_port() in legacy VLB host drivers (take 2)

* Add IDE_HFLAG_QD_2ND_PORT host flag to indicate the need of skipping
first ide_hwifs[] slot for the second port of QD65xx controller.

* Handle this new host flag in ide_find_port_slot().

* Convert legacy VLB host drivers to use ide_find_port().

While at it:

* Fix couple of printk()-s in qd65xx host driver to not use hwif->name.

v2:
* Fix qd65xx.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
fe80b937c9917887e4fbfaaf52f498b5ac3a6999 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: merge ide_match_hwif() and ide_find_port()

* Change ide_match_hwif() argument from 'u8 bootable' to
'struct ide_port_info *d'.

* Move ide_match_hwif() to ide-probe.c from setup-pci.c and rename
it to ide_find_port_slot(). Update some comments while at it.

* ide_find_port() can be now just a wrapper for ide_find_port_slot().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
078fdf789c4ef13dcb7b5651ff330e325d764c0e 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove PIO "downgrade" quirk

No need for it nowadays so remove quirk code from ide_get_best_pio_mode()
and IDE_HFLAG_PIO_DOWNGRADE host flag.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5e71d9c5a50b92b33d35061d42ac39166db9578e 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: IDE_HFLAG_BOOTABLE -> IDE_HFLAG_NON_BOOTABLE

"bootable" should be the default behavior so replace
IDE_HFLAG_BOOTABLE host flag with IDE_HFLAG_NON_BOOTABLE.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
59bff5ba5529feac3a0214d897b1920cbe4e2278 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: cleanup ide_find_port()

Remove no longer needed matching against I/O base and 'base' argument.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5a6483feb0c5193519625d0ea8c4254364d423cc 26-Feb-2008 Matthew Wilcox <matthew@wil.cx> include: Remove unnecessary inclusions of asm/semaphore.h

None of these files use any of the functionality promised by
asm/semaphore.h. It's possible that they (or some user of them) rely
on it dragging in some unrelated header file, but I can't build all
these files, so we'll have to fix any build failures as they come up.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
0e33555fffdc8490630d98070e76e5fe031bcac2 18-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add CONFIG_IDE_ARCH_OBSOLETE_DEFAULTS (take 2)

* Add CONFIG_IDE_ARCH_OBSOLETE_DEFAULTS to drivers/ide/Kconfig and use
it instead of defining IDE_ARCH_OBSOLETE_DEFAULTS in <arch/ide.h>.

v2:
* Define ide_default_irq() in ide-probe.c/ns87415.c if not already defined
and drop defining ide_default_irq() for CONFIG_IDE_ARCH_OBSOLETE_DEFAULTS=n.

[ Thanks to Stephen Rothwell and David Miller for noticing the problem. ]

Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
eaec3e7ded9dbc88bad393c076b65f4b7b11d30d 18-Apr-2008 Borislav Petkov <petkovbb@googlemail.com> ide: use generic ATAPI packet command flags in ide-{floppy,tape}

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
8303b46e18b58b2d0257e6842e60b50ac880a6d1 18-Apr-2008 Borislav Petkov <petkovbb@googlemail.com> ide: add generic packet command representation ide_atapi_pc

This new struct unifies ide{-floppy,-tape,-scsi}'s view of a packet command. For now,
it represents the common denominator between the three drivers while adding driver-
specific members at the end of the struct which will be merged/simplified into the
generic ATAPI handling code in later steps, or removed completely.

Bart:
- move struct ide_atapi_pc outside of #ifdef/#endif CONFIG_IDE_PROC_FS

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
23579a2a170265aacf78069f4817a41c1d6e9323 18-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove IDE_*_REG macros

* Add IDE_{ALTSTATUS,IREASON,BCOUNTL,BCOUNTH}_OFFSET defines.

* Remove IDE_*_REG macros - this results in more readable
and slightly smaller code.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7616c0ad2087c7d244b8985390c63059a6223c45 18-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_atapi_{discard_data,write_zeros} inline helpers

Add ide_atapi_{discard_data,write_zeros} inline helpers to <linux/ide.h>
and use them instead of home-brewn helpers in ide-{floppy,tape,scsi}.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e6bfa38a4803646e212ef542b957344e790c3733 18-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_init_hwif_ports()

ide_init_hwif_ports() is only used by init_ide_data() now, inline it there.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2304dc6481f9d4fb4f0cb5b72497dfe1694cef9c 18-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->hold field from ide_hwif_t (take 2)

->hold is write-only now, remove it.

v2:
* v1 missed bast-ide, palm_bk3710, ide-cs and delkin_cb host drivers.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
93de00fd1c70e1a23a73a865e0f9abfe74a7a719 18-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove broken/dangerous HDIO_[UNREGISTER,SCAN]_HWIF ioctls (take 3)

hdparm explicitely marks HDIO_[UNREGISTER,SCAN]_HWIF ioctls as DANGEROUS
and given the number of bugs we can assume that there are no real users:

* DMA has no chance of working because DMA resources are released by
ide_unregister() and they are never allocated again.

* Since ide_init_hwif_ports() is used for ->io_ports[] setup the ioctls
don't work for almost all hosts with "non-standard" (== non ISA-like)
layout of IDE taskfile registers (there is a lot of such host drivers).

* ide_port_init_devices() is not called when probing IDE devices so:
- drive->autotune is never set and IDE host/devices are not programmed
for the correct PIO/DMA transfer modes (=> possible data corruption)
- host specific I/O 32-bit and IRQ unmasking settings are not applied
(=> possible data corruption)
- host specific ->port_init_devs method is not called (=> no luck with
ht6560b, qd65xx and opti621 host drivers)

* ->rw_disk method is not preserved (=> no HPT3xxN chipsets support).

* ->serialized flag is not preserved (=> possible data corruption when
using icside, aec62xx (ATP850UF chipset), cmd640, cs5530, hpt366
(HPT3xxN chipsets), rz1000, sc1200, dtc2278 and ht6560b host drivers).

* ->ack_intr method is not preserved (=> needed by ide-cris, buddha,
gayle and macide host drivers).

* ->sata_scr[] and sata_misc[] is cleared by ide_unregister() and it
isn't initialized again (SiI3112 support needs them).

* To issue an ioctl() there need to be at least one IDE device present
in the system.

* ->cable_detect method is not preserved + it is not called when probing
IDE devices so cable detection is broken (however since DMA support is
also broken it doesn't really matter ;-).

* Some objects which may have already been freed in ide_unregister()
are restored by ide_hwif_restore() (i.e. ->hwgroup).

* ide_register_hw() may unregister unrelated IDE ports if free ide_hwifs[]
slot cannot be found.

* When IDE host drivers are modular unregistered port may be re-used by
different host driver that owned it first causing subtle bugs.

Since we now have a proper warm-plug support remove these ioctls,
then remove no longer needed:
- ide_register_hw() and ide_hwif_restore() functions
- 'init_default' and 'restore' arguments of ide_unregister()
- zeroeing of hwif->{dma,extra}_* fields in ide_unregister()

As an added bonus IDE core code size shrinks by ~3kB (x86-32).

v2:
* fix ide_unregister() arguments in cleanup_module() (Andrew Morton).

v3:
* fix ide_unregister() arguments in palm_bk3710.c.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9a0e77f28b50128df0c9e26ae489e44e29a7270a 18-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove obsoleted "idex=base[,ctl[,irq]]" kernel parameters (take 2)

* Remove obsoleted "idex=base[,ctl[,irq]]" kernel parameters
and update Documentation/ide/ide.txt.

* Remove no longer needed ide_forced chipset type.

v2:
* is_chipset_set[] -> is_chipset_set in ide.c.

* Documentation/ide/ide.txt fix.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f74c91413ec6140ee0553180c5f56fdd27c22a2e 18-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add warm-plug support for IDE devices (take 2)

* Add 'struct class ide_port_class' ('ide_port' class) and a 'struct
device *portdev' ('ide_port' class device) in ide_hwif_t.

* Register 'ide_port' class in ide_init() and unregister it in
cleanup_module().

* Create ->portdev in ide_register_port () and unregister it in
ide_unregister().

* Add "delete_devices" class device attribute for unregistering IDE devices
on a port and "scan" one for probing+registering IDE devices on a port.

* Add ide_sysfs_register_port() helper for registering "delete_devices"
and "scan" attributes with ->portdev. Call it in ide_device_add_all().

* Document IDE warm-plug support in Documentation/ide/warm-plug-howto.txt.

v2:
* Convert patch from using 'struct class_device' to use 'struct device'.
(thanks to Kay Sievers for doing it)

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
50672e5d7486c9ab312432cbe180ac071f1de8e0 18-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove dead/obsolete ->busproc method

->busproc method is used by HDIO_SET_BUSSTATE ioctl but it has no chance
of working as intended (in 2.4.x days) because to issue an ioctl there
is a device node needed and:

- for BUSSTATE_TRISTATE+OFF it is too late (devices are already gone)

- for BUSSTATE_TRISTATE+ON it is too early (devices are not registered yet)

Just remove ->busproc method for now (it was only implemented by hpt366,
siimage and tc86c001 host drivers).

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2dde7861afa23cd59db83515cb0b810b92b220aa 18-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: rework PowerMac media-bay support (take 2)

Rework PowerMac media-bay support in such way that instead of
un/registering the IDE interface we un/register IDE devices:

* Add ide_port_scan() helper for probing+registerering devices on a port.

* Rename ide_port_unregister_devices() to __ide_port_unregister_devices().

* Add ide_port_unregister_devices() helper for unregistering devices on a port.

* Add 'ide_hwif_t *cd_port' to 'struct media_bay_info', pass 'hwif' instead
of hwif->index to media_bay_set_ide_infos() and use it to setup 'cd_port'.

* Use ide_port_unregister_devices() instead of ide_unregister()
and ide_port_scan() instead of ide_register_hw() in media_bay_step().

* Unexport ide_register_hw() and make it static.

v2:
* Fix build by adding <linux/ide.h> include to <asm-powerpc/mediabay.h>.
(Reported by Michael/Kamalesh/Andrew).

Cc: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
Cc: Michael Ellerman <michael@ellerman.id.au>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5b0c4b30a625927340a3e7f565aa4de8b60489cc 18-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove IDE devices from /proc/ide/ before unregistering them

IDE devices need to be removed from /proc/ide/ _before_ being unregistered:

* Drop 'ide_hwif_t *hwif' argument from destroy_proc_ide_device()
and use drive->hwif instead.

* Rename destroy_proc_ide_device() to ide_proc_unregister_device().

* Call ide_proc_unregister_device() in drive_release_dev().

* Remove no longer needed destroy_proc_ide_drives().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4f0eee4d877e3b617b6a22d209d52b3dfca2b2a7 18-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ide_find_port() instead of ide_deprecated_find_port()

* Use ide_find_port() instead of ide_deprecated_find_port() in bast-ide/
palm_bk3710/ide-cs/delkin_cb host drivers and in ide_register_hw().

* Remove no longer needed ide_deprecated_find_port().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
a594eeb1a1d320981fccc29584b6f21fcebd765f 18-Apr-2008 Greg Kroah-Hartman <gregkh@suse.de> IDE: remove ide=reverse IDE core

This option is obsolete and can be removed safely.

It allows us to remove the pci_get_device_reverse() function from the
PCI core.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
729d4de96a5c090e40a918a41f63b7fb1b27c240 29-Mar-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix defining SUPPORT_VLB_SYNC

We need to check for CONFIG_{CRIS,FRV} not {CRIS,FRV}.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1f07e988290fc45932f5028c9e2a862c37a57336 11-Feb-2008 Andi Kleen <andi@firstfloor.org> Prevent IDE boot ops on NUMA system

Without this patch a Opteron test system here oopses at boot with
current git.

Calling to_pci_dev() on a NULL pointer gives a negative value so the
following NULL pointer check never triggers and then an illegal address
is referenced. Check the unadjusted original device pointer for NULL
instead.

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
395d8ef5bebe547a80737692f9789d2e36da16f2 11-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-disk: fix flush requests (take 2)

commit 813a0eb233ee67d7166241a8b389b6a76f2247f9
Author: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Date: Fri Jan 25 22:17:10 2008 +0100

ide: switch idedisk_prepare_flush() to use REQ_TYPE_ATA_TASKFILE requests

...

broke flush requests.

Allocating IDE command structure on the stack for flush requests is not
a very brilliant idea:

- idedisk_prepare_flush() only prepares the request and it doesn't wait
for it to be completed

- there are can be multiple flush requests queued in the queue

Fix the problem (per hints from James Bottomley) by:
- dynamically allocating ide_task_t instance using kmalloc(..., GFP_ATOMIC)
- adding new taskfile flag (IDE_TFLAG_DYN)
- calling kfree() in ide_end_drive_command() if IDE_TFLAG_DYN is set
(while at it rename 'args' to 'task' and fix whitespace damage)

[ This will be fixed properly before 2.6.25 but this bug is rather
critical and the proper solution requires some more work + testing. ]

Thanks to Sebastian Siewior and Christoph Hellwig for reporting the
problem and testing patches (extra thanks to Sebastian for bisecting
it to the guilty commmit).

Tested-by: Sebastian Siewior <ide-bug@ml.breakpoint.cc>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Tejun Heo <htejun@gmail.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
8e882ba111bb52fbb42c34a265afb97ddd4fcea1 11-Feb-2008 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: introduce CONFIG_BLK_DEV_IDEDMA_SFF option

Introduce new option CONFIG_BLK_DEV_IDEDMA_SFF for non-PCI SFF-8038i compatible
bus mastering IDE controllers (which there are a few known), thus fixing a hack
made for Palmchip BK3710 controller...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Anton Salnikov <asalnikov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
64a57fe4393bae920d03c253173f59d8a7ec8e25 06-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_read_error() inline helper

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c47137a99c597330b69057158b26061a360c0e09 06-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_read_[alt]status() inline helpers

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
29dd59755a849cc6475faa6a75f3b804e23a6fc2 06-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_setup_ports()

ide-cris.c:
* Add cris_setup_ports() helper and use it instead of ide_setup_ports()
(fixes random value being set in ->io_ports[IDE_IRQ_OFFSET]).

buddha.c:
* Add buddha_setup_ports() helper and use it instead of ide_setup_ports().

falconide.c:
* Add falconide_setup_ports() helper and use it instead of ide_setup_ports(),
also fix return value of falconide_init() while at it.

gayle.c:
* Add gayle_setup_ports() helper and use it instead of ide_setup_ports().

macide.c:
* Add macide_setup_ports() helper and use it instead of ide_setup_ports()
(fixes incorrect value being set in ->io_ports[IDE_IRQ_OFFSET]).

q40ide.c:
* Fix q40_ide_setup_ports() comments.

ide.c:
* Remove no longer needed ide_setup_ports().

Cc: Mikael Starvik <starvik@axis.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
afdd360c95632b0c882790a7b25ff505664adcd0 06-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove write-only ->sata_misc[] from ide_hwif_t

* Remove write-only ->sata_misc[] from ide_hwif_t.

* Remove no longer used SATA_{MISC,PHY,IEN}_OFFSET defines.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7c7e92a9268965e08bba853ecdb94fa55e886741 06-Feb-2008 Anton Salnikov <asalnikov@ru.mvista.com> Palmchip BK3710 IDE driver

This is Palmchip BK3710 IDE controller support.

The IDE controller logic supports PIO, MultiWord-DMA and Ultra-DMA modes.
Supports interface to Compact Flash (CF) configured in True-IDE mode.

Bart:
- remove dead code
- fix ide_hwif_setup_dma() build problem

Signed-off-by: Anton Salnikov <asalnikov@ru.mvista.com>
Reviewed-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Reviewed-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
578cfa0d72f81526b2fcb1dd2463c47bbf633989 02-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move check_dma_crc() to ide-dma.c

* Move check_dma_crc() to ide-dma.c and add inline version for
CONFIG_BLK_DEV_IDEDMA=n case.

* Rename check_dma_crc() to ide_check_dma_crc().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
af10f77390f6c7c5cf6f53e6b3cdaa38562b03af 02-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_ata66_check()

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5efe7c540ec6021905d443dfe23cc44a11345edd 02-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove set_transfer()

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
835457def90c86fe84d7729c0531fd551fb14eda 02-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove SATA_*_REG macros

* siimage.c: use hwif->sata_scr[SATA_{ERROR,STATUS}_OFFSET] instead of
SATA_{ERROR,STATUS}_REG macros.

* Remove no longer needed SATA_*_REG macros.

While at it:

* Remove needless SATA Status register read from sil_sata_reset_poll().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
92b83c8f3219c36d61a6600ceb422e65c409be59 02-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->nice0 and ->nice2 fields from ide_drive_t

* ->nice0 and ->nice2 ide_drive_t fields are always zero so remove them.

* IDE_NICE_0 and IDE_NICE_2 defines from <linux/hdreg.h> are no longer
used by any kernel code so cover them with #ifndef/#endif __KERNEL__.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b034304a28d15f019ca914e954c3de20df28065e 02-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: convert ->straight8 field in ide_hwif_t to bit flag

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b60acab1e74734fc60ee5efd281ecff93f8e993b 02-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove unused ->auto_poll field from ide_hwif_t

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
d9270a3f1d5b6f9de58250e8ecdba4c48c54c20b 02-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move create_proc_ide_drives() call to ide_device_add_all()

* Un-static create_proc_ide_drives() and call it from ide_device_add_all().

While at it:
* Rename create_proc_ide_drives() to ide_proc_port_register_devices().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
eafd88a3b5d86ba2dd515d430b57a01349d0867b 02-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: factor out devices setup from ide_acpi_init()

* Factor out devices setup from ide_acpi_init() to
ide_acpi_port_init_devices().

* Call ide_acpi_port_init_devices() in ide_device_add_all().

While at it:
* Remove no longer needed 'drive' field from struct ide_acpi_drive_link.

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1f2cf8b0014fdfa3141449b508aca25e78c078a7 02-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->port_init_devs method to ide_hwif_t

* Add ->port_init_devs method to ide_hwif_t for a host specific
initialization of devices on a port. Call the new method from
ide_port_init_devices().

* Convert ht6560b, qd65xx and opti621 host drivers to use the new
->port_init_devs method.

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
807b90d0be23b8d088d4369b02539dada70f03f4 02-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_NO_{IO32_BIT,UNMASK_IRQS} host flags

* Use the same bit for IDE_HFLAG_CS5520 and IDE_HFLAG_VDMA host flags
(both are used only by cs5520 host driver currently).

* Add IDE_HFLAG_NO_IO32_BIT host flag and use it instead of ->no_io_32bit
ide_hwif_t field.

* Add IDE_HFLAG_NO_UNMASK_IRQS host flag, then convert dtc2278 and rz1000
host drivers to use it.

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9e016a719209d95338e314b46c3012cc7feaaeec 02-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_deprecated_find_port() helper

* Factor out code for finding ide_hwifs[] slot from ide_register_hw()
to ide_deprecated_find_port().

* Convert bast-ide, ide-cs and delkin_cb host drivers to use ide_device_add()
instead of ide_register_hw() (while at it drop doing "ide_unregister()" loop
which tries to unregister _all_ IDE interfaces if useable ide_hwifs[] slot
cannot be find).

This patch leaves us with only two ide_register_hw() users:
- drivers/macintosh/mediabay.c
- drivers/ide/ide.c

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f82c2b171905b6d5af92395d8159546351ab602f 02-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add 'init_default' and 'restore' arguments to ide_unregister()

* Add 'init_default' (flag for calling init_hwif_default()) and 'restore'
(flag for calling ide_hwif_restore()) arguments to ide_unregister().

* Update ide_unregister() users to set 'init_default' and 'restore' flags.

* No need to set 'init_default' flag in ide_register_hw() if the setup done
by init_hwif_default() is going to be overridden by ide_init_port_hw().

* No need to set 'init_default' and 'restore' flags in cleanup_module().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
0eea6458c04a1cbb2e8e5c2cdbef736d882d200c 02-Feb-2008 Borislav Petkov <bbpetkov@yahoo.de> ide-floppy: use an xfer_func_t and io_buf_t typedefs in order to unify rw

Also, move xfer_func_t typedef to the ide.h since it is used by two drivers
now (more coming).

Bart:
- use __func__ while at it

Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
bfa14b42a3bd671f0287b3db42e703e86ef27b48 02-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->cable_detect method to ide_hwif_t

* Add ->cable_detect method to ide_hwif_t.

* Call the new method in ide_init_port() if:
- the host supports UDMA modes > UDMA2 ('hwif->ultra_mask & 78')
- DMA initialization was successful (if hwif->dma_base is not set
ide_init_port() sets hwif->ultra_mask to zero)
- "idex=ata66" is not used ('hwif->cbl != ATA_CBL_PATA40_SHORT')

* Convert PCI host drivers to use ->cable_detect method.

While at it:

* Factor out cable detection to separate functions (if not already done).

* hpt366.c/it8213.c/slc90e66.c:
- don't check cable type if "idex=ata66" is used

* pdc202xx_new.c:
- add __devinit tag to pdcnew_cable_detect()

* pdc202xx_old.c:
- rename pdc202xx_old_cable_detect() to pdc2026x_old_cable_detect()
- add __devinit tag to pdc2026x_old_cable_detect()

Reviewed-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c413b9b94d9a8e7548cc4b2e04b7df0439ce76fd 02-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add struct ide_port_info instances to legacy host drivers

* Remove 'struct pci_dev *dev' argument from ide_hwif_setup_dma().

* Un-static ide_hwif_setup_dma() and add CONFIG_BLK_DEV_IDEDMA_PCI=n version.

* Add 'const struct ide_port_info *d' argument to ide_device_add[_all]().

* Factor out generic ports init from ide_pci_setup_ports() to ide_init_port(),
move it to ide-probe.c and call it in in ide_device_add_all() instead of
ide_pci_setup_ports().

* Move ->mate setup to ide_device_add_all() from ide_port_init().

* Add IDE_HFLAG_NO_AUTOTUNE host flag for host drivers that don't enable
->autotune currently.

* Setup hwif->chipset in ide_init_port() but iff pi->chipset is set
(to not override setup done by ide_hwif_configure()).

* Add ETRAX host handling to ide_device_add_all().

* cmd640.c: set IDE_HFLAG_ABUSE_* also for CONFIG_BLK_DEV_CMD640_ENHANCED=n.

* pmac.c: make pmac_ide_setup_dma() return an error value and move DMA masks
setup to pmac_ide_setup_device().

* Add 'struct ide_port_info' instances to legacy host drivers, pass them to
ide_device_add() calls and then remove open-coded ports initialization.

Reviewed-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
fbd130887a45341259cde02e134581fb3dac6e14 01-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ide_remove_port_from_hwgroup in init_irq()

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
a6fbb1c8c312be902f1085824c98ca50c86d5893 01-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove unused ide_hwgroup_t fields

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
dac2242047666a6709df6a2574f11c0ac8ebcd0b 01-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: don't include <linux/hdsmart.h>

IDE doesn't need it.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
062f9f024dcdb927cfd35c9ee8a68f59cbb1136f 01-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ide_build_sglist() and ide_destroy_dmatable() in non-PCI host drivers

* Make ide_build_sglist() and ide_destroy_dmatable() available also when
CONFIG_BLK_DEV_IDEDMA_PCI=n.

* Use ide_build_sglist() and ide_destroy_dmatable() in {ics,au1xxx-}ide.c
and remove no longer needed {ics,au}ide_build_sglist().

There should be no functionality changes caused by this patch.

Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
36501650ec45b1db308c3b51886044863be2d762 01-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: keep pointer to struct device instead of struct pci_dev in ide_hwif_t

Keep pointer to struct device instead of struct pci_dev in ide_hwif_t.

While on it:
* Use *dev->dma_mask instead of pci_dev->dma_mask in ide_toggle_bounce().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4166c1993b9e7f87c4d08e2e27f83ada890c2599 01-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_NO_DSC host flag

* Add IDE_HFLAG_NO_DSC host flag for hosts that doesn't support DSC overlap.

* Set it in aec62xx (for ATP850UF only) and hpt34x host drivers.

* Convert ide-tape device driver to check for IDE_HFLAG_NO_DSC flag.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
8ac2b42a45896641ed292deaf038a1d2703d85a6 01-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_CLEAR_SIMPLEX host flag

* Rename 'simplex_stat' variable to 'dma_stat' in ide_get_or_set_dma_base().

* Factor out code for forcing host out of "simplex" mode from
ide_get_or_set_dma_base() to ide_pci_clear_simplex() helper.

* Add IDE_HFLAG_CLEAR_SIMPLEX host flag and set it in alim15x3 (for M5229),
amd74xx (for AMD 7409), cmd64x (for CMD643), generic (for Netcell) and
serverworks (for CSB5) host drivers.

* Make ide_get_or_set_dma_base() test for IDE_HFLAG_CLEAR_SIMPLEX host flag
instead of checking dev->device (BTW the code was buggy because it didn't
check for dev->vendor, luckily none of these PCI Device IDs was used by
some other vendor for PCI IDE controller).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ecf32796395ed0e27667e7f735946d6dc60e1765 01-Feb-2008 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: ide_setup_dma() assumes 8 ports

According to http://marc.info/?l=linux-ide&m=114346138611631, the drivers must
always register 8 DMA ports with ide_setup_dma(), so its last argument is not
needed. While at it, kill some useless parens in that function...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7b9f25b539c3fa3c7b8c82775488a0021d90220f 01-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_dump_identify() debug helper

* Add ide_dump_identify() debug helper for dumping raw identify data in
the hdparm friendly format (== the identify data can be extracted from
dmesg output and passed to hdparm --Istdin).

* Dump identify data in ide-probe.c::do_identify() if DEBUG is enabled.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
da6f4c7f6fe02f92aff72071ed541f59e5880398 01-Feb-2008 Adrian Bunk <bunk@kernel.org> ide: make wait_drive_not_busy() static again

After commit 7267c3377443322588cddaf457cf106839a60463
wait_drive_not_busy() can become static again.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2eae6ebbf99a083687466c010e3129fede9cdb4b 01-Feb-2008 Adrian Bunk <bunk@kernel.org> ide: small ide-scan-pci.c cleanup

- ide_scan_pcibus() can become static
- instead of ide_scan_pci() we can use ide_scan_pcibus() directly
in module_init()

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
34f5d5ae35240a11846875d76eb935875ab0c366 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: switch set_xfer_rate() to use REQ_TYPE_ATA_TASKFILE requests

Based on the earlier work by Tejun Heo.

Switch set_xfer_rate() to use REQ_TYPE_ATA_TASKFILE requests
and make ide_wait_cmd() static.

There should be no functionality changes caused by this patch.

Cc: Tejun Heo <htejun@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2624565caacedd740fce7803fe2c162842aa5df4 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use wait_drive_not_busy() in drive_cmd_intr() (take 2)

Use wait_drive_not_busy() in drive_cmd_intr().

v2:
* Fix wait_drive_not_busy() comment (noticed by Sergei).

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4906f3b4cddc3e4d62955ed386598561f95602c0 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: kill DATA_READY define

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4d7a984bdcbdda69fc6b2a4a655415140270aa7b 26-Jan-2008 Tejun Heo <htejun@gmail.com> ide: task_end_request() fix

task_end_request() modified to always call ide_end_drive_cmd()
for taskfile requests. Previously, ide_end_drive_cmd() was
called only when IDE_TFLAG_FLAGGED was set. Also,
ide_dma_intr() is modified to use task_end_request().

Enables TASKFILE ioctls to get valid register outputs on
successful completion.

Bart:
- ported it over recent IDE changes

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
657cc1a8f6cd6a9e2974cba3af9fccd8c25e06ad 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: set IDE_TFLAG_IN_* flags before queuing/executing command

* Add IDE_TFLAG_{HOB,TF,DEVICE} defines.

* Set IDE_TFLAG_IN_* flags in {do_rw,ide_no_data,ide_raw}_taskfile() users.

* Remove no longer needed ->tf_flags setup from ide_end_drive_cmd().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
35cf2b94d0ecb7034cfa05dd725721538bbb83fc 26-Jan-2008 Tejun Heo <htejun@gmail.com> ide: fix ->io_32bit race in ide_taskfile_ioctl()

In ide_taskfile_ioctl(), there was a race condition involving
drive->io_32bit. It was cleared and restored during ioctl
requests but there was no synchronization with other requests.
So, other requests could execute with the altered ->io_32bit
setting or updated drive->io_32bit could be overwritten by
ide_taskfile_ioctl().

This patch adds IDE_TFLAG_IO_16BIT flag to indicate to
ide_pio_datablock() that 16-bit I/O is needed regardless of
drive->io_32bit settting.

Bart:
- ported it over recent IDE changes

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9e47be0c97f7357b80e91dc0632e9cce2eb025e0 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove broken disk byte-swapping support

Remove broken disk byte-swapping support:
- it can cause a data corruption on SMP (or if using PREEMPT on UP)
- all data coming from disk are byte-swapped by taskfile_*_data() which
results in incorrect identify data being reported by /proc/ide/ and IOCTLs
- "hdx=bswap/byteswap" kernel parameter has been broken on m68k host drivers
(including Atari/Q40 ones) since 2.5.x days (because of 'hwif' zero-ing)
- byte-swapping is limited to PIO transfers (for working with TiVo disks on
x86 machines using user-space solutions or dm-byteswap should result in
much better performance because DMA can be used)

For previous discussions please see:

http://www.ussg.iu.edu/hypermail/linux/kernel/0201.0/0768.html
http://lkml.org/lkml/2004/2/28/111

[ I have dm-byteswap device mapper target if somebody is interested
(patch is for 2.6.4 though but I'll dust it off if needed). ]

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
81ca691981da718727281238b435dcf1528d2fda 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_set_irq() inline helper

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ade2daf9c6e57845fe83a24e0a9fa1c03c6e91b1 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make remaining built-in only IDE host drivers modular (take 2)

* Make remaining built-in only IDE host drivers modular, add ide-scan-pci.c
file for probing PCI host drivers registered with IDE core (special case
for built-in IDE and CONFIG_IDEPCI_PCIBUS_ORDER=y) and then take care of
the ordering in which all IDE host drivers are probed when IDE is built-in
during link time.

* Move probing of gayle, falconide, macide, q40ide and buddha (m68k arch
specific) host drivers, before PCI ones (no PCI on m68k), ide-cris (cris
arch specific), cmd640 (x86 arch specific) and pmac (ppc arch specific).

* Move probing of ide-cris (cris arch specific) host driver before cmd640
(x86 arch specific).

* Move probing of mpc8xx (ppc specific) host driver before ide-pnp (depends
on ISA and none of ppc platform that use mpc8xx supports ISA) and ide-h8300
(h8300 arch specific).

* Add "probe_vlb" kernel parameter to cmd640 host driver and update
Documentation/ide.txt accordingly.

* Make IDE_ARM config option visible so it can also be disabled if needed.

* Remove bogus comment from ide.c while at it.

v2:
* Fix two issues spotted by Sergei:
- replace ENOMEM error value by ENOENT in ide-h8300 host driver
- fix MODULE_PARM_DESC() in cmd640 host driver

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
cbb010c180294a5242a7681555c28737d9dd26ab 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: drop 'initializing' argument from ide_register_hw()

* Rename init_hwif_data() to ide_init_port_data() and export it.

* For all users of ide_register_hw() with 'initializing' argument set
hwif->present and hwif->hold are always zero so convert these host
drivers to use ide_find_port()+ide_init_port_data()+ide_init_port_hw()
instead (also no need for init_hwif_default() call since the setup
done by it gets over-ridden by ide_init_port_hw() call).

* Drop 'initializing' argument from ide_register_hw().

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
57c802e84f9c759c3d1794a9dbe81bc10444df62 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_init_port_hw() helper

* Add ide_init_port_hw() helper.

* rapide.c: convert rapide_locate_hwif() to rapide_setup_ports()
and use ide_init_port_hw().

* ide_platform.c: convert plat_ide_locate_hwif() to plat_ide_setup_ports()
and use ide_init_port_hw().

* sgiioc4.c: use ide_init_port_hw().

* pmac.c: add 'hw_regs_t *hw' argument to pmac_ide_setup_device(),
setup 'hw' in pmac_ide_{macio,pci}_attach() and use ide_init_port_hw()
in pmac_ide_setup_device().

This patch is a preparation for the future changes in the IDE probing code.

There should be no functionality changes caused by this patch.

Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Anton Vorontsov <avorontsov@ru.mvista.com>
Cc: Jeremy Higdon <jeremy@sgi.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b0d5bc27ce995adaafbc114b92fa76815025c94e 26-Jan-2008 Olof Johansson <olof@lixom.net> ide: Fix build break caused by "ide: remove ideprobe_init()"

Fix build break of powerpc holly_defconfig:

In file included from arch/powerpc/platforms/embedded6xx/holly.c:24:
include/linux/ide.h:1206: error: 'CONFIG_IDE_MAX_HWIFS' undeclared here (not in a function)

There's no need to have a sized array in the prototype, might as well
turn it into a pointer.

It could probably be argued that large parts of the include file can be
covered under #ifdef CONFIG_IDE, but that's a larger undertaking.

Signed-off-by: Olof Johansson <olof@lixom.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
151575e4644f917d3a9f83c777ac3543284954f8 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ideprobe_init()

* Rename ide_device_add() to ide_device_add_all() and make it accept
'u8 idx[MAX_HWIFS]' instead of 'u8 idx[4]' as an argument.

* Add ide_device_add() wrapper for ide_device_add_all().

* Convert ide_generic_init() to use ide_device_add_all().

* Remove no longer needed ideprobe_init().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f01393e48c44e30f7c9a36c8b98a07b0232580fe 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: merge ->fixup and ->quirkproc methods

* Assign drive->quirk_list in ->quirkproc implementations:
- hpt366.c::hpt3xx_quirkproc()
- pdc202xx_new.c::pdcnew_quirkproc()
- pdc202xx_old.c::pdc202xx_quirkproc()

* Make ->quirkproc void.

* Move calling ->quirkproc from do_identify() to probe_hwif().

* Convert it821x_fixups() to it821x_quirkproc() in it821x.c.

* Convert siimage_fixup() to sil_quirkproc() in siimage.c, also remove
no longer needed drive->present check from is_dev_seagate_sata().

* Convert ide_undecoded_slave() to accept 'drive' instead of 'hwif'
as an argument. Then convert ide_register_hw() to accept 'quirkproc'
argument instead of 'fixup' one.

* Remove no longer needed ->fixup method.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
15ce926ada545cb078711bd9a18c083c93fa01d7 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: merge ->dma_host_{on,off} methods into ->dma_host_set method

Merge ->dma_host_{on,off} methods into ->dma_host_set method
which takes 'int on' argument.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4a546e046d562bcd389149591fa5a534c8f832ca 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->ide_dma_on and ->dma_off_quietly methods from ide_hwif_t

* Make ide_dma_off_quietly() and __ide_dma_on() always available.

* Drop "__" prefix from __ide_dma_on().

* Check for presence of ->dma_host_on instead of ->ide_dma_on.

* Convert all users of ->ide_dma_on and ->dma_off_quietly methods
to use ide_dma_on() and ide_dma_off_quietly() instead.

* Remove no longer needed ->ide_dma_on and ->dma_off_quietly methods
from ide_hwif_t.

* Make ide_dma_on() void.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
8704de8f296fcf6a4b2ff6bfd9a63974ad909b3e 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> cy82c693: add ->set_dma_mode method

* Fix SWDMA/MWDMA masks in cy82c693_chipset.

* Add IDE_HFLAG_CY82C693 host flag and use it in ide_tune_dma() to
check whether the DMA should be enabled even if ide_max_dma_mode()
fails.

* Convert cy82c693_dma_enable() to become cy82c693_set_dma_mode()
and remove no longer needed cy82c693_ide_dma_on(). Then set
IDE_HFLAG_CY82C693 instead of IDE_HFLAG_TRUST_BIOS_FOR_DMA in
cy82c693_chipset.

* Bump driver version.

As a result of this patch cy82c693 driver will configure and use DMA on
all SWDMA0-2 and MWDMA0-2 capable ATA devices instead of relying on BIOS.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4db90a145292327b95b03f6dcd3352327235cc36 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_ABUSE_SET_DMA_MODE host flag

* Add IDE_HFLAG_ABUSE_SET_DMA_MODE host flag and use it to decide
what to do with transfer modes < XFER_PIO_0 in ide_set_xfer_rate().

* Set IDE_HFLAG_ABUSE_SET_DMA_MODE in host drivers that need it
(aec62xx, amd74xx, cs5520, cs5535, hpt34x, hpt366, pdc202xx_old,
serverworks, tc86c001 and via82cxxx) and cleanup ->set_dma_mode
methods in host drivers that don't (IDE core code guarantees that
->set_dma_mode will be called only for modes which are present
in SWDMA/MWDMA/UDMA masks).

While at it:

* Add IDE_HFLAGS_HPT34X/HPT3XX/PDC202XX/SVWKS define in
hpt34x/hpt366/pdc202xx_old/serverworks host driver.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
3071a9d00b8684899d93f368e670c4de0293df29 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make 'extra' field in struct ide_port_info u8

The maximum value used currently for 'extra' field in struct ide_port_info
is 240.

Make 'extra' u8 so it packs nicely together with enablebits[] and 'chipset'
fields (ide_pci_enablebit_t is 3 bytes and hwif_chipset_t is 1 byte).

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
a501633c7d44087e806597d3a213d735346edd51 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-disk: use ide_get_lba_addr()

* Export ide_get_lba_addr().

* Convert idedisk_{read_native,set}_max_address() to use ide_get_lba_addr().

* Remove incorrect comment from idedisk_read_native_max_address()
(noticed by Sergei).

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c2b57cdc1d2976444d451a2a2e43e11b61ed0638 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_tf_read() helper

* Factor out code reading taskfile registers from ide_end_drive_cmd()
to the new ide_tf_read() helper.

* Add IDE_TFLAG_IN_* taskfile flags to indicate the need to load
particular IDE taskfile register in ide_tf_read().

* Update ide_end_drive_cmd() to set respective IDE_TFLAG_IN_* taksfile flags.

* Add ide_get_lba_addr() for getting LBA sector address from taskfile struct.

* Factor out code getting sector address from ide_dump_ata_status()
to the new ide_dump_sector() function.

* Convert ide_dump_sector() to use ide_tf_read() and ide_get_lba_addr().

* Remove no longer needed ide_read_24().

The only change in functionality caused by this patch is that
ide_dump_ata_status() no longer prints "high"/"low" parts of LBA48
sector address (of course LBA48 sector address is still printed).

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f6e29e35cc0f9facf2eb0b0454f9b09021b5aa6f 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-disk: use do_rw_taskfile() (take 2)

* Add IDE_TFLAG_DMA_PIO_FALLBACK taskfile flag to indicate the need
to skip loading taskfile registers in do_rw_taskfile().

* Export do_rw_taskfile().

* Convert __ide_do_rw_disk() to use do_rw_taskfile().

* Unexport ide_tf_load().

* Unexport {pre_task_out,task_in}_intr() and make it static.

* Remove incorrect comment about do_rw_taskfile() from <linux/ide.h>.

There should be no functionality changes caused by this patch.

v2:
* Add missing blk_fs_request() check to task_dma_ok() (for VDMA).

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
57d7366b78b74a9eef873e8212c03d8c2033a764 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove 'handler' field from ide_task_t (take 2)

* Add IDE_TFLAG_CUSTOM_HANDLER taskfile flag and use it for internal requests
which require custom handlers. Check the flag in do_rw_taskfile() and set
handler accordingly.

* Cleanup ide_init_{specify,restore,setmult}_cmd() and rename it to
ide_tf_set_{specify,restore,setmult}_cmd().

* Make {set_geometry,recal,set_multmode}_intr() static.

* Remove no longer needed 'handler' field from ide_task_t.

v2:
* 'handler' in do_rw_taskfile() must be set to NULL initially.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1192e528e064ebb9a578219731d2b0f78ca3c1ec 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ->data_phase to set ->handler in do_rw_taskfile()

* Use ->data_phase to set ->handler in do_rw_taskfile() instead of
setting ->handler in callers of ide_raw_taskfile()/do_rw_taskfile().

* Unexport task_no_data_intr() and make it static.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
10d90157c83d4b6743c9063c36f9e7f27aa254b6 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: convert do_rw_taskfile() to use ->data_phase

* Use task->data_phase in do_rw_taskfile() to decide what to do.

* task->prehandler is only used by TASKFILE[_MULTI]_OUT so just
use pre_task_out_intr() directly and remove no longer needed
'prehandler' field from ide_task_t.

* Remove no longer needed ide_pre_handler_t type.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1edee60e9d994f2b9a79b1333be39790683541fe 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: merge flagged_taskfile() into do_rw_taskfile()

Based on the earlier work by Tejun Heo.

task->data_phase == TASKFILE_MULTI_{IN,OUT} vs drive->mult_count == 0
check is needed also for ide_taskfile_ioctl() requests that don't have
IDE_TFLAG_FLAGGED taskfile flag set.

Cc: Tejun Heo <htejun@gmail.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
866e2ec9ce525de0e7c10d02ead8d85af27adffd 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove 'tf_in_flags' field from ide_task_t

* Add IDE_TFLAG_IN_DATA taskfile flag to indicate the need of reading
IDE_DATA_REG in ide_end_drive_cmd().

Set the new flag in ide_taskfile_ioctl() if ->in_flags.b.data is set.

* Add IDE_TFLAG_FLAGGED_SET_IN_FLAGS taskfile flag to indicate the
need of modifying ->in_flags in ide_taskfile_ioctl().

Set the new flag in flagged_taskfile() and move the code modifying
->tf_in_flags to ide_taskfile_ioctl().

While at it remove the bogus comment: ->tf_in_flags (except .b.data)
have no effect on selection of registers to read.

* Remove no longer needed 'tf_in_flags' field from ide_task_t.

As the result we finally have the internals of HDIO_DRIVE_TASKFILE ioctl
separated from the core IDE code.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ac026ff254b32915bb14ba97a23b4019d137f181 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove 'command_type' field from ide_task_t

* Add 'data_buf' and 'nsect' variables in ide_taskfile_ioctl()
to cache data buffer pointer and number of sectors to transfer
(this allows us to have only one ide_diag_taskfile() call).

* Add IDE_TFLAG_WRITE taskfile flag and use it to check whether
the REQ_RW request flag should be set.

* Move ->command_type handling from ide_diag_taskfile() to
ide_taskfile_ioctl() and use ->req_cmd instead of ->command_type.

* Add 'nsect' parameter to ide_raw_taskfile().

* Merge ide_diag_taskfile() into ide_raw_taskfile().

* Initialize ->data_phase explicitly in idedisk_prepare_flush(),
ide_start_power_step() and ide_disk_special().

* Remove no longer needed 'command_type' field from ide_task_t.

* Add #ifndef/#endif __KERNEL__ to <linux/hdreg.h> around no
longer used by kernel IDE_DRIVE_TASK_* and TASKFILE_* defines.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7299a3918442dc9a5abb71b9f65b1dd17637c8c0 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove hwif->intrproc

Given that:

* hpt366.c::hpt3xx_intrproc() is the only user of hwif->intrproc

* hpt366.c::hpt3xx_quirkproc() sets drive->quirk_list to 1 for quirky drives
which is a value unique to hpt366 host driver

we can remove hwif->intproc and just check for drive->quirk_list == 1
in ide_do_request().

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f919790f8c929ab1b392ad1a0c2e1b53337b5071 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove SELECT_INTERRUPT()

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
cd3dbc99da337f2130f3cb2691fbb65c8bf22337 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove QUIRK_LIST()

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2fc573881957337c4ea1c84b92d2f27d076cad57 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_pktcmd_tf_load() helper

Add ide_pktcmd_tf_load() helper and convert ATAPI device drivers to use it.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
8e7657ae0f56c14882e53ffdae8055c2b1624de1 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove atapi_ireason_t (take 3)

Remove atapi_ireason_t.

While at it:
* replace 'HWIF(drive)' by 'drive->hwif' (or just 'hwif' where possible)

v2:
* v1 had CD and IO bits reversed in many places.

* Use CD and IO defines from <linux/hdreg.h>.

v3:
* Fix incorrect "(ireason & IO) == test_bit()". (Noticed by Sergei)

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
790d1239898d4f893112280decd344d90f43ee96 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ata_nsector_t, ata_data_t and atapi_bcount_t

Remove ata_nsector_t, ata_data_t (unused) and atapi_bcount_t.

While at it:
* replace 'HWIF(drive)' by 'hwif'

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e5f9f5a89a01abc2b9c09747452aeb9218d6bffd 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove atapi_feature_t

Remove atapi_feature_t.

While at it:
* replace 'HWIF(drive)' by 'hwif'

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
0e38a66a1e69821ab57a06d5a7b11f0df9275bf4 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove atapi_error_t (take 2)

Remove atapi_error_t.

While at it:
* replace 'HWIF(drive)' by 'drive->hwif'

v2:
* Add {ILI,EOM,LFS}_ERR defines to <linux/hdreg.h>.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
22c525b976778cce5bb6f8fdcc70046168c54b1a 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ata_status_t and atapi_status_t

Remove ata_status_t (unused) and atapi_status_t.

While at it:
* replace 'HWIF(drive)' by 'drive->hwif' (or just 'hwif' where possible)

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6a2144146aa2e0eb60e48ba73ac0e1c51346edf6 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: CPU endianness doesn't matter for special_t

special_t is used only internally by the IDE subsystem (it isn't
related to hardware registers and isn't exported to the user-space).

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
807e35d695690011faa1ce3ad67dfc23c1e39bdc 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ide_tf_load() in execute_drive_cmd()

* Add IDE_TFLAG_OUT_DEVICE taskfile flag to indicate the need of writing
the Device register and handle it in ide_tf_load().

Update ide_tf_load() and {do_rw,flagged}_taskfile() users accordingly.

* Use struct ide_taskfile and ide_tf_load() in execute_drive_cmd().

* Make the debugging code dump all taskfile registers for both
REQ_ATA_TYPE_{CMD,TASK} requests and move it to ide_tf_load()
so it also covers REQ_ATA_TYPE_TASKFILE requests.

There should be no functionality changes caused by this patch
(unless DEBUG is defined).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4ee06b7e677da4c75f2fcc5fd850543852d18bf2 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove stale ide.h "configuration options"

Remove stale ide.h "configuration options":

* INITIAL_MULT_COUNT - always defined to 0

* SUPPORT_SLOW_DATA_PORTS - unused

* OK_TO_RESET_CONTROLLER - always defined to 1

* DISABLE_IRQ_NOSYNC - always defined to 0

Leave SUPPORT_VLB_SYNC (defined to 0 for CRIS and FRV, otherwise to 1)
for now but disallow overriding it by <asm/ide.h>.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
74095a91ed02f6727b62d4416be00a041f2d7436 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use do_rw_taskfile() in flagged_taskfile()

Based on the earlier work by Tejun Heo.

* Move setting IDE_TFLAG_LBA48 taskfile flag from do_rw_taskfile()
function to the callers.

* Add IDE_TFLAG_FLAGGED taskfile flag for flagged taskfiles coming
from ide_taskfile_ioctl(). Check it instead of ->tf_out_flags.all.

* Add IDE_TFLAG_OUT_DATA taskfile flag to indicate the need to load
IDE data register in ide_tf_load().

* Add IDE_TFLAG_OUT_* taskfile flags to indicate the need to load
particular IDE taskfile registers in ide_tf_load().

* Update do_rw_taskfile() and ide_tf_load() users to set respective
IDE_TFLAG_OUT_* taksfile flags.

* Add task_dma_ok() helper.

* Use IDE_TFLAG_FLAGGED taskfile flag to select HIHI mask in ide_tf_load().

* Use do_rw_taskfile() in flagged_taskfile().

* Remove no longer needed 'tf_out_flags' field from ide_task_t.

There should be no functionality changes caused by this patch.

Cc: Tejun Heo <htejun@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9a3c49be5c5f7388eefb712be9a383904140532e 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_no_data_taskfile() helper

* Add ide_no_data_taskfile() helper and convert ide_raw_taskfile() w/ NO DATA
protocol users to use it instead.

* Set ->data_phase explicitly in ide_no_data_taskfile()
(TASKFILE_NO_DATA is defined as 0x0000).

* Unexport task_no_data_intr().

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9e42237f26cf517a3f682505f03a3a8d89b3b35d 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_tf_load() helper

Based on the earlier work by Tejun Heo.

* Add 'tf_flags' field (for taskfile flags) to ide_task_t.

* Add IDE_TFLAG_LBA48 taskfile flag for LBA48 taskfiles.

* Add IDE_TFLAG_NO_SELECT_MASK taskfile flag for __ide_do_rw_disk()
which doesn't use SELECT_MASK() (looks like a bug but it requires
some more investigation).

* Split off ide_tf_load() helper from do_rw_taskfile().

* Convert __ide_do_rw_disk() to use ide_tf_load().

There should be no functionality changes caused by this patch.

Cc: Tejun Heo <htejun@gmail.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
650d841d9e053a618dd8ce753422f91b493cf2f6 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add struct ide_taskfile (take 2)

* Don't set write-only ide_task_t.hobRegister[6] and ide_task_t.hobRegister[7]
in idedisk_set_max_address_ext().

* Add struct ide_taskfile and use it in ide_task_t instead of tfRegister[]
and hobRegister[].

* Remove no longer needed IDE_CONTROL_OFFSET_HOB define.

* Add #ifndef/#endif __KERNEL__ around definitions of {task,hob}_struct_t.

While at it:

* Use ATA_LBA define for LBA bit (0x40) as suggested by Tejun Heo.

v2:
* Add missing newlines. (Noticed by Sergei)

* Use ~ATA_LBA instead of 0xBF. (Noticed by Sergei)

* Use unnamed unions for error/feature and status/command.
(Suggested by Sergei).

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Tejun Heo <htejun@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
cd2a2d969761c26542095c01324201ca0b3ee896 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove task_ioreg_t typedef (take 2)

Remove task_ioreg_t typedef from the kernel code (but leave it
in <linux/hdreg.h> for #ifndef/#endif __KERNEL__ case).

While at it also move sata_ioreg_t typedef under #ifndef/#endif __KERNEL__.

v2:
Remove name of the second parameter from ide_execute_command() declaration.
(Noticed by Sergei).

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1c029fd658baa2442e8e51dc9c819301cad95777 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->dma_master field from ide_hwif_t (take 5)

* Convert cmd64x, hpt366 and pdc202xx_old host drivers to use
pci_resource_start(hwif->pci_dev, 4) instead of hwif->dma_master.

* Remove no longer needed ->dma_master field from ide_hwif_t.

v2:
* Use the more readable 'hwif->dma_base - (hwif->channel * 8)' instead of
pci_resource_start(hwif->pci_dev, 4).

v3:
* Use hwif->extra_base in hpt366/pdc20xx_old + some cosmetic fixups over v2
(suggested by Sergei).

v4:
* Correct offsets in hpt3xxn_set_clock().

v5:
* Use hwif->extra_base in hpt366 for _real_ this time. (Noticed by Sergei)

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
3ab7efe8e2cbcca2d401b43cfcc2fa9a7dac2299 12-Dec-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: DMA reporting and validity checking fixes (take 3)

* ide_xfer_verbose() fixups:
- beautify returned mode names
- fix PIO5 reporting
- make it return 'const char *'

* Change printk() level from KERN_DEBUG to KERN_INFO in ide_find_dma_mode().

* Add ide_id_dma_bug() helper based on ide_dma_verbose() to check for invalid
DMA info in identify block.

* Use ide_id_dma_bug() in ide_tune_dma() and ide_driveid_update().

As a result DMA won't be tuned or will be disabled after tuning if device
reports inconsistent info about enabled DMA mode (ide_dma_verbose() does the
same checks while the IDE device is probed by ide-{cd,disk} device driver).

* Remove no longer needed ide_dma_verbose().

This patch should fix the following problem with out-of-sync IDE messages
reported by Nick Warne:

hdd: ATAPI 48X DVD-ROM DVD-R-RAM CD-R/RW drive, 2048kB Cache<7>hdd:
skipping word 93 validity check
, UDMA(66)

and later debugged by Mark Lord to be caused by:

ide_dma_verbose()
printk( ... "2048kB Cache");
eighty_ninty_three()
printk(KERN_DEBUG "%s: skipping word 93 validity check\n");
ide_dma_verbose()
printk(", UDMA(66)"

Please note that as a result ide-{cd,disk} device drivers won't report the
DMA speed used but this is intended since now DMA mode being used is always
reported by IDE core code.

v2:
* fixes suggested by Randy:
- use KERN_CONT for printk()-s in ide-{cd,disk}.c
- don't remove argument name from ide_xfer_verbose() declaration

v3:
* Remove incorrect check for (id->field_valid & 1) from ide_id_dma_bug()
(spotted by Sergei).

* "XFER SLOW" -> "PIO SLOW" in ide_xfer_verbose() (suggested by Sergei).

* Fix ide_find_dma_mode() to report the correct mode ('mode' after being
limited by 'req_mode').

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Nick Warne <nick@ukfsn.org>
Cc: Mark Lord <lkml@rtr.ca>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
01745112de5f721dd5afb06bc60b4a1e65e397ce 05-Nov-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move ide_fixstring() documentation to ide-iops.c from ide.h

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e95d9c6b046f665da551a51b4071902336a6118c 22-Oct-2007 David Miller <davem@davemloft.net> Expand hwif->host_flags so that it fits new flags.

Commit 238e4f142c33bb34440cc64029dde7b9fbc4e65f ("ide: add
IDE_HFLAG_NO_LBA48 and IDE_HFLAG_NO_LBA48_DMA host flags") caused a
regression because the host_flags in struct hwif_s wasn't expanded to
cope with the fact that the host flags no longer fit in 16 bits.

Signed-off-by: David S. Miller <davem@davemloft.net>
[ I hate having to add good commit descriptions. - Linus ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
8562043606430185cad26d085d46adcc7ad67fd1 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: constify struct ide_port_info

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
039788e1532368eeca1071a873c14e03920cdf38 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: replace ide_pci_device_t by struct ide_port_info

* Rename struct ide_pci_device_s to struct ide_port_info.

* Remove ide_pci_device_t typedef.

While at it:

* Fix __ide_pci_register_driver() comment.

* Fix aec62xx_init_one() comment.

* Remove unused 'cds' field from ide_hwgroup_t.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9239b333939dd1e5b1a9f033a1c136273d58efe8 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove write-only hwif->hw

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
18e181fe13b7340194d09e6dd7f571a5f96f0367 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add hwif->ack_intr hook

* Add hwif->ack_intr hook and use it instead of hwif->hw.ack_intr.

* Add missing brackets to cris-v32 and powerpc ide_ack_intr() macros.

Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
86f3a492bb09eee5745b93af35f2212179c251fd 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> icside: use ec->dma directly

* hwif->hwif_data contains pointer to struct expansion_card so use ec->dma
directly instead of caching it in hwif->hw.dma.

* Remove no longer needed hw_regs_t.dma and NO_DMA define.

Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
847ddd2bbe15c6e452606503b5d073826aaaddb7 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add CONFIG_IDE_ARCH_OBSOLETE_INIT

Add CONFIG_IDE_ARCH_OBSOLETE_INIT to drivers/ide/Kconfig and use it instead
of defining IDE_ARCH_OBSOLETE_INIT in <arch/ide.h>.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f9b93097375761930c52b3a20acd374a8d012fbc 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove redundant comments from ide.h

There is better documentation for these functions in drivers/ide/.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
baa8f3e94bc7a7ba3650d80b67d54c3e08365dee 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_find_port() helper

* Add ide_find_port() helper.

* Convert icside, rapide and ide_platform host drivers to use it.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
8447d9d52adbe4c653482bd0d5ccb9b5d26f9c9d 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_device_add()

* Add ide_device_add() helper and convert host drivers to use it
instead of open-coded variants.

* Make ide_pci_setup_ports() and do_ide_setup_pci_device()
take 'u8 *idx' argument instead of 'ata_index_t *index'.

* Remove no longer needed ata_index_t.

* Unexport probe_hwif_init() and make it static.

* Unexport ide_proc_register_port().

There should be no functionality changes caused by this patch
(sgiioc4.c: ide_proc_register_port() requires hwif->present
to be set and it won't be set if probe_hwif_init() fails).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
fd9bb53942a7ca3398a63f2c238afd8fbed3ec0e 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->fixup method to ide_hwif_t

* Add ->fixup method to ide_hwif_t.

* Set hwif->fixup in ide_pci_setup_ports() to d->fixup.

* Use hwif->fixup in probe_hwif().

* Use probe_hwif_init() instead of probe_hwif_init_with_fixup() in
ide_setup_pci_device().

* Add 'fixup' argument to ide_register_hw() and use it to set hwif->fixup,
update all ide_register_hw() users accordingly.

* Convert ide-cs/delkin_cb host drivers to use ide_register_hw().

* Restore hwif->fixup in ide_hwif_restore().

* Remove ide_register_hw_with_fixup(), probe_hwif_init_with_fixup()
and 'fixup' argument from probe_hwif().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
caea7602f309cbd55ba609800fd3c3e5d19ab684 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_{IO_32BIT,UNMASK_IRQS} host flags

Add IDE_HFLAG_{IO_32BIT,UNMASK_IRQS} host flag to tell ide_pci_setup_ports()
to set drive->{io_32bit,unmask} for both drives on the interface. Convert
amd74xx, sl82c105 and via82cxxx host drivers to use these new host flags.

While at it:

* Add IDE_HFLAGS_AMD define (amd74xx host driver).

* Add IDE_HFLAGS_VIA define (via82cxxx host driver).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
272a370900e5d2ae84662338397bb7b2375ff5cf 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_RQSIZE_256 host flag

Add IDE_HFLAG_RQSIZE_256 host flag to tell ide_pci_setup_ports() to set
hwif->rqsize to 256 sectors. Convert pdc202xx_old host driver to use it.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
8acf28c090f0e5e049f56b27bdd7cf1fb40c6b98 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_FORCE_LEGACY_IRQS host flag

Add IDE_HFLAG_FORCE_LEGACY_IRQS host flag to tell ide_pci_setup_ports()
to always set hwif->irq to legacy IRQ 14/15 and convert generic IDE PCI
and via82cxxx host drivers to use it.

While at it:

* Add IDE_HFLAGS_UMC define (generic IDE PCI host driver).

* Remove no longer needed init_hwif_generic() (generic IDE PCI host driver).

* Set d->udma_mask instead of hwif->ultra_mask (via82cxxx host driver).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
528a572daea90aa41db92683e5a8756acef514c4 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->chipset field to ide_pci_device_t

Add ->chipset field to ide_pci_device_t and use it in ide_hwif_configure()
to set hwif->chipset. Convert cmd64x, cy82c693, rz1000 and trm290 host
drivers to use this new ability.

While at it define hwif_chipset_t as u8 to save some space in hw_regs_t,
ide_hwif_t and ide_pci_device_t instances.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
44a59ad59f4285ce91e61f05e65a3e8fd0943c85 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove unused ->next field from ide_pci_device_t

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
3985ee3b4c5f9e1d73623b92715375b089c54353 19-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_LEGACY_IRQS host flag

Add IDE_HFLAG_LEGACY_IRQS host flag to tell ide_pci_setup_ports() to set
hwif->irq to legacy IRQ 14/15 (iff hwif->irq is not already set) and convert
atiixp, piix, serverworks, sis5513 and slc90e66 host drivers to use it.

While at it:

* In piix.c add IDE_HFLAGS_PIIX define and don't use ->init_hwif for MPIIX.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1c51361a9867021dd7444b56d87834003d4ca67d 19-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_SERIALIZE host flag

Add IDE_HFLAG_SERIALIZE host flag to tell ide_pci_setup_ports() to set
hwif/mate->serialized and convert aec62xx, cs5530 and sc1200 host drivers
to use it.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ed67b92385a5afddc98d5ff0894b2854c4a54dac 19-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_ERROR_STOPS_FIFO host flag

Add IDE_HFLAG_ERROR_STOPS_FIFO host flag and use it instead
of hwif->err_stops_fifo. As a side-effect this change fixes
hwif->err_stops_fifo not being restored by ide_hwif_restore().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
942278ef6424c5d661ad0a8202ef60dc0f268a95 19-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove .init_setup from ide_pci_device_t

Now that all users were fixed we can safely remove it.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5f8b6c34854a966fe5eb7241fde0419d47d5d408 19-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->mwdma_mask and ->swdma_mask to ide_pci_device_t (take 2)

* Add ->mwdma_mask and ->swdma_mask to ide_pci_device_t.

* Set ide_hwif_t DMA masks using DMA masks from ide_pci_device_t in
setup-pci.c::ide_pci_setup_ports() (iff DMA base is valid and ->init_hwif
method may still override them).

* Convert IDE PCI host drivers to use ide_pci_device_t DMA masks.

While at it:

* Use ATA_{UDMA,MWDMA,SWDMA}* defines.

* hpt34x.c: add separate ide_pci_device_t instances for HPT343 and HPT345.

* serverworks.c: fix DMA masks being set before checking DMA base.

v2:
* Add missing masks to DECLARE_GENERIC_PCI_DEV() macro.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
238e4f142c33bb34440cc64029dde7b9fbc4e65f 19-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_NO_LBA48 and IDE_HFLAG_NO_LBA48_DMA host flags

Add IDE_HFLAG_NO_LBA48[_DMA] host flags, use it instead of hwif->no_lba48[_dma]
and then remove no longer needed hwif->no_lba48[_dma]. As a side-effect
this change fixes hwif->no_lba48_dma not being restored by ide_hwif_restore().

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9ffcf364f9d0aca3ea79e9987c368eb75925460e 19-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->init_setup_dma from ide_pci_device_t (take 2)

* Make ide_pci_device_t.host_flags u32 and add IDE_HFLAG_CS5520 host flag.

* Pass ide_pci_device_t *d to setup-pci.c::ide_get_or_set_dma_base()
and use d->name instead of hwif->cds->name.

* Set IDE_HFLAG_CS5520 host flag in cs5520 host driver and use it in
ide_get_or_set_dma_base() to find out which PCI BAR to use, remove no longer
needed cs5520.c::cs5520_init_setup_dma() and ide_pci_device_t.init_setup_dma.

This fixes PCI bus-mastering not being checked for CS5510/CS5520 hosts.

v2:
* It is wrong to check simplex bits on CS5510/CS5520 as v1 did.
(Noticed by Alan).

Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
47b687882c02f802dd5bbe1227effe006820246e 19-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_NO_{DMA,AUTODMA} host flags

Add IDE_HFLAG_NO_{DMA,AUTODMA} host flags. Convert all host drivers using
ide_pci_device_t to use these flags instead of d->autodma and then remove no
longer needed d->autodma.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7cab14a79973893392111b8f887856a54621f759 19-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_BOOTABLE host flag

Add IDE_HFLAG_BOOTABLE host flag and IDE_HFLAG_OFF_BOARD define. Convert
all host drivers using ide_pci_device_t to use IDE_HFLAG_{BOOTABLE,OFF_BOARD}
instead of d->bootable and then remove no longer needed d->bootable.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
33c1002ed912ac9dacedd5d5b166da3b72d18460 19-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_NO_ATAPI_DMA host flag

Add IDE_HFLAG_NO_ATAPI_DMA host flag and set it in host drivers which
don't support ATAPI DMA. Then remove no longer needed hwif->atapi_dma.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1b678347121001c3c230c6eccfdf9f65c3ec1a4e 19-Oct-2007 Benjamin Herrenschmidt <benh@kernel.crashing.org> ide: Add ide_get_paired_drive() helper

This adds a helper to get to the "other" drive on a pair connected
to a given hwif.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Andrew Morton <akpm@osdl.org>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c223701cf6c706f42840631c1ca919a18e6e2800 16-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add "hdx=nodma" kernel parameter

* Add "hdx=nodma" option allowing user to disallow DMA for a given device.

* Obsolete "ide=nodma" option.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
9ff6f72f432364991d68e99cae72cb141c166e70 16-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove hwif->autodma and drive->autodma

* hpt34x.c: disable DMA masks for HPT345
(hwif->autodma is zero so DMA won't be enabled anyway).

* trm290.c: disable IDE_HFLAG_TRUST_BIOS_FOR_DMA flag
(hwif->autodma is zero so DMA won't be enabled anyway).

* Check noautodma global variable instead of drive->autodma in ide_tune_dma().

This fixes handling of "ide=nodma" kernel parameter for icside, ide-cris,
au1xxx-ide, pmac, it821x, jmicron, sgiioc4 and siimage host drivers.

* Remove hwif->autodma (it was not checked by IDE core code anyway) and
drive->autodma (was set by all host drivers - except HPT345/TRM290 special
cases - unless "ide=nodma" was used).

While at it:
- remove needless printk() from icside.c
- remove stale FIXME/comment from ide-probe.c
- don't force DMA off if PCI bus-mastering had to be enabled in setup-pci.c
(this setting was always later over-ridden by host drivers anyway)

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
0ae2e178652753ae1797d407755a3505f7c1d2a7 16-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->ide_dma_check (take 2)

* Add IDE_HFLAG_TRUST_BIOS_FOR_DMA host flag for host drivers that depend
on BIOS for programming device/controller for DMA. Set it in cy82c693,
generic, ns87415, opti621 and trm290 host drivers.

* Add IDE_HFLAG_VDMA host flag for host drivers using VDMA. Set it in cs5520
host driver.

* Teach ide_tune_dma() about IDE_HFLAG_TRUST_BIOS_FOR_DMA flag.

* Add generic ide_dma_check() helper and remove all open coded ->ide_dma_check
implementations. Fix all places checking for presence of ->ide_dma_check
hook to check for ->ide_dma_on instead.

* Remove no longer needed code from config_drive_for_dma().

* Make ide_tune_dma() static.

v2:
* Fix config_drive_for_dma() return values.

* Fix ide-dma.c build for CONFIG_BLK_DEV_IDEDMA_PCI=n by adding
dummy config_drive_for_dma() inline.

* Fix IDE_HFLAG_TRUST_BIOS_FOR_DMA handling in ide_dma_check().

* Fix init_hwif_it8213() comment.

There should be no functionality changes caused by this patch.

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
65c9cd23cab821c165a70ddd0447eb6362ebbb0c 16-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_use_fast_pio()

Remove ide_use_fast_pio() and just re-tune PIO unconditionally if DMA tuning
has failed in ->ide_dma_check. All host drivers using ide_use_fast_pio() set
drive->autotune so PIO is always tuned anyway and in some cases we _really_
need to re-tune PIO because PIO and DMA timings are shared.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
55c16a70041ba55e235c5944dccb9c1de0dd3ca6 25-Jul-2007 Jens Axboe <jens.axboe@oracle.com> IDE: sg chaining support

Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
bb879463b5346302a3891ebb7406247c53cebac1 14-Sep-2007 Adrian Bunk <bunk@kernel.org> remove ide_get_error_location()

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
88b2b32babd46cd54d2de4d17eb869aea3383e11 13-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move ide_config_drive_speed() calls to upper layers (take 2)

* Convert {ide_hwif_t,ide_pci_device_t}->host_flag to be u16.

* Add IDE_HFLAG_POST_SET_MODE host flag to indicate the need to program
the host for the transfer mode after programming the device. Set it
in au1xxx-ide, amd74xx, cs5530, cs5535, pdc202xx_new, sc1200, pmac
and via82cxxx host drivers.

* Add IDE_HFLAG_NO_SET_MODE host flag to indicate the need to completely
skip programming of host/device for the transfer mode ("smart" hosts).
Set it in it821x host driver and check it in ide_tune_dma().

* Add ide_set_pio_mode()/ide_set_dma_mode() helpers and convert all
direct ->set_pio_mode/->speedproc users to use these helpers.

* Move ide_config_drive_speed() calls from ->set_pio_mode/->speedproc
methods to callers.

* Rename ->speedproc method to ->set_dma_mode, make it void and update
all implementations accordingly.

* Update ide_set_xfer_rate() comments.

* Unexport ide_config_drive_speed().

v2:
* Fix issues noticed by Sergei:
- export ide_set_dma_mode() instead of moving ->set_pio_mode abuse wrt
to setting DMA modes from sc1200_set_pio_mode() to do_special()
- check IDE_HFLAG_NO_SET_MODE in ide_tune_dma()
- check for (hwif->set_pio_mode) == NULL in ide_set_pio_mode()
- check for (hwif->set_dma_mode) == NULL in ide_set_dma_mode()
- return -1 from ide_set_{pio,dma}_mode() if ->set_{pio,dma}_mode == NULL
- don't set ->set_{pio,dma}_mode on it821x in "smart" mode
- fix build problem in pmac.c
- minor fixes in au1xxx-ide.c/cs5530.c/siimage.c
- improve patch description

Changes in behavior caused by this patch:
- HDIO_SET_PIO_MODE ioctl would now return -ENOSYS for attempts to change
PIO mode if it821x controller is in "smart" mode
- removal of two debugging printk-s (from cs5530.c and sc1200.c)
- transfer modes 0x00-0x07 passed from user space may be programmed twice on
the device (not really an issue since 0x00 is not supported correctly by
any host driver ATM, 0x01 is not supported at all and 0x02-0x07 are invalid)

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
75d7d963e3dcf8a1410000ab246921709e276cd9 13-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> icside: use ide_tune_dma()

* Add "good DMA drives" hack for icside to ide-dma.c::ide_find_dma_mode()
(in the long-term it should be either removed or generalized for all hosts).

* Use ide_tune_dma() in icside.c::icside_dma_check().

This results in the following changes in behavior:
- pre-EIDE SWDMA modes are now also respected
- drive->autodma is checked instead of hwif->autodma
(doesn't really matter as icside sets both to "1")

* Make ide-dma.c::__ide_dma_good_drive() static and drop "__" prefix.

Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
aedea5910ce44fea79e2c517bb22e0006372156f 13-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-pmac: remove pmac_ide_do_setfeature() (take 2)

Use ide_config_drive_speed() instead of pmac_ide_do_setfeature() and remove
the latter, also ide-iops.c::__ide_wait_stat() could be static again.

Since for IDE PMAC host driver IDE_CONTROL_REG is always true, device's
->quirk_list is always zero and ->ide_dma_host_{on,off} are nops than
the only changes in behavior are:

* if PIO mode is set then ->dma_off_queitly is called to disable DMA

* if setting transfer mode fails ide_dump_status() is called to dump status

v2:
* IDE PMAC controllers allow separate PIO and DMA timings and PPC userland
depends on this fact, and calls "hdparm -p" without calling "hdparm -d".

Therefore to compensate for DMA being disabled by ide_config_drive_speed()
for PIO modes:

- add IDE_HFLAG_SET_PIO_MODE_KEEP_DMA flag and set it in PMAC host driver

- add handling of the new flag to ide-io.c::do_special()

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ddf151026a293725507fedc39b18ae6edb86d775 13-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-pmac: use __ide_wait_stat()

* Use __ide_wait_stat() instead of wait_for_ready() in pmac_ide_do_setfeature().

While at it do following changes to match __ide_wait_stat() call in
ide_config_drive_speed():

* Wait WAIT_CMD time (20 sec) instead of 2 sec for device to clear BUSY_STAT.

* Check DRQ_STAT bit (shouldn't be set for good device status).

Also remove no longer needed wait_for_ready() from ide-iops.c.

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
74af21cf4d0ab67df53608753a443dc7904ec12e 13-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add __ide_wait_stat() helper

* Split off checking of the status register from ide_wait_stat() to
__ide_wait_stat() helper.

* Use the new helper in ide_config_drive_speed(). The only change in the
functionality is that the function now fails if after 20 sec (WAIT_CMD)
device is still busy (BUSY_STAT bit is set) while previously instead of
failing the function continued with checking for the correct device status
(which would give the device additional 10 usec to clear BUSY_STAT bit).

* Remove stale comment for ide_config_drive_speed().

* Remove duplicate comment for ide_wait_stat() from <linux/ide.h>.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
26bcb879c03254545a19c6700fe5bcef6f21e7b1 11-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_set{_max}_pio() (take 4)

* Add IDE_HFLAG_ABUSE_{PREFETCH,FAST_DEVSEL,DMA_MODES} flags
and set them in ht6560, cmd640, cmd64x and sc1200 host drivers.

* Add set_pio_mode_abuse() for checking if host driver has a non-standard
->tuneproc() implementation and use it in do_special().

* Add ide_set_pio() for setting PIO mode (it uses hwif->pio_mask to find
the maximum PIO mode supported by the host), also add ide_set_max_pio()
wrapper for ide_set_pio() to use for auto-tuning. Convert users of
->tuneproc to use ide_set{_max}_pio() where possible. This leaves only
do_special(), set_using_pio(), ide_hwif_restore() and ide_set_pio() as
a direct users of ->tuneproc.

* Remove no longer needed ide_get_best_pio_mode() calls and printk-s
reporting PIO mode selected from ->tuneproc implementations.

* Rename ->tuneproc hook to ->set_pio_mode and make 'pio' argument const.

* Remove stale comment from ide_config_drive_speed().

v2:
* Fix "ata_" prefix (Noticed by Jeff).

v3:
* Minor cleanups/fixups per Sergei's suggestions.

v4:
* Fix compile problem in drivers/ide/pci/cmd640.c
(Noticed by Andrew Morton).

* Improve some ->set_pio_mode comments.

Reviewed-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f212ff28f08e4ddcef9f25b13463c45cc4204a0c 11-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move ide_rate_filter() calls to the upper layer (take 2)

* Move ide_rate_filter() calls from host drivers to IDE core.

* Make ide_rate_filter() static.

* Make 'speed' argument of ->speedproc const.

v2:
* Fix it8213_tune_chipset() comment.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7670df73fba373d19471a2ebedb3302ea0607be0 11-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: mode limiting fixes for user requested speed changes

* Add an extra argument to ide_max_dma_mode() for passing requested transfer
mode. Use it as an upper limit when finding the best DMA for device/host.

* Rename ide_max_dma_mode() to ide_find_dma_mode() and at the same time add
ide_max_dma_mode() wrapper which passes XFER_UDMA_6 as a requested mode to
ide_find_dma_mode(). Also add inline ide_find_dma_mode() version for
CONFIG_BLK_DEV_IDEDMA=n case.

* Pass requested transfer mode from ide_find_dma_mode() to ide_get_mode_mask()
to avoid false warning from eighty_ninty_three().

* Use ide_find_dma_mode() to limit the user requested transfer mode in
ide_rate_filter(). Also limit the requested mode by host max PIO mode.


Above changes make ide_rate_filter() to:

* Clip desired transfer mode down if it is invalid (values 0x0F, 0x13-0x19
and 0x25-0x39, values > 0x46 were already clipped down, same for values
0x25-0x39 but iff UDMA was not supported by the host).

* Clip desired transfer mode down if it is currently unsupported by IDE core
(PIO6 and MWDMA3-4, the latter were already clipped down but iff UDMA was
not supported by the host).

* Clip desired transfer mode down according to the host capabilities
(UDMA modes were already clipped down but MWDMA/SWDMA/PIO weren't,
also ->atapi_dma flag was not respected).

* Clip desired transfer mode down according to the device capabilities
(except PIO modes for now which require mode work) - shouldn't be a
problem since ide_set_xfer_rate() is called _after_ device has accepted
given transfer mode.

and also result in a number of host driver specific bugfixes:

* icside
- clip unsupported PIO5 mode down
- fix unsupported/invalid modes being set in drive->current_speed

* ide-cris
- clip unsupported PIO5 and SWDMA0-2 modes down
- clip DMA modes down for ATAPI devices
- fix BUG() on unsupported/invalid modes

* au1xxx-ide
- clip unsupported PIO5, SWDMA0-2 and MWDMA0-2
(if BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA=n) modes down

* aec62xx
- clip unsupported PIO5 and SWDMA0-2 modes down
- clip DMA modes down for ATAPI devices
- fix 0x00 being programmed as PIO timing for unsupported/invalid modes
- fix unsupported/invalid modes being set on the device

* alim15x3
- clip DMA modes down for ATAPI devices (chipset revision == 0x20 only)
- fix theoretical OOPS for 0x0F mode
- fix unsupported/invalid modes being set on the device

* amd74xx
- clip unsupported SWDMA0-2 (on COBRA_7401 revs <= 7) modes down
- fix random PIO timings being set for unsupported/invalid modes
- fix unsupported/invalid modes being set on the device

* atiixp
- clip unsupported PIO5 and SWDMA0-2 modes down
- fix cached MWDMA mode being cleared for unsupported/invalid modes
- fix PIO{0,2} timings being programmed for unsupported/invalid modes
- fix theoretical OOPS for PIO5-6 and 0x0F modes
- fix unsupported/invalid modes being set on the device

* cmd64x
- clip unsupported SWDMA0-2 modes down

* cs5530
- clip unsupported PIO5 and SWDMA0-2 modes down
- fix unsupported/invalid modes being set on the device
- fix BUG() on unsupported/invalid modes
(which happened if the device accepted the setting)

* cs5535
- clip unsupported PIO5 and SWDMA0-2 modes down
- fix unsupported/invalid modes being set on the device
- fix theoretical OOPS for PIO5-6 and 0x0F modes

* hpt34x
- clip DMA modes down for ATAPI devices
- fix invalid timings being programmed for unsupported/invalid modes
- fix unsupported/invalid modes being set on the device

* hpt366
- clip unsupported PIO5 and SWDMA0-2 modes down
- fix PIO0 timings being programmed for unsupported/invalid modes
- fix DMA timings being cleared for MWDMA3-4 and 0x25-0x39 modes
- fix unsupported/invalid modes being set on the device

* it8213
- clip unsupported PIO5, SWDMA0-1 and MWDMA0 modes down

* it821x
- clip unsupported PIO5 and SWDMA0-2 modes down
- clip DMA modes down for ATAPI devices
(chipset in smart mode and revision 0x10 in pass-through mode)

* jmicron
- clip unsupported SWDMA0-2 modes down
- fix unsupported/invalid modes being set on the device

* pdc202xx_new
- clip unsupported PIO5 and SWDMA0-2 modes down
- fix unsupported/invalid modes being set on the device

* pdc202xx_old
- clip unsupported PIO5 mode down
- fix incorrect timings being set for unsupported/invalid modes
- fix unsupported/invalid modes being set on the device

* piix
- clip unsupported PIO5, SWDMA0-1 and MWDMA0 modes down

* sc1200
- clip unsupported PIO5 and SWDMA0-2 modes down
- fix unsupported/invalid modes being set on the device
- fix BUG() on unsupported/invalid modes
(which happened if the device accepted the setting)

* scc_pata
- clip unsupported PIO5, SWDMA0-2 and MWDMA0-2 modes down

* serverworks
- clip unsupported PIO5 and SWDMA0-2 modes down
- fix DMA/UDMA timings/settings being cleared for unsupported/invalid modes
- fix unsupported/invalid modes being set on the device

* siimage
- clip unsupported PIO5 and SWDMA0-2 modes down
- clip DMA modes down for ATAPI devices (SATA chipsets)

* sis5513
- clip unsupported PIO5 mode down
- fix BUG() on unsupported/invalid modes

* sl82c105
- clip unsupported SWDMA0-2 modes down

* slc90e66
- clip unsupported PIO5, SWDMA0-1 and MWDMA0 modes down

* tc86c001
- clip unsupported PIO5 and SWDMA0-2 modes down
- fix PIO0 timings being programmed for PIO5/0x0F/SWDMA0-2/0x13-0x19 modes
- fix invalid 0x00 DMA timing being programmed for MWDMA3-4/0x25-0x39 modes
- fix unsupported/invalid modes being set on the device

* triflex
- clip unsupported PIO5 mode down

* via82cxxx
- fix random PIO timings being set for unsupported/invalid modes
- fix unsupported/invalid modes being set on the device

* pmac
- clip unsupported PIO5 and SWDMA0-2 modes down

* cmd640/ht6560b
- clip DMA modes down (if CONFIG_BLK_DEV_IDEDMA=y)
- fix PIO5 being clipped to PIO4 (if CONFIG_BLK_DEV_IDEDMA=n)

* opti621
- clip DMA modes down (if CONFIG_BLK_DEV_IDEDMA=y)
- clip unsupported PIO4 to PIO3 (if CONFIG_BLK_DEV_IDEDMA=n)


While at it:

* Use ide_rate_filter() in cs5520.c::cs5520_tune_chipset().

* Remove no longer needed checks from hpt366.c::hpt3{6,7}x_tune_chipset().

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5e32132befa5d2cefadf3141fee0bbb40cd11f0e 11-Oct-2007 Shaohua Li <shaohua.li@intel.com> ide: hook ACPI _PSx method to IDE power on/off

ACPI spec defines the sequence of IDE power on/off:
Powering down:
Call _GTM.
Power down drive (calls _PS3 method and turns off power planes).
Powering up:
Power up drive (calls _PS0 method if present and turns on power planes).
Call _STM passing info from _GTM (possibly modified), with ID data from
each drive.
Initialize the channel.
May modify the results of _GTF.
For each drive:
Call _GTF.
Execute task file (possibly modified).
This patch adds the missed _PS0/_PS3 methods call.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
Acked-by: Len Brown <len.brown@intel.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
b4e44369a380c1836d0983c2a5011099b7b26eb1 11-Oct-2007 Sergei Shtylyov <sshtylyov@ru.mvista.com> hpt366: MWDMA filter for SATA cards (take 2)

The Marvell bridge chips used on HighPoint SATA cards do not seem to support
the MWDMA modes (at least that could be seen in their so-called drivers :-),
so the driver needs to account for this -- to achieve this:

- add mdma_filter() method from the original patch by Bartlomiej Zolnierkiewicz
with his consent;

- install the method for all chips to only return empty mask if a SATA drive
is detected on HPT372{AN]/374 chips...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6c3c22f3cb2b7cd0a42a024b93db76b5c3133d37 11-Sep-2007 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: add ide_dev_is_sata() helper (take 2)

Make the SATA drive detection code from eighty_ninty_three() into inline
ide_dev_is_sata() helper fixing it along the way to be more strict while
checking word 80 for the reserved values...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
a5b7e70d787f528386eda025d3e38f545017f241 20-Aug-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add cable detection for early UDMA66 devices (take 3)

* Move ide_in_drive_list() from ide-dma.c to ide-iops.c.

* Add ivb_list[] table for listening early UDMA66 devices which don't conform
to ATA4 standard wrt cable detection (bit14 is zero, only bit13 is valid)
and use only device side cable detection for them since host side cable
detection may be unreliable.

* Add model "QUANTUM FIREBALLlct10 05" with firwmare "A03.0900" to the list
(from Craig's bugreport).

v2:
* Improve kernel message basing on suggestion from Sergei.

v3:
* Don't print kernel message when no device side cable detection is done,
plus some minor fixes. (Noticed by Sergei)

Thanks to Craig for testing this patch.

Cc: Craig Block <chblock3@yahoo.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1116fae5fdfa80c6744a9b5d75fb3ef687a69b19 20-Aug-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: config_drive_for_dma() fixes

* Add DMA blacklist checking (->ide_dma_on check probably can go now).

* Add ->atapi_dma flag checking and remove no longer needed
ns87415_ide_dma_check() from ns87415 host driver.

* Remove now needless __ide_dma_check() wrapper and symbol export.

* Check drive->autodma instead of hwif->autodma (there should be no changes in
behavior as all users of config_drive_for_dma() set both ->autodma flags).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
165125e1e480f9510a5ffcfbfee4e3ee38c05f23 24-Jul-2007 Jens Axboe <jens.axboe@oracle.com> [BLOCK] Get rid of request_queue_t typedef

Some of the code has been gradually transitioned to using the proper
struct request_queue, but there's lots left. So do a full sweet of
the kernel and get rid of this typedef and replace its uses with
the proper type.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
4099d14322149c7a467e4997b87be4ba8eb78697 20-Jul-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add PIO masks

* Add ATA_PIO[0-6] defines to <linux/ata.h>.

* Add ->pio_mask field to ide_pci_device_t and ide_hwif_t.

* Add PIO masks to host drivers.

<linux/ata.h> change ACK-ed by Jeff Garzik <jeff@garzik.org>.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6a824c92db4d606c324272c4eed366fb71672440 20-Jul-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_find_best_pio_mode()

* Add ->host_flags to ide_hwif_t to store ide_pci_device_t.host_flags,
assign it in setup-pci.c:ide_pci_setup_ports().

* Add IDE_HFLAG_PIO_NO_{BLACKLIST,DOWNGRADE} to ide_pci_device_t.host_flags
and teach ide_get_best_pio_mode() about them. Also remove needless
!drive->id check while at it (drive->id is always present).

* Convert amd74xx, via82cxxx and ide-timing.h to use ide_get_best_pio_mode()
and then remove no longer needed ide_find_best_pio_mode().

There should be no functionality changes caused by this patch.

Acked-by: Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2134758d2a5429325cee4d4ce8959af5314eeba1 20-Jul-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: drop "PIO data" argument from ide_get_best_pio_mode()

* Drop no longer needed "PIO data" argument from ide_get_best_pio_mode()
and convert all users accordingly.

* Remove no longer needed ide_pio_data_t.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7dd00083b1160b560fa2a0a486799b57baa5d035 20-Jul-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_pio_cycle_time() helper (take 2)

* Add ide_pio_cycle_time() helper.

* Use it in ali14xx/ht6560b/qd65xx/cmd64{0,x}/sl82c105 and pmac host drivers
(previously cycle time given by the device was only used for "pio" == 255).

* Remove no longer needed ide_pio_data_t.cycle_time field.

v2:
* Fix "ata_" prefix (Noticed by Jeff).

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
a5d8c5c834d3cabf4b7b477c3f6ee923c25026fc 20-Jul-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_pci_device_t.host_flags (take 2)

* Rename ide_pci_device_t.flags to ide_pci_device_t.host_flags
and IDEPCI_FLAG_ISA_PORTS flag to IDE_HFLAG_ISA_PORTS.

* Add IDE_HFLAG_SINGLE flag for single channel devices.

* Convert core code and all IDE PCI drivers to use IDE_HFLAG_SINGLE
and remove no longer needed ide_pci_device_t.channels field.

v2:
* Fix issues noticed by Sergei:
- correct code alignment in scc_pata.c
- s/IDE_HFLAG_SINGLE/~IDE_HFLAG_SINGLE/ in serverworks.c

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2229833c1365346b64357a9263fa724f74f5e376 20-Jul-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_dev_has_iordy() helper (take 4)

* Add ide_dev_has_iordy() helper and use it sl82c105 host driver.

* Remove no longer needed ide_pio_data_t.use_iordy field.

v2/v3:
* Fix issues noticed by Sergei:
- correct patch description
- fix comment in ide_get_best_pio_mode()

v4:
* Fix "ata_" prefix (Noticed by Jeff).

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
342cdb6d4739cee430efc3eafcacd1605db66036 20-Jul-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make ide_get_best_pio_mode() print info if overriding PIO mode

* Print info about overriding PIO mode in ide_get_best_pio_mode().

* Remove info about overriding PIO mode from cmd64{0,x} host drivers.

* Remove no longer needed ide_pio_data_t.overridden field.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
49521f97ccd3c2bf6e71a91cea8fe65d170fa4fb 09-Jul-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add short cables support

This patch allows users to override both host and device side cable detection
with "ideX=ata66" kernel parameter. Thanks to this it should be now possible
to use UDMA > 2 modes on systems (laptops mainly) which use short 40-pin cable
instead of 80-pin one.

Next patches add automatic detection of some systems using short cables.

Changes:

* Rename hwif->udma_four to hwif->cbl and make it u8.

* Convert all existing users accordingly (use ATA_CBL_* defines while at it).

* Add ATA_CBL_PATA40_SHORT support to ide-iops.c:eighty_ninty_three().

* Use ATA_CBL_PATA40_SHORT for "ideX=ata66" kernel parameter.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Reviewed-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
f9383c4269d264c3cf563bd2de365891f6592ebd 09-Jul-2007 Matthias Kaehlcke <matthias.kaehlcke@gmail.com> ide: use mutex instead of ide_setting_sem semaphore in IDE driver

The IDE driver uses a semaphore as mutex.
Use the mutex API instead of the (binary) semaphore.

Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

--
ef29888ea8e1fdc499e995260195b66fc91d2728 09-Jul-2007 Matthias Kaehlcke <matthias.kaehlcke@gmail.com> ide: use mutex instead of ide_cfg_sem semaphore in IDE driver

The IDE driver uses a semaphore as mutex.
Use the mutex API instead of the (binary) semaphore.

Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c283f5dbe31920ca70b80a594a97bfaa2a28be13 09-Jul-2007 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: make void and rename ide_dma_timeout() method

Since ide_dma_timeout() method's result is discarded, make it return 'void'.
While at it, drop 'ide_' from the method's name, drop the '__' prefix from
the default method's name, and do some cleanups in this method driver-wise:

- in ide-dma.c, au1xxx-ide.c, and pdc202xx_old.c, define/use 'hwif' variable;

- in au1xxx-ide.c, get rid of commented out printk();

- in sl82c105.c, get rid of unnecessary variables.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
841d2a9bf16471716ba3a5172d24aa40a2ea9398 09-Jul-2007 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: make void and rename ide_dma_lostirq() method

Since ide_dma_lostirq() method's result is discarded, make it return 'void'.
While at it, rename the method to dma_lost_irq(), drop the '__' prefix from the
default method's name, and do some cleanups in this method driver-wise:

- in aec62xx.c, rename the method in accordance with other drivers, and get rid
of unnecessary variables there;

- in pdc202xx_old.c, define/use 'hwif' variable;

- in sgiioc4.c, rearrange the code to call the resetproc() method directly.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
0d2157f78d17fcee17791f54959e67cc0af0da74 08-Jun-2007 Lee Trager <lt73@cs.drexel.edu> ide: HPA detect from resume

Currently when system which have HPA require HPA to be detected and
disabled upon resume from RAM or disk. The current IDE drivers do not do
this nor does libata (obviously it since it doesn't support HPA yet).

I have implemented this into the current IDE drivers and it has been
tested by many others since 7/15/2006 in bug number 6840:

http://bugzilla.kernel.org/show_bug.cgi?id=6840

and it has been confirmed to work fine with no problems.

bart: added drv != NULL check to generic_ide_suspend()

From: Lee Trager <lt73@cs.drexel.edu>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
122ab0887c36247bd4508c25e4fccf9264546fe2 16-May-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_use_dma()

ide_use_dma() duplicates a lot of ide_max_dma_mode() functionality
and as all users of ide_use_dma() were converted to use ide_tune_dma()
now it is possible to add missing checks to ide_tune_dma() and remove
ide_use_dma() completely, so do it.

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4728d546d7137ad5350cc2e53d4748fd26f61a60 16-May-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_dma_enable()

* check ->speedproc return value in ide_tune_dma()
* use ide_tune_dma() in cmd64x/cs5530/sc1200/siimage/sl82c105/scc_pata drivers
* remove no longer needed ide_dma_enable()

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6d208b39c45edee5def6c201fcd51561c5a39828 10-May-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: legacy PCI bus order probing fixes

IDE PCI host drivers should register themselves with IDE core only when
IDE driver is built-in, otherwise (IDE driver is modular and thus IDE PCI
host drivers are also modular) the code has no effect and just complicates
the probing.

Fix it by adding new config option CONFIG_IDEPCI_PCIBUS (defined only when
needed and invisible to the user) and covering by #ifdef/#endif the code
in question. It turned out that "ide=reverse" was silently accepted but did
nothing in case when IDE driver was modular, this is fixed now.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
5cbf79cdb37be2aa2a1b4fa94144526b14557060 10-May-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_proc_register_port()

* create_proc_ide_interfaces() tries to add /proc entries for every probed
and initialized IDE port, replace it by ide_proc_register_port() which does
it only for the given port (also rename destroy_proc_ide_interface() to
ide_proc_unregister_port() for consistency)

* convert {create,destroy}_proc_ide_interface[s]() users to use new functions

* pmac driver depended on proc_ide_create() to add /proc port entries, fix it

* au1xxx-ide, swarm and cs5520 drivers depended indirectly on ide-generic
driver (CONFIG_IDE_GENERIC=y) to add port /proc entries, fix them

* there is now no need to add /proc entries for IDE ports in proc_ide_create()
so don't do it

* proc_ide_create() needs now to be called before drivers are probed - fix it,
while at it make proc_ide_create() create /proc "ide" directory

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
869c56ee9de1b72cd3f8ab9cdfbd3601e55c61f2 10-May-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add "initializing" argument to ide_register_hw()

Add "initializing" argument to ide_register_hw() and use it instead of ide.c
wide variable of the same name. Update all users of ide_register_hw()
accordingly.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7f8f48af0861c38c28d4abd550102643e0ea9e6a 10-May-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: cable detection fixes (take 2)

Tejun's recent eighty_ninty_three() fix has inspired me to do more thorough
review of the cable detection code...

* print user-friendly warning about limiting the maximum transfer speed
to UDMA33 (and the reason behind it) when 80-wire cable is not detected,
also while at it cleanup eighty_ninty_three() a bit

* use eighty_ninty_three() in ide_ata66_check(), this actually fixes 3 bugs:
- bit 14 (word 93 validity check) == 1 && bit 13 (80-wire cable test) == 1
were used as 80-wire cable present test for CONFIG_IDEDMA_IVB=n case
(please see FIXME comment in eighty_ninty_three() for more details)
- CONFIG_IDEDMA_IVB=y/n cases were interchanged
- check for SATA devices was missing

* remove private cable warnings from pdc_202xx{old,new} drivers now that core
code provides this functionality (plus, in pdc202xx_new case the test could
give false warnings for ATAPI devices because pdc202xx_new driver doesn't
even support ATAPI DMA)

Cc: Tejun Heo <htejun@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7662d046df09e80680b77b68de896beab45e675e 10-May-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move IDE settings handling to ide-proc.c

* move
__ide_add_setting()
ide_add_setting()
__ide_remove_setting()
auto_remove_settings()
ide_find_setting_by_name()
ide_read_setting()
ide_write_setting()
set_xfer_rate()
ide_add_generic_settings()
ide_register_subdriver()
ide_unregister_subdriver()

from ide.c to ide-proc.c

* set_{io_32bit,pio_mode,using_dma}() cannot be marked static now, fix it

* rename ide_[un]register_subdriver() to ide_proc_[un]register_driver(),
update device drivers to use new names

* add CONFIG_IDE_PROC_FS=n versions of ide_proc_[un]register_driver()
and ide_add_generic_settings()

* make ide_find_setting_by_name(), ide_{read,write}_setting()
and ide_{add,remove}_proc_entries() static

* cover IDE settings code in device drivers with CONFIG_IDE_PROC_FS #ifdef,
also while at it cover with CONFIG_IDE_PROC_FS #ifdef ide_driver_t.proc

* remove bogus comment from ide.h

* cover with CONFIG_IDE_PROC_FS #ifdef .proc and .settings in ide_drive_t

Besides saner code this patch results in the IDE core smaller by ~2 kB
(on x86-32) and IDE disk driver by ~1 kB (ditto) when CONFIG_IDE_PROC_FS=n.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1497943ee692aa7519fa972d0e3a339649bf3a96 10-May-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: split off ioctl handling from IDE settings (v2)

* do write permission and min/max checks in ide_procset_t functions

* ide-disk.c: drive->id is always available so cleanup "multcount" setting
accordingly

* ide-disk.c: "address" setting was incorrectly defined as type TYPE_INTA,
fix it by using type TYPE_BYTE and updating ide_drive_t->adressing field,
the bug didn't trigger because this IDE setting uses custom ->set function

* ide.c: add set_ksettings() for handling HDIO_SET_KEEPSETTINGS ioctl

* ide.c: add set_unmaskirq() for handling HDIO_SET_UNMASKINTR ioctl

* handle ioctls directly in generic_ide_ioclt() and idedisk_ioctl()
instead of using IDE settings to deal with them

* remove no longer needed ide_find_setting_by_ioctl() and {read,write}_ioctl
fields from ide_settings_t, also remove now unused TYPE_INTA handling

v2:
* add missing EXPORT_SYMBOL_GPL(ide_setting_sem) needed now for ide-disk

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ecfd80e4a514123070b4cfb674b817ba75055df2 10-May-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make /proc/ide/ optional

All important information/features should be already available through
sysfs and ioctl interfaces.

Add CONFIG_IDE_PROC_FS (CONFIG_SCSI_PROC_FS rip-off) config option,
disabling it makes IDE driver ~5 kB smaller (on x86-32).

While at it add CONFIG_PROC_FS=n versions of proc_ide_{create,destroy}()
and remove no longer needed #ifdefs.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
29e744d088e3555f4efbdf390f01088dd66993b6 10-May-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_tune_dma() helper

After reworking the code responsible for selecting the best DMA
transfer mode it is now possible to add generic ide_tune_dma() helper.

Convert some IDE PCI host drivers to use it (the ones left need more work).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2d5eaa6dd744a641e75503232a01f52d0768884c 10-May-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: rework the code for selecting the best DMA transfer mode (v3)

Depends on the "ide: fix UDMA/MWDMA/SWDMA masks" patch.

* add ide_hwif_t.udma_filter hook for filtering UDMA mask
(use it in alim15x3, hpt366, siimage and serverworks drivers)
* add ide_max_dma_mode() for finding best DMA mode for the device
(loosely based on some older libata-core.c code)
* convert ide_dma_speed() users to use ide_max_dma_mode()
* make ide_rate_filter() take "ide_drive_t *drive" as an argument instead
of "u8 mode" and teach it to how to use UDMA mask to do filtering
* use ide_rate_filter() in hpt366 driver
* remove no longer needed ide_dma_speed() and *_ratemask()
* unexport eighty_ninty_three()

v2:
* rename ->filter_udma_mask to ->udma_filter
[ Suggested by Sergei Shtylyov <sshtylyov@ru.mvista.com>. ]

v3:
* updated for scc_pata driver (fixes XFER_UDMA_6 filtering for user-space
originated transfer mode change requests when 100MHz clock is used)

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
18137207236285989dfc0ee7f929b954199228f3 10-May-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix UDMA/MWDMA/SWDMA masks (v3)

* use 0x00 instead of 0x80 to disable ->{ultra,mwdma,swdma}_mask
* add udma_mask field to ide_pci_device_t and use it to initialize
->ultra_mask in aec62xx, cmd64x, pdc202xx_{new,old} and piix drivers
* fix UDMA masks to match with chipset specific *_ratemask()
(alim15x3, hpt366, serverworks and siimage drivers need UDMA mask
filtering method - done in the next patch)

v2:
* piix: fix cable detection for 82801AA_1 and 82372FB_1
[ Noticed by Sergei Shtylyov <sshtylyov@ru.mvista.com>. ]
* cmd64x: use hwif->cds->udma_mask
[ Suggested by Sergei Shtylyov <sshtylyov@ru.mvista.com>. ]
* aec62xx: fix newly introduced bug - check DMA status not command register
[ Noticed by Sergei Shtylyov <sshtylyov@ru.mvista.com>. ]

v3:
* piix: use hwif->cds->udma_mask
[ Suggested by Sergei Shtylyov <sshtylyov@ru.mvista.com>. ]

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
e93df705af1992dbf5956a8c80fcb9987bc595c0 05-May-2007 Sergei Shtylyov <sshtylyov@ru.mvista.com> sl82c105: rework PIO support (take 2)

Get rid of the 'pio_speed' member of 'ide_drive_t' that was only used by this
driver by storing the PIO mode timings in the 'drive_data' instead -- this
allows us to greatly simplify the process of "reloading" of the chip's timing
register and do it right in sl82c150_dma_off_quietly() and to get rid of two
extra arguments to config_for_pio() -- which got renamed to sl82c105_tune_pio()
and now returns a PIO mode selected, with ide_config_drive_speed() call moved
into the tuneproc() method, now called sl82c105_tune_drive() with the code to
set drive's 'io_32bit' and 'unmask' flags in its turn moved to its proper place
in the init_hwif() method.
Also, while at it, rename get_timing_sl82c105() into get_pio_timings() and get
rid of the code in it clamping cycle counts to 32 which was both incorrect and
never executed anyway...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
23450319e2890986c247ec0aa1442f060e657e6d 10-Apr-2007 Suleiman Souhlal <suleiman@google.com> ide: correctly prevent IDE timer expiry function to run if request was already handled

It is possible for the timer expiry function to run even though the
request has already been handled: ide_timer_expiry() only checks that
the handler is not NULL, but it is possible that we have handled a
request (thus clearing the handler) and then started a new request
(thus starting the timer again, and setting a handler).

A simple way to exhibit this is to set the DMA timeout to 1 jiffy and
run dd: The kernel will panic after a few minutes because
ide_timer_expiry() tries to add a timer when it's already active.

To fix this, we simply add a request generation count that gets
incremented at every interrupt, and check in ide_timer_expiry() that
we have not already handled a new interrupt before running the expiry
function.

Signed-off-by: Suleiman Souhlal <suleiman@google.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
513daadd152ddbf32cb6d0447ddba3427ce5b8e8 26-Mar-2007 Suleiman Souhlal <suleiman@google.com> ide: use correct IDE error recovery

IDE error recovery is using IDLE IMMEDIATE if the drive is busy or has DRQ set.
This violates the ATA spec (can only send IDLE IMMEDIATE when drive is not
busy) and really hoses up some drives (modern drives will not be able to
recover using this error handling). The correct thing to do is issue a SRST
followed by a SET FEATURES command. This is what Western Digital recommends
for error recovery and what Western Digital says Windows does.  It also does
not violate the ATA spec as far as I can tell.

Bart:
* port the patch over the current tree
* undo the recalibration code removal
* send SET FEATURES command after checking for good drive status
* don't check whether the current request is of REQ_TYPE_ATA_{CMD,TASK}
type because we need to send SET FEATURES before handling any requests
* some pre-ATA4 drives require INITIALIZE DEVICE PARAMETERS command before
other commands (except IDENTIFY) so send SET FEATURES only if there are
no pending drive->special requests
* update comments and patch description
* any bugs introduced by this patch are mine and not Suleiman's :-)

Signed-off-by: Suleiman Souhlal <suleiman@google.com>
Acked-by: Alan Cox <alan@redhat.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
81d368e0e2591497106b2543918c79dd6d78277b 03-Mar-2007 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: ide_get_best_pio_mode() returns incorrect IORDY setting (take 2)

The function ide_get_best_pio_mode() fails to return the correct IORDY setting
for the explicitly specified modes -- fix this along with the heading comment,
and also remove the long commented out code.

Also, while at it, correct the misliading comment about the PIO cycle time in
<linux/ide.h> -- it actually consists of only the active and recovery periods,
with only some chips also including the address setup time into equation...

[ bart: sl82c105 seems to be currently the only driver affected by this fix ]

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ccf352894ceef79d40d015e1deee4c46c3aa42ed 17-Feb-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make ide_hwif_t.ide_dma_host_on void (v2)

* since ide_hwif_t.ide_dma_host_on is called either when drive->using_dma == 1
or when return value is discarded make it void, also drop "ide_" prefix
* make __ide_dma_host_on() void and drop "__" prefix

v2:
* while at it rename atiixp_ide_dma_host_on() to atiixp_dma_host_on()
and sgiioc4_ide_dma_host_on() to sgiioc4_dma_host_on().
[ Noticed by Sergei Shtylyov <sshtylyov@ru.mvista.com>. ]

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7469aaf6a30f4187ed6de7c0aed5c2dd2d1c2d31 17-Feb-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make ide_hwif_t.ide_dma_{host_off,off_quietly} void (v2)

* since ide_hwif_t.ide_dma_{host_off,off_quietly} always return '0'
make these functions void and while at it drop "ide_" prefix
* fix comment for __ide_dma_off_quietly()
* make __ide_dma_{host_off,off_quietly,off}() void and drop "__" prefix

v2:
* while at it rename atiixp_ide_dma_host_off() to atiixp_dma_host_off(),
sgiioc4_ide_dma_{host_off,off_quietly}() to sgiioc4_dma_{host_off,off_quietly}()
and sl82c105_ide_dma_off_quietly() to sl82c105_dma_off_quietly()
[ Noticed by Sergei Shtylyov <sshtylyov@ru.mvista.com>. ]

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
3608b5d71a52c053787dbad6af20c25f7e0b75a9 17-Feb-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_set_dma() helper (v2)

* add ide_set_dma() helper and make ide_hwif_t.ide_dma_check return
-1 when DMA needs to be disabled (== need to call ->ide_dma_off_quietly)
0 when DMA needs to be enabled (== need to call ->ide_dma_on)
1 when DMA setting shouldn't be changed
* fix IDE code to use ide_set_dma() instead if using ->ide_dma_check directly

v2:
* updated for scc_pata

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2ad1e558a2305c2b3d5099ee2f4a5929307c20ca 17-Feb-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: convert ide_hwif_t.mmio into flag (v2)

All users of ->mmio == 1 are gone so convert ->mmio into flag.

Noticed by Alan Cox.

v2:
* updated for scc_pata

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
0ecdca26e556eae9668ce6de9554757dddb942ef 17-Feb-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use PIO/MMIO operations directly where possible (v2)

This results in smaller/faster/simpler code and allows future optimizations.
Also remove no longer needed ide[_mm]_{inl,outl}() and ide_hwif_t.{INL,OUTL}.

v2:
* updated for scc_pata

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
7569e8dc2213ecc47024ea5edbadc8736487d926 17-Feb-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_use_fast_pio() helper (v3)

* add ide_use_fast_pio() helper for use by host drivers

* add DMA capability and hwif->autodma checks to ide_use_dma()

- au1xxx-ide/it8213/it821x drivers didn't check for (id->capability & 1)

[ for the IT8211/2 in SMART mode this check shouldn't be made but since
in it821x_fixups() we set DMA bit explicitly:

if(strstr(id->model, "Integrated Technology Express")) {
/* In raid mode the ident block is slightly buggy
We need to set the bits so that the IDE layer knows
LBA28. LBA48 and DMA ar valid */
id->capability |= 3; /* LBA28, DMA */

we are better off using generic helper if we can ]

- ide-cris driver didn't set ->autodma

[ before the patch hwif->autodma was only checked in the chipset specific
hwif->ide_dma_check implementations, for ide-cris it is cris_dma_check()
function so there no behavior change here ]

v2:
* updated patch description (thanks to Alan Cox for the feedback)

v3:
* updated for scc_pata driver

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c94964a4555eb58be3f45edf2b63a2b3f549ef29 17-Feb-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_drive_t.usage

This field is no longer used by the core IDE code so fix ide-{disk,floppy}
drivers to keep openers count in the driver specific objects and remove
it from ide-{cd,scsi,tape} drivers (it was write-only).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
c1607e1af238b823a2158a18ff6c89144ce38c6c 17-Feb-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove write-only ide_hwif_t.no_dsc flag

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6679054895f9b1dc676d14637306b297451f1ac0 17-Feb-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove write-only ide_pio_data_t.blacklisted

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
6e6cd4c4388f399dd5726b826f02732c53df3ba5 17-Feb-2007 Albert Lee <albertcc@tw.ibm.com> ide: remove clearing bmdma status from cdrom_decode_status() (rev #4)

patch 2/2:
Remove clearing bmdma status from cdrom_decode_status() since ATA devices
might need it as well.

(http://lkml.org/lkml/2006/12/4/201 and http://lkml.org/lkml/2006/11/15/94)

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: "Adam W. Hawks" <awhawks@us.ibm.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
f0dd8712eb8cc5687b4582fbc41cfbcd55bba0d2 17-Feb-2007 Albert Lee <albertcc@tw.ibm.com> ide: clear bmdma status in ide_intr() for ICHx controllers (revised #4)

patch 1/2 (revised):
- Fix drive->waiting_for_dma to work with CDB-intr devices.
- Do the dma status clearing in ide_intr() and add a new
hwif->ide_dma_clear_irq for Intel ICHx controllers.

Revised per Alan, Sergei and Bart's advice.

Patch against 2.6.20-rc6. Tested ok on my ICH4 and pdc20275 adapters.
Please review/apply, thanks.

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: "Adam W. Hawks" <awhawks@us.ibm.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
725522b5453dd680412f2b6463a988e4fd148757 15-Jan-2007 Greg Kroah-Hartman <gregkh@suse.de> PCI: add the sysfs driver name to all modules

This adds the module name to all PCI drivers, if they are built into the
kernel or not. It will show up in /sys/modules/MODULE_NAME/drivers/

It also fixes up the IDE core, which was calling __pci_register_driver()
directly.

Cc: Kay Sievers <kay.sievers@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
e3a59b4d9378522479609042836ae930305a67fe 07-Feb-2007 Hannes Reinecke <hare@suse.de> ACPI support for IDE devices

This patch implements ACPI integration for generic IDE devices.
The ACPI spec mandates that some methods are called during suspend and
resume. And consequently there most modern Laptops cannot resume
properly without it.

According to the spec, we should call '_GTM' (Get Timing) upon suspend
to store the current IDE adapter settings.
Upon resume we should call '_STM' (Set Timing) to initialize the
adapter with the stored settings; afterwards '_GTF' (Get Taskfile)
should be called which returns a buffer with some IDE initialisation
commands. Those commands should be passed to the drive.

There are two module params which control the behaviour of this patch:

'ide=noacpi'
Do not call any ACPI methods (Disables any ACPI method calls)
'ide=acpigtf'
Enable execution of _GTF methods upon resume.
Has no effect if 'ide=noacpi' is set.
'ide=acpionboot'
Enable execution of ACPI methods during boot.
This might be required on some machines if 'ide=acpigtf' is
selected as some machines modify the _GTF information
depending on the drive identification passed down with _STM.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2b02a1792000900ead4638f4d42fcdd742062cfa 05-Dec-2006 Boaz Harrosh <bharrosh@panasas.com> [PATCH] remove blk_queue_activity_fn

While working on bidi support at struct request level
I have found that blk_queue_activity_fn is actually never used.
The only user is in ide-probe.c with this code:

/* enable led activity for disk drives only */
if (drive->media == ide_disk && hwif->led_act)
blk_queue_activity_fn(q, hwif->led_act, drive);

And led_act is never initialized anywhere.
(Looking back at older kernels it was used in the PPC arch, but was removed around 2.6.18)
Unless it is all for future use off course.
(this patch is against linux-2.6-block.git as off 2006/12/4)

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
ee2f344b33b507af23610c8fdfdde38d7c10fb33 10-Dec-2006 Alan Cox <alan@lxorguk.ukuu.org.uk> [PATCH] ide-cd: Handle strange interrupt on the Intel ESB2

The ESB2 appears to emit spurious DMA interrupts when configured for native
mode and handling ATAPI devices. Stratus were able to pin this bug down and
produce a patch. This is a rework which applies the fixup only to the ESB2
(for now). We can apply it to other chips later if the same problem is found.

This code has been tested and confirmed to fix the problem on the tested
systems.

Signed-off-by: Alan Cox <alan@redhat.com>
(Most of the hard work done by Stratus however)
Cc: Jens Axboe <axboe@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
7d12e780e003f93433d49ce78cfedf4b4c52adc5 05-Oct-2006 David Howells <dhowells@redhat.com> IRQ: Maintain regs pointer globally rather than passing to IRQ handlers

Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.

The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).

Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.

Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.

I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.

This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:

struct pt_regs *old_regs = set_irq_regs(regs);

And put the old one back at the end:

set_irq_regs(old_regs);

Don't pass regs through to generic_handle_irq() or __do_IRQ().

In timer_interrupt(), this sort of change will be necessary:

- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);

I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().

Some notes on the interrupt handling in the drivers:

(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.

(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.

(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.

Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
913759ac90a727b86da72efcfb70931f497d1cb7 03-Oct-2006 Alan Cox <alan@lxorguk.ukuu.org.uk> [PATCH] ide: Fix crash on repeated reset

Michal Miroslaw reported a problem (bugzilla #7023) where a user initiated
reset while the IDE layer was already resetting the channel caused a crash,
and provided a rough fix.

This is a slightly cleaner version of the fix which tracks the reset state
and blocks further reset requests while a reset is in progress.

Note this is not a security issue - random end users can't access the
ioctl in question anyway.

Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Michal Miroslaw <mirq-linux@rere.qmqm.pl>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
3f63c5e88a5ce45b423f3712293f1664115b09c0 03-Oct-2006 Sergei Shtylyov <sshtylyov@ru.mvista.com> [PATCH] ide: remove dma_base2 field from ide_hwif_t

Remove dma_base2 field from ide_hwif_t as it's used only in 2 drivers and
without great need.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: John Keller <jpk@sgi.com>
Signed-off-by: Jeremy Higdon <jeremy@sgi.com>
Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
27ac6036f31dea8117ecc525e0dbfd17b23e8c09 03-Oct-2006 Adrian Bunk <bunk@stusta.de> [PATCH] drivers/ide/: cleanups

- setup-pci.c: remove the unused ide_pci_unregister_driver()
- ide-dma.c: remove the unused EXPORT_SYMBOL_GPL(ide_in_drive_list)

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
83d7dbc4095a0c314b191c573be5fb4fa6ce0897 03-Oct-2006 Matt Mackall <mpm@selenic.com> [PATCH] Make number of IDE interfaces configurable

Make IDE_HWIFS configurable if EMBEDDED

This lets us lop as much as 16k off an x86 build. It's a little ugly, but
it's dead simple. Note the fix for HWIFS < 2.

Sizing interfaces dynamically unfortunately turns out to be pretty
major surgery.

add/remove: 0/1 grow/shrink: 0/11 up/down: 0/-16182 (-16182)
function old new delta
ide_hwifs 16920 1692 -15228
init_irq 1113 750 -363
ideprobe_init 283 138 -145
ide_pci_setup_ports 1329 1193 -136
save_match 85 - -85
ide_register_hw_with_fixup 367 287 -80
ide_setup 1364 1308 -56
is_chipset_set 40 4 -36
create_proc_ide_interfaces 225 205 -20
init_ide_data 84 67 -17
ide_probe_for_cmd640x 1198 1183 -15
ide_unregister 1452 1451 -1

Signed-off-by: Matt Mackall <mpm@selenic.com>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
020e322de3ff75d32daa58e431aad07071da27c6 03-Oct-2006 Sergei Shtylylov <sshtylyov@ru.mvista.com> [PATCH] IDE: claim extra DMA ports regardless of channel

- Claim extra DMA I/O ports regardless of what IDE channels are
present/enabled.

- Remove extra ports handling from ide_mapped_mmio_dma() since it's not
applicable to the custom-mapping IDE drivers.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
361934849e9c0418950bedf667732f36337d88b9 28-Jul-2006 Jens Axboe <axboe@suse.de> [PATCH] ide: option to disable cache flushes for buggy drives

Some drives claim they support cache flushing, but get seriously
confused if you try. Add this option to be able to boot with
barriers enabled by default.

Signed-off-by: Jens Axboe <axboe@suse.de>
366c7f554e888e51b8395f9b07b273fe775c7ff3 03-Jul-2006 Ingo Molnar <mingo@elte.hu> [PATCH] lockdep: annotate enable_in_hardirq()

Make use of local_irq_enable_in_hardirq() API to annotate places that enable
hardirqs in hardirq context.

Has no effect on non-lockdep kernels.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
da574af755bcb1d604e01feadf2a8c31b364447c 28-Jun-2006 Alan Cox <alan@lxorguk.ukuu.org.uk> [PATCH] ide: fix error handling for drives which clear the FIFO on error

If the controller FIFO cleared automatically on error we must not try
and drain it as this will hang some chips.

Based in concept on a broken patch from -mm some while back

Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
94f6c59dcf16f10a20fbe3d1f098b159433f94bd 21-Jun-2005 Greg Kroah-Hartman <gregkh@suse.de> [PATCH] devfs: Remove devfs support from the ide subsystem.

Also removes the ide drive devfs_name field as it's no longer needed

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
dbe217af3be08346f4b1abb885c2d9ec29c98fac 25-Jun-2006 Alan Cox <alan@lxorguk.ukuu.org.uk> [PATCH] IDE CD end-of media error fix

This is a patch from Alan that fixes a real ide-cd.c regression causing
bogus "Media Check" failures for perfectly valid Fedora install ISOs, on
certain CD-ROM drives.

This is a forward port to 2.6.16 (from RHEL) of the minimal changes for the
end of media problem. It may not be sufficient for some controllers
(promise notably) and it does not touch the locking so the error path
locking is as horked as in mainstream.

From: Ingo Molnar <mingo@elte.hu>

I have ported the patch to 2.6.17-rc4 and tested it by provoking
end-of-media IO errors with an unaligned ISO image. Unlike the vanilla
kernel, the patched kernel interpreted the error condition correctly with
512 byte granularity:

hdc: command error: status=0x51 { DriveReady SeekComplete Error }
hdc: command error: error=0x54 { AbortedCommand LastFailedSense=0x05 }
ide: failed opcode was: unknown
ATAPI device hdc:
Error: Illegal request -- (Sense key=0x05)
Illegal mode for this track or incompatible medium -- (asc=0x64, ascq=0x00)
The failed "Read 10" packet command was:
"28 00 00 04 fb 78 00 00 06 00 00 00 00 00 00 00 "
end_request: I/O error, dev hdc, sector 1306080
Buffer I/O error on device hdc, logical block 163260
Buffer I/O error on device hdc, logical block 163261
Buffer I/O error on device hdc, logical block 163262

the unpatched kernel produces an incorrect error dump:

hdc: command error: status=0x51 { DriveReady SeekComplete Error }
hdc: command error: error=0x54 { AbortedCommand LastFailedSense=0x05 }
ide: failed opcode was: unknown
end_request: I/O error, dev hdc, sector 1306080
Buffer I/O error on device hdc, logical block 163260
hdc: command error: status=0x51 { DriveReady SeekComplete Error }
hdc: command error: error=0x54 { AbortedCommand LastFailedSense=0x05 }
ide: failed opcode was: unknown
end_request: I/O error, dev hdc, sector 1306088
Buffer I/O error on device hdc, logical block 163261
hdc: command error: status=0x51 { DriveReady SeekComplete Error }
hdc: command error: error=0x54 { AbortedCommand LastFailedSense=0x05 }
ide: failed opcode was: unknown
end_request: I/O error, dev hdc, sector 1306096
Buffer I/O error on device hdc, logical block 163262

I do not have the right type of CD-ROM drive to reproduce the end-of-media
data corruption bug myself, but this same patch in RHEL solved it.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Cc: Jens Axboe <axboe@suse.de>
Cc: Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
62c4f0a2d5a188f73a94f2cb8ea0dba3e7cf0a7f 26-Apr-2006 David Woodhouse <dwmw2@infradead.org> Don't include linux/config.h from anywhere else in include/

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
d3a7b202995421631f486313aacf9ab2ad48b2c8 19-Apr-2006 Adrian Bunk <bunk@stusta.de> [PATCH] remove the obsolete IDEPCI_FLAG_FORCE_PDC

Noted by Sergei Shtylylov <sshtylyov@ru.mvista.com>

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
208a08f7cc2a8932ed76162d9844f9ae7d7fc015 24-Mar-2006 Kumar Gala <galak@kernel.crashing.org> [PATCH] ide: Allow IDE interface to specify its not capable of 32-bit operations

In some embedded systems the IDE hardware interface may only support 16-bit
or smaller accesses. Allow the interface to specify if this is the case
and don't allow the drive or user to override the setting.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
a7ff7d41fec06c518caa82a818a70610a29d0e75 03-Feb-2006 Adrian Bunk <bunk@stusta.de> [PATCH] drivers/ide/ide-io.c: make __ide_end_request() static

Since there's no longer any external user, we can make __ide_end_request()
static.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Acked-by: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
9810933701a09f9c4dd0ad963d5ec2efb7df07b7 03-Feb-2006 Richard Purdie <rpurdie@rpsys.net> [PATCH] stop CompactFlash devices being marked as removable

This patch stops CompactFlash devices being marked as removable. They are
not removable (as defined by Linux) as the media and device are
inseparable. When a card is removed, the whole device is removed from the
system and never sits in a media-less state.

This stops some nasty udev device creation/destruction loops.

Further, once this change is made, there is no need for ide to can be
removed from ide_drive_t.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Acked-by: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
4031bbe4bbec6c0fe50412ef7fb43a270b0f29f1 06-Jan-2006 Russell King <rmk@arm.linux.org.uk> [PATCH] Add ide_bus_type probe and remove methods

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
ba027def7be0d6494b72603d5758acc0fb1c7514 12-Jan-2006 Jens Axboe <axboe@suse.de> [PATCH] Revert ide softirq handling

There's a problem with the REQ_BLOCK_PC handling as well (bad ->data_len
handling) where it could actually complete a request ahead of time. I
suggest we just back this out for now, I will resubmit it later when I'm
fully confident in it.

This reverts commit 8672d57138b34447719cd7749f3d21070e1175a1

Signed-off-by: Jens Axboe <axboe@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
f36d4024caa3790606e43228a574157c45b73b22 10-Jan-2006 Aleksey Makarov <amakarov@ru.mvista.com> [PATCH] mutex subsystem, semaphore to completion: IDE ->gendev_rel_sem

The patch changes semaphores that are initialized as
locked to complete().

Source: MontaVista Software, Inc.

Modified-by: Steven Rostedt <rostedt@goodmis.org>

The following patch is from Montavista. I modified it slightly.
Semaphores are currently being used where it makes more sense for
completions. This patch corrects that.

Signed-off-by: Aleksey Makarov <amakarov@ru.mvista.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
8672d57138b34447719cd7749f3d21070e1175a1 09-Jan-2006 Jens Axboe <axboe@suse.de> [IDE] Use the block layer deferred softirq request completion

This patch makes IDE use the new blk_complete_request() interface.
There's still room for improvement, as __ide_end_request() really
could drop the lock after getting HWGROUP->rq (why does it need to
hold it in the first place? If ->rq access isn't serialized, we are
screwed anyways).

Signed-off-by: Jens Axboe <axboe@suse.de>
22fc6eccbf4ce4eb6265e6ada7b50a7b9cc57d05 08-Jan-2006 Ravikiran G Thirumalai <kiran@scalex86.org> [PATCH] Change maxaligned_in_smp alignemnt macros to internodealigned_in_smp macros

____cacheline_maxaligned_in_smp is currently used to align critical structures
and avoid false sharing. It uses per-arch L1_CACHE_SHIFT_MAX and people find
L1_CACHE_SHIFT_MAX useless.

However, we have been using ____cacheline_maxaligned_in_smp to align
structures on the internode cacheline size. As per Andi's suggestion,
following patch kills ____cacheline_maxaligned_in_smp and introduces
INTERNODE_CACHE_SHIFT, which defaults to L1_CACHE_SHIFT for all arches.
Arches needing L3/Internode cacheline alignment can define
INTERNODE_CACHE_SHIFT in the arch asm/cache.h. Patch replaces
____cacheline_maxaligned_in_smp with ____cacheline_internodealigned_in_smp

With this patch, L1_CACHE_SHIFT_MAX can be killed

Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Signed-off-by: Shai Fultheim <shai@scalex86.org>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
7b4df9ece9b4c4a754bd1f5603cdabff26b987e5 15-Dec-2005 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> [PATCH] ide: cleanup ide_driver_t

Remove unused fields: ioctl, ata[pi]_prebuilder.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
517bd1d5eac739a7f398058a9524386667fff032 15-Dec-2005 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> [PATCH] ide: cleanup ide.h

Remove:
* stale comment
* unused HOST() macro
* unused ata_{error,control}_t types
* unused atapi_select_t type
* ide_init_subdrivers() prototype

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
65e5f2e3b457b6b20a5c4481312189d141a33d24 15-Dec-2005 Jordan Crouse <jordan.crouse@amd.com> [PATCH] ide: core modifications for AU1200

bart: slightly modified by me

Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
071ffcc0f7dd8df871f443be3f5059f05da528e2 19-Nov-2005 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> [PATCH] ide: remove unused ide_action_t:ide_next

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
84e7b9e94b474d40582090b7e09139f0029cff2c 19-Nov-2005 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> [PATCH] ide: remove duplicate documentation for ide_do_drive_cmd()

Remove duplicate documentation for ide_do_drive_cmd() from
<linux/ide.h>, this function is already documented in ide-io.c.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4ef3b8f4a5c056d5f784725974a530d1a7b4a811 18-Nov-2005 Laurent Riffard <laurent.riffard@free.fr> [PATCH] ide: remove ide_driver_t.owner field

The structure ide_driver_t have a .owner field which is a duplicate
of .gendriver.owner field (.gen_driver is a struct device_driver).

This patch removes ide_driver_t's owner field.

Signed-off-by: Laurent Riffard <laurent.riffard@free.fr>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
863b18f4b5e7d9e6903b353328cf6fa084dbb619 27-Oct-2005 Laurent riffard <laurent.riffard@free.fr> [PATCH] PCI: automatically set device_driver.owner

A nice feature of sysfs is that it can create the symlink from the
driver to the module that is contained in it.

It requires that the device_driver.owner is set, what is not the
case for many PCI drivers.

This patch allows pci_register_driver to set automatically the
device_driver.owner for any PCI driver.

Credits to Al Viro who suggested the method.

Signed-off-by: Laurent Riffard <laurent.riffard@free.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
--

drivers/ide/setup-pci.c | 12 +++++++-----
drivers/pci/pci-driver.c | 9 +++++----
include/linux/ide.h | 3 ++-
include/linux/pci.h | 10 ++++++++--
4 files changed, 22 insertions(+), 12 deletions(-)
83ae20c849f1bff32100fa8584408dca99ce4a62 09-Nov-2005 Bjorn Helgaas <bjorn.helgaas@hp.com> [PATCH] ide: move CONFIG_IDE_MAX_HWIFS into linux/ide.h

CONFIG_IDE_MAX_HWIFS is a generic thing, no need to have it duplicated
by every arch that uses it.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
4349d5cdf28d46c22d467079e80ee9695dcec0ad 09-Nov-2005 Hannes Reinecke <hare@suse.de> [PATCH] ide: incorrect device link for ide-cs

Devices driven by ide-cs will appear under /sys/devices instead of the
appropriate PCMCIA device. To fix this I had to extend the hw_regs_t
structure with a 'struct device' field, which allows us to set the
parent link for the appropriate hwif.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Jens Axboe <axboe@suse.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
26a940e21752e0de8f068f77dad606a7d1986937 15-Sep-2005 Pete Popov <ppopov@embeddedalley.com> Cleaned up AMD Au1200 IDE driver:
- converted to platform bus
- removed pci dependencies
- removed virt_to_phys/phys_to_virt calls

System now can root off of a disk.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

diff --git a/Documentation/mips/AU1xxx_IDE.README b/Documentation/mips/AU1xxx_IDE.README
new file mode 100644
86b3786078d63242d3194ffc58ae8dae1d1bbef3 10-Aug-2005 Christoph Lameter <christoph@lameter.com> [PATCH] Fix ide-disk.c oops caused by hwif == NULL

1. Move hwif_to_node to ide.h

2. Use hwif_to_node in ide-disk.c

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1946089a109251655c5438d92c539bd2930e71ea 23-Jun-2005 Christoph Lameter <christoph@lameter.com> [PATCH] NUMA aware block device control structure allocation

Patch to allocate the control structures for for ide devices on the node of
the device itself (for NUMA systems). The patch depends on the Slab API
change patch by Manfred and me (in mm) and the pcidev_to_node patch that I
posted today.

Does some realignment too.

Signed-off-by: Justin M. Forbes <jmforbes@linuxtx.org>
Signed-off-by: Christoph Lameter <christoph@lameter.com>
Signed-off-by: Pravin Shelar <pravin@calsoftinc.com>
Signed-off-by: Shobhit Dayal <shobhit@calsoftinc.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
8604affde9d4f52f04342d6a37c77d95fa167e7a 26-May-2005 Bartlomiej Zolnierkiewicz <bzolnier@elka.pw.edu.pl> [PATCH] convert IDE device drivers to driver-model

* add ide_bus_match() and export ide_bus_type
* split ide_remove_driver_from_hwgroup() out of ide_unregister()
* move device cleanup from ide_unregister() to drive_release_dev()
* convert ide_driver_t->name to driver->name
* convert ide_driver_t->{attach,cleanup} to driver->{probe,remove}
* remove ide_driver_t->busy as ide_bus_type->subsys.rwsem
protects against concurrent ->{probe,remove} calls
* make ide_{un}register_driver() void as it cannot fail now
* use driver_{un}register() directly, remove ide_{un}register_driver()
* use device_register() instead of ata_attach(), remove ata_attach()
* add proc_print_driver() and ide_drivers_show(), remove ide_drivers_op
* fix ide_replace_subdriver() and move it to ide-proc.c
* remove ide_driver_t->drives, ide_drives and drives_lock
* remove ide_driver_t->drivers, drivers and drivers_lock
* remove ide_drive_t->driver and DRIVER() macro

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@elka.pw.edu.pl>
1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 17-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org> Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!