linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
From: shobhitkukreti at gmail.com (Shobhit Kukreti)
Subject: [Linux-kernel-mentees] [PATCH v3] video: atmel_lcdc: Fix Shifting signed 32 bit value by 31 bits problem
Date: Sun, 21 Jul 2019 17:42:40 -0700	[thread overview]
Message-ID: <1563756160-29702-1-git-send-email-shobhitkukreti@gmail.com> (raw)
In-Reply-To: <9c98fd20-5bc8-48a6-96ed-889a18d1a0c0@samsung.com>

Fix ATMEL_LCDC_MEMOR and ATMEL_LCDC_MEMOR_LITTLE defines to use "U"
cast to avoid shifting signed 32 bit values by 31 bit problem. This
problem. This is not a problem for gcc built kernel.

However, this may be a problem since the header is part of pbulic API
which could be included for builds using compilers which do not handle
this condition safely resulting in undefined behavior

Signed-off-by: Shobhit Kukreti <shobhitkukreti at gmail.com>
---
Changes in v3:
	Replace Bit Shift Operations with BIT() macros

Changes in v2:
       Fixed spelling typo

 include/video/atmel_lcdc.h | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/include/video/atmel_lcdc.h b/include/video/atmel_lcdc.h
index 43e497c..985e2d6 100644
--- a/include/video/atmel_lcdc.h
+++ b/include/video/atmel_lcdc.h
@@ -85,27 +85,27 @@ struct atmel_lcdfb_pdata {
 #define		ATMEL_LCDC_PIXELSIZE_16		(4 << 5)
 #define		ATMEL_LCDC_PIXELSIZE_24		(5 << 5)
 #define		ATMEL_LCDC_PIXELSIZE_32		(6 << 5)
-#define	ATMEL_LCDC_INVVD	(1 << 8)
+#define	ATMEL_LCDC_INVVD	BIT(8)
 #define		ATMEL_LCDC_INVVD_NORMAL		(0 << 8)
-#define		ATMEL_LCDC_INVVD_INVERTED	(1 << 8)
-#define	ATMEL_LCDC_INVFRAME	(1 << 9 )
+#define		ATMEL_LCDC_INVVD_INVERTED	BIT(8)
+#define	ATMEL_LCDC_INVFRAME	BIT(9)
 #define		ATMEL_LCDC_INVFRAME_NORMAL	(0 << 9)
-#define		ATMEL_LCDC_INVFRAME_INVERTED	(1 << 9)
-#define	ATMEL_LCDC_INVLINE	(1 << 10)
+#define		ATMEL_LCDC_INVFRAME_INVERTED	BIT(9)
+#define	ATMEL_LCDC_INVLINE	BIT(10)
 #define		ATMEL_LCDC_INVLINE_NORMAL	(0 << 10)
-#define		ATMEL_LCDC_INVLINE_INVERTED	(1 << 10)
-#define	ATMEL_LCDC_INVCLK	(1 << 11)
+#define		ATMEL_LCDC_INVLINE_INVERTED	BIT(10)
+#define	ATMEL_LCDC_INVCLK	BIT(11)
 #define		ATMEL_LCDC_INVCLK_NORMAL	(0 << 11)
-#define		ATMEL_LCDC_INVCLK_INVERTED	(1 << 11)
-#define	ATMEL_LCDC_INVDVAL	(1 << 12)
+#define		ATMEL_LCDC_INVCLK_INVERTED	BIT(11)
+#define	ATMEL_LCDC_INVDVAL	BIT(12)
 #define		ATMEL_LCDC_INVDVAL_NORMAL	(0 << 12)
-#define		ATMEL_LCDC_INVDVAL_INVERTED	(1 << 12)
-#define	ATMEL_LCDC_CLKMOD	(1 << 15)
+#define		ATMEL_LCDC_INVDVAL_INVERTED	BIT(12)
+#define	ATMEL_LCDC_CLKMOD	BIT(15)
 #define		ATMEL_LCDC_CLKMOD_ACTIVEDISPLAY	(0 << 15)
-#define		ATMEL_LCDC_CLKMOD_ALWAYSACTIVE	(1 << 15)
-#define	ATMEL_LCDC_MEMOR	(1 << 31)
+#define		ATMEL_LCDC_CLKMOD_ALWAYSACTIVE	BIT(15)
+#define	ATMEL_LCDC_MEMOR	BIT(31)
 #define		ATMEL_LCDC_MEMOR_BIG		(0 << 31)
-#define		ATMEL_LCDC_MEMOR_LITTLE		(1 << 31)
+#define		ATMEL_LCDC_MEMOR_LITTLE		BIT(31)
 
 #define ATMEL_LCDC_TIM1		0x0808
 #define	ATMEL_LCDC_VFP		(0xffU <<  0)
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: shobhitkukreti@gmail.com (Shobhit Kukreti)
Subject: [Linux-kernel-mentees] [PATCH v3] video: atmel_lcdc: Fix Shifting signed 32 bit value by 31 bits problem
Date: Sun, 21 Jul 2019 17:42:40 -0700	[thread overview]
Message-ID: <1563756160-29702-1-git-send-email-shobhitkukreti@gmail.com> (raw)
Message-ID: <20190722004240.6KEeEEdvKsLjTyx88byKlwPBsRZyDUxHj8MLdw24ePY@z> (raw)
In-Reply-To: <9c98fd20-5bc8-48a6-96ed-889a18d1a0c0@samsung.com>

Fix ATMEL_LCDC_MEMOR and ATMEL_LCDC_MEMOR_LITTLE defines to use "U"
cast to avoid shifting signed 32 bit values by 31 bit problem. This
problem. This is not a problem for gcc built kernel.

However, this may be a problem since the header is part of pbulic API
which could be included for builds using compilers which do not handle
this condition safely resulting in undefined behavior

Signed-off-by: Shobhit Kukreti <shobhitkukreti at gmail.com>
---
Changes in v3:
	Replace Bit Shift Operations with BIT() macros

Changes in v2:
       Fixed spelling typo

 include/video/atmel_lcdc.h | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/include/video/atmel_lcdc.h b/include/video/atmel_lcdc.h
index 43e497c..985e2d6 100644
--- a/include/video/atmel_lcdc.h
+++ b/include/video/atmel_lcdc.h
@@ -85,27 +85,27 @@ struct atmel_lcdfb_pdata {
 #define		ATMEL_LCDC_PIXELSIZE_16		(4 << 5)
 #define		ATMEL_LCDC_PIXELSIZE_24		(5 << 5)
 #define		ATMEL_LCDC_PIXELSIZE_32		(6 << 5)
-#define	ATMEL_LCDC_INVVD	(1 << 8)
+#define	ATMEL_LCDC_INVVD	BIT(8)
 #define		ATMEL_LCDC_INVVD_NORMAL		(0 << 8)
-#define		ATMEL_LCDC_INVVD_INVERTED	(1 << 8)
-#define	ATMEL_LCDC_INVFRAME	(1 << 9 )
+#define		ATMEL_LCDC_INVVD_INVERTED	BIT(8)
+#define	ATMEL_LCDC_INVFRAME	BIT(9)
 #define		ATMEL_LCDC_INVFRAME_NORMAL	(0 << 9)
-#define		ATMEL_LCDC_INVFRAME_INVERTED	(1 << 9)
-#define	ATMEL_LCDC_INVLINE	(1 << 10)
+#define		ATMEL_LCDC_INVFRAME_INVERTED	BIT(9)
+#define	ATMEL_LCDC_INVLINE	BIT(10)
 #define		ATMEL_LCDC_INVLINE_NORMAL	(0 << 10)
-#define		ATMEL_LCDC_INVLINE_INVERTED	(1 << 10)
-#define	ATMEL_LCDC_INVCLK	(1 << 11)
+#define		ATMEL_LCDC_INVLINE_INVERTED	BIT(10)
+#define	ATMEL_LCDC_INVCLK	BIT(11)
 #define		ATMEL_LCDC_INVCLK_NORMAL	(0 << 11)
-#define		ATMEL_LCDC_INVCLK_INVERTED	(1 << 11)
-#define	ATMEL_LCDC_INVDVAL	(1 << 12)
+#define		ATMEL_LCDC_INVCLK_INVERTED	BIT(11)
+#define	ATMEL_LCDC_INVDVAL	BIT(12)
 #define		ATMEL_LCDC_INVDVAL_NORMAL	(0 << 12)
-#define		ATMEL_LCDC_INVDVAL_INVERTED	(1 << 12)
-#define	ATMEL_LCDC_CLKMOD	(1 << 15)
+#define		ATMEL_LCDC_INVDVAL_INVERTED	BIT(12)
+#define	ATMEL_LCDC_CLKMOD	BIT(15)
 #define		ATMEL_LCDC_CLKMOD_ACTIVEDISPLAY	(0 << 15)
-#define		ATMEL_LCDC_CLKMOD_ALWAYSACTIVE	(1 << 15)
-#define	ATMEL_LCDC_MEMOR	(1 << 31)
+#define		ATMEL_LCDC_CLKMOD_ALWAYSACTIVE	BIT(15)
+#define	ATMEL_LCDC_MEMOR	BIT(31)
 #define		ATMEL_LCDC_MEMOR_BIG		(0 << 31)
-#define		ATMEL_LCDC_MEMOR_LITTLE		(1 << 31)
+#define		ATMEL_LCDC_MEMOR_LITTLE		BIT(31)
 
 #define ATMEL_LCDC_TIM1		0x0808
 #define	ATMEL_LCDC_VFP		(0xffU <<  0)
-- 
2.7.4

  parent reply	other threads:[~2019-07-22  0:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-06 17:41 [Linux-kernel-mentees] [PATCH] video: atmel_lcdc: Fix Shifting signed 32 bit value by 31 bits problem shobhitkukreti
2019-07-06 17:41 ` Shobhit Kukreti
2019-07-06 18:28 ` [Linux-kernel-mentees] [PATCH v2] " shobhitkukreti
2019-07-06 18:28   ` shobhitkukreti
2019-07-15 11:33   ` b.zolnierkie
2019-07-15 11:33     ` Bartlomiej Zolnierkiewicz
2019-07-22  0:42     ` shobhitkukreti [this message]
2019-07-22  0:42       ` [Linux-kernel-mentees] [PATCH v3] " Shobhit Kukreti
2019-08-19 14:29       ` b.zolnierkie
2019-08-19 14:29         ` Bartlomiej Zolnierkiewicz
2020-01-08 13:08       ` Nicolas.Ferre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1563756160-29702-1-git-send-email-shobhitkukreti@gmail.com \
    --to=linux-kernel-mentees@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).