Make scst_local compile cleanly on a range of versions of Linux. I have tested

2.6.24, 2.6.25.4, 2.6.27.x and 2.6.29. I have also tested under 2.6.18 on a
CentOS 5.3 system. 

There might still be problems with some 2.6.18 systems, and I will commit more
changes as the need arises.

I have only tested that scst_local builds and loads with these changes. I have
not tested any devices as yet.



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@899 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Richard Sharpe
2009-06-14 21:00:52 +00:00
parent 010750bf7c
commit 8187f28719

View File

@@ -71,6 +71,29 @@
static unsigned long scst_local_trace_flag = SCST_LOCAL_DEFAULT_LOG_FLAGS;
#endif
/*
* Provide some local definitions that are not provided for some earlier
* kernels so we operate over a wider range of kernels
*
* Some time before 2.6.24 scsi_sg_count, scsi_sglist and scsi_bufflen were
* not available. Make it available for 2.6.18 which is used still on some
* distros, like CentOS etc.
*/
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19))
#define scsi_sg_count(cmd) ((cmd)->use_sg)
#define scsi_sglist(cmd) ((struct scatterlist *)(cmd)->request_buffer)
#define scsi_bufflen(cmd) ((cmd)->request_bufflen)
/* Include the following manually of scsi_set_resid is not defined */
#if 0
static inline void scsi_set_resid(struct scsi_cmnd *cmd, int resid)
{
cmd->resid = resid;
}
#endif
#endif
#define TRUE 1
#define FALSE 0
@@ -80,8 +103,8 @@ static unsigned long scst_local_trace_flag = SCST_LOCAL_DEFAULT_LOG_FLAGS;
static void scst_local_remove_adapter(void);
static int scst_local_add_adapter(void);
#define SCST_LOCAL_VERSION "0.9.1"
static const char *scst_local_version_date = "20081130";
#define SCST_LOCAL_VERSION "0.9.2"
static const char *scst_local_version_date = "20090614";
/*
* Target structures that are shared between the two pieces
@@ -506,6 +529,8 @@ static int scst_local_queuecommand(struct scsi_cmnd *SCpnt,
scsi_sg_count(SCpnt));
break;
case DMA_BIDIRECTIONAL:
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 24))
/* Some of these symbols are only defined after 2.6.24 */
dir = SCST_DATA_BIDI;
scst_cmd_set_expected(scst_cmd, dir, scsi_bufflen(SCpnt));
scst_cmd_set_expected_in_transfer_len(scst_cmd,
@@ -515,6 +540,7 @@ static int scst_local_queuecommand(struct scsi_cmnd *SCpnt,
scst_cmd_set_tgt_in_sg(scst_cmd, scsi_in(SCpnt)->table.sgl,
scsi_in(SCpnt)->table.nents);
break;
#endif
case DMA_NONE:
default:
dir = SCST_DATA_NONE;