From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D13C3C4338F for ; Tue, 27 Jul 2021 14:01:16 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC74061AA9 for ; Tue, 27 Jul 2021 14:01:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DC74061AA9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8F0768347B; Tue, 27 Jul 2021 16:01:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ea5RQOjy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9590583483; Tue, 27 Jul 2021 16:01:11 +0200 (CEST) Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 32E1D83343 for ; Tue, 27 Jul 2021 16:01:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qk1-x72b.google.com with SMTP id z24so12382994qkz.7 for ; Tue, 27 Jul 2021 07:01:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=BFRuTUUrP1k/jxJCEJdNB/JX+pYTU0xgY/CjJh6iXNE=; b=ea5RQOjyJWWnB9JHoCp+3DXkP4bsQiilYfo5LU9AUxPbVozy+cDytH/XyRVHWKKyz9 Wr3ZwvfVJYiJy+8RlXF8AXfhum79UAa+6kS/IDDn7kbzXjaqDgyRe9Ne698ojhAFGgJZ DxBWviAv9IXUSLEkjUdJ8ebTe2aRL52ibRq1G0D+Selk/gOige6Zj4JD2aSDePNtWzGN c0LCYdvT//nldKA7FPObQPKI4ndNjRXXqI80/uh9ZtoTWTKfKLOFPlReZjFk7NVnfihV BdzDZkqxeFqqIHwVKhsH0iNc2IUK41gLgeLKKo4yLMYHc4zPsVRErt5XewLFqLQmmtXb j3mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=BFRuTUUrP1k/jxJCEJdNB/JX+pYTU0xgY/CjJh6iXNE=; b=AYy0fZSzhC6zEuqeufoJ16mxNW5yVQArDR+IBIZfyvCue3CDz3U7SzTLqRrHTfjste fYTxZVQ4QSqzU5ux/3uLxOmXb65/5OU3HMOS3VFZPYuZhgyirZdb7lh4CIsSGJMD2gyC R00mkPiUOY47khyXZTXtgWDj1gJp/GmVG+Uxx+K7MkYIJ2dSpR5fr5JkK3X1b9vcE6qc aDarPaK1IO2jqJUdvnLKLD4AaRRshOq5I2k1oSfdo48Sg+XYKg0PHzsv2o385RnVhzT0 El5xcQpLYY95prBq88fH5WymAyatqmJGRFClQOBLbK6lw8Wn9/1NVDy3CqjOBj22G86q F6Hg== X-Gm-Message-State: AOAM533RSVCI0vJ8d0NncNd+Hczpcue4r4h5Pf61lZh46+n9lP1PB7no uNvptbbX+dsKZfww1fHIpKM= X-Google-Smtp-Source: ABdhPJyC4iU2oxbz5ioge+E1D8EZQUmNcCT+B8Svq1TTfJDJvY6wSVOTmhDVyTsYpVyM15eycoxWeA== X-Received: by 2002:a05:620a:80b:: with SMTP id s11mr6823388qks.466.1627394464857; Tue, 27 Jul 2021 07:01:04 -0700 (PDT) Received: from [192.168.1.201] (pool-74-96-87-9.washdc.fios.verizon.net. [74.96.87.9]) by smtp.googlemail.com with ESMTPSA id c197sm1707344qke.33.2021.07.27.07.01.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Jul 2021 07:01:04 -0700 (PDT) From: Sean Anderson Subject: Re: [PATCH 1/4] clk: k210: Fix checking if ulongs are less than 0 To: Damien Le Moal , "u-boot@lists.denx.de" , Leo Liang Cc: Lukasz Majewski , Coverity Scan References: <20210727035144.298277-1-seanga2@gmail.com> Message-ID: <0cc8025a-d483-6058-634b-38a853f640bf@gmail.com> Date: Tue, 27 Jul 2021 10:01:03 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 7/27/21 4:15 AM, Damien Le Moal wrote: > On 2021/07/27 12:51, Sean Anderson wrote: >> Some clock functions return ulong but still have "negative" errors. To deal >> with this, cast the relevant arguments to long. >> >> Fixes: 609bd60b94 ("clk: k210: Rewrite to remove CCF") >> Reported-by: Coverity Scan >> Signed-off-by: Sean Anderson >> --- >> >> drivers/clk/clk_kendryte.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/clk/clk_kendryte.c b/drivers/clk/clk_kendryte.c >> index 3148756968..37bd624eca 100644 >> --- a/drivers/clk/clk_kendryte.c >> +++ b/drivers/clk/clk_kendryte.c >> @@ -439,7 +439,7 @@ static const struct k210_clk_params k210_clks[] = { >> #ifdef CONFIG_CLK_K210_SET_RATE >> static int k210_pll_enable(struct k210_clk_priv *priv, int id); >> static int k210_pll_disable(struct k210_clk_priv *priv, int id); >> -static ulong k210_pll_get_rate(struct k210_clk_priv *priv, int id, ulong rate_in); >> +static ulong k210_pll_get_rate(struct k210_clk_priv *priv, int id, long rate_in); >> >> /* >> * The PLL included with the Kendryte K210 appears to be a True Circuits, Inc. >> @@ -841,7 +841,7 @@ TEST_STATIC int k210_pll_calc_config(u32 rate, u32 rate_in, >> } >> >> static ulong k210_pll_set_rate(struct k210_clk_priv *priv, int id, ulong rate, > > Shouldn't this one return a long, in case of error ? It seems that the commit > messages hints at such a change, but you are changing the argument type instead. > A little confusing. What am I missing ? Perhaps they should return long, but these are basically matching the prototypes in include/clk-uclass.h. And there, get_rate and set_rate take ulong arguments and return ulongs. > >> - ulong rate_in) >> + long rate_in) >> { >> int err; >> const struct k210_pll_params *pll = &k210_plls[id]; >> @@ -890,7 +890,7 @@ static ulong k210_pll_set_rate(struct k210_clk_priv *priv, int id, ulong rate, >> #endif /* CONFIG_CLK_K210_SET_RATE */ >> >> static ulong k210_pll_get_rate(struct k210_clk_priv *priv, int id, > > Same here ? > >> - ulong rate_in) >> + long rate_in) > > I would assume that these functions are called if the rate_in argument is > correct, so I do not really understand why the argument type needs to be changed... Hm, I suppose the better patch would be to check the return of get_rate and set_rate when we call them. I think my intent here was to allow subsequent functions to be no-ops in case of error, but it looks like I act on these values directly. Will fix in v2. --Sean > >> { >> u64 r, f, od; >> u32 reg = readl(priv->base + k210_plls[id].off); >> > >