aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/mvsas
diff options
context:
space:
mode:
authorXi Wang <xi.wang@gmail.com>2012-11-16 14:40:03 -0500
committerJames Bottomley <JBottomley@Parallels.com>2012-11-30 04:20:17 -0500
commitbeecadea1b8d67f591b13f7099559f32f3fd601d (patch)
treee96c70ef947343902268e9d6d294333f275706aa /drivers/scsi/mvsas
parent072f19b4bea31cdd482d79f805413f2f9ac9e233 (diff)
[SCSI] mvsas: fix undefined bit shift
The macro bit(n) is defined as ((u32)1 << n), and thus it doesn't work with n >= 32, such as in mvs_94xx_assign_reg_set(): if (i >= 32) { mvi->sata_reg_set |= bit(i); ... } The shift ((u32)1 << n) with n >= 32 also leads to undefined behavior. The result varies depending on the architecture. This patch changes bit(n) to do a 64-bit shift. It also simplifies mv_ffc64() using __ffs64(), since invoking ffz() with ~0 is undefined. Signed-off-by: Xi Wang <xi.wang@gmail.com> Acked-by: Xiangliang Yu <yuxiangl@marvell.com> Cc: stable@vger.kernel.org Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/mvsas')
-rw-r--r--drivers/scsi/mvsas/mv_94xx.h14
-rw-r--r--drivers/scsi/mvsas/mv_sas.h2
2 files changed, 3 insertions, 13 deletions
diff --git a/drivers/scsi/mvsas/mv_94xx.h b/drivers/scsi/mvsas/mv_94xx.h
index 8f7eb4f21140..487aa6f97412 100644
--- a/drivers/scsi/mvsas/mv_94xx.h
+++ b/drivers/scsi/mvsas/mv_94xx.h
@@ -258,21 +258,11 @@ enum sas_sata_phy_regs {
258#define SPI_ADDR_VLD_94XX (1U << 1) 258#define SPI_ADDR_VLD_94XX (1U << 1)
259#define SPI_CTRL_SpiStart_94XX (1U << 0) 259#define SPI_CTRL_SpiStart_94XX (1U << 0)
260 260
261#define mv_ffc(x) ffz(x)
262
263static inline int 261static inline int
264mv_ffc64(u64 v) 262mv_ffc64(u64 v)
265{ 263{
266 int i; 264 u64 x = ~v;
267 i = mv_ffc((u32)v); 265 return x ? __ffs64(x) : -1;
268 if (i >= 0)
269 return i;
270 i = mv_ffc((u32)(v>>32));
271
272 if (i != 0)
273 return 32 + i;
274
275 return -1;
276} 266}
277 267
278#define r_reg_set_enable(i) \ 268#define r_reg_set_enable(i) \
diff --git a/drivers/scsi/mvsas/mv_sas.h b/drivers/scsi/mvsas/mv_sas.h
index c04a4f5b5972..da249553858c 100644
--- a/drivers/scsi/mvsas/mv_sas.h
+++ b/drivers/scsi/mvsas/mv_sas.h
@@ -69,7 +69,7 @@ extern struct kmem_cache *mvs_task_list_cache;
69#define DEV_IS_EXPANDER(type) \ 69#define DEV_IS_EXPANDER(type) \
70 ((type == EDGE_DEV) || (type == FANOUT_DEV)) 70 ((type == EDGE_DEV) || (type == FANOUT_DEV))
71 71
72#define bit(n) ((u32)1 << n) 72#define bit(n) ((u64)1 << n)
73 73
74#define for_each_phy(__lseq_mask, __mc, __lseq) \ 74#define for_each_phy(__lseq_mask, __mc, __lseq) \
75 for ((__mc) = (__lseq_mask), (__lseq) = 0; \ 75 for ((__mc) = (__lseq_mask), (__lseq) = 0; \