From: Baolin Wang Date: Wed, 25 Oct 2017 11:25:09 +0000 (+0800) Subject: spi: sprd: Fix the possible negative value of BIT() X-Git-Tag: v4.15-rc1~174^2^4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=54e2fc28d9cf1be7dd2ebe74b20dc20cc2a3e55d;p=thirdparty%2Fkernel%2Flinux.git spi: sprd: Fix the possible negative value of BIT() When enabling the ADI hardware channels, if the channel id is 31, then we will get one negative value -1 for BIT() macro, which will write incorrect value to register. Fixes: 7e2903cb91df ("spi: Add ADI driver for Spreadtrum platform") Reported-by: Dan Carpenter Signed-off-by: Baolin Wang Signed-off-by: Mark Brown --- diff --git a/drivers/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c index 6a5ff3003044d..5993bdbf79e46 100644 --- a/drivers/spi/spi-sprd-adi.c +++ b/drivers/spi/spi-sprd-adi.c @@ -303,7 +303,7 @@ static void sprd_adi_hw_init(struct sprd_adi *sadi) writel_relaxed(chn_config, sadi->base + REG_ADI_CHN_ADDR(chn_id)); - if (chn_id < 31) { + if (chn_id < 32) { value = readl_relaxed(sadi->base + REG_ADI_CHN_EN); value |= BIT(chn_id); writel_relaxed(value, sadi->base + REG_ADI_CHN_EN);