All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alison Schofield <amsfield22@gmail.com>
To: outreachy-kernel@googlegroups.com
Subject: Re: [PATCH] Staging: fbtft: Do not use same argument more than once in bit operation.
Date: Thu,  3 Mar 2016 17:26:02 -0800	[thread overview]
Message-ID: <1457054762-3682-1-git-send-email-amsfield22@gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1603032053480.2061@localhost6.localdomain6>

The reason may be that author is trying to
to explicitly reflect the register settings.

Considering this code...

static int init_display(struct fbtft_par *par)
{
.................snip........................

	/* Set temperature compensation */
        write_reg(par, 0x24 | (temp & 0x03));

        /* Set panel loading */
        write_reg(par, 0x28 | (load & 0x03));

        /* Set pump control */
        write_reg(par, 0x2C | (pump & 0x03));

        /* Set inverse display */
        write_reg(par, 0xA6 | (0x01 & 0x01));

        /* Set 4-bit grayscale mode */
        write_reg(par, 0xD0 | (0x02 & 0x03));

In the first 3 commands temp,load,pump are vars &'d with a mask.
In the last 2 commands 0x01 and 0x02 are hardcoded values &'d with a mask.
Sometimes that hardcoded value just happens to be the same as its mask.
I might even guess that this author knew it was redundant, but
that the compiler would reduce all of that for him anyway.

you can see the register definitions here if you want to get to
very bottom of this ;)
http://lcdhype.condense.de/index.php?act=Attach&type=post&id=6112&index=0

I wonder if it is better to define all those hardcode values for even
more clarity.



  reply	other threads:[~2016-03-04  1:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-03 10:33 [PATCH] Staging: fbtft: Do not use same argument more than once in bit operation Sandhya Bankar
2016-03-03 19:54 ` [Outreachy kernel] " Julia Lawall
2016-03-04  1:26   ` Alison Schofield [this message]
2016-03-04  6:12     ` [Outreachy kernel] " Julia Lawall

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=1457054762-3682-1-git-send-email-amsfield22@gmail.com \
    --to=amsfield22@gmail.com \
    --cc=outreachy-kernel@googlegroups.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.