linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: yanguoxiong@huawei.com
Cc: linux-media@vger.kernel.org
Subject: [bug report] [media] rc: Introduce hix5hd2 IR transmitter driver
Date: Wed, 25 Sep 2019 16:34:15 +0300	[thread overview]
Message-ID: <20190925133415.GA15578@mwanda> (raw)

[ Ancient code, but maybe someone knows the answer.  - dan ]

Hello Guoxiong Yan,

The patch a84fcdaa9058: "[media] rc: Introduce hix5hd2 IR transmitter
driver" from Aug 30, 2014, leads to the following static checker
warning:

	./drivers/media/rc/ir-hix5hd2.c:112 (null)()
	warn: odd binop '0x3e80 & 0xffffffffffff0000'

drivers/media/rc/ir-hix5hd2.c
    95  static int hix5hd2_ir_config(struct hix5hd2_ir_priv *priv)
    96  {
    97          int timeout = 10000;
    98          u32 val, rate;
    99  
   100          writel_relaxed(0x01, priv->base + IR_ENABLE);
   101          while (readl_relaxed(priv->base + IR_BUSY)) {
   102                  if (timeout--) {
   103                          udelay(1);
   104                  } else {
   105                          dev_err(priv->dev, "IR_BUSY timeout\n");
   106                          return -ETIMEDOUT;
   107                  }
   108          }
   109  
   110          /* Now only support raw mode, with symbol start from low to high */
   111          rate = DIV_ROUND_CLOSEST(priv->rate, 1000000);
   112          val = IR_CFG_SYMBOL_MAXWIDTH & IR_CFG_WIDTH_MASK << IR_CFG_WIDTH_SHIFT;
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is zero because << has higher precedence than &.  But maybe what
was intended was:

		val = (IR_CFG_SYMBOL_MAXWIDTH & IR_CFG_WIDTH_MASK) << IR_CFG_WIDTH_SHIFT;

   113          val |= IR_CFG_SYMBOL_FMT & IR_CFG_FORMAT_MASK << IR_CFG_FORMAT_SHIFT;
                       ^^^^^^^^^^^^^^^^^
This is zero anyway, so it doesn't matter but maybe there is a precedence
bug here as well.

   114          val |= (IR_CFG_INT_THRESHOLD - 1) & IR_CFG_INT_LEVEL_MASK
   115                 << IR_CFG_INT_LEVEL_SHIFT;
                       ^^^^^^^^^^^^^^^^^^^^^^^^^
Same

   116          val |= IR_CFG_MODE_RAW;
   117          val |= (rate - 1) & IR_CFG_FREQ_MASK << IR_CFG_FREQ_SHIFT;
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Same

   118          writel_relaxed(val, priv->base + IR_CONFIG);
   119  
   120          writel_relaxed(0x00, priv->base + IR_INTM);
   121          /* write arbitrary value to start  */
   122          writel_relaxed(0x01, priv->base + IR_START);
   123          return 0;
   124  }

regards,
dan carpenter

                 reply	other threads:[~2019-09-25 13:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20190925133415.GA15578@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=linux-media@vger.kernel.org \
    --cc=yanguoxiong@huawei.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 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).