]> git.karo-electronics.de Git - karo-tx-linux.git/commit
SCSI: mvsas: fix undefined bit shift
authorXi Wang <xi.wang@gmail.com>
Fri, 16 Nov 2012 19:40:03 +0000 (14:40 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jan 2013 16:45:56 +0000 (08:45 -0800)
commitac434537ba0a4a62f220eb745fce394193fa6bd8
treec212babab39dad791a717923cf67810c42b0cbeb
parent7b9442906ecd833be4d67a8f9bfa161155a32de6
SCSI: 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/scsi/mvsas/mv_94xx.h
drivers/scsi/mvsas/mv_sas.h