Thread (5 messages) flat view 5 messages, 3 authors, 2015-05-25

Re: fbdev: ssd1307fb: Unify init code and obtain hw specific bits from DT

From: Thomas Niederprüm <hidden>
Date: 2015-05-25 07:34:32

Am Sat, 23 May 2015 20:32:45 +0300
schrieb Dan Carpenter [off-list ref]:
Hello Thomas Niederprüm,

The patch a3998fe03e87: "fbdev: ssd1307fb: Unify init code and obtain
hw specific bits from DT" from Mar 31, 2015, leads to the following
static checker warning:

	drivers/video/fbdev/ssd1307fb.c:371 ssd1307fb_init()
	warn: add some parenthesis here?

drivers/video/fbdev/ssd1307fb.c
   366          /* Set COM pins configuration */
   367          ret = ssd1307fb_write_cmd(par->client,
SSD1307FB_SET_COM_PINS_CONFIG); 368          if (ret < 0)
   369                  return ret;
   370  
   371          compins = 0x02 | (!par->com_seq & 0x1) << 4
   372                                     | (par->com_lrremap & 0x1)
<< 5;

Smatch is complaining because it's normally  "!par->com_seq & 0x1" is
a bug and "!(par->com_seq & 0x1)" is intended.  I don't know what was
intended here though.  If the current code is correct, you can silence
the static checker warning by writing it as "(!par->com_seq) & 0x1".
Indeed "!(par->com_seq & 0x1)" is what I intended. Thanks for spotting
this. 
What is the best way to handle this now? Will you send a fixup
patch as for the backlight code or will this be my task?
But I also have a hard time remembering if | or << is higher
precedence so that might be clearer with parenthesis as well even
though the code is clearly correct when I google for "order of
operations" in C.

   373          ret = ssd1307fb_write_cmd(par->client, compins);
   374          if (ret < 0)
   375                  return ret;
Thanks!

Thomas
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help