diff --git a/scst/include/scst.h b/scst/include/scst.h index f6b681e56..f430d7611 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -2396,7 +2396,7 @@ struct scst_aen { int event_fn; /* AEN fn */ struct scst_session *sess; /* corresponding session */ - uint64_t lun; /* corresponding LUN in SCSI form */ + __be64 lun; /* corresponding LUN in SCSI form */ union { /* SCSI AEN data */ diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 9088b9453..217b8304d 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -1535,7 +1535,7 @@ static int vdisk_rigid_geo_pg(unsigned char *p, int pcontrol, if (rem != 0) ncyl++; memcpy(&n, p + 2, sizeof(u32)); - n = n | (cpu_to_be32(ncyl) >> 8); + n = n | ((__force u32)cpu_to_be32(ncyl) >> 8); memcpy(p + 2, &n, sizeof(u32)); if (1 == pcontrol) memset(p + 2, 0, sizeof(geo_m_pg) - 2); @@ -1956,7 +1956,7 @@ static void vdisk_exec_read_capacity(struct scst_cmd *cmd) nblocks = virt_dev->nblocks; if ((cmd->cdb[8] & 1) == 0) { - uint64_t lba = be64_to_cpu(get_unaligned((uint64_t *)&cmd->cdb[2])); + uint64_t lba = be64_to_cpu(get_unaligned((__be64 *)&cmd->cdb[2])); if (lba != 0) { TRACE_DBG("PMI zero and LBA not zero (cmd %p)", cmd); scst_set_cmd_error(cmd, @@ -2023,7 +2023,7 @@ static void vdisk_exec_read_capacity16(struct scst_cmd *cmd) nblocks = virt_dev->nblocks - 1; if ((cmd->cdb[14] & 1) == 0) { - uint64_t lba = be64_to_cpu(get_unaligned((uint64_t *)&cmd->cdb[2])); + uint64_t lba = be64_to_cpu(get_unaligned((__be64 *)&cmd->cdb[2])); if (lba != 0) { TRACE_DBG("PMI zero and LBA not zero (cmd %p)", cmd); scst_set_cmd_error(cmd, diff --git a/scst/src/scst_debug.c b/scst/src/scst_debug.c index 7d1772132..1d136d918 100644 --- a/scst/src/scst_debug.c +++ b/scst/src/scst_debug.c @@ -188,8 +188,8 @@ const char *debug_transport_id_to_initiator_name(const uint8_t *transport_id) break; case SCSI_TRANSPORTID_PROTOCOLID_SPI5: scnprintf(name_buf, SIZEOF_NAME_BUF, - "%x:%x", be16_to_cpu((uint16_t)transport_id[2]), - be16_to_cpu((uint16_t)transport_id[6])); + "%x:%x", be16_to_cpu((__force __be16)transport_id[2]), + be16_to_cpu((__force __be16)transport_id[6])); break; case SCSI_TRANSPORTID_PROTOCOLID_SRP: scnprintf(name_buf, SIZEOF_NAME_BUF, diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 6193a255e..afcfbdf92 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -5198,10 +5198,9 @@ out: EXPORT_SYMBOL(scst_get_cdb_info); /* Packs SCST LUN back to SCSI form */ -uint64_t scst_pack_lun(const uint64_t lun, unsigned int addr_method) +__be64 scst_pack_lun(const uint64_t lun, unsigned int addr_method) { - - uint64_t res = 0; + uint64_t res; uint16_t *p = (uint16_t *)&res; res = lun; @@ -5216,10 +5215,10 @@ uint64_t scst_pack_lun(const uint64_t lun, unsigned int addr_method) } /* Default is to use peripheral device addressing mode */ - *p = cpu_to_be16(*p); + *p = (__force u16)cpu_to_be16(*p); TRACE_EXIT_HRES((unsigned long)res); - return res; + return (__force __be64)res; } /* @@ -5246,16 +5245,16 @@ uint64_t scst_unpack_lun(const uint8_t *lun, int len) if (len > 2) { switch (len) { case 8: - if ((*((uint64_t *)lun) & + if ((*((__be64 *)lun) & __constant_cpu_to_be64(0x0000FFFFFFFFFFFFLL)) != 0) goto out_err; break; case 4: - if (*((uint16_t *)&lun[2]) != 0) + if (*((__be16 *)&lun[2]) != 0) goto out_err; break; case 6: - if (*((uint32_t *)&lun[2]) != 0) + if (*((__be32 *)&lun[2]) != 0) goto out_err; break; default: diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index d4196340f..61a298464 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -519,7 +519,7 @@ static void scst_pr_abort_reg(struct scst_device *dev, struct scst_cmd *pr_cmd, struct scst_dev_registrant *reg) { struct scst_session *sess; - uint64_t packed_lun; + __be64 packed_lun; int rc; TRACE_ENTRY(); diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 522b016b2..0cce2f334 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -427,7 +427,7 @@ void scst_lib_exit(void); int scst_get_full_buf(struct scst_cmd *cmd, uint8_t **buf); void scst_put_full_buf(struct scst_cmd *cmd, uint8_t *buf); -uint64_t scst_pack_lun(const uint64_t lun, unsigned int addr_method); +__be64 scst_pack_lun(const uint64_t lun, unsigned int addr_method); uint64_t scst_unpack_lun(const uint8_t *lun, int len); struct scst_mgmt_cmd *scst_alloc_mgmt_cmd(gfp_t gfp_mask);