Commit 33aa687d authored by James Bottomley's avatar James Bottomley

[SCSI] convert SPI transport class to scsi_execute

This one's slightly more difficult.  The transport class uses
REQ_FAILFAST, so another interface (scsi_execute) had to be invented to
take the extra flag.  Also, the sense functions are shifted around to
allow spi_execute to place data directly into a struct scsi_sense_hdr.
With this change, there's probably a lot of unnecessary sense buffer
allocation going on which we can fix later.
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 1cf72699
...@@ -1847,12 +1847,16 @@ EXPORT_SYMBOL(scsi_reset_provider); ...@@ -1847,12 +1847,16 @@ EXPORT_SYMBOL(scsi_reset_provider);
int scsi_normalize_sense(const u8 *sense_buffer, int sb_len, int scsi_normalize_sense(const u8 *sense_buffer, int sb_len,
struct scsi_sense_hdr *sshdr) struct scsi_sense_hdr *sshdr)
{ {
if (!sense_buffer || !sb_len || (sense_buffer[0] & 0x70) != 0x70) if (!sense_buffer || !sb_len)
return 0; return 0;
memset(sshdr, 0, sizeof(struct scsi_sense_hdr)); memset(sshdr, 0, sizeof(struct scsi_sense_hdr));
sshdr->response_code = (sense_buffer[0] & 0x7f); sshdr->response_code = (sense_buffer[0] & 0x7f);
if (!scsi_sense_valid(sshdr))
return 0;
if (sshdr->response_code >= 0x72) { if (sshdr->response_code >= 0x72) {
/* /*
* descriptor format * descriptor format
......
...@@ -282,7 +282,7 @@ void scsi_wait_req(struct scsi_request *sreq, const void *cmnd, void *buffer, ...@@ -282,7 +282,7 @@ void scsi_wait_req(struct scsi_request *sreq, const void *cmnd, void *buffer,
EXPORT_SYMBOL(scsi_wait_req); EXPORT_SYMBOL(scsi_wait_req);
/** /**
* scsi_execute_req - insert request and wait for the result * scsi_execute - insert request and wait for the result
* @sdev: scsi device * @sdev: scsi device
* @cmd: scsi command * @cmd: scsi command
* @data_direction: data direction * @data_direction: data direction
...@@ -291,13 +291,14 @@ EXPORT_SYMBOL(scsi_wait_req); ...@@ -291,13 +291,14 @@ EXPORT_SYMBOL(scsi_wait_req);
* @sense: optional sense buffer * @sense: optional sense buffer
* @timeout: request timeout in seconds * @timeout: request timeout in seconds
* @retries: number of times to retry request * @retries: number of times to retry request
* @flags: or into request flags;
* *
* scsi_execute_req returns the req->errors value which is the * scsi_execute_req returns the req->errors value which is the
* the scsi_cmnd result field. * the scsi_cmnd result field.
**/ **/
int scsi_execute_req(struct scsi_device *sdev, unsigned char *cmd, int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
int data_direction, void *buffer, unsigned bufflen, int data_direction, void *buffer, unsigned bufflen,
unsigned char *sense, int timeout, int retries) unsigned char *sense, int timeout, int retries, int flags)
{ {
struct request *req; struct request *req;
int write = (data_direction == DMA_TO_DEVICE); int write = (data_direction == DMA_TO_DEVICE);
...@@ -314,7 +315,7 @@ int scsi_execute_req(struct scsi_device *sdev, unsigned char *cmd, ...@@ -314,7 +315,7 @@ int scsi_execute_req(struct scsi_device *sdev, unsigned char *cmd,
req->sense = sense; req->sense = sense;
req->sense_len = 0; req->sense_len = 0;
req->timeout = timeout; req->timeout = timeout;
req->flags |= REQ_BLOCK_PC | REQ_SPECIAL; req->flags |= flags | REQ_BLOCK_PC | REQ_SPECIAL;
/* /*
* head injection *required* here otherwise quiesce won't work * head injection *required* here otherwise quiesce won't work
...@@ -328,7 +329,7 @@ int scsi_execute_req(struct scsi_device *sdev, unsigned char *cmd, ...@@ -328,7 +329,7 @@ int scsi_execute_req(struct scsi_device *sdev, unsigned char *cmd,
return ret; return ret;
} }
EXPORT_SYMBOL(scsi_execute_req); EXPORT_SYMBOL(scsi_execute);
/* /*
* Function: scsi_init_cmd_errh() * Function: scsi_init_cmd_errh()
......
This diff is collapsed.
...@@ -256,6 +256,19 @@ extern void int_to_scsilun(unsigned int, struct scsi_lun *); ...@@ -256,6 +256,19 @@ extern void int_to_scsilun(unsigned int, struct scsi_lun *);
extern const char *scsi_device_state_name(enum scsi_device_state); extern const char *scsi_device_state_name(enum scsi_device_state);
extern int scsi_is_sdev_device(const struct device *); extern int scsi_is_sdev_device(const struct device *);
extern int scsi_is_target_device(const struct device *); extern int scsi_is_target_device(const struct device *);
extern int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
int data_direction, void *buffer, unsigned bufflen,
unsigned char *sense, int timeout, int retries,
int flag);
static inline int
scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd,
int data_direction, void *buffer, unsigned bufflen,
unsigned char *sense, int timeout, int retries)
{
return scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense,
timeout, retries, 0);
}
static inline int scsi_device_online(struct scsi_device *sdev) static inline int scsi_device_online(struct scsi_device *sdev)
{ {
return sdev->sdev_state != SDEV_OFFLINE; return sdev->sdev_state != SDEV_OFFLINE;
......
...@@ -26,6 +26,14 @@ struct scsi_sense_hdr { /* See SPC-3 section 4.5 */ ...@@ -26,6 +26,14 @@ struct scsi_sense_hdr { /* See SPC-3 section 4.5 */
u8 additional_length; /* always 0 for fixed sense format */ u8 additional_length; /* always 0 for fixed sense format */
}; };
static inline int scsi_sense_valid(struct scsi_sense_hdr *sshdr)
{
if (!sshdr)
return 0;
return (sshdr->response_code & 0x70) == 0x70;
}
extern void scsi_add_timer(struct scsi_cmnd *, int, extern void scsi_add_timer(struct scsi_cmnd *, int,
void (*)(struct scsi_cmnd *)); void (*)(struct scsi_cmnd *));
......
...@@ -54,8 +54,4 @@ extern void scsi_do_req(struct scsi_request *, const void *cmnd, ...@@ -54,8 +54,4 @@ extern void scsi_do_req(struct scsi_request *, const void *cmnd,
void *buffer, unsigned bufflen, void *buffer, unsigned bufflen,
void (*done) (struct scsi_cmnd *), void (*done) (struct scsi_cmnd *),
int timeout, int retries); int timeout, int retries);
extern int scsi_execute_req(struct scsi_device *sdev, unsigned char *cmd,
int data_direction, void *buffer, unsigned bufflen,
unsigned char *sense, int timeout, int retries);
#endif /* _SCSI_SCSI_REQUEST_H */ #endif /* _SCSI_SCSI_REQUEST_H */
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