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

[PATCH] use generic dma direction bits in scsi

Make the *_data_direction flags of type enum dma_data_direction from
the generic dma mapping API.  The SCSI_DATA_* defines are kept for
compatiblity and map to the dma mapping API values now.
scsi_to_pci_dma_dir and scsi_to_sbus_dma_dir are kept as stubs -
we define them to nothing as both the PCI and SBUS constants have
the same values as the generic dma mapping ones.  Unfortunately
we can't check anymore whether someone messes this up as the values
are enumes now and not cpp defines.
parent f16e95b6
...@@ -139,7 +139,7 @@ struct scsi_request *scsi_allocate_request(struct scsi_device *sdev) ...@@ -139,7 +139,7 @@ struct scsi_request *scsi_allocate_request(struct scsi_device *sdev)
sreq->sr_device = sdev; sreq->sr_device = sdev;
sreq->sr_host = sdev->host; sreq->sr_host = sdev->host;
sreq->sr_magic = SCSI_REQ_MAGIC; sreq->sr_magic = SCSI_REQ_MAGIC;
sreq->sr_data_direction = SCSI_DATA_UNKNOWN; sreq->sr_data_direction = DMA_BIDIRECTIONAL;
} }
return sreq; return sreq;
......
...@@ -24,54 +24,6 @@ ...@@ -24,54 +24,6 @@
#include <scsi/scsi_tcq.h> #include <scsi/scsi_tcq.h>
#include <scsi/scsi.h> #include <scsi/scsi.h>
/*
* These are the values that the SCpnt->sc_data_direction and
* SRpnt->sr_data_direction can take. These need to be set
* The SCSI_DATA_UNKNOWN value is essentially the default.
* In the event that the command creator didn't bother to
* set a value, you will see SCSI_DATA_UNKNOWN.
*/
#define SCSI_DATA_UNKNOWN 0
#define SCSI_DATA_WRITE 1
#define SCSI_DATA_READ 2
#define SCSI_DATA_NONE 3
#ifdef CONFIG_PCI
#include <linux/pci.h>
#if ((SCSI_DATA_UNKNOWN == PCI_DMA_BIDIRECTIONAL) && (SCSI_DATA_WRITE == PCI_DMA_TODEVICE) && (SCSI_DATA_READ == PCI_DMA_FROMDEVICE) && (SCSI_DATA_NONE == PCI_DMA_NONE))
#define scsi_to_pci_dma_dir(scsi_dir) ((int)(scsi_dir))
#else
extern __inline__ int scsi_to_pci_dma_dir(unsigned char scsi_dir)
{
if (scsi_dir == SCSI_DATA_UNKNOWN)
return PCI_DMA_BIDIRECTIONAL;
if (scsi_dir == SCSI_DATA_WRITE)
return PCI_DMA_TODEVICE;
if (scsi_dir == SCSI_DATA_READ)
return PCI_DMA_FROMDEVICE;
return PCI_DMA_NONE;
}
#endif
#endif
#if defined(CONFIG_SBUS) && !defined(CONFIG_SUN3) && !defined(CONFIG_SUN3X)
#include <asm/sbus.h>
#if ((SCSI_DATA_UNKNOWN == SBUS_DMA_BIDIRECTIONAL) && (SCSI_DATA_WRITE == SBUS_DMA_TODEVICE) && (SCSI_DATA_READ == SBUS_DMA_FROMDEVICE) && (SCSI_DATA_NONE == SBUS_DMA_NONE))
#define scsi_to_sbus_dma_dir(scsi_dir) ((int)(scsi_dir))
#else
extern __inline__ int scsi_to_sbus_dma_dir(unsigned char scsi_dir)
{
if (scsi_dir == SCSI_DATA_UNKNOWN)
return SBUS_DMA_BIDIRECTIONAL;
if (scsi_dir == SCSI_DATA_WRITE)
return SBUS_DMA_TODEVICE;
if (scsi_dir == SCSI_DATA_READ)
return SBUS_DMA_FROMDEVICE;
return SBUS_DMA_NONE;
}
#endif
#endif
/* /*
* Some defs, in case these are not defined elsewhere. * Some defs, in case these are not defined elsewhere.
*/ */
...@@ -227,6 +179,21 @@ extern int scsi_sysfs_modify_sdev_attribute(struct device_attribute ***dev_attrs ...@@ -227,6 +179,21 @@ extern int scsi_sysfs_modify_sdev_attribute(struct device_attribute ***dev_attrs
extern int scsi_sysfs_modify_shost_attribute(struct class_device_attribute ***class_attrs, extern int scsi_sysfs_modify_shost_attribute(struct class_device_attribute ***class_attrs,
struct class_device_attribute *attr); struct class_device_attribute *attr);
/*
* Legacy dma direction interfaces.
*
* This assumes the pci/sbus dma mapping flags have the same numercial
* values as the generic dma-mapping ones. Currently they have but there's
* no way to check. Better don't use these interfaces!
*/
#define SCSI_DATA_UNKNOWN (DMA_BIDIRECTIONAL)
#define SCSI_DATA_WRITE (DMA_TO_DEVICE)
#define SCSI_DATA_READ (DMA_FROM_DEVICE)
#define SCSI_DATA_NONE (DMA_NONE)
#define scsi_to_pci_dma_dir(scsi_dir) ((int)(scsi_dir))
#define scsi_to_sbus_dma_dir(scsi_dir) ((int)(scsi_dir))
/* /*
* This is the crap from the old error handling code. We have it in a special * This is the crap from the old error handling code. We have it in a special
* place so that we can more easily delete it later on. * place so that we can more easily delete it later on.
......
...@@ -562,7 +562,7 @@ static int scsi_request_sense(struct scsi_cmnd *scmd) ...@@ -562,7 +562,7 @@ static int scsi_request_sense(struct scsi_cmnd *scmd)
scmd->request_bufflen = 252; scmd->request_bufflen = 252;
scmd->use_sg = 0; scmd->use_sg = 0;
scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);
scmd->sc_data_direction = SCSI_DATA_READ; scmd->sc_data_direction = DMA_FROM_DEVICE;
scmd->underflow = 0; scmd->underflow = 0;
rtn = scsi_send_eh_cmnd(scmd, SENSE_TIMEOUT); rtn = scsi_send_eh_cmnd(scmd, SENSE_TIMEOUT);
...@@ -742,7 +742,7 @@ static int scsi_eh_tur(struct scsi_cmnd *scmd) ...@@ -742,7 +742,7 @@ static int scsi_eh_tur(struct scsi_cmnd *scmd)
scmd->use_sg = 0; scmd->use_sg = 0;
scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);
scmd->underflow = 0; scmd->underflow = 0;
scmd->sc_data_direction = SCSI_DATA_NONE; scmd->sc_data_direction = DMA_NONE;
rtn = scsi_send_eh_cmnd(scmd, SENSE_TIMEOUT); rtn = scsi_send_eh_cmnd(scmd, SENSE_TIMEOUT);
...@@ -1348,7 +1348,7 @@ static void scsi_eh_lock_door(struct scsi_device *sdev) ...@@ -1348,7 +1348,7 @@ static void scsi_eh_lock_door(struct scsi_device *sdev)
sreq->sr_cmnd[3] = 0; sreq->sr_cmnd[3] = 0;
sreq->sr_cmnd[4] = SCSI_REMOVAL_PREVENT; sreq->sr_cmnd[4] = SCSI_REMOVAL_PREVENT;
sreq->sr_cmnd[5] = 0; sreq->sr_cmnd[5] = 0;
sreq->sr_data_direction = SCSI_DATA_NONE; sreq->sr_data_direction = DMA_NONE;
sreq->sr_bufflen = 0; sreq->sr_bufflen = 0;
sreq->sr_buffer = NULL; sreq->sr_buffer = NULL;
sreq->sr_allowed = 5; sreq->sr_allowed = 5;
...@@ -1723,7 +1723,7 @@ scsi_reset_provider(struct scsi_device *dev, int flag) ...@@ -1723,7 +1723,7 @@ scsi_reset_provider(struct scsi_device *dev, int flag)
scmd->cmd_len = 0; scmd->cmd_len = 0;
scmd->sc_data_direction = SCSI_DATA_UNKNOWN; scmd->sc_data_direction = DMA_BIDIRECTIONAL;
scmd->sc_request = NULL; scmd->sc_request = NULL;
scmd->sc_magic = SCSI_CMND_MAGIC; scmd->sc_magic = SCSI_CMND_MAGIC;
......
...@@ -104,7 +104,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd, ...@@ -104,7 +104,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
return -ENOMEM; return -ENOMEM;
} }
sreq->sr_data_direction = SCSI_DATA_NONE; sreq->sr_data_direction = DMA_NONE;
scsi_wait_req(sreq, cmd, NULL, 0, timeout, retries); scsi_wait_req(sreq, cmd, NULL, 0, timeout, retries);
SCSI_LOG_IOCTL(2, printk("Ioctl returned 0x%x\n", sreq->sr_result)); SCSI_LOG_IOCTL(2, printk("Ioctl returned 0x%x\n", sreq->sr_result));
...@@ -258,19 +258,19 @@ int scsi_ioctl_send_command(struct scsi_device *sdev, ...@@ -258,19 +258,19 @@ int scsi_ioctl_send_command(struct scsi_device *sdev,
return -ENOMEM; return -ENOMEM;
memset(buf, 0, buf_needed); memset(buf, 0, buf_needed);
if (inlen == 0) { if (inlen == 0) {
data_direction = SCSI_DATA_READ; data_direction = DMA_FROM_DEVICE;
} else if (outlen == 0 ) { } else if (outlen == 0 ) {
data_direction = SCSI_DATA_WRITE; data_direction = DMA_TO_DEVICE;
} else { } else {
/* /*
* Can this ever happen? * Can this ever happen?
*/ */
data_direction = SCSI_DATA_UNKNOWN; data_direction = DMA_BIDIRECTIONAL;
} }
} else { } else {
buf = NULL; buf = NULL;
data_direction = SCSI_DATA_NONE; data_direction = DMA_NONE;
} }
/* /*
......
...@@ -117,7 +117,7 @@ static void scsi_unlock_floptical(struct scsi_request *sreq, ...@@ -117,7 +117,7 @@ static void scsi_unlock_floptical(struct scsi_request *sreq,
scsi_cmd[4] = 0x2a; /* size */ scsi_cmd[4] = 0x2a; /* size */
scsi_cmd[5] = 0; scsi_cmd[5] = 0;
sreq->sr_cmd_len = 0; sreq->sr_cmd_len = 0;
sreq->sr_data_direction = SCSI_DATA_READ; sreq->sr_data_direction = DMA_FROM_DEVICE;
scsi_wait_req(sreq, scsi_cmd, result, 0x2a /* size */, SCSI_TIMEOUT, 3); scsi_wait_req(sreq, scsi_cmd, result, 0x2a /* size */, SCSI_TIMEOUT, 3);
} }
...@@ -334,7 +334,7 @@ static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result, ...@@ -334,7 +334,7 @@ static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result,
scsi_cmd[0] = INQUIRY; scsi_cmd[0] = INQUIRY;
scsi_cmd[4] = 36; /* issue conservative alloc_length */ scsi_cmd[4] = 36; /* issue conservative alloc_length */
sreq->sr_cmd_len = 0; sreq->sr_cmd_len = 0;
sreq->sr_data_direction = SCSI_DATA_READ; sreq->sr_data_direction = DMA_FROM_DEVICE;
memset(inq_result, 0, 36); memset(inq_result, 0, 36);
scsi_wait_req(sreq, (void *) scsi_cmd, (void *) inq_result, 36, scsi_wait_req(sreq, (void *) scsi_cmd, (void *) inq_result, 36,
...@@ -380,7 +380,7 @@ static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result, ...@@ -380,7 +380,7 @@ static void scsi_probe_lun(struct scsi_request *sreq, char *inq_result,
scsi_cmd[0] = INQUIRY; scsi_cmd[0] = INQUIRY;
scsi_cmd[4] = (unsigned char) possible_inq_resp_len; scsi_cmd[4] = (unsigned char) possible_inq_resp_len;
sreq->sr_cmd_len = 0; sreq->sr_cmd_len = 0;
sreq->sr_data_direction = SCSI_DATA_READ; sreq->sr_data_direction = DMA_FROM_DEVICE;
/* /*
* re-zero inq_result just to be safe. * re-zero inq_result just to be safe.
*/ */
...@@ -941,7 +941,7 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags) ...@@ -941,7 +941,7 @@ static int scsi_report_lun_scan(struct scsi_device *sdev, int bflags)
scsi_cmd[10] = 0; /* reserved */ scsi_cmd[10] = 0; /* reserved */
scsi_cmd[11] = 0; /* control */ scsi_cmd[11] = 0; /* control */
sreq->sr_cmd_len = 0; sreq->sr_cmd_len = 0;
sreq->sr_data_direction = SCSI_DATA_READ; sreq->sr_data_direction = DMA_FROM_DEVICE;
/* /*
* We can get a UNIT ATTENTION, for example a power on/reset, so * We can get a UNIT ATTENTION, for example a power on/reset, so
......
...@@ -163,11 +163,11 @@ static int sd_init_command(struct scsi_cmnd * SCpnt) ...@@ -163,11 +163,11 @@ static int sd_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_dir(rq) == WRITE) if (rq_data_dir(rq) == WRITE)
SCpnt->sc_data_direction = SCSI_DATA_WRITE; SCpnt->sc_data_direction = DMA_TO_DEVICE;
else if (rq->data_len) else if (rq->data_len)
SCpnt->sc_data_direction = SCSI_DATA_READ; SCpnt->sc_data_direction = DMA_FROM_DEVICE;
else else
SCpnt->sc_data_direction = SCSI_DATA_NONE; SCpnt->sc_data_direction = DMA_NONE;
this_count = rq->data_len; this_count = rq->data_len;
if (rq->timeout) if (rq->timeout)
...@@ -253,10 +253,10 @@ static int sd_init_command(struct scsi_cmnd * SCpnt) ...@@ -253,10 +253,10 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
return 0; return 0;
} }
SCpnt->cmnd[0] = WRITE_6; SCpnt->cmnd[0] = WRITE_6;
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_6; SCpnt->cmnd[0] = READ_6;
SCpnt->sc_data_direction = SCSI_DATA_READ; SCpnt->sc_data_direction = DMA_FROM_DEVICE;
} else { } else {
printk(KERN_ERR "sd: Unknown command %lx\n", printk(KERN_ERR "sd: Unknown command %lx\n",
SCpnt->request->flags); SCpnt->request->flags);
...@@ -792,7 +792,7 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, ...@@ -792,7 +792,7 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname,
SRpnt->sr_cmd_len = 0; SRpnt->sr_cmd_len = 0;
SRpnt->sr_sense_buffer[0] = 0; SRpnt->sr_sense_buffer[0] = 0;
SRpnt->sr_sense_buffer[2] = 0; SRpnt->sr_sense_buffer[2] = 0;
SRpnt->sr_data_direction = SCSI_DATA_NONE; SRpnt->sr_data_direction = DMA_NONE;
scsi_wait_req (SRpnt, (void *) cmd, (void *) buffer, scsi_wait_req (SRpnt, (void *) cmd, (void *) buffer,
0/*512*/, SD_TIMEOUT, SD_MAX_RETRIES); 0/*512*/, SD_TIMEOUT, SD_MAX_RETRIES);
...@@ -852,7 +852,7 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname, ...@@ -852,7 +852,7 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname,
SRpnt->sr_sense_buffer[0] = 0; SRpnt->sr_sense_buffer[0] = 0;
SRpnt->sr_sense_buffer[2] = 0; SRpnt->sr_sense_buffer[2] = 0;
SRpnt->sr_data_direction = SCSI_DATA_NONE; SRpnt->sr_data_direction = DMA_NONE;
scsi_wait_req(SRpnt, (void *)cmd, scsi_wait_req(SRpnt, (void *)cmd,
(void *) buffer, 0/*512*/, (void *) buffer, 0/*512*/,
SD_TIMEOUT, SD_MAX_RETRIES); SD_TIMEOUT, SD_MAX_RETRIES);
...@@ -917,7 +917,7 @@ sd_read_capacity(struct scsi_disk *sdkp, char *diskname, ...@@ -917,7 +917,7 @@ sd_read_capacity(struct scsi_disk *sdkp, char *diskname,
SRpnt->sr_cmd_len = 0; SRpnt->sr_cmd_len = 0;
SRpnt->sr_sense_buffer[0] = 0; SRpnt->sr_sense_buffer[0] = 0;
SRpnt->sr_sense_buffer[2] = 0; SRpnt->sr_sense_buffer[2] = 0;
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,
longrc ? 12 : 8, SD_TIMEOUT, SD_MAX_RETRIES); longrc ? 12 : 8, SD_TIMEOUT, SD_MAX_RETRIES);
...@@ -1394,7 +1394,7 @@ static void sd_shutdown(struct device *dev) ...@@ -1394,7 +1394,7 @@ static void sd_shutdown(struct device *dev)
return; return;
} }
sreq->sr_data_direction = SCSI_DATA_NONE; sreq->sr_data_direction = DMA_NONE;
for (retries = 3; retries > 0; --retries) { for (retries = 3; retries > 0; --retries) {
unsigned char cmd[10] = { 0 }; unsigned char cmd[10] = { 0 };
......
#ifndef _SCSI_SCSI_CMND_H #ifndef _SCSI_SCSI_CMND_H
#define _SCSI_SCSI_CMND_H #define _SCSI_SCSI_CMND_H
#include <linux/dma-mapping.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -71,8 +72,8 @@ struct scsi_cmnd { ...@@ -71,8 +72,8 @@ struct scsi_cmnd {
unsigned char cmd_len; unsigned char cmd_len;
unsigned char old_cmd_len; unsigned char old_cmd_len;
unsigned char sc_data_direction; enum dma_data_direction sc_data_direction;
unsigned char sc_old_data_direction; enum dma_data_direction sc_old_data_direction;
/* These elements define the operation we are about to perform */ /* These elements define the operation we are about to perform */
#define MAX_COMMAND_SIZE 16 #define MAX_COMMAND_SIZE 16
......
...@@ -32,7 +32,7 @@ struct scsi_request { ...@@ -32,7 +32,7 @@ struct scsi_request {
unsigned sr_bufflen; /* Size of data buffer */ unsigned sr_bufflen; /* Size of data buffer */
void *sr_buffer; /* Data buffer */ void *sr_buffer; /* Data buffer */
int sr_allowed; int sr_allowed;
unsigned char sr_data_direction; enum dma_data_direction sr_data_direction;
unsigned char sr_cmd_len; unsigned char sr_cmd_len;
unsigned char sr_cmnd[MAX_COMMAND_SIZE]; unsigned char sr_cmnd[MAX_COMMAND_SIZE];
void (*sr_done) (struct scsi_cmnd *); /* Mid-level done function */ void (*sr_done) (struct scsi_cmnd *); /* Mid-level done function */
......
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