linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: sprd: Fix the possible negative value of BIT()
@ 2017-10-25 11:25 Baolin Wang
       [not found] ` <501d5362189cd3ec99e52082827f5d40a220cc3d.1508930323.git.baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Baolin Wang @ 2017-10-25 11:25 UTC (permalink / raw)
  To: broonie-DgEjT+Ai2ygdnm+yROfE0A
  Cc: dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA,
	linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	baolin.wang-QSEj5FYQhm4dnm+yROfE0A

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 <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Baolin Wang <baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/spi/spi-sprd-adi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c
index 6a5ff30..5993bdb 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);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Applied "spi: sprd: Fix the possible negative value of BIT()" to the spi tree
       [not found] ` <501d5362189cd3ec99e52082827f5d40a220cc3d.1508930323.git.baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
@ 2017-10-25 12:03   ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2017-10-25 12:03 UTC (permalink / raw)
  To: Baolin Wang
  Cc: Dan Carpenter, Mark Brown, broonie-DgEjT+Ai2ygdnm+yROfE0A,
	dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA,
	linux-spi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	baolin.wang-QSEj5FYQhm4dnm+yROfE0A,
	linux-spi-u79uwXL29TY76Z2rM5mHXA

The patch

   spi: sprd: Fix the possible negative value of BIT()

has been applied to the spi tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 54e2fc28d9cf1be7dd2ebe74b20dc20cc2a3e55d Mon Sep 17 00:00:00 2001
From: Baolin Wang <baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Date: Wed, 25 Oct 2017 19:25:09 +0800
Subject: [PATCH] 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 <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Baolin Wang <baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
 drivers/spi/spi-sprd-adi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c
index 6a5ff3003044..5993bdbf79e4 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);
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-25 12:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-25 11:25 [PATCH] spi: sprd: Fix the possible negative value of BIT() Baolin Wang
     [not found] ` <501d5362189cd3ec99e52082827f5d40a220cc3d.1508930323.git.baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-10-25 12:03   ` Applied "spi: sprd: Fix the possible negative value of BIT()" to the spi tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).