1
0
Fork 0
Commit Graph

305 Commits (6da2ec56059c3c7a7e5f729e6349e74ace1e5c57)

Author SHA1 Message Date
Bartlomiej Zolnierkiewicz 6b4924962c 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>
2008-12-29 20:27:34 +01:00
Bartlomiej Zolnierkiewicz f58c1ab8de 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>
2008-12-29 20:27:33 +01:00
Bartlomiej Zolnierkiewicz 6b5cde3629 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>
2008-12-29 20:27:32 +01:00
Bartlomiej Zolnierkiewicz 02fb5683c9 ali14xx: doesn't use shared IRQs
init_irq() shouldn't use IRQF_SHARED for ali14xx IDE IRQ handler.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-12-29 20:27:32 +01:00
Bartlomiej Zolnierkiewicz 2a2ca6a961 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>
2008-12-29 20:27:31 +01:00
Bartlomiej Zolnierkiewicz 6636487e8d 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>
2008-12-02 20:40:03 +01:00
Bartlomiej Zolnierkiewicz 42619d35c7 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>
2008-10-17 18:09:11 +02:00
Greg Kroah-Hartman 3ee074bf43 device create: ide: convert device_create_drvdata to device_create
Now that device_create() has been audited, rename things back to the
original call to be sane.

Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-10-16 09:24:45 -07:00
Elias Oltmanns 4abdc6ee7c 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>
2008-10-13 21:39:50 +02:00
Elias Oltmanns e415e495f8 ide: Two fixes regarding memory allocation
In function ide_devset_execute() we should use __GFP_WAIT rather than
GFP_KERNEL. Also, the allocation cannot possibly fail at that point.
More importantly, there is a potential memory leak in the device probing
code. The infrastructure seems rather complex and I hope I haven't messed
anything up by trying to fix this.

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
[bart: remove superfluous ide_lock taking]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-10-13 21:39:45 +02:00
Bartlomiej Zolnierkiewicz 4ab3d50224 ide: set IDE_AFLAG_DRQ_INTERRUPT in do_identify()
Set IDE_AFLAG_DRQ_INTERRUPT in do_identify() instead of ATAPI
device drivers *_setup() methods.

While at it:
- use ata_id_cdb_intr()

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-10-13 21:39:43 +02:00
Bartlomiej Zolnierkiewicz a36223b0dc 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>
2008-10-13 21:39:43 +02:00
Bartlomiej Zolnierkiewicz 7f612f272a 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>
2008-10-13 21:39:40 +02:00
Bartlomiej Zolnierkiewicz 123995b971 ide: use 'drive->dn & 1' instead of drive->select.b.unit
* Call ide_port_init_devices() in ide_host_register()
  also if 'struct ide_port_info *d' is not available.

* Init drive->dn in ide_port_init_devices() instead of
  ide_probe_port() so it is valid also in ->init_dev.

* Pass device number to ide_dev_apply_params().

* Use 'drive->dn & 1' instead of drive->select.b.unit.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-10-13 21:39:40 +02:00
Bartlomiej Zolnierkiewicz 97100fc816 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>
2008-10-13 21:39:36 +02:00
Bartlomiej Zolnierkiewicz 75d21fffd8 ide: remove unnecessary MAX_HWIFS checks from ide-probe.c
MAX_HWIFS is now always equal to the number of IDE major numbers.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-10-13 21:39:33 +02:00
Bartlomiej Zolnierkiewicz feb22b7f8e 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>
2008-10-10 22:39:32 +02:00
Bartlomiej Zolnierkiewicz 718c72e83d ide: use ata_id_is_cfa()
Use ata_id_is_cfa() in do_identify() instead of open-coding
check for CompactFlash devices (the inline helper also takes
care of detecting CFs advertising themselves as ATA disks).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-10-10 22:39:31 +02:00
Bartlomiej Zolnierkiewicz 151a670186 ide: remove SECTOR_WORDS define
Just use SECTOR_SIZE instead.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-10-10 22:39:28 +02:00
Bartlomiej Zolnierkiewicz 8185d5aa93 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>
2008-10-10 22:39:28 +02:00
Bartlomiej Zolnierkiewicz 7c51c17e04 ide: remove CONFIG_IDEDISK_MULTI_MODE
Use multi PIO by default when available and remove no longer
needed CONFIG_IDEDISK_MULTI_MODE (it should be safe nowadays,
despite to what help entry has been saying).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-10-10 22:39:26 +02:00
Bartlomiej Zolnierkiewicz a2cdee5a9a ide: remove IDE_CHIPSET_* macros
They just obfuscate the code.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-10-10 22:39:24 +02:00
Bartlomiej Zolnierkiewicz 7c199a5496 ide: remove no longer needed BUG_ON()-s from init_irq()
init_irq() is now called only during initial host registration
so these BUG_ON()-s are no loner needed (+ the last one was done
too late anyway).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-10-10 22:39:23 +02:00
Bartlomiej Zolnierkiewicz b163f46d5e 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>
2008-10-10 22:39:23 +02:00
Bartlomiej Zolnierkiewicz c36a7e9884 ide: fix EXABYTENEST handling in probe_for_drive()
Fix EXABYTENEST handling in probe_for_drive() (so drive->present
is checked for "nested" device) and cleanup enable_nest().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-10-10 22:39:23 +02:00
Bartlomiej Zolnierkiewicz 3a7d24841a 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>
2008-10-10 22:39:21 +02:00
Bartlomiej Zolnierkiewicz aaaade3f05 ide: WIN_* -> ATA_CMD_*
* Use ATA_CMD_* defines instead of WIN_* ones.

While at it:

* EXABYTE_ENABLE_NEXT -> ATA_EXABYTE_ENABLE_NEST

* SETFEATURES_{EN,DIS}_WCACHE -> SETFEATURES_WC_{ON,OFF}

* SETFEATURES_{EN,DIS}_AAM -> SETFEATURES_AAM_{ON,OFF}

* SMART_* -> ATA_SMART_*

* Remove stale comment from ide-proc.c.

Partially based on earlier work by Chris Wedgwood.

Acked-by: Chris Wedgwood <cw@f00f.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-10-10 22:39:21 +02:00
Bartlomiej Zolnierkiewicz dd8f46f64a ide: use ata_id_current_chs_valid()
Replace open-coded checks by ata_id_current_chs_valid().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-10-10 22:39:19 +02:00
Bartlomiej Zolnierkiewicz 48fb2688aa 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>
2008-10-10 22:39:19 +02:00
Bartlomiej Zolnierkiewicz 4dde4492d8 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>
2008-10-10 22:39:19 +02:00
Bartlomiej Zolnierkiewicz df1f8378c2 ide: cleanup ide_disk_init_mult_count()
* Remove superfluous checks for drive->mult_req.

* No need to zero drive's fields.

* Move the common code out of #ifdef scope.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-10-10 22:39:18 +02:00
Tejun Heo ed9e198234 block: implement and use {disk|part}_to_dev()
Implement {disk|part}_to_dev() and use them to access generic device
instead of directly dereferencing {disk|part}->dev.  To make sure no
user is left behind, rename generic devices fields to __dev.

This is in preparation of unifying partition 0 handling with other
partitions.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
2008-10-09 08:56:07 +02:00
Bartlomiej Zolnierkiewicz ca09a237b8 ide: workaround for bogus gcc warning in ide_sysfs_register_port()
Reported-by: "Steven Noonan" <steven@uplinklabs.net>
Suggested-by: "Elias Oltmanns" <eo@nebensachen.de>
Cc: mingo@elte.hu
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-10-05 18:23:28 +02:00
Bartlomiej Zolnierkiewicz 1b8ebad87b ide: use proper printk() KERN_* levels in ide-probe.c
While at it:

- fixup printk() messages in save_match() and hwif_init().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-24 22:53:36 +02:00
Bartlomiej Zolnierkiewicz 52f3a771fe ide: fix for EATA SCSI HBA in ATA emulating mode
IDE probing code used to skip devices attached to EATA SCSI HBA
in ATA emulating mode but because of warm-plug support port I/O
resources are no longer freed if no devices are detected on a port
and the decision about the driver to use is left up to the user.

Remove no longer valid EATA SCSI HBA quirk from do_identify().

Noticed-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-24 22:53:36 +02:00
Bartlomiej Zolnierkiewicz ef0b04276d 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>
2008-07-24 22:53:19 +02:00
Bartlomiej Zolnierkiewicz 08da591e14 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>
2008-07-24 22:53:15 +02:00
Bartlomiej Zolnierkiewicz 6cdf6eb357 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>
2008-07-24 22:53:14 +02:00
Pavel Machek fc410698eb ide: small whitespace fixes
Small whitespace fixes for drivers/ide.

Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-23 19:56:02 +02:00
Bartlomiej Zolnierkiewicz 8a69580e1e 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>
2008-07-23 19:55:59 +02:00
Bartlomiej Zolnierkiewicz 18de10170d ide: allocate ide_hwif_t instances dynamically
* Allocate ide_hwif_t instances dynamically and remove ide_hwifs[].

  This cuts almost ~14kB from ide-probe.o (x86-32, MAX_HWIFS == 10):

   text    data     bss     dec     hex filename
   9140      40   14084   23264    5ae0 drivers/ide/ide-probe.o.before
   9169      40      44    9253    2425 drivers/ide/ide-probe.o.after

* Remove no longer needed ide_init_port_data() call from ide_unregister().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-23 19:55:58 +02:00
Bartlomiej Zolnierkiewicz af1cbba373 ide: add ide_ports[]
* Add ide_ports[] table keeping pointers to all initialized ports.

* Set ide_ports[] entry for a given port in init_irq() and clear it
  ide_remove_port_from_hwgroup().

* Convert init_irq() to use ide_ports[] instead of ide_hwifs[] for
  grouping ports into hwgroup.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-23 19:55:58 +02:00
Bartlomiej Zolnierkiewicz 6059143ae3 ide: move ide_remove_port_from_hwgroup() to ide-probe.c
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-23 19:55:58 +02:00
Bartlomiej Zolnierkiewicz 8cdf310025 ide: fix IDE port slots reservation and freeing (take 2)
* Make ide_find_port_slot() return port slot index.

* Add ide_free_port_slot() helper.

* Move ide_init_port_data() call and error printk() from
  ide_find_port_slot() to ide_host_alloc_all().

* Make ide_{find,free}_port_slot() take ide_cfg_mtx mutex
  and convert them use ide_indexes bitmap to keep track of
  reserved port slots.

* Don't set hwif->chipset in ide_host_alloc_all() as it is
  no longer necessary.

v2:
* Pass the correct slot index to ide_init_port_data().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-23 19:55:57 +02:00
Bartlomiej Zolnierkiewicz e0d0020788 ide: fix ide_host_register() return value
Fix ide_host_register() to fail only if all ports cannot be registered.

While at it:

* Use host->ports[] instead of ide_hwifs[] and remove idx[].

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-23 19:55:57 +02:00
Bartlomiej Zolnierkiewicz 6f904d0152 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>
2008-07-23 19:55:57 +02:00
Bartlomiej Zolnierkiewicz 48c3c10726 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>
2008-07-23 19:55:57 +02:00
Bartlomiej Zolnierkiewicz 374e042c3e 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>
2008-07-23 19:55:56 +02:00
Bartlomiej Zolnierkiewicz d6276b5f5c 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>
2008-07-23 19:55:56 +02:00
Bartlomiej Zolnierkiewicz 1f2efb82af ide: add ide_read_device() helper
Add ide_read_device() helper and convert do_probe() to use it
instead of ->INB.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-23 19:55:54 +02:00
Bartlomiej Zolnierkiewicz 4e65837b29 ide: use ->tf_load in actual_try_to_identify()
Convert actual_try_to_identify() to use ->tf_load instead of ->OUTB.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-23 19:55:53 +02:00
Bartlomiej Zolnierkiewicz 6e6afb3b74 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>
2008-07-23 19:55:52 +02:00
Bartlomiej Zolnierkiewicz 1f6d8a0fd8 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>
2008-07-23 19:55:52 +02:00
Bartlomiej Zolnierkiewicz b73c7ee25d 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>
2008-07-23 19:55:52 +02:00
Bartlomiej Zolnierkiewicz c6dfa867bb 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>
2008-07-23 19:55:51 +02:00
Bartlomiej Zolnierkiewicz ebb00fb55d 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>
2008-07-23 19:55:51 +02:00
Bartlomiej Zolnierkiewicz c97c6aca75 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>
2008-07-23 19:55:50 +02:00
Bartlomiej Zolnierkiewicz eb3aff5530 ide: print message on error in ide_find_port_slot()
* Add DRV_NAME define to ide-h8300.c.

* Fix ide-h8300.c, swarm.c and sgiioc4.c to set .name field in
  struct ide_port_info to DRV_NAME, then convert these host drivers
  to use ide_find_port_slot() instead of ide_find_port().

* Print message on error in ide_find_port_slot().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-16 20:33:42 +02:00
Bartlomiej Zolnierkiewicz e6d95bd149 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>
2008-07-16 20:33:42 +02:00
Bartlomiej Zolnierkiewicz 63b51c6d1d 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>
2008-07-16 20:33:40 +02:00
Bartlomiej Zolnierkiewicz 256c5f8eef ide: fix hwif-s initialization
* Add ide_hwifs[] entry initialization to ide_find_port_slot()
  and remove ide_init_port_data() calls from host drivers.

* Unexport ide_init_port_data().

* Remove no longer needed init_ide_data().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-16 20:33:39 +02:00
Bartlomiej Zolnierkiewicz ff07488346 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>
2008-07-15 21:21:50 +02:00
Bartlomiej Zolnierkiewicz 6a732e11be ide: use ->OUTBSYNC in init_irq()
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-15 21:21:50 +02:00
Bartlomiej Zolnierkiewicz f8c4bd0ab2 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>
2008-07-15 21:21:49 +02:00
Bartlomiej Zolnierkiewicz e81a3bde13 ide: fix do_probe() to use SELECT_DRIVE()
Fix one place in do_probe() which used ->OUTB directly instead
of calling SELECT_DRIVE() (so ->selectproc method is also used).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-15 21:21:48 +02:00
Bartlomiej Zolnierkiewicz a861beb140 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>
2008-07-08 19:27:22 +02:00
Bartlomiej Zolnierkiewicz 7cd95f56cb ide: fix hwif->gendev refcounting
class->dev_release is called by device_release() iff dev->release
is not present so ide_port_class_release() is never called and the
last hwif->gendev reference is not dropped.

Fix it by removing ide_port_class_release() and get_device() call
from ide_register_port() (device_create_drvdata() takes a hwif->gendev
reference anyway).

This patch fixes hang on wait_for_completion(&hwif->gendev_rel_comp)
in ide_unregister() reported by Pavel Machek.

Cc: Pavel Machek <pavel@suse.cz>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-07-05 20:30:51 +02:00
Bartlomiej Zolnierkiewicz d427e836d1 ide: fix host drivers missing hwif->chipset initialization
ide_find_port() now depends on ->chipset being set for occupied ide_hwifs[]
slots so all host drivers have to initialize hwif->chipset properly.

This patch fixes a regression on hosts with > 1 port or with a single port
but no devices attached to it for an affected host drivers.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-06-10 20:56:37 +02:00
Adrian Bunk b76916462d 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>
2008-06-10 20:56:36 +02:00
Greg Kroah-Hartman 716ad8750a ide: fix race in device_create
There is a race from when a device is created with device_create() and
then the drvdata is set with a call to dev_set_drvdata() in which a
sysfs file could be open, yet the drvdata will be NULL, causing all
sorts of bad things to happen.

This patch fixes the problem by using the new function,
device_create_drvdata().

Cc: Kay Sievers <kay.sievers@vrfy.org>
Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-05-20 13:31:54 -07:00
Bartlomiej Zolnierkiewicz 1024c5f4be ide: IDE_HFLAG_SERIALIZE_DMA bugfix
Patch re-ordering could be harmful:

commit 1fd1890594
Author: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Date:   Sat Apr 26 22:25:24 2008 +0200

    ide: add IDE_HFLAG_SERIALIZE_DMA host flag
...

is buggy because ->init_dma method / ide_hwif_setup_dma() is called
before IDE_HFLAG_SERIALIZE_DMA host flag is checked.

Fix it by checking IDE_HFLAG_SERIALIZE[_DMA] after DMA initialization.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-05-04 17:03:41 +02:00
Bartlomiej Zolnierkiewicz 23f8e4bf7c ide: fix early setup of hwif->host_flags
On Thursday 01 May 2008, Jeremy Kerr wrote:
> Hi all,
> 
> On QS20 Cell machines, Linus' current git tree explodes on boot:
> 
> SiI680: IDE controller (0x1095:0x0680 rev 0x02) at  PCI slot 
> 0000:00:0a.0
> SiI680: BASE CLOCK == 133
> SiI680: 100% native mode on irq 51
>     ide0: MMIO-DMA
>     ide1: MMIO-DMA
> Unable to handle kernel paging request for data at address 
> 0xa000100081220080
> Faulting instruction address: 0xc000000000024748
> cpu 0x2: Vector: 300 (Data Access) at [c00000001e143420]
>     pc: c000000000024748: ._insw_ns+0x10/0x30
>     lr: c000000000037fc4: .spiderpci_readsw+0x24/0x6c
>     sp: c00000001e1436a0
>    msr: 9000000000001032
>    dar: a000100081220080
>  dsisr: 40000000
>   current = 0xc00000003d060000
>   paca    = 0xc000000000623880
>     pid   = 1, comm = swapper
> enter ? for help
> [link register   ] c000000000037fc4 .spiderpci_readsw+0x24/0x6c
> [c00000001e1436a0] c00000000062ce63 (unreliable)
> [c00000001e143730] c0000000000379d4 .iowa_readsw+0x78/0xa8
> [c00000001e1437c0] c000000000037a98 .iowa_insw+0x94/0xd4
> [c00000001e143850] c00000000022a190 .ata_input_data+0x298/0x2ec
> [c00000001e143910] c00000000022b600 .try_to_identify+0x2c0/0x6d4
> [c00000001e1439d0] c00000000022bb54 .do_probe+0x140/0x35c
> [c00000001e143a80] c00000000022bfbc .ide_probe_port+0x24c/0x670
> [c00000001e143b50] c00000000022d09c .ide_device_add_all+0x2ec/0x690
> [c00000001e143c00] c00000000022d4a4 .ide_device_add+0x64/0x74
> [c00000001e143c90] c00000000022f834 .ide_setup_pci_device+0x58/0x7c
> [c00000001e143d30] c00000000038bdf8
> [c00000001e143e10] c000000000486fb0 .ide_scan_pcibus+0x8c/0x178
> [c00000001e143ea0] c000000000460c00 .kernel_init+0x1c4/0x344
> [c00000001e143f90] c000000000024a1c .kernel_thread+0x4c/0x68
> 
> It looks like we're trying to do PIO accesses (which appear to be 
> broken, but that's another issue) to this MMIO device. In 
> ata_input_data, we see that:
> 
> 	u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
> 
> Gives mmio == 0.
> 
> (what's the difference between hwif->mmio and ID_HFLAG_MMIO?)
> 
> In the siimage driver, hwif->host flags is initially set up correctly 
> (host_flags includes IDE_HFLAG_MMIO), but we then *clear* this bit in 
> ide_init_port: 
> 
> 	hwif->host_flags = d->host_flags;
> 
> where d is the struct ide_port_info for this chipset. In my case, 
> d->host_flags is 0x0. It looks like this will be the same for all of 
> the siimage chipsets.

Don't over-write hwif->host_flags in ide_init_port(), some host drivers
set IDE_HFLAG_MMIO or IDE_HFLAG_NO_IO_32BIT host flag early.

Thanks to Jeremy Kerr for the excellent analysis of the bug.

Reported-by: Jeremy Kerr <jk@ozlabs.org>
Tested-by: Jeremy Kerr <jk@ozlabs.org>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Ben Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-05-01 14:08:51 +02:00
Bartlomiej Zolnierkiewicz 32b3fe4fff ide: always use ->OUTBSYNC method for executing commands
Always use ->OUTBSYNC method for executing commands so the posting is done
if needed (this affects only pmac and scc_pata host drivers at the moment).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-04-28 23:44:38 +02:00
Bartlomiej Zolnierkiewicz 9567b349f7 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>
2008-04-28 23:44:36 +02:00
Bartlomiej Zolnierkiewicz 92d3ab27e8 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>
2008-04-28 23:44:36 +02:00
Bartlomiej Zolnierkiewicz 4c3032d8a4 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>
2008-04-27 15:38:32 +02:00
Bartlomiej Zolnierkiewicz 207daeaabb 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>
2008-04-27 15:38:29 +02:00
Bartlomiej Zolnierkiewicz e160124ff6 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>
2008-04-27 15:38:29 +02:00
Bartlomiej Zolnierkiewicz cc12175ff2 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>
2008-04-27 15:38:24 +02:00
Bartlomiej Zolnierkiewicz e460a59751 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>
2008-04-27 15:38:24 +02:00
Bartlomiej Zolnierkiewicz 9fd91d959f 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>
2008-04-27 15:38:23 +02:00
Bartlomiej Zolnierkiewicz 5e37bdc081 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>
2008-04-26 22:25:24 +02:00
Bartlomiej Zolnierkiewicz 1fd1890594 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>
2008-04-26 22:25:24 +02:00
Bartlomiej Zolnierkiewicz b123f56e04 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>
2008-04-26 22:25:22 +02:00
Harvey Harrison eb63963a55 ide: replace remaining __FUNCTION__ occurrences
__FUNCTION__ is gcc-specific, use __func__

[bart: fix checkpatch.pl errors in ide-lib.c and ppc/mpc8xx.c while at it]

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-04-26 22:25:20 +02:00
Bartlomiej Zolnierkiewicz 3dd89a9b2a ide: cleanup setting hwif->mmio flag
It is no longer needed to set hwif->mmio flag to tell IDE layer to not
manage resources so cleanup host drivers that used hwif->mmio flag only
for this purpose.

Ditto for ide_legacy_init_one().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-04-26 22:25:19 +02:00
Bartlomiej Zolnierkiewicz 0d1bad216c 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>
2008-04-26 22:25:19 +02:00
Bartlomiej Zolnierkiewicz d92f1a2829 ide: manage I/O resources in ide_legacy_init_one()
* Tell IDE layer to not manage resources by setting hwif->mmio flag.

* Use {request,release}_region() for resources management.

* Set ->name field of 'struct ide_port_info' instances in legacy VLB
  host drivers and use driver name for resources management.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-04-26 22:25:18 +02:00
Bartlomiej Zolnierkiewicz d9b819a025 ide: add ide_legacy_init_one() helper
Move the common code for primary/seconary port setup from
ide_legacy_device_add() to ide_legacy_init_one().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-04-26 22:25:18 +02:00
Bartlomiej Zolnierkiewicz 2c4be251be ide-4drives: manage I/O resources in driver
* Tell IDE layer to not manage resources by setting hwif->mmio flag.

* Use {request,release}_region() for resources management.

* Use driver name for resources management.

* Remove no longer needed 'hwif->chipset == ide_4drives' handling
  from ide_device_add_all().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-04-26 22:25:18 +02:00
Bartlomiej Zolnierkiewicz eb716beb0a ide: register ports with non-present devices (for warm-plug)
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-04-26 22:25:17 +02:00
Bartlomiej Zolnierkiewicz 0bfeee7d41 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>
2008-04-26 22:25:16 +02:00
Bartlomiej Zolnierkiewicz 3b36f66b81 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>
2008-04-26 22:25:16 +02:00
Bartlomiej Zolnierkiewicz e53cd458d5 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>
2008-04-26 22:25:16 +02:00
Bartlomiej Zolnierkiewicz ac95beedf8 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>
2008-04-26 22:25:14 +02:00
Bartlomiej Zolnierkiewicz e277f91fef 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>
2008-04-26 17:36:36 +02:00
Bartlomiej Zolnierkiewicz fe80b937c9 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>
2008-04-26 17:36:36 +02:00
Bartlomiej Zolnierkiewicz 0e33555fff 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>
2008-04-18 00:46:33 +02:00
Bartlomiej Zolnierkiewicz 23579a2a17 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>
2008-04-18 00:46:26 +02:00
Bartlomiej Zolnierkiewicz 9a0e77f28b 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>
2008-04-18 00:46:24 +02:00
Bartlomiej Zolnierkiewicz fef39d95ea ide: remove needless CONFIG_BLK_DEV_HD hack from init_hwif()
request_irq() will fail if there is already another IRQ handler
registered and IRQ flags are mismatched.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-04-18 00:46:23 +02:00
Bartlomiej Zolnierkiewicz f74c91413e 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>
2008-04-18 00:46:23 +02:00
Bartlomiej Zolnierkiewicz 2dde7861af 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>
2008-04-18 00:46:23 +02:00
Bartlomiej Zolnierkiewicz 26042d058b ide: move ide_port_setup_devices() call to ide_device_add_all()
Add ide_cfg_mtx lock/unlock to ide_port_setup_devices() and then move
ide_port_setup_devices() call from init_irq() to ide_device_add_all().

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-04-18 00:46:22 +02:00
Bartlomiej Zolnierkiewicz 5b0c4b30a6 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>
2008-04-18 00:46:22 +02:00
Bartlomiej Zolnierkiewicz c7f6f21aae ide: factor out cable detection from ide_init_port()
* Factor out cable detection from ide_init_port() to ide_port_cable_detect().

* Move ide_port_cable_detect() call to ide_device_add_all().

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-04-18 00:46:22 +02:00
Bartlomiej Zolnierkiewicz f367bed005 Revert "ide: change master/slave IDENTIFY order"
This reverts commit b140b99c41.

[ conflict in drivers/ide/ide-probe.c fixed manually ]

It turned out that probing order change causes problems for some drives:

	http://bugzilla.kernel.org/show_bug.cgi?id=10239

Since root causes are still being investigated and are unlikely to be fixed
before 2.6.25 lets revert this change for now.  As a result cable detection
becomes less reliable when compared with 2.6.24 but the affected drives are
useable again.

Reported-by: Richard Genoud <richard.genoud@gmail.com>
Bisected-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-03-29 19:48:21 +01:00
Bartlomiej Zolnierkiewicz c53ea18dc2 ide: skip probing port if "hdx=noprobe" was used for both devices on it
* Skip probing port if "hdx=noprobe" parameter was used for both devices on it.

* Obsolete "idex=noprobe" parameter - it only works for ide_generic, cmd640
  and PCI hosts in Compatibility mode (on alpha/x86/ia64/m32r/mips/ppc32).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-26 21:50:34 +01:00
Bartlomiej Zolnierkiewicz e1771e20c8 ide: fix comment in init_irq()
APUS support is gone...

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-11 00:32:15 +01:00
Bartlomiej Zolnierkiewicz 4280094225 ide: ide_init_port() bugfix
On Sunday 10 February 2008, Atsushi Nemoto wrote:
> On Sun, 06 Jan 2008 18:03:10 +0100, Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> wrote:
> > +	/* reset DMA masks only for SFF-style DMA controllers */
> > +	if ((d->host_flags && IDE_HFLAG_NO_DMA) == 0 && hwif->dma_base == 0)
> > +		hwif->swdma_mask = hwif->mwdma_mask = hwif->ultra_mask = 0;
> 
> It might be too late, but "host_flags && IDE_HFLAGS_NO_DMA" seems
> wrong for me.

Fix regression caused by commmit c413b9b94d
("ide: add struct ide_port_info instances to legacy host drivers").

Reported-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-11 00:32:15 +01:00
Adrian Bunk 7b892806b0 cleanup after APUS removal
After the APUS removal, some code can be removed.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Karsten Keil <kkeil@suse.de>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-06 10:41:01 -08:00
Bartlomiej Zolnierkiewicz c47137a99c ide: add ide_read_[alt]status() inline helpers
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-06 02:57:51 +01:00
Bartlomiej Zolnierkiewicz 57b5527573 ide-probe: remove needless Status register reads
* Cache value read from the Status register in 'stat' variable in do_probe()
  and enable_nest(), then remove remove needless Status register reads.

While at it:

* Add proper KERN_* levels to printk() calls.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-02 19:56:45 +01:00
Bartlomiej Zolnierkiewicz d9270a3f1d 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>
2008-02-02 19:56:43 +01:00
Bartlomiej Zolnierkiewicz 327617e1da ide: move hwif->present check out from ide_proc_register_port()
Move hwif->present check out from ide_proc_register_port() to
ide_device_add_all().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-02 19:56:43 +01:00
Bartlomiej Zolnierkiewicz eafd88a3b5 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>
2008-02-02 19:56:43 +01:00
Bartlomiej Zolnierkiewicz decdc3f0d6 ide: move ide_acpi_init() call to ide_device_add_all()
There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-02 19:56:41 +01:00
Bartlomiej Zolnierkiewicz d5bc6592df ide: factor out devices setup from init_irq()
* Factor out devices setup from init_irq() to ide_port_setup_devices().

While at it:
* Do devices setup after printing port information.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-02 19:56:41 +01:00
Bartlomiej Zolnierkiewicz 0947e0dcd6 ide: factor out adding drive to hwgroup from init_irq()
Factor out adding drive to hwgroup from init_irq() to
ide_add_drive_to_hwgroup().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-02 19:56:41 +01:00
Bartlomiej Zolnierkiewicz 8a0e7e14a2 ide: move hwif->rqsize init from ide_init_queue() to init_irq()
Move hwif->rqsize init from ide_init_queue() to init_irq().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-02 19:56:41 +01:00
Bartlomiej Zolnierkiewicz c5d70cc73a ide: merge init_gendisk() into hwif_register_devices()
There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-02 19:56:41 +01:00
Bartlomiej Zolnierkiewicz 346d49969b ide: call init_gendisk() after ide_acpi_init()
There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-02 19:56:40 +01:00
Bartlomiej Zolnierkiewicz 3a4e7c96d6 ide: move blk_register_region() call out from init_gendisk()
Move blk_register_region() call out from init_gendisk() to hwif_init().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-02 19:56:40 +01:00
Bartlomiej Zolnierkiewicz 5c2854e62c ide: skip not present devices in init_gendisk()
No need to initialize drive->gendev and waste memory on IDE settings
for not present devices.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-02 19:56:40 +01:00
Bartlomiej Zolnierkiewicz 521fd1e8d1 ide: remove incorrect init_gendisk() comment
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-02 19:56:40 +01:00
Bartlomiej Zolnierkiewicz 1f2cf8b001 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>
2008-02-02 19:56:40 +01:00
Bartlomiej Zolnierkiewicz 807b90d0be 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>
2008-02-02 19:56:40 +01:00
Bartlomiej Zolnierkiewicz 7704ca2a3e ide: factor out code initializing devices from ide_init_port()
* Factor out code initializing devices from ide_init_port() to
  ide_port_init_devices().

* Call the new function from ide_device_add_all().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-02 19:56:39 +01:00
Bartlomiej Zolnierkiewicz bfa14b42a3 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>
2008-02-02 19:56:31 +01:00
Bartlomiej Zolnierkiewicz c413b9b94d 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>
2008-02-02 19:56:31 +01:00
Bartlomiej Zolnierkiewicz a14dc57495 ide: move hwif_register() call out of ide_probe_port()
* Add BUG_ON(hwif->present) at the start of ide_probe_port().

* Move hwif_register() call (along with setting hwif->present) from
  ide_probe_port() to ide_device_add_all().

  As a result the port will be registered with the device tree _after_:
  - probing both devices (if both are present)
  - port reset (if hwif->reset is set)
  - restoring local IRQs state and re-enabling port IRQ

While at it:

* Rename hwif_register() to ide_register_port().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-01 23:09:36 +01:00
Bartlomiej Zolnierkiewicz e84e7ea7c4 ide: factor out code for tuning devices from ide_probe_port()
* Factor out code for tuning devices from ide_probe_port()
  to ide_port_tune_devices().

* Move ide_port_tune_devices() call from ide_probe_port()
  to ide_device_add_all().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-01 23:09:36 +01:00
Bartlomiej Zolnierkiewicz 139ddfcab5 ide: move handling of I/O resources out of ide_probe_port()
Reserve/release I/O resources in ide_device_add_all() instead of
ide_probe_port().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-01 23:09:36 +01:00
Bartlomiej Zolnierkiewicz 9d501529b6 ide: make probe_hwif() return an error value
Make probe_hwif() return an error value.

While at it:

* Remove comment about MAX_DRIVES == 2 limitation (it is not special to
  probe_hwif(), it is a general assumption taken by a lot of IDE code).

* Rename probe_hwif() to ide_probe_port().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-01 23:09:36 +01:00
Bartlomiej Zolnierkiewicz fbd130887a 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>
2008-02-01 23:09:36 +01:00
Bartlomiej Zolnierkiewicz cae5c82022 ide: prepare init_irq() for using ide_remove_port_from_hwgroup()
* BUG_ON() early if 'hwif->next == hwif' and there is a 'match' hwgroup.

* Remove printk() for impossible condition and add a BUG_ON(hwgroup->drive)
  to match code in ide_unregister().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-01 23:09:36 +01:00
Bartlomiej Zolnierkiewicz 422278ef95 ide: remove needless zeroing of hwgroup fields from init_irq()
Since kmalloc_node() is called with __GFP_ZERO flag there is no need to
explicitly zero hwgroup fields.

While at it:

* Use 'hwif' instead of 'hwif->drives[0].hwif' for kmalloc_node() call.

* Fix whitespace damage.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-01 23:09:35 +01:00
Bartlomiej Zolnierkiewicz 48535651f6 ide: remove hwif->present manipulations from hwif_init()
* Call hwif_init() only if hwif->present is set.

* If hwif_init() fails clear hwif->present.

* Remove hwif->present manipulations from hwif_init().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-01 23:09:34 +01:00
Bartlomiej Zolnierkiewicz c860a8f2d2 ide: move wait_hwif_ready() documentation in the right place
* Move wait_hwif_ready() documentation before this function.

* Fix trailing whitespaces.

* s/wait-for-busy/wait-for-non-busy/

* Remove no longer valid comment about the current code behavior.

* Docbook-ize it.

* Rename wait_hwif_ready() to ide_port_wait_ready().

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-01 23:09:34 +01:00
Bartlomiej Zolnierkiewicz cf7125ae05 ide: fix handling of busy I/O resources in probe_hwif()
It could be that I/O resources are busy because some other host driver
has already claimed them so don't unregister the devices.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-01 23:09:34 +01:00
Bartlomiej Zolnierkiewicz 59bca8cc99 ide: update/add my Copyrights
The last years stuff and a trip down memory lane...

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-01 23:09:33 +01:00
Bartlomiej Zolnierkiewicz 58f189fccc ide: delete filenames/versions from comments
Delete filenames/versions from comments.

I'm leaving decisions about adding DRV_VERSION defines and MODULE_VERSION()-s
to maintainers of the respective drivers.

While at it:

* Remove unused VERSION define from ide.c.

* Remove unused/stale DRV_VERSION define from au1xxx-ide.c.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-02-01 23:09:33 +01:00
Bartlomiej Zolnierkiewicz 36501650ec 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>
2008-02-01 23:09:31 +01:00
Bartlomiej Zolnierkiewicz 7b9f25b539 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>
2008-02-01 23:09:28 +01:00
Bartlomiej Zolnierkiewicz 3a5015cc9d ide: add ide_busy_sleep() helper
Add ide_busy_sleep() helper and use it in do_probe(),
enable_nest() and probe_hwif().

As a nice side-effect this fixes a minor bug in do_probe()
(the code was reading status register without any delay).

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-01-26 20:13:09 +01:00
Bartlomiej Zolnierkiewicz 81ca691981 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>
2008-01-26 20:13:08 +01:00
Olof Johansson b0d5bc27ce 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>
2008-01-26 20:13:05 +01:00
Bartlomiej Zolnierkiewicz 151575e464 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>
2008-01-26 20:13:05 +01:00
Bartlomiej Zolnierkiewicz 71518342bf ide: add hwif->chipset fixup to ide_device_add()
Add hwif->chipset fixup identical to the one in ideprobe_init()
to ide_device_add().

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-01-26 20:13:04 +01:00
Bartlomiej Zolnierkiewicz 2e13093a83 ide: fix probing for hosts with serialized or IRQ sharing interfaces
After hwif_register_devices() IDE devices are ready to be used so
the way in which ide_device_add() works currently is racy for hosts
with serialized / IRQ sharing interfaces.

Fix ide_device_add() by looping over interfaces for probe_hwif(),
hwif_init() and hwif_register_devices() operations.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
2008-01-26 20:13:04 +01:00