Skip to contentSkip to conversation

fbcon: replace mono_col macro with static inline

PATCH In review Harvey Harrison 3 participants 6 messages Feb 25, 2008 – Feb 26, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fbcon: replace mono_col macro with static inline

Use __u32 for max_len to match the declaration of length in the struct fb_bitfield.

Suppresses sparse shadowed variable warnings from the nested max() macros:
drivers/video/console/fbcon.h:130:8: warning: symbol '_x' shadows an earlier one drivers/video/console/fbcon.h:130:8: originally declared here drivers/video/console/fbcon.h:130:8: warning: symbol '_x' shadows an earlier one drivers/video/console/fbcon.h:130:8: originally declared here drivers/video/console/fbcon.h:130:8: warning: symbol '_y' shadows an earlier one drivers/video/console/fbcon.h:130:8: originally declared here

---
 drivers/video/console/fbcon.h |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
drivers/video/console/fbcon.h +8 -4
index 3706307..51a6bf4 100644
@@ -104,10 +104,14 @@ struct fbcon_ops {
 #define attr_blink(s) \
 	((s) & 0x8000)
 	
-#define mono_col(info)							\
-	(~(0xfff << (max((info)->var.green.length,			\
-			 max((info)->var.red.length,			\
-			     (info)->var.blue.length)))) & 0xff)
+
+static inline int mono_col(struct fb_info *info)
+{
+	__u32 max_len;
+	max_len = max(info->var.green.length, info->var.red.length);
+	max_len = max(info->var.blue.length, max_len);
+	return ~(0xfff << (max_len & 0xff));
+}
 
 static inline int attr_col_ec(int shift, struct vc_data *vc,
 			      struct fb_info *info, int is_fg)
Signature · 1 line
1.5.4.3.328.gcaed
#1 lore raw
Quoted 30 lines · On Mon, 25 Feb 2008 10:13:57 -0800 Harvey Harrison <[email protected]>…

Use __u32 for max_len to match the declaration of length in the struct fb_bitfield.

Suppresses sparse shadowed variable warnings from the nested max() macros:
drivers/video/console/fbcon.h:130:8: warning: symbol '_x' shadows an earlier one drivers/video/console/fbcon.h:130:8: originally declared here drivers/video/console/fbcon.h:130:8: warning: symbol '_x' shadows an earlier one drivers/video/console/fbcon.h:130:8: originally declared here drivers/video/console/fbcon.h:130:8: warning: symbol '_y' shadows an earlier one drivers/video/console/fbcon.h:130:8: originally declared here

---
 drivers/video/console/fbcon.h |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
drivers/video/console/fbcon.h +1 -4
index 3706307..51a6bf4 100644
@@ -104,10 +104,14 @@ struct fbcon_ops {
 #define attr_blink(s) \
 	((s) & 0x8000)
 
-#define mono_col(info)							\
-	(~(0xfff << (max((info)->var.green.length,			\
-			 max((info)->var.red.length,			\
-			     (info)->var.blue.length)))) & 0xff)
+

drivers/video/console/fbcon.h struct fbcon_ops { · line 117

Quoted 10 lines
drivers/video/console/fbcon.h +7 -0
+static inline int mono_col(struct fb_info *info)
+{
+	__u32 max_len;
+	max_len = max(info->var.green.length, info->var.red.length);
+	max_len = max(info->var.blue.length, max_len);
+	return ~(0xfff << (max_len & 0xff));
+}
 
 static inline int attr_col_ec(int shift, struct vc_data *vc,
 			      struct fb_info *info, int is_fg)

Thanks, but please do try to copy a suitable mailing list on the patches. Particularly fbdev - Tony has been out of contact for a while, but there are other fbdev developers who can help us to review code, as long as we tell them about it.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#2 lore raw
In reply to Harvey Harrison
Quoted 22 lines · Harvey Harrison

Use __u32 for max_len to match the declaration of length in the struct fb_bitfield.

Suppresses sparse shadowed variable warnings from the nested max() macros:
drivers/video/console/fbcon.h:130:8: warning: symbol '_x' shadows an earlier one drivers/video/console/fbcon.h:130:8: originally declared here drivers/video/console/fbcon.h:130:8: warning: symbol '_x' shadows an earlier one drivers/video/console/fbcon.h:130:8: originally declared here drivers/video/console/fbcon.h:130:8: warning: symbol '_y' shadows an earlier one drivers/video/console/fbcon.h:130:8: originally declared here

---
 drivers/video/console/fbcon.h |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
drivers/video/console/fbcon.h +0 -0
index 3706307..51a6bf4 100644

drivers/video/console/fbcon.h struct fbcon_ops { · line 108

Quoted 9 lines
drivers/video/console/fbcon.h +2 -4
@@ -104,10 +104,14 @@ struct fbcon_ops {
 #define attr_blink(s) \
 	((s) & 0x8000)
 
-#define mono_col(info)							\
-	(~(0xfff << (max((info)->var.green.length,			\
-			 max((info)->var.red.length,			\
-			     (info)->var.blue.length)))) & 0xff)
+
+static inline int mono_col(struct fb_info *info)
                              ^^^^^^^^^^^^^^^^^^^^

const struct fb_info *info?

drivers/video/console/fbcon.h struct fbcon_ops { · line 117

Quoted 9 lines
drivers/video/console/fbcon.h +6 -0
+{
+	__u32 max_len;
+	max_len = max(info->var.green.length, info->var.red.length);
+	max_len = max(info->var.blue.length, max_len);
+	return ~(0xfff << (max_len & 0xff));
+}
 
 static inline int attr_col_ec(int shift, struct vc_data *vc,
 			      struct fb_info *info, int is_fg)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#3 lore raw
Quoted 5 lines · Geert Uytterhoeven
Quoted 1 line · Harvey Harrison

+static inline int mono_col(struct fb_info *info)

                              ^^^^^^^^^^^^^^^^^^^^

const struct fb_info *info?

I suppose, but seeing as it's an inline, does it really matter?

Harvey

#4 lore raw
Quoted 7 lines · Harvey Harrison
Quoted 4 lines · Geert Uytterhoeven
Quoted 1 line · Harvey Harrison

+static inline int mono_col(struct fb_info *info)

                              ^^^^^^^^^^^^^^^^^^^^

const struct fb_info *info?

I suppose, but seeing as it's an inline, does it really matter?

Sure, if one day a new routine calls mono_col() passing a const struct fb_info pointer, it won't compile.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#5 lore raw
Quoted 11 lines · Geert Uytterhoeven
Quoted 7 lines · Harvey Harrison
Quoted 4 lines · Geert Uytterhoeven
Quoted 1 line · Harvey Harrison

+static inline int mono_col(struct fb_info *info)

                              ^^^^^^^^^^^^^^^^^^^^

const struct fb_info *info?

I suppose, but seeing as it's an inline, does it really matter?

Sure, if one day a new routine calls mono_col() passing a const struct fb_info pointer, it won't compile.

Fair enough, want an updated patch, or will Andrew just make the small addition?

Harvey

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/