diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2008-07-15 15:21:42 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-07-15 15:21:42 -0400 |
commit | 5f828546e1acb45678e73d3a9a796c1a3a8c7846 (patch) | |
tree | c8a8cf3a1249518f03d455c5757622adc7f582fa | |
parent | c6866a6ff571eebebda45bf14b5b62188768893a (diff) |
ide-cd: convert ide_cd_queue_pc to use blk_execute_rq
This converts ide_cd_queue_pc to use blk_execute_rq, necessitating
changing the ide_cd_queue_pc prototype into a form that doesn't takes
a pointer to request struct. ide_cd_queue_pc works like scsi_execute.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Borislav Petkov <petkovbb@gmail.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r-- | drivers/ide/ide-cd.c | 96 | ||||
-rw-r--r-- | drivers/ide/ide-cd.h | 3 | ||||
-rw-r--r-- | drivers/ide/ide-cd_ioctl.c | 101 |
3 files changed, 103 insertions, 97 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index ff8815937d32..792a3cf73d6e 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -839,34 +839,54 @@ static void ide_cd_request_sense_fixup(struct request *rq) | |||
839 | } | 839 | } |
840 | } | 840 | } |
841 | 841 | ||
842 | int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq) | 842 | int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd, |
843 | int write, void *buffer, unsigned *bufflen, | ||
844 | struct request_sense *sense, int timeout, | ||
845 | unsigned int cmd_flags) | ||
843 | { | 846 | { |
844 | struct request_sense sense; | 847 | struct cdrom_info *info = drive->driver_data; |
848 | struct request_sense local_sense; | ||
845 | int retries = 10; | 849 | int retries = 10; |
846 | unsigned int flags = rq->cmd_flags; | 850 | unsigned int flags = 0; |
847 | 851 | ||
848 | if (rq->sense == NULL) | 852 | if (!sense) |
849 | rq->sense = &sense; | 853 | sense = &local_sense; |
850 | 854 | ||
851 | /* start of retry loop */ | 855 | /* start of retry loop */ |
852 | do { | 856 | do { |
857 | struct request *rq; | ||
853 | int error; | 858 | int error; |
854 | unsigned long time = jiffies; | ||
855 | rq->cmd_flags = flags; | ||
856 | 859 | ||
857 | error = ide_do_drive_cmd(drive, rq, ide_wait); | 860 | rq = blk_get_request(drive->queue, write, __GFP_WAIT); |
858 | time = jiffies - time; | 861 | |
862 | memcpy(rq->cmd, cmd, BLK_MAX_CDB); | ||
863 | rq->cmd_type = REQ_TYPE_ATA_PC; | ||
864 | rq->sense = sense; | ||
865 | rq->cmd_flags |= cmd_flags; | ||
866 | rq->timeout = timeout; | ||
867 | if (buffer) { | ||
868 | rq->data = buffer; | ||
869 | rq->data_len = *bufflen; | ||
870 | } | ||
871 | |||
872 | error = blk_execute_rq(drive->queue, info->disk, rq, 0); | ||
873 | |||
874 | if (buffer) | ||
875 | *bufflen = rq->data_len; | ||
876 | |||
877 | flags = rq->cmd_flags; | ||
878 | blk_put_request(rq); | ||
859 | 879 | ||
860 | /* | 880 | /* |
861 | * FIXME: we should probably abort/retry or something in case of | 881 | * FIXME: we should probably abort/retry or something in case of |
862 | * failure. | 882 | * failure. |
863 | */ | 883 | */ |
864 | if (rq->cmd_flags & REQ_FAILED) { | 884 | if (flags & REQ_FAILED) { |
865 | /* | 885 | /* |
866 | * The request failed. Retry if it was due to a unit | 886 | * The request failed. Retry if it was due to a unit |
867 | * attention status (usually means media was changed). | 887 | * attention status (usually means media was changed). |
868 | */ | 888 | */ |
869 | struct request_sense *reqbuf = rq->sense; | 889 | struct request_sense *reqbuf = sense; |
870 | 890 | ||
871 | if (reqbuf->sense_key == UNIT_ATTENTION) | 891 | if (reqbuf->sense_key == UNIT_ATTENTION) |
872 | cdrom_saw_media_change(drive); | 892 | cdrom_saw_media_change(drive); |
@@ -886,10 +906,10 @@ int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq) | |||
886 | } | 906 | } |
887 | 907 | ||
888 | /* end of retry loop */ | 908 | /* end of retry loop */ |
889 | } while ((rq->cmd_flags & REQ_FAILED) && retries >= 0); | 909 | } while ((flags & REQ_FAILED) && retries >= 0); |
890 | 910 | ||
891 | /* return an error if the command failed */ | 911 | /* return an error if the command failed */ |
892 | return (rq->cmd_flags & REQ_FAILED) ? -EIO : 0; | 912 | return (flags & REQ_FAILED) ? -EIO : 0; |
893 | } | 913 | } |
894 | 914 | ||
895 | /* | 915 | /* |
@@ -1269,23 +1289,20 @@ static void msf_from_bcd(struct atapi_msf *msf) | |||
1269 | 1289 | ||
1270 | int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) | 1290 | int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) |
1271 | { | 1291 | { |
1272 | struct request req; | ||
1273 | struct cdrom_info *info = drive->driver_data; | 1292 | struct cdrom_info *info = drive->driver_data; |
1274 | struct cdrom_device_info *cdi = &info->devinfo; | 1293 | struct cdrom_device_info *cdi = &info->devinfo; |
1294 | unsigned char cmd[BLK_MAX_CDB]; | ||
1275 | 1295 | ||
1276 | ide_cd_init_rq(drive, &req); | 1296 | memset(cmd, 0, BLK_MAX_CDB); |
1277 | 1297 | cmd[0] = GPCMD_TEST_UNIT_READY; | |
1278 | req.sense = sense; | ||
1279 | req.cmd[0] = GPCMD_TEST_UNIT_READY; | ||
1280 | req.cmd_flags |= REQ_QUIET; | ||
1281 | 1298 | ||
1282 | /* | 1299 | /* |
1283 | * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to switch CDs | 1300 | * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to switch CDs |
1284 | * instead of supporting the LOAD_UNLOAD opcode. | 1301 | * instead of supporting the LOAD_UNLOAD opcode. |
1285 | */ | 1302 | */ |
1286 | req.cmd[7] = cdi->sanyo_slot % 3; | 1303 | cmd[7] = cdi->sanyo_slot % 3; |
1287 | 1304 | ||
1288 | return ide_cd_queue_pc(drive, &req); | 1305 | return ide_cd_queue_pc(drive, cmd, 0, NULL, 0, sense, 0, REQ_QUIET); |
1289 | } | 1306 | } |
1290 | 1307 | ||
1291 | static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, | 1308 | static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, |
@@ -1298,17 +1315,14 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, | |||
1298 | } capbuf; | 1315 | } capbuf; |
1299 | 1316 | ||
1300 | int stat; | 1317 | int stat; |
1301 | struct request req; | 1318 | unsigned char cmd[BLK_MAX_CDB]; |
1302 | 1319 | unsigned len = sizeof(capbuf); | |
1303 | ide_cd_init_rq(drive, &req); | ||
1304 | 1320 | ||
1305 | req.sense = sense; | 1321 | memset(cmd, 0, BLK_MAX_CDB); |
1306 | req.cmd[0] = GPCMD_READ_CDVD_CAPACITY; | 1322 | cmd[0] = GPCMD_READ_CDVD_CAPACITY; |
1307 | req.data = (char *)&capbuf; | ||
1308 | req.data_len = sizeof(capbuf); | ||
1309 | req.cmd_flags |= REQ_QUIET; | ||
1310 | 1323 | ||
1311 | stat = ide_cd_queue_pc(drive, &req); | 1324 | stat = ide_cd_queue_pc(drive, cmd, 0, &capbuf, &len, sense, 0, |
1325 | REQ_QUIET); | ||
1312 | if (stat == 0) { | 1326 | if (stat == 0) { |
1313 | *capacity = 1 + be32_to_cpu(capbuf.lba); | 1327 | *capacity = 1 + be32_to_cpu(capbuf.lba); |
1314 | *sectors_per_frame = | 1328 | *sectors_per_frame = |
@@ -1322,24 +1336,20 @@ static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag, | |||
1322 | int format, char *buf, int buflen, | 1336 | int format, char *buf, int buflen, |
1323 | struct request_sense *sense) | 1337 | struct request_sense *sense) |
1324 | { | 1338 | { |
1325 | struct request req; | 1339 | unsigned char cmd[BLK_MAX_CDB]; |
1326 | 1340 | ||
1327 | ide_cd_init_rq(drive, &req); | 1341 | memset(cmd, 0, BLK_MAX_CDB); |
1328 | 1342 | ||
1329 | req.sense = sense; | 1343 | cmd[0] = GPCMD_READ_TOC_PMA_ATIP; |
1330 | req.data = buf; | 1344 | cmd[6] = trackno; |
1331 | req.data_len = buflen; | 1345 | cmd[7] = (buflen >> 8); |
1332 | req.cmd_flags |= REQ_QUIET; | 1346 | cmd[8] = (buflen & 0xff); |
1333 | req.cmd[0] = GPCMD_READ_TOC_PMA_ATIP; | 1347 | cmd[9] = (format << 6); |
1334 | req.cmd[6] = trackno; | ||
1335 | req.cmd[7] = (buflen >> 8); | ||
1336 | req.cmd[8] = (buflen & 0xff); | ||
1337 | req.cmd[9] = (format << 6); | ||
1338 | 1348 | ||
1339 | if (msf_flag) | 1349 | if (msf_flag) |
1340 | req.cmd[1] = 2; | 1350 | cmd[1] = 2; |
1341 | 1351 | ||
1342 | return ide_cd_queue_pc(drive, &req); | 1352 | return ide_cd_queue_pc(drive, cmd, 0, buf, &buflen, sense, 0, REQ_QUIET); |
1343 | } | 1353 | } |
1344 | 1354 | ||
1345 | /* Try to read the entire TOC for the disk into our internal buffer. */ | 1355 | /* Try to read the entire TOC for the disk into our internal buffer. */ |
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h index a58801c4484d..df01cfd797cf 100644 --- a/drivers/ide/ide-cd.h +++ b/drivers/ide/ide-cd.h | |||
@@ -144,7 +144,8 @@ void ide_cd_log_error(const char *, struct request *, struct request_sense *); | |||
144 | 144 | ||
145 | /* ide-cd.c functions used by ide-cd_ioctl.c */ | 145 | /* ide-cd.c functions used by ide-cd_ioctl.c */ |
146 | void ide_cd_init_rq(ide_drive_t *, struct request *); | 146 | void ide_cd_init_rq(ide_drive_t *, struct request *); |
147 | int ide_cd_queue_pc(ide_drive_t *, struct request *); | 147 | int ide_cd_queue_pc(ide_drive_t *, const unsigned char *, int, void *, |
148 | unsigned *, struct request_sense *, int, unsigned int); | ||
148 | int ide_cd_read_toc(ide_drive_t *, struct request_sense *); | 149 | int ide_cd_read_toc(ide_drive_t *, struct request_sense *); |
149 | int ide_cdrom_get_capabilities(ide_drive_t *, u8 *); | 150 | int ide_cdrom_get_capabilities(ide_drive_t *, u8 *); |
150 | void ide_cdrom_update_speed(ide_drive_t *, u8 *); | 151 | void ide_cdrom_update_speed(ide_drive_t *, u8 *); |
diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c index 6d147ce6782f..851277074302 100644 --- a/drivers/ide/ide-cd_ioctl.c +++ b/drivers/ide/ide-cd_ioctl.c | |||
@@ -104,8 +104,8 @@ int cdrom_eject(ide_drive_t *drive, int ejectflag, | |||
104 | { | 104 | { |
105 | struct cdrom_info *cd = drive->driver_data; | 105 | struct cdrom_info *cd = drive->driver_data; |
106 | struct cdrom_device_info *cdi = &cd->devinfo; | 106 | struct cdrom_device_info *cdi = &cd->devinfo; |
107 | struct request req; | ||
108 | char loej = 0x02; | 107 | char loej = 0x02; |
108 | unsigned char cmd[BLK_MAX_CDB]; | ||
109 | 109 | ||
110 | if ((cd->cd_flags & IDE_CD_FLAG_NO_EJECT) && !ejectflag) | 110 | if ((cd->cd_flags & IDE_CD_FLAG_NO_EJECT) && !ejectflag) |
111 | return -EDRIVE_CANT_DO_THIS; | 111 | return -EDRIVE_CANT_DO_THIS; |
@@ -114,17 +114,16 @@ int cdrom_eject(ide_drive_t *drive, int ejectflag, | |||
114 | if ((cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) && ejectflag) | 114 | if ((cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) && ejectflag) |
115 | return 0; | 115 | return 0; |
116 | 116 | ||
117 | ide_cd_init_rq(drive, &req); | ||
118 | |||
119 | /* only tell drive to close tray if open, if it can do that */ | 117 | /* only tell drive to close tray if open, if it can do that */ |
120 | if (ejectflag && (cdi->mask & CDC_CLOSE_TRAY)) | 118 | if (ejectflag && (cdi->mask & CDC_CLOSE_TRAY)) |
121 | loej = 0; | 119 | loej = 0; |
122 | 120 | ||
123 | req.sense = sense; | 121 | memset(cmd, 0, BLK_MAX_CDB); |
124 | req.cmd[0] = GPCMD_START_STOP_UNIT; | 122 | |
125 | req.cmd[4] = loej | (ejectflag != 0); | 123 | cmd[0] = GPCMD_START_STOP_UNIT; |
124 | cmd[4] = loej | (ejectflag != 0); | ||
126 | 125 | ||
127 | return ide_cd_queue_pc(drive, &req); | 126 | return ide_cd_queue_pc(drive, cmd, 0, NULL, 0, sense, 0, 0); |
128 | } | 127 | } |
129 | 128 | ||
130 | /* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */ | 129 | /* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */ |
@@ -134,7 +133,6 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag, | |||
134 | { | 133 | { |
135 | struct cdrom_info *cd = drive->driver_data; | 134 | struct cdrom_info *cd = drive->driver_data; |
136 | struct request_sense my_sense; | 135 | struct request_sense my_sense; |
137 | struct request req; | ||
138 | int stat; | 136 | int stat; |
139 | 137 | ||
140 | if (sense == NULL) | 138 | if (sense == NULL) |
@@ -144,11 +142,15 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag, | |||
144 | if (cd->cd_flags & IDE_CD_FLAG_NO_DOORLOCK) { | 142 | if (cd->cd_flags & IDE_CD_FLAG_NO_DOORLOCK) { |
145 | stat = 0; | 143 | stat = 0; |
146 | } else { | 144 | } else { |
147 | ide_cd_init_rq(drive, &req); | 145 | unsigned char cmd[BLK_MAX_CDB]; |
148 | req.sense = sense; | 146 | |
149 | req.cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; | 147 | memset(cmd, 0, BLK_MAX_CDB); |
150 | req.cmd[4] = lockflag ? 1 : 0; | 148 | |
151 | stat = ide_cd_queue_pc(drive, &req); | 149 | cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; |
150 | cmd[4] = lockflag ? 1 : 0; | ||
151 | |||
152 | stat = ide_cd_queue_pc(drive, cmd, 0, NULL, 0, | ||
153 | sense, 0, 0); | ||
152 | } | 154 | } |
153 | 155 | ||
154 | /* If we got an illegal field error, the drive | 156 | /* If we got an illegal field error, the drive |
@@ -206,32 +208,30 @@ int ide_cdrom_select_speed(struct cdrom_device_info *cdi, int speed) | |||
206 | { | 208 | { |
207 | ide_drive_t *drive = cdi->handle; | 209 | ide_drive_t *drive = cdi->handle; |
208 | struct cdrom_info *cd = drive->driver_data; | 210 | struct cdrom_info *cd = drive->driver_data; |
209 | struct request rq; | ||
210 | struct request_sense sense; | 211 | struct request_sense sense; |
211 | u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; | 212 | u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; |
212 | int stat; | 213 | int stat; |
213 | 214 | unsigned char cmd[BLK_MAX_CDB]; | |
214 | ide_cd_init_rq(drive, &rq); | ||
215 | |||
216 | rq.sense = &sense; | ||
217 | 215 | ||
218 | if (speed == 0) | 216 | if (speed == 0) |
219 | speed = 0xffff; /* set to max */ | 217 | speed = 0xffff; /* set to max */ |
220 | else | 218 | else |
221 | speed *= 177; /* Nx to kbytes/s */ | 219 | speed *= 177; /* Nx to kbytes/s */ |
222 | 220 | ||
223 | rq.cmd[0] = GPCMD_SET_SPEED; | 221 | memset(cmd, 0, BLK_MAX_CDB); |
222 | |||
223 | cmd[0] = GPCMD_SET_SPEED; | ||
224 | /* Read Drive speed in kbytes/second MSB/LSB */ | 224 | /* Read Drive speed in kbytes/second MSB/LSB */ |
225 | rq.cmd[2] = (speed >> 8) & 0xff; | 225 | cmd[2] = (speed >> 8) & 0xff; |
226 | rq.cmd[3] = speed & 0xff; | 226 | cmd[3] = speed & 0xff; |
227 | if ((cdi->mask & (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) != | 227 | if ((cdi->mask & (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) != |
228 | (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) { | 228 | (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) { |
229 | /* Write Drive speed in kbytes/second MSB/LSB */ | 229 | /* Write Drive speed in kbytes/second MSB/LSB */ |
230 | rq.cmd[4] = (speed >> 8) & 0xff; | 230 | cmd[4] = (speed >> 8) & 0xff; |
231 | rq.cmd[5] = speed & 0xff; | 231 | cmd[5] = speed & 0xff; |
232 | } | 232 | } |
233 | 233 | ||
234 | stat = ide_cd_queue_pc(drive, &rq); | 234 | stat = ide_cd_queue_pc(drive, cmd, 0, NULL, 0, &sense, 0, 0); |
235 | 235 | ||
236 | if (!ide_cdrom_get_capabilities(drive, buf)) { | 236 | if (!ide_cdrom_get_capabilities(drive, buf)) { |
237 | ide_cdrom_update_speed(drive, buf); | 237 | ide_cdrom_update_speed(drive, buf); |
@@ -268,21 +268,19 @@ int ide_cdrom_get_mcn(struct cdrom_device_info *cdi, | |||
268 | { | 268 | { |
269 | ide_drive_t *drive = cdi->handle; | 269 | ide_drive_t *drive = cdi->handle; |
270 | int stat, mcnlen; | 270 | int stat, mcnlen; |
271 | struct request rq; | ||
272 | char buf[24]; | 271 | char buf[24]; |
272 | unsigned char cmd[BLK_MAX_CDB]; | ||
273 | unsigned len = sizeof(buf); | ||
273 | 274 | ||
274 | ide_cd_init_rq(drive, &rq); | 275 | memset(cmd, 0, BLK_MAX_CDB); |
275 | 276 | ||
276 | rq.data = buf; | 277 | cmd[0] = GPCMD_READ_SUBCHANNEL; |
277 | rq.data_len = sizeof(buf); | 278 | cmd[1] = 2; /* MSF addressing */ |
279 | cmd[2] = 0x40; /* request subQ data */ | ||
280 | cmd[3] = 2; /* format */ | ||
281 | cmd[8] = len; | ||
278 | 282 | ||
279 | rq.cmd[0] = GPCMD_READ_SUBCHANNEL; | 283 | stat = ide_cd_queue_pc(drive, cmd, 0, buf, &len, NULL, 0, 0); |
280 | rq.cmd[1] = 2; /* MSF addressing */ | ||
281 | rq.cmd[2] = 0x40; /* request subQ data */ | ||
282 | rq.cmd[3] = 2; /* format */ | ||
283 | rq.cmd[8] = sizeof(buf); | ||
284 | |||
285 | stat = ide_cd_queue_pc(drive, &rq); | ||
286 | if (stat) | 284 | if (stat) |
287 | return stat; | 285 | return stat; |
288 | 286 | ||
@@ -351,8 +349,8 @@ static int ide_cd_fake_play_trkind(ide_drive_t *drive, void *arg) | |||
351 | struct atapi_toc_entry *first_toc, *last_toc; | 349 | struct atapi_toc_entry *first_toc, *last_toc; |
352 | unsigned long lba_start, lba_end; | 350 | unsigned long lba_start, lba_end; |
353 | int stat; | 351 | int stat; |
354 | struct request rq; | ||
355 | struct request_sense sense; | 352 | struct request_sense sense; |
353 | unsigned char cmd[BLK_MAX_CDB]; | ||
356 | 354 | ||
357 | stat = ide_cd_get_toc_entry(drive, ti->cdti_trk0, &first_toc); | 355 | stat = ide_cd_get_toc_entry(drive, ti->cdti_trk0, &first_toc); |
358 | if (stat) | 356 | if (stat) |
@@ -370,14 +368,13 @@ static int ide_cd_fake_play_trkind(ide_drive_t *drive, void *arg) | |||
370 | if (lba_end <= lba_start) | 368 | if (lba_end <= lba_start) |
371 | return -EINVAL; | 369 | return -EINVAL; |
372 | 370 | ||
373 | ide_cd_init_rq(drive, &rq); | 371 | memset(cmd, 0, BLK_MAX_CDB); |
374 | 372 | ||
375 | rq.sense = &sense; | 373 | cmd[0] = GPCMD_PLAY_AUDIO_MSF; |
376 | rq.cmd[0] = GPCMD_PLAY_AUDIO_MSF; | 374 | lba_to_msf(lba_start, &cmd[3], &cmd[4], &cmd[5]); |
377 | lba_to_msf(lba_start, &rq.cmd[3], &rq.cmd[4], &rq.cmd[5]); | 375 | lba_to_msf(lba_end - 1, &cmd[6], &cmd[7], &cmd[8]); |
378 | lba_to_msf(lba_end - 1, &rq.cmd[6], &rq.cmd[7], &rq.cmd[8]); | ||
379 | 376 | ||
380 | return ide_cd_queue_pc(drive, &rq); | 377 | return ide_cd_queue_pc(drive, cmd, 0, NULL, 0, &sense, 0, 0); |
381 | } | 378 | } |
382 | 379 | ||
383 | static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg) | 380 | static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg) |
@@ -447,8 +444,9 @@ int ide_cdrom_audio_ioctl(struct cdrom_device_info *cdi, | |||
447 | int ide_cdrom_packet(struct cdrom_device_info *cdi, | 444 | int ide_cdrom_packet(struct cdrom_device_info *cdi, |
448 | struct packet_command *cgc) | 445 | struct packet_command *cgc) |
449 | { | 446 | { |
450 | struct request req; | ||
451 | ide_drive_t *drive = cdi->handle; | 447 | ide_drive_t *drive = cdi->handle; |
448 | unsigned int flags = 0; | ||
449 | unsigned len = cgc->buflen; | ||
452 | 450 | ||
453 | if (cgc->timeout <= 0) | 451 | if (cgc->timeout <= 0) |
454 | cgc->timeout = ATAPI_WAIT_PC; | 452 | cgc->timeout = ATAPI_WAIT_PC; |
@@ -456,24 +454,21 @@ int ide_cdrom_packet(struct cdrom_device_info *cdi, | |||
456 | /* here we queue the commands from the uniform CD-ROM | 454 | /* here we queue the commands from the uniform CD-ROM |
457 | layer. the packet must be complete, as we do not | 455 | layer. the packet must be complete, as we do not |
458 | touch it at all. */ | 456 | touch it at all. */ |
459 | ide_cd_init_rq(drive, &req); | ||
460 | 457 | ||
461 | if (cgc->data_direction == CGC_DATA_WRITE) | 458 | if (cgc->data_direction == CGC_DATA_WRITE) |
462 | req.cmd_flags |= REQ_RW; | 459 | flags |= REQ_RW; |
463 | 460 | ||
464 | memcpy(req.cmd, cgc->cmd, CDROM_PACKET_SIZE); | ||
465 | if (cgc->sense) | 461 | if (cgc->sense) |
466 | memset(cgc->sense, 0, sizeof(struct request_sense)); | 462 | memset(cgc->sense, 0, sizeof(struct request_sense)); |
467 | req.data = cgc->buffer; | ||
468 | req.data_len = cgc->buflen; | ||
469 | req.timeout = cgc->timeout; | ||
470 | 463 | ||
471 | if (cgc->quiet) | 464 | if (cgc->quiet) |
472 | req.cmd_flags |= REQ_QUIET; | 465 | flags |= REQ_QUIET; |
473 | 466 | ||
474 | req.sense = cgc->sense; | 467 | cgc->stat = ide_cd_queue_pc(drive, cgc->cmd, |
475 | cgc->stat = ide_cd_queue_pc(drive, &req); | 468 | cgc->data_direction == CGC_DATA_WRITE, |
469 | cgc->buffer, &len, | ||
470 | cgc->sense, cgc->timeout, flags); | ||
476 | if (!cgc->stat) | 471 | if (!cgc->stat) |
477 | cgc->buflen -= req.data_len; | 472 | cgc->buflen -= len; |
478 | return cgc->stat; | 473 | return cgc->stat; |
479 | } | 474 | } |