scst: Several RHEL 5 build fixes

Move the get_unaligned_*() functions up such that these occur
before the T10-PI functions. Backport the definition of
VARIABLE_LENGTH_CMD. Make scst_dif_crc_fn() build on RHEL 5
systems.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6415 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2015-07-10 22:26:43 +00:00
parent f92a917d45
commit ae9de304c4
3 changed files with 43 additions and 32 deletions

View File

@@ -4704,6 +4704,38 @@ static inline __be16 scst_cmd_get_dif_app_tag(struct scst_cmd *cmd,
return cmd->dev->dev_dif_static_app_tag;
}
#if defined(RHEL_MAJOR) && RHEL_MAJOR -0 <= 5
static inline uint16_t get_unaligned_be16(const void *p)
{
return be16_to_cpu(get_unaligned((__be16 *)p));
}
static inline void put_unaligned_be16(uint16_t i, void *p)
{
put_unaligned(cpu_to_be16(i), (__be16 *)p);
}
static inline uint32_t get_unaligned_be32(const void *p)
{
return be32_to_cpu(get_unaligned((__be32 *)p));
}
static inline void put_unaligned_be32(uint32_t i, void *p)
{
put_unaligned(cpu_to_be32(i), (__be32 *)p);
}
static inline uint64_t get_unaligned_be64(const void *p)
{
return be64_to_cpu(get_unaligned((__be64 *)p));
}
static inline void put_unaligned_be64(uint64_t i, void *p)
{
put_unaligned(cpu_to_be64(i), (__be64 *)p);
}
#endif
/*
* Returns T10-PI type 2 expected initial reference tag as LBA, i.e. converted
* into CPU endianness. Valid only with protection type 2.
@@ -5595,38 +5627,6 @@ if (!(condition)) { \
finish_wait(&(wq), &__wait); \
}
#if defined(RHEL_MAJOR) && RHEL_MAJOR -0 <= 5
static inline uint16_t get_unaligned_be16(const void *p)
{
return be16_to_cpu(get_unaligned((__be16 *)p));
}
static inline void put_unaligned_be16(uint16_t i, void *p)
{
put_unaligned(cpu_to_be16(i), (__be16 *)p);
}
static inline uint32_t get_unaligned_be32(const void *p)
{
return be32_to_cpu(get_unaligned((__be32 *)p));
}
static inline void put_unaligned_be32(uint32_t i, void *p)
{
put_unaligned(cpu_to_be32(i), (__be32 *)p);
}
static inline uint64_t get_unaligned_be64(const void *p)
{
return be64_to_cpu(get_unaligned((__be64 *)p));
}
static inline void put_unaligned_be64(uint64_t i, void *p)
{
put_unaligned(cpu_to_be64(i), (__be64 *)p);
}
#endif
/* Only use get_unaligned_be24() if reading p - 1 is allowed. */
static inline uint32_t get_unaligned_be24(const uint8_t *const p)
{

View File

@@ -375,6 +375,9 @@ static inline int scst_sense_response_code(const uint8_t *sense)
/* Upstream commit 93aae17a (v2.6.38) */
#define GET_EVENT_STATUS_NOTIFICATION 0x4a
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
#define VARIABLE_LENGTH_CMD 0x7f
#endif
#ifndef READ_16
#define READ_16 0x88
#endif

View File

@@ -33,7 +33,10 @@
#include <asm/kmap_types.h>
#include <asm/unaligned.h>
#include <asm/checksum.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
#include <linux/crc-t10dif.h>
#endif
#include <linux/namei.h>
#include <linux/mount.h>
@@ -7696,7 +7699,12 @@ EXPORT_SYMBOL(scst_put_buf_full);
static __be16 scst_dif_crc_fn(const void *data, unsigned int len)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
return cpu_to_be16(crc_t10dif(data, len));
#else
WARN_ON_ONCE(true);
return 0;
#endif
}
static __be16 scst_dif_ip_fn(const void *data, unsigned int len)