]> git.karo-electronics.de Git - karo-tx-linux.git/commit
mvsas: fix undefined bit shift
authorXi Wang <xi.wang@gmail.com>
Fri, 16 Nov 2012 19:40:03 +0000 (14:40 -0500)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 3 Jan 2013 03:33:21 +0000 (03:33 +0000)
commit463c45b0cdd91bf8426330373e5d292b002c5617
treef9c3771fcc56d7dbfe864508b86de27ef0564546
parent567fd40fe65a51594d7745827226f93d9a40ec6f
mvsas: fix undefined bit shift

commit beecadea1b8d67f591b13f7099559f32f3fd601d upstream.

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>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/scsi/mvsas/mv_94xx.h
drivers/scsi/mvsas/mv_sas.h