ide: factor out completion of taskfile from ide_end_drive_cmd()

Factor out completion of taskfile from ide_end_drive_cmd()
to ide_complete_task().

There should be no functional changes caused by this patch.

Signed-off-by: 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>
ide: no need to read Status and Error registers for "empty" taskfile requests

Signed-off-by: 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>
ide: move smart_enable() call out from get_smart_data()

Move smart_enable() call out from get_smart_data() to
proc_idedisk_read_smart().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
icside: icside_dma_setup() fixes

Check for ide_build_sglist() return value and re-map sg table if necessary.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
trm290: trm290_dma_setup() fix

Re-map sg table if necessary (not that it really matters since
DMA support is disabled currently).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
au1xxx-ide: auide_dma_end() cleanup

No need to check / clear hwif->sg_nents.

There should be no functional changes caused by this patch.

Signed-off-by: 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>
ide-floppy: remove superfluous check from ide_floppy_end_request()

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>
ide-tape: remove superfluous tape->lock

tape->lock is not needed (->queue_lock protects queue).

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: 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>
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>
ide-{floppy,tape}: cleanup ide*_end_request()

* ide*_end_request() is only called with uptodate == 0 or uptodate == 1
  so cleanup it accordingly.

* Inline ide*_end_request() content at call sites so the only user left
  is ->end_request method.

* ->end_request is now used only for private driver requests so remove
  handling of other requests from ide*_end_request().

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>
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>
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>
ide: use blk_fs_request() check in ide-taskfile.c

Use blk_fs_request() in ide-taskfile.c instead of checking for:
- rq->bio in ide_pio_datablock() and task_error()
- rq->cmd_type == REQ_TYPE_ATA_TASKFILE in task_end_request()

There should be no functional changes caused by this patch.

Signed-off-by: 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>
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>
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>