Skip to content

Commit

Permalink
spi: sprd: Fix the possible negative value of BIT()
Browse files Browse the repository at this point in the history
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: 7e2903c ("spi: Add ADI driver for Spreadtrum platform")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Baolin Wang authored and Mark Brown committed Oct 25, 2017
1 parent 8955b26 commit 54e2fc2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/spi/spi-sprd-adi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 54e2fc2

Please sign in to comment.