aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-cd_ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-cd_ioctl.c')
-rw-r--r--drivers/ide/ide-cd_ioctl.c113
1 files changed, 54 insertions, 59 deletions
diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c
index 6d147ce6782f..24d002addf73 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
@@ -298,14 +296,14 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi)
298 ide_drive_t *drive = cdi->handle; 296 ide_drive_t *drive = cdi->handle;
299 struct cdrom_info *cd = drive->driver_data; 297 struct cdrom_info *cd = drive->driver_data;
300 struct request_sense sense; 298 struct request_sense sense;
301 struct request req; 299 struct request *rq;
302 int ret; 300 int ret;
303 301
304 ide_cd_init_rq(drive, &req); 302 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
305 req.cmd_type = REQ_TYPE_SPECIAL; 303 rq->cmd_type = REQ_TYPE_SPECIAL;
306 req.cmd_flags = REQ_QUIET; 304 rq->cmd_flags = REQ_QUIET;
307 ret = ide_do_drive_cmd(drive, &req, ide_wait); 305 ret = blk_execute_rq(drive->queue, cd->disk, rq, 0);
308 306 blk_put_request(rq);
309 /* 307 /*
310 * A reset will unlock the door. If it was previously locked, 308 * A reset will unlock the door. If it was previously locked,
311 * lock it again. 309 * lock it again.
@@ -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
383static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg) 380static 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,
447int ide_cdrom_packet(struct cdrom_device_info *cdi, 444int 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}