aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-atapi.c
diff options
context:
space:
mode:
authorBorislav Petkov <petkovbb@googlemail.com>2009-04-18 18:00:42 -0400
committerTejun Heo <tj@kernel.org>2009-04-18 18:00:42 -0400
commita1df5169f9bf08f6067029bfb840a05e282b1b97 (patch)
treef0ec5f74cc80f15d9d5720aa68997aa307f10dc1 /drivers/ide/ide-atapi.c
parentcbfd082abfcbed8c57a12636f36e9bead8d6cfc6 (diff)
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>
Diffstat (limited to 'drivers/ide/ide-atapi.c')
-rw-r--r--drivers/ide/ide-atapi.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 2894577237ba..c6e03485a63a 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -191,6 +191,67 @@ void ide_create_request_sense_cmd(ide_drive_t *drive, struct ide_atapi_pc *pc)
191} 191}
192EXPORT_SYMBOL_GPL(ide_create_request_sense_cmd); 192EXPORT_SYMBOL_GPL(ide_create_request_sense_cmd);
193 193
194void ide_prep_sense(ide_drive_t *drive, struct request *rq)
195{
196 struct request_sense *sense = &drive->sense_data;
197 struct request *sense_rq = &drive->sense_rq;
198 unsigned int cmd_len, sense_len;
199
200 debug_log("%s: enter\n", __func__);
201
202 switch (drive->media) {
203 case ide_floppy:
204 cmd_len = 255;
205 sense_len = 18;
206 break;
207 case ide_tape:
208 cmd_len = 20;
209 sense_len = 20;
210 break;
211 default:
212 cmd_len = 18;
213 sense_len = 18;
214 }
215
216 BUG_ON(sense_len > sizeof(*sense));
217
218 if (blk_sense_request(rq) || drive->sense_rq_armed)
219 return;
220
221 memset(sense, 0, sizeof(*sense));
222
223 blk_rq_init(rq->q, sense_rq);
224 sense_rq->rq_disk = rq->rq_disk;
225
226 sense_rq->data = sense;
227 sense_rq->cmd[0] = GPCMD_REQUEST_SENSE;
228 sense_rq->cmd[4] = cmd_len;
229 sense_rq->data_len = sense_len;
230
231 sense_rq->cmd_type = REQ_TYPE_SENSE;
232 sense_rq->cmd_flags |= REQ_PREEMPT;
233
234 if (drive->media == ide_tape)
235 sense_rq->cmd[13] = REQ_IDETAPE_PC1;
236
237 drive->sense_rq_armed = true;
238}
239EXPORT_SYMBOL_GPL(ide_prep_sense);
240
241void ide_queue_sense_rq(ide_drive_t *drive, void *special)
242{
243 BUG_ON(!drive->sense_rq_armed);
244
245 drive->sense_rq.special = special;
246 drive->sense_rq_armed = false;
247
248 drive->hwif->rq = NULL;
249
250 elv_add_request(drive->queue, &drive->sense_rq,
251 ELEVATOR_INSERT_FRONT, 0);
252}
253EXPORT_SYMBOL_GPL(ide_queue_sense_rq);
254
194/* 255/*
195 * Called when an error was detected during the last packet command. 256 * Called when an error was detected during the last packet command.
196 * We queue a request sense packet command in the head of the request list. 257 * We queue a request sense packet command in the head of the request list.