All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: miquel.raynal@bootlin.com
Cc: linux-rtc@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: [bug report] rtc: rzn1: Add oscillator offset support
Date: Thu, 19 May 2022 16:56:31 +0300	[thread overview]
Message-ID: <YoZMjwjcDlVCG+TR@kili> (raw)

Hello Miquel Raynal,

The patch be4a11cf98af: "rtc: rzn1: Add oscillator offset support"
from May 16, 2022, leads to the following Smatch static checker
warning:

	drivers/rtc/rtc-rzn1.c:302 rzn1_rtc_set_offset()
	warn: 'steps' 'true' implies 'steps > 0' is 'true'

drivers/rtc/rtc-rzn1.c
    270 static int rzn1_rtc_set_offset(struct device *dev, long offset)
    271 {
    272         struct rzn1_rtc *rtc = dev_get_drvdata(dev);
    273         unsigned int steps;
                ^^^^^^^^^^^^^^^^^^
steps is unsigned

    274         int stepsh, stepsl;
    275         u32 val = 0;
    276         int ret;
    277 
    278         /*
    279          * Check which resolution mode (every 20 or 60s) can be used.
    280          * Between 2 and 124 clock pulses can be added or substracted.
    281          *
    282          * In 20s mode, the minimum resolution is 2 / (32768 * 20) which is
    283          * close to 3051 ppb. In 60s mode, the resolution is closer to 1017.
    284          */
    285         stepsh = DIV_ROUND_CLOSEST(offset, 1017);
    286         stepsl = DIV_ROUND_CLOSEST(offset, 3051);
    287 
    288         if (stepsh >= -0x3E && stepsh <= 0x3E) {
    289                 /* 1017 ppb per step */
    290                 steps = stepsh;
    291                 val |= RZN1_RTC_SUBU_DEV;
    292         } else if (stepsl >= -0x3E && stepsl <= 0x3E) {
    293                 /* 3051 ppb per step */
    294                 steps = stepsl;
    295         } else {
    296                 return -ERANGE;
    297         }
    298 
    299         if (!steps)

if steps is zero return

    300                 return 0;
    301 
--> 302         if (steps > 0) {

This is true.  No need to check.

    303                 val |= steps + 1;
    304         } else {
    305                 val |= RZN1_RTC_SUBU_DECR;
    306                 val |= (~(-steps - 1)) & 0x3F;
    307         }
    308 
    309         ret = readl_poll_timeout(rtc->base + RZN1_RTC_CTL2, val,
    310                                  !(val & RZN1_RTC_CTL2_WUST), 100, 2000000);
    311         if (ret)
    312                 return ret;
    313 
    314         writel(val, rtc->base + RZN1_RTC_SUBU);
    315 
    316         return 0;
    317 }

regards,
dan carpenter

             reply	other threads:[~2022-05-19 13:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-19 13:56 Dan Carpenter [this message]
2022-05-19 14:11 ` [bug report] rtc: rzn1: Add oscillator offset support Miquel Raynal

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=YoZMjwjcDlVCG+TR@kili \
    --to=dan.carpenter@oracle.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=miquel.raynal@bootlin.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.