Commit c70f6d91 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by James Bottomley

[PATCH] avoid obsolete APIs in sr

Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 86d7520d
...@@ -46,11 +46,14 @@ ...@@ -46,11 +46,14 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "scsi.h" #include <scsi/scsi.h>
#include <scsi/scsi_host.h> #include <scsi/scsi_dbg.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_driver.h> #include <scsi/scsi_driver.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_ioctl.h> /* For the door lock/unlock commands */ #include <scsi/scsi_ioctl.h> /* For the door lock/unlock commands */
#include <scsi/scsi_request.h>
#include "scsi_logging.h" #include "scsi_logging.h"
#include "sr.h" #include "sr.h"
...@@ -282,7 +285,7 @@ static void rw_intr(struct scsi_cmnd * SCpnt) ...@@ -282,7 +285,7 @@ static void rw_intr(struct scsi_cmnd * SCpnt)
* user, but make sure that it's not treated as a * user, but make sure that it's not treated as a
* hard error. * hard error.
*/ */
print_sense("sr", SCpnt); scsi_print_sense("sr", SCpnt);
SCpnt->result = 0; SCpnt->result = 0;
SCpnt->sense_buffer[0] = 0x0; SCpnt->sense_buffer[0] = 0x0;
good_bytes = this_count; good_bytes = this_count;
...@@ -335,11 +338,11 @@ static int sr_init_command(struct scsi_cmnd * SCpnt) ...@@ -335,11 +338,11 @@ static int sr_init_command(struct scsi_cmnd * SCpnt)
memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd)); memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
if (!rq->data_len) if (!rq->data_len)
SCpnt->sc_data_direction = SCSI_DATA_NONE; SCpnt->sc_data_direction = DMA_NONE;
else if (rq_data_dir(rq) == WRITE) else if (rq_data_dir(rq) == WRITE)
SCpnt->sc_data_direction = SCSI_DATA_WRITE; SCpnt->sc_data_direction = DMA_TO_DEVICE;
else else
SCpnt->sc_data_direction = SCSI_DATA_READ; SCpnt->sc_data_direction = DMA_FROM_DEVICE;
this_count = rq->data_len; this_count = rq->data_len;
if (rq->timeout) if (rq->timeout)
...@@ -375,10 +378,10 @@ static int sr_init_command(struct scsi_cmnd * SCpnt) ...@@ -375,10 +378,10 @@ static int sr_init_command(struct scsi_cmnd * SCpnt)
if (!cd->device->writeable) if (!cd->device->writeable)
return 0; return 0;
SCpnt->cmnd[0] = WRITE_10; SCpnt->cmnd[0] = WRITE_10;
SCpnt->sc_data_direction = SCSI_DATA_WRITE; SCpnt->sc_data_direction = DMA_TO_DEVICE;
} else if (rq_data_dir(SCpnt->request) == READ) { } else if (rq_data_dir(SCpnt->request) == READ) {
SCpnt->cmnd[0] = READ_10; SCpnt->cmnd[0] = READ_10;
SCpnt->sc_data_direction = SCSI_DATA_READ; SCpnt->sc_data_direction = DMA_FROM_DEVICE;
} else { } else {
blk_dump_rq_flags(SCpnt->request, "Unknown sr command"); blk_dump_rq_flags(SCpnt->request, "Unknown sr command");
return 0; return 0;
...@@ -674,7 +677,7 @@ static void get_sectorsize(struct scsi_cd *cd) ...@@ -674,7 +677,7 @@ static void get_sectorsize(struct scsi_cd *cd)
memset(buffer, 0, 8); memset(buffer, 0, 8);
/* Do the command and wait.. */ /* Do the command and wait.. */
SRpnt->sr_data_direction = SCSI_DATA_READ; SRpnt->sr_data_direction = DMA_FROM_DEVICE;
scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer, scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer,
8, SR_TIMEOUT, MAX_RETRIES); 8, SR_TIMEOUT, MAX_RETRIES);
......
...@@ -17,18 +17,20 @@ ...@@ -17,18 +17,20 @@
#ifndef _SR_H #ifndef _SR_H
#define _SR_H #define _SR_H
#include "scsi.h"
#include <linux/genhd.h> #include <linux/genhd.h>
#include <linux/kref.h> #include <linux/kref.h>
struct scsi_device;
/* The CDROM is fairly slow, so we need a little extra time */ /* The CDROM is fairly slow, so we need a little extra time */
/* In fact, it is very slow if it has to spin up first */ /* In fact, it is very slow if it has to spin up first */
#define IOCTL_TIMEOUT 30*HZ #define IOCTL_TIMEOUT 30*HZ
typedef struct scsi_cd { typedef struct scsi_cd {
struct scsi_driver *driver; struct scsi_driver *driver;
unsigned capacity; /* size in blocks */ unsigned capacity; /* size in blocks */
Scsi_Device *device; struct scsi_device *device;
unsigned int vendor; /* vendor code, see sr_vendor.c */ unsigned int vendor; /* vendor code, see sr_vendor.c */
unsigned long ms_offset; /* for reading multisession-CD's */ unsigned long ms_offset; /* for reading multisession-CD's */
unsigned needs_sector_size:1; /* needs to get sector size */ unsigned needs_sector_size:1; /* needs to get sector size */
......
...@@ -10,9 +10,13 @@ ...@@ -10,9 +10,13 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "scsi.h" #include <scsi/scsi.h>
#include <scsi/scsi_dbg.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_eh.h>
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <scsi/scsi_ioctl.h> #include <scsi/scsi_ioctl.h>
#include <scsi/scsi_request.h>
#include "sr.h" #include "sr.h"
...@@ -65,7 +69,7 @@ static int sr_fake_playtrkind(struct cdrom_device_info *cdi, struct cdrom_ti *ti ...@@ -65,7 +69,7 @@ static int sr_fake_playtrkind(struct cdrom_device_info *cdi, struct cdrom_ti *ti
cgc.cmd[6] = trk1_te.cdte_addr.msf.minute; cgc.cmd[6] = trk1_te.cdte_addr.msf.minute;
cgc.cmd[7] = trk1_te.cdte_addr.msf.second; cgc.cmd[7] = trk1_te.cdte_addr.msf.second;
cgc.cmd[8] = trk1_te.cdte_addr.msf.frame; cgc.cmd[8] = trk1_te.cdte_addr.msf.frame;
cgc.data_direction = SCSI_DATA_NONE; cgc.data_direction = DMA_NONE;
cgc.timeout = IOCTL_TIMEOUT; cgc.timeout = IOCTL_TIMEOUT;
return sr_do_ioctl(cdi->handle, &cgc); return sr_do_ioctl(cdi->handle, &cgc);
} }
...@@ -138,7 +142,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) ...@@ -138,7 +142,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
if (!cgc->quiet) if (!cgc->quiet)
printk(KERN_INFO "%s: CDROM not ready. Make sure there is a disc in the drive.\n", cd->cdi.name); printk(KERN_INFO "%s: CDROM not ready. Make sure there is a disc in the drive.\n", cd->cdi.name);
#ifdef DEBUG #ifdef DEBUG
print_req_sense("sr", SRpnt); scsi_print_req_sense("sr", SRpnt);
#endif #endif
err = -ENOMEDIUM; err = -ENOMEDIUM;
break; break;
...@@ -149,14 +153,14 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) ...@@ -149,14 +153,14 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc)
/* sense: Invalid command operation code */ /* sense: Invalid command operation code */
err = -EDRIVE_CANT_DO_THIS; err = -EDRIVE_CANT_DO_THIS;
#ifdef DEBUG #ifdef DEBUG
print_command(cgc->cmd); __scsi_print_command(cgc->cmd);
print_req_sense("sr", SRpnt); scsi_print_req_sense("sr", SRpnt);
#endif #endif
break; break;
default: default:
printk(KERN_ERR "%s: CDROM (ioctl) error, command: ", cd->cdi.name); printk(KERN_ERR "%s: CDROM (ioctl) error, command: ", cd->cdi.name);
print_command(cgc->cmd); __scsi_print_command(cgc->cmd);
print_req_sense("sr", SRpnt); scsi_print_req_sense("sr", SRpnt);
err = -EIO; err = -EIO;
} }
} }
...@@ -183,7 +187,7 @@ static int test_unit_ready(Scsi_CD *cd) ...@@ -183,7 +187,7 @@ static int test_unit_ready(Scsi_CD *cd)
memset(&cgc, 0, sizeof(struct packet_command)); memset(&cgc, 0, sizeof(struct packet_command));
cgc.cmd[0] = GPCMD_TEST_UNIT_READY; cgc.cmd[0] = GPCMD_TEST_UNIT_READY;
cgc.quiet = 1; cgc.quiet = 1;
cgc.data_direction = SCSI_DATA_NONE; cgc.data_direction = DMA_NONE;
cgc.timeout = IOCTL_TIMEOUT; cgc.timeout = IOCTL_TIMEOUT;
return sr_do_ioctl(cd, &cgc); return sr_do_ioctl(cd, &cgc);
} }
...@@ -196,7 +200,7 @@ int sr_tray_move(struct cdrom_device_info *cdi, int pos) ...@@ -196,7 +200,7 @@ int sr_tray_move(struct cdrom_device_info *cdi, int pos)
memset(&cgc, 0, sizeof(struct packet_command)); memset(&cgc, 0, sizeof(struct packet_command));
cgc.cmd[0] = GPCMD_START_STOP_UNIT; cgc.cmd[0] = GPCMD_START_STOP_UNIT;
cgc.cmd[4] = (pos == 0) ? 0x03 /* close */ : 0x02 /* eject */ ; cgc.cmd[4] = (pos == 0) ? 0x03 /* close */ : 0x02 /* eject */ ;
cgc.data_direction = SCSI_DATA_NONE; cgc.data_direction = DMA_NONE;
cgc.timeout = IOCTL_TIMEOUT; cgc.timeout = IOCTL_TIMEOUT;
return sr_do_ioctl(cd, &cgc); return sr_do_ioctl(cd, &cgc);
} }
...@@ -280,7 +284,7 @@ int sr_get_mcn(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn) ...@@ -280,7 +284,7 @@ int sr_get_mcn(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn)
cgc.cmd[8] = 24; cgc.cmd[8] = 24;
cgc.buffer = buffer; cgc.buffer = buffer;
cgc.buflen = 24; cgc.buflen = 24;
cgc.data_direction = SCSI_DATA_READ; cgc.data_direction = DMA_FROM_DEVICE;
cgc.timeout = IOCTL_TIMEOUT; cgc.timeout = IOCTL_TIMEOUT;
result = sr_do_ioctl(cd, &cgc); result = sr_do_ioctl(cd, &cgc);
...@@ -310,7 +314,7 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed) ...@@ -310,7 +314,7 @@ int sr_select_speed(struct cdrom_device_info *cdi, int speed)
cgc.cmd[0] = GPCMD_SET_SPEED; /* SET CD SPEED */ cgc.cmd[0] = GPCMD_SET_SPEED; /* SET CD SPEED */
cgc.cmd[2] = (speed >> 8) & 0xff; /* MSB for speed (in kbytes/sec) */ cgc.cmd[2] = (speed >> 8) & 0xff; /* MSB for speed (in kbytes/sec) */
cgc.cmd[3] = speed & 0xff; /* LSB */ cgc.cmd[3] = speed & 0xff; /* LSB */
cgc.data_direction = SCSI_DATA_NONE; cgc.data_direction = DMA_NONE;
cgc.timeout = IOCTL_TIMEOUT; cgc.timeout = IOCTL_TIMEOUT;
if (sr_do_ioctl(cd, &cgc)) if (sr_do_ioctl(cd, &cgc))
...@@ -347,7 +351,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) ...@@ -347,7 +351,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
cgc.buffer = buffer; cgc.buffer = buffer;
cgc.buflen = 12; cgc.buflen = 12;
cgc.quiet = 1; cgc.quiet = 1;
cgc.data_direction = SCSI_DATA_READ; cgc.data_direction = DMA_FROM_DEVICE;
result = sr_do_ioctl(cd, &cgc); result = sr_do_ioctl(cd, &cgc);
...@@ -367,7 +371,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) ...@@ -367,7 +371,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
cgc.cmd[8] = 12; /* LSB of length */ cgc.cmd[8] = 12; /* LSB of length */
cgc.buffer = buffer; cgc.buffer = buffer;
cgc.buflen = 12; cgc.buflen = 12;
cgc.data_direction = SCSI_DATA_READ; cgc.data_direction = DMA_FROM_DEVICE;
result = sr_do_ioctl(cd, &cgc); result = sr_do_ioctl(cd, &cgc);
...@@ -393,7 +397,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg) ...@@ -393,7 +397,7 @@ int sr_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, void *arg)
cgc.cmd[5] = ti->cdti_ind0; cgc.cmd[5] = ti->cdti_ind0;
cgc.cmd[7] = ti->cdti_trk1; cgc.cmd[7] = ti->cdti_trk1;
cgc.cmd[8] = ti->cdti_ind1; cgc.cmd[8] = ti->cdti_ind1;
cgc.data_direction = SCSI_DATA_NONE; cgc.data_direction = DMA_NONE;
result = sr_do_ioctl(cd, &cgc); result = sr_do_ioctl(cd, &cgc);
if (result == -EDRIVE_CANT_DO_THIS) if (result == -EDRIVE_CANT_DO_THIS)
...@@ -462,7 +466,7 @@ static int sr_read_cd(Scsi_CD *cd, unsigned char *dest, int lba, int format, int ...@@ -462,7 +466,7 @@ static int sr_read_cd(Scsi_CD *cd, unsigned char *dest, int lba, int format, int
} }
cgc.buffer = dest; cgc.buffer = dest;
cgc.buflen = blksize; cgc.buflen = blksize;
cgc.data_direction = SCSI_DATA_READ; cgc.data_direction = DMA_FROM_DEVICE;
cgc.timeout = IOCTL_TIMEOUT; cgc.timeout = IOCTL_TIMEOUT;
return sr_do_ioctl(cd, &cgc); return sr_do_ioctl(cd, &cgc);
} }
...@@ -503,7 +507,7 @@ static int sr_read_sector(Scsi_CD *cd, int lba, int blksize, unsigned char *dest ...@@ -503,7 +507,7 @@ static int sr_read_sector(Scsi_CD *cd, int lba, int blksize, unsigned char *dest
cgc.cmd[8] = 1; cgc.cmd[8] = 1;
cgc.buffer = dest; cgc.buffer = dest;
cgc.buflen = blksize; cgc.buflen = blksize;
cgc.data_direction = SCSI_DATA_READ; cgc.data_direction = DMA_FROM_DEVICE;
cgc.timeout = IOCTL_TIMEOUT; cgc.timeout = IOCTL_TIMEOUT;
rc = sr_do_ioctl(cd, &cgc); rc = sr_do_ioctl(cd, &cgc);
......
...@@ -35,16 +35,18 @@ ...@@ -35,16 +35,18 @@
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/cdrom.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/bcd.h> #include <linux/bcd.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include "scsi.h"
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <scsi/scsi_ioctl.h> #include <scsi/scsi_ioctl.h>
#include <linux/cdrom.h>
#include "sr.h" #include "sr.h"
#if 0 #if 0
...@@ -135,7 +137,7 @@ int sr_set_blocklength(Scsi_CD *cd, int blocklength) ...@@ -135,7 +137,7 @@ int sr_set_blocklength(Scsi_CD *cd, int blocklength)
modesel->block_length_lo = blocklength & 0xff; modesel->block_length_lo = blocklength & 0xff;
cgc.buffer = buffer; cgc.buffer = buffer;
cgc.buflen = sizeof(*modesel); cgc.buflen = sizeof(*modesel);
cgc.data_direction = SCSI_DATA_WRITE; cgc.data_direction = DMA_TO_DEVICE;
cgc.timeout = VENDOR_TIMEOUT; cgc.timeout = VENDOR_TIMEOUT;
if (0 == (rc = sr_do_ioctl(cd, &cgc))) { if (0 == (rc = sr_do_ioctl(cd, &cgc))) {
cd->device->sector_size = blocklength; cd->device->sector_size = blocklength;
...@@ -182,7 +184,7 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -182,7 +184,7 @@ int sr_cd_check(struct cdrom_device_info *cdi)
cgc.buffer = buffer; cgc.buffer = buffer;
cgc.buflen = 12; cgc.buflen = 12;
cgc.quiet = 1; cgc.quiet = 1;
cgc.data_direction = SCSI_DATA_READ; cgc.data_direction = DMA_FROM_DEVICE;
cgc.timeout = VENDOR_TIMEOUT; cgc.timeout = VENDOR_TIMEOUT;
rc = sr_do_ioctl(cd, &cgc); rc = sr_do_ioctl(cd, &cgc);
if (rc != 0) if (rc != 0)
...@@ -210,7 +212,7 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -210,7 +212,7 @@ int sr_cd_check(struct cdrom_device_info *cdi)
cgc.buffer = buffer; cgc.buffer = buffer;
cgc.buflen = 0x16; cgc.buflen = 0x16;
cgc.quiet = 1; cgc.quiet = 1;
cgc.data_direction = SCSI_DATA_READ; cgc.data_direction = DMA_FROM_DEVICE;
cgc.timeout = VENDOR_TIMEOUT; cgc.timeout = VENDOR_TIMEOUT;
rc = sr_do_ioctl(cd, &cgc); rc = sr_do_ioctl(cd, &cgc);
if (rc != 0) if (rc != 0)
...@@ -239,7 +241,7 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -239,7 +241,7 @@ int sr_cd_check(struct cdrom_device_info *cdi)
cgc.buffer = buffer; cgc.buffer = buffer;
cgc.buflen = 4; cgc.buflen = 4;
cgc.quiet = 1; cgc.quiet = 1;
cgc.data_direction = SCSI_DATA_READ; cgc.data_direction = DMA_FROM_DEVICE;
cgc.timeout = VENDOR_TIMEOUT; cgc.timeout = VENDOR_TIMEOUT;
rc = sr_do_ioctl(cd, &cgc); rc = sr_do_ioctl(cd, &cgc);
if (rc == -EINVAL) { if (rc == -EINVAL) {
...@@ -268,7 +270,7 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -268,7 +270,7 @@ int sr_cd_check(struct cdrom_device_info *cdi)
cgc.buffer = buffer; cgc.buffer = buffer;
cgc.buflen = 0x04; cgc.buflen = 0x04;
cgc.quiet = 1; cgc.quiet = 1;
cgc.data_direction = SCSI_DATA_READ; cgc.data_direction = DMA_FROM_DEVICE;
cgc.timeout = VENDOR_TIMEOUT; cgc.timeout = VENDOR_TIMEOUT;
rc = sr_do_ioctl(cd, &cgc); rc = sr_do_ioctl(cd, &cgc);
if (rc != 0) { if (rc != 0) {
...@@ -286,7 +288,7 @@ int sr_cd_check(struct cdrom_device_info *cdi) ...@@ -286,7 +288,7 @@ int sr_cd_check(struct cdrom_device_info *cdi)
cgc.buffer = buffer; cgc.buffer = buffer;
cgc.buflen = 12; cgc.buflen = 12;
cgc.quiet = 1; cgc.quiet = 1;
cgc.data_direction = SCSI_DATA_READ; cgc.data_direction = DMA_FROM_DEVICE;
cgc.timeout = VENDOR_TIMEOUT; cgc.timeout = VENDOR_TIMEOUT;
rc = sr_do_ioctl(cd, &cgc); rc = sr_do_ioctl(cd, &cgc);
if (rc != 0) { if (rc != 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment