History log of /drivers/ide/ide-atapi.c
Revision Date Author Comments
38789fda295689689d064c0157bc363b1837b5e6 17-Jul-2011 Paul Gortmaker <paul.gortmaker@windriver.com> ide/ata: Add export.h for EXPORT_SYMBOL/THIS_MODULE where needed

They were getting this implicitly by an include of module.h
from device.h -- but we are going to clean that up and break
that include chain, so include export.h explicitly now.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
7eaceaccab5f40bbfda044629a6298616aeaed50 10-Mar-2011 Jens Axboe <jaxboe@fusionio.com> block: remove per-queue plugging

Code has been converted over to the new explicit on-stack plugging,
and delay users have been converted to use the new API for that.
So lets kill off the old plugging along with aops->sync_page().

Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
4c4762d10faf93167b84ee03e4b58dd62012b06f 19-Jun-2010 Christoph Hellwig <hch@lst.de> block: fix some more cmd_type cleanup fallout

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
33659ebbae262228eef4e0fe990f393d1f0ed941 07-Aug-2010 Christoph Hellwig <hch@lst.de> block: remove wrappers for request type/flags

Remove all the trivial wrappers for the cmd_type and cmd_flags fields in
struct requests. This allows much easier grepping for different request
types instead of unwinding through macros.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
1af185034662b75279f90e1c7cb958271d4121e2 31-Mar-2010 Herbert Xu <herbert@gondor.apana.org.au> ide: Must hold queue lock when requeueing

ide-atapi requeues requests without holding the queue lock.
This patch fixes it by using ide_requeue_and_plug.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
5a0e3ad6af8660be21ca98a971cd00f331318c05 24-Mar-2010 Tejun Heo <tj@kernel.org> include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
19af5cdb7c79ff5ec96a99893ffb7f894f4a3dc1 23-Apr-2009 Martin Olsson <martin@minimum.se> trivial: fix typo milisecond/millisecond for documentation and source comments.

Signed-off-by: Martin Olsson <martin@minimum.se>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
626542ca2277961aaa64855206574f8ca4f360e3 07-Jun-2009 Borislav Petkov <petkovbb@gmail.com> ide-tape: change IDE_AFLAG_IGNORE_DSC non-atomically

There are two sites where the flag is being changed: ide_retry_pc
and idetape_do_request. Both codepaths are protected by hwif->busy
(ide_lock_port) and therefore we shouldn't need the atomic accesses.

Spotted-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Borislav Petkov <petkovbb@gmail.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>
ae3a8387be529e632eac69b342524c25b892fc63 02-May-2009 Borislav Petkov <petkovbb@gmail.com> ide-atapi: use local sense buffer

Access the sense buffer through the bio in ->pc_callback method thus
alleviating the need for the pc->buf pointer.

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>
dfb7e621fa12c0579e88560ab176c5768f9e0bfb 01-May-2009 Borislav Petkov <petkovbb@gmail.com> ide-atapi: switch to blk_rq_bytes() on do_request() path

After the recent struct request cleanups, blk_rq_bytes() is guaranteed
to be valid and is the current total length of the rq's bio. Use that
instead of pc->req_xfer in the do_request() path after the command has
been queued

The remaining usage of pc->req_xfer now is only until we map the rq to a
bio.

While at it:

- remove local caching of rq completion length in ide_tape_issue_pc()

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
9934c8c04561413609d2bc38c6b9f268cba774a4 08-May-2009 Tejun Heo <tj@kernel.org> block: implement and enforce request peek/start/fetch

Till now block layer allowed two separate modes of request execution.
A request is always acquired from the request queue via
elv_next_request(). After that, drivers are free to either dequeue it
or process it without dequeueing. Dequeue allows elv_next_request()
to return the next request so that multiple requests can be in flight.

Executing requests without dequeueing has its merits mostly in
allowing drivers for simpler devices which can't do sg to deal with
segments only without considering request boundary. However, the
benefit this brings is dubious and declining while the cost of the API
ambiguity is increasing. Segment based drivers are usually for very
old or limited devices and as converting to dequeueing model isn't
difficult, it doesn't justify the API overhead it puts on block layer
and its more modern users.

Previous patches converted all block low level drivers to dequeueing
model. This patch completes the API transition by...

* renaming elv_next_request() to blk_peek_request()

* renaming blkdev_dequeue_request() to blk_start_request()

* adding blk_fetch_request() which is combination of peek and start

* disallowing completion of queued (not started) requests

* applying new API to all LLDs

Renamings are for consistency and to break out of tree code so that
it's apparent that out of tree drivers need updating.

[ Impact: block request issue API cleanup, no functional change ]

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Mike Miller <mike.miller@hp.com>
Cc: unsik Kim <donari75@gmail.com>
Cc: Paul Clements <paul.clements@steeleye.com>
Cc: Tim Waugh <tim@cyberelk.net>
Cc: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Laurent Vivier <Laurent@lvivier.info>
Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Adrian McMenamin <adrian@mcmen.demon.co.uk>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Borislav Petkov <petkovbb@googlemail.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Alex Dubov <oakad@yahoo.com>
Cc: Pierre Ossman <drzeus@drzeus.cx>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Markus Lidel <Markus.Lidel@shadowconnect.com>
Cc: Stefan Weinhuber <wein@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Pete Zaitcev <zaitcev@redhat.com>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
8f6205cd572fece673da0255d74843680f67f879 08-May-2009 Tejun Heo <tj@kernel.org> ide: dequeue in-flight request

ide generally has single request in flight and tracks it using
hwif->rq and all state handlers follow the following convention.

* ide_started is returned if the request is in flight.

* ide_stopped is returned if the queue needs to be restarted. The
request might or might not have been processed fully or partially.

* hwif->rq is set to NULL, when an issued request completes.

So, dequeueing model can be implemented by dequeueing after fetch,
requeueing if hwif->rq isn't NULL on ide_stopped return and doing
about the same thing on completion / port unlock paths. These changes
can be made in ide-io proper.

In addition to the above main changes, the following updates are
necessary.

* ide-cd shouldn't dequeue a request when issuing REQUEST SENSE for it
as the request is already dequeued.

* ide-atapi uses request queue as stack when issuing REQUEST SENSE to
put the REQUEST SENSE in front of the failed request. This now
needs to be done using requeueing.

[ Impact: dequeue in-flight request ]

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Borislav Petkov <petkovbb@googlemail.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
34b7d2c957199834c474c9d46739265643f4d9c7 07-May-2009 Tejun Heo <tj@kernel.org> ide: cleanup rq->data_len usages

With recent unification of fields, it's now guaranteed that
rq->data_len always equals blk_rq_bytes(). Convert all direct users
to accessors.

[ Impact: convert direct rq->data_len usages to blk_rq_bytes() ]

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Borislav Petkov <petkovbb@googlemail.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
c3a4d78c580de4edc9ef0f7c59812fb02ceb037f 07-May-2009 Tejun Heo <tj@kernel.org> block: add rq->resid_len

rq->data_len served two purposes - the length of data buffer on issue
and the residual count on completion. This duality creates some
headaches.

First of all, block layer and low level drivers can't really determine
what rq->data_len contains while a request is executing. It could be
the total request length or it coulde be anything else one of the
lower layers is using to keep track of residual count. This
complicates things because blk_rq_bytes() and thus
[__]blk_end_request_all() relies on rq->data_len for PC commands.
Drivers which want to report residual count should first cache the
total request length, update rq->data_len and then complete the
request with the cached data length.

Secondly, it makes requests default to reporting full residual count,
ie. reporting that no data transfer occurred. The residual count is
an exception not the norm; however, the driver should clear
rq->data_len to zero to signify the normal cases while leaving it
alone means no data transfer occurred at all. This reverse default
behavior complicates code unnecessarily and renders block PC on some
drivers (ide-tape/floppy) unuseable.

This patch adds rq->resid_len which is used only for residual count.

While at it, remove now unnecessasry blk_rq_bytes() caching in
ide_pc_intr() as rq->data_len is not changed anymore.

Boaz : spotted missing conversion in osd
Sergei : spotted too early conversion to blk_rq_bytes() in ide-tape

[ Impact: cleanup residual count handling, report 0 resid by default ]

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Borislav Petkov <petkovbb@googlemail.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Mike Miller <mike.miller@hp.com>
Cc: Eric Moore <Eric.Moore@lsi.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Doug Gilbert <dgilbert@interlog.com>
Cc: Mike Miller <mike.miller@hp.com>
Cc: Eric Moore <Eric.Moore@lsi.com>
Cc: Darrick J. Wong <djwong@us.ibm.com>
Cc: Pete Zaitcev <zaitcev@redhat.com>
Cc: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.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>
e998f30b45efb99a3c3ce7b5483f76317a17abed 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-tape: use standard data transfer mechanism

Impact: use standard way to transfer data

ide-tape uses rq in an interesting way. For r/w requests, rq->special
is used to carry a private buffer management structure idetape_bh and
rq->nr_sectors and current_nr_sectors are initialized to the number of
idetape blocks which isn't necessary 512 bytes. Also,
rq->current_nr_sectors is used to report back the residual count in
units of idetape blocks.

This peculiarity taxes both block layer and ide. ide-atapi has
different paths and hooks to accomodate it and what a rq means becomes
quite confusing and making changes at the block layer becomes quite
difficult and error-prone.

This patch makes ide-tape use bio instead. With the previous patch,
ide-tape currently is using single contiguos buffer so replacing it
isn't difficult. Data buffer is mapped into bio using
blk_rq_map_kern() in idetape_queue_rw_tail(). idetape_io_buffers()
and idetape_update_buffers() are dropped and pc->bh is set to null to
tell ide-atapi to use standard data transfer mechanism and idetape_bh
byte counts are updated by the issuer on completion using the residual
count.

This change also nicely removes the FIXME in ide_pc_intr() where
ide-tape rqs need to be completed using ide_rq_bytes() instead of
blk_rq_bytes() (although this didn't really matter as the request
didn't have bio).

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <jens.axboe@oracle.com>
eb6a61bb9543aa54d62595e27206b3d3c0293bcc 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-atapi,tape,floppy: allow ->pc_callback() to change rq->data_len

Impact: allow residual count implementation in ->pc_callback()

rq->data_len has two duties - carrying the number of input bytes on
issue and carrying residual count back to the issuer on completion.
ide-atapi completion callback ->pc_callback() is the right place to do
this but currently ide-atapi depends on rq->data_len carrying the
original request size after calling ->pc_callback() to complete the pc
request.

This patch makes ide_pc_intr(), ide_tape_issue_pc() and
ide_floppy_issue_pc() cache length to complete before calling
->pc_callback() so that it can modify rq->data_len as necessary.

Note: As using rq->data_len for two purposes can make cases like this
incorrect in subtle ways, future changes will introduce separate
field for residual count.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <jens.axboe@oracle.com>
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>
ac0b0113ddbab3ed2388132d368c97292f9f3c84 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-atapi: don't abuse rq->buffer

Impact: rq->buffer usage cleanup

ide-atapi uses rq->buffer as private opaque value for internal special
requests. rq->special isn't used for these cases (the only case where
rq->special is used is for ide-tape rw requests). Use rq->special
instead.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
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>
21d9c5d227593d15630ae83a336d1519653e9b8a 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-tape: use standard data transfer mechanism

Impact: use standard way to transfer data

ide-tape uses rq in an interesting way. For r/w requests, rq->special
is used to carry a private buffer management structure idetape_bh and
rq->nr_sectors and current_nr_sectors are initialized to the number of
idetape blocks which isn't necessary 512 bytes. Also,
rq->current_nr_sectors is used to report back the residual count in
units of idetape blocks.

This peculiarity taxes both block layer and ide. ide-atapi has
different paths and hooks to accomodate it and what a rq means becomes
quite confusing and making changes at the block layer becomes quite
difficult and error-prone.

This patch makes ide-tape use bio instead. With the previous patch,
ide-tape currently is using single contiguos buffer so replacing it
isn't difficult. Data buffer is mapped into bio using
blk_rq_map_kern() in idetape_queue_rw_tail(). idetape_io_buffers()
and idetape_update_buffers() are dropped and pc->bh is set to null to
tell ide-atapi to use standard data transfer mechanism and idetape_bh
byte counts are updated by the issuer on completion using the residual
count.

This change also nicely removes the FIXME in ide_pc_intr() where
ide-tape rqs need to be completed using ide_rq_bytes() instead of
blk_rq_bytes() (although this didn't really matter as the request
didn't have bio).

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <jens.axboe@oracle.com>
b3071d190d6757b14af002a9d79832f12de61bce 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-atapi,tape,floppy: allow ->pc_callback() to change rq->data_len

Impact: allow residual count implementation in ->pc_callback()

rq->data_len has two duties - carrying the number of input bytes on
issue and carrying residual count back to the issuer on completion.
ide-atapi completion callback ->pc_callback() is the right place to do
this but currently ide-atapi depends on rq->data_len carrying the
original request size after calling ->pc_callback() to complete the pc
request.

This patch makes ide_pc_intr(), ide_tape_issue_pc() and
ide_floppy_issue_pc() cache length to complete before calling
->pc_callback() so that it can modify rq->data_len as necessary.

Note: As using rq->data_len for two purposes can make cases like this
incorrect in subtle ways, future changes will introduce separate
field for residual count.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <jens.axboe@oracle.com>
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>
c267cc1c4db4ccb3406d045a8da8660f0bbfe08d 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-atapi: don't abuse rq->buffer

Impact: rq->buffer usage cleanup

ide-atapi uses rq->buffer as private opaque value for internal special
requests. rq->special isn't used for these cases (the only case where
rq->special is used is for ide-tape rw requests). Use rq->special
instead.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
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>
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>
5b6c942dd1f13835eff8105ec2aa859544a1498d 31-Mar-2009 Borislav Petkov <petkovbb@gmail.com> ide-floppy: do not complete rq's prematurely

... and access them afterwards. Simplify rq completing code while at it.

Spotted-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Borislav Petkov <petkovbb@gmail.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>
d93bc4521c80e9d87767779814e88f6d725453d7 31-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-{floppy,tape}: fix padding for PIO transfers

* Return number of bytes left to transfer from idetape_{in,out}put_buffers()
and number of bytes done from ide_tape_io_buffers().

* Fix padding for PIO transfers in ide_pc_intr() so read/write buffers are
always completely processed and then the transfer is padded if necessary.

* Remove invalid error messages.

* Remove now superfluous padding from ide{_io_buffers,tape_input_buffers}().

While at it:

* Set pc->bh to NULL in idetape_input_buffers() after all bh-s are done.

* Cache !!(pc->flags & PC_FLAG_WRITING) in local variable in ide_pc_intr().

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>
88b4132e101e60e8fa67996ae3072ab6b71e8500 31-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: set/clear drive->waiting_for_dma flag in the core code

Set/clear drive->waiting_for_dma flag in the core code
instead of in ->dma_setup and ->dma_end methods.

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>
2eba08270990b99fb5429b76ee97184ddd272f7f 31-Mar-2009 Borislav Petkov <petkovbb@gmail.com> ide-atapi: start DMA after issuing a packet command

Apparently¹, some ATAPI devices want to see the packet command first
before enabling DMA otherwise they simply hang indefinitely. Reorder the
two steps and start DMA only after having issued the command first.

[1] http://marc.info/?l=linux-kernel&m=123835520317235&w=2

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Reported-by: Michael Roth <mroth@nessie.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
479edf065576aeed7ac99d10838bb3b4f870b5f9 31-Mar-2009 Geert Uytterhoeven <geert@linux-m68k.org> ide: drivers/ide/ide-atapi.c needs <linux/scatterlist.h>

On m68k:
| drivers/ide/ide-atapi.c: In function 'ide_io_buffers':
| drivers/ide/ide-atapi.c:87: error: implicit declaration of function 'sg_page'
| drivers/ide/ide-atapi.c:87: warning: passing argument 1 of 'PageHighMem' makes pointer from integer without a cast
| drivers/ide/ide-atapi.c:91: warning: passing argument 1 of 'kmap_atomic' makes pointer from integer without a cast
| drivers/ide/ide-atapi.c:96: error: implicit declaration of function 'sg_virt'
| drivers/ide/ide-atapi.c:96: warning: assignment makes pointer from integer without a cast
| drivers/ide/ide-atapi.c:107: error: implicit declaration of function 'sg_next'
| drivers/ide/ide-atapi.c:107: warning: assignment makes pointer from integer without a cast

[bart: Dmitri Vorobiev submitted similar patch fixing MIPS]

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Dmitri Vorobiev <dmitri.vorobiev@movial.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>
89f78b3261f7e331e41753ea2459fbb9b60a6f7a 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move rq->errors quirk out from ide_end_request()

Move rq->errors quirk out from ide_end_request() to its call sites.

There should be no functional changes caused by this patch.

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>
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>
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>
0d6a9754c06e173552b0ad5fad45f69786b6de99 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move ide_read_bcount_and_ireason() to ide-atapi.c

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>
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>
3eb76c1ccde496c3c0bfda23d1c803e40b762ce6 13-Mar-2009 Borislav Petkov <petkovbb@gmail.com> ide-floppy: do not map dataless cmds to an sg

since it fails the virt_to_page() translation check with DEBUG_VIRTUAL
enabled.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
[bart: backport to Linus' tree]
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>
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>
b16aabc9374217fa2d28e72fd9a6e6d60905e1b9 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: start dma in a drive-specific way

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>
06cc2778a1744b79edcfa394ce2d41f09134b2b1 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: put the rest of non-ide-cd code into the else-clause of ide_transfer_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>
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>
d77612ab0ad7515623b084b952dfefd547073ada 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: split drive-specific functionality in 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>
def860d061d0fcab7fbbe193c0b8b8f0b9b4c828 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: assign expiry and timeout based on device type

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>
8c662852d1aa35ed370942ef2740759cd334d2d5 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: compute cmd_len based on device type in ide_transfer_pc

There should be no functionality change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
[bart: move cmd_len check closer to ->output_data() call]
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>
5fe3110431ccf437607bdc11ac3677bf3eeee6e3 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: remove ide-scsi remnants from ide_transfer_pc()

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
152fe1cc38ebebb81724663e3b1e1e10272a729e 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: remove ide-scsi remnants from ide_issue_pc

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>
5f25843fa79b7c35097b0ffe8b2c5cc2428d6495 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: teach ide atapi about drive->waiting_for_dma

In addition, we wait for DRQ to be asserted by repeatedly polling
device status no matter what DRQ type each device implements.

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>
4f02ff06b4d33aba50ce5157c23e99cd21d447ee 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: setup dma for ide-cd

There should be no functional change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
ed48554fad7091b9613b967462f082bf1a9cb035 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: combine drive-specific assignments

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>
991cb26a6ad287c3bc6555c41e830590a23910c4 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: add a dev_is_idecd-inline

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>
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>
f9476b96b5c19a843d6256b8d228ebf1edabb1b6 13-Oct-2008 Borislav Petkov <petkovbb@googlemail.com> ide-atapi: assign taskfile flags per device type

There should be no functional change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@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>
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>
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>
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>
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>
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>
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>
aaaade3f059fa1b57283d4a7c8351a42ec747bf0 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> 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>
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>
8fccf8995c6d462db50265a5f7fa9a288a5a4590 23-Jul-2008 Borislav Petkov <petkovbb@googlemail.com> ide: use rq->cmd instead of pc->c in atapi common code

There should be no functionality change resulting from this patch.

[bart: s/HWGROUP(drive)/hwif->hwgroup/]

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
db9d286988b9e905045c536f681e85fa5e3a728b 23-Jul-2008 Borislav Petkov <petkovbb@googlemail.com> ide-scsi: use drive->pc_callback instead of pc->callback

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>
776bb0270ea72c40f95347dcac868c9f602dcb3e 23-Jul-2008 Borislav Petkov <petkovbb@googlemail.com> ide-tape: use drive->pc_callback instead of pc->callback

The if-else block in the IRQ handler is only temporary so that bisect searches
don't break and it'll be removed after converting the remainder of the drivers.

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>
2207fa5af1507ea018fc95e777276edb1ca5601a 23-Jul-2008 Borislav Petkov <petkovbb@googlemail.com> ide-floppy: use drive->pc_callback instead of pc->callback

It is important that drive->pc_callback is set prior to enabling IRQs on the
device since this is called from the IRQ handler. Otherwise it hurts as I learnt
the hard way from the several "Kernel panic - not synching: Fatal exception in
interrupt" during the weekend :).

The if-else block in the IRQ handler is only temporary so that bisect searches
don't break and it'll be removed after converting the remainder of the drivers.

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>
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>
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>
88a72109b2256bf2974f324a8f890b4a06faf7e9 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_read_ireason() helper

Add ide_read_ireason() helper and use instead of ->INB for reading
ATAPI Interrupt Reason register.

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>
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>
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>