Message ID | 20230413-fixes-for-mt8195-hdmi-phy-v1-1-b8482458df0d@baylibre.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1013256vqo; Thu, 13 Apr 2023 06:00:59 -0700 (PDT) X-Google-Smtp-Source: AKy350Yt7E2djUyzh+5v+ceTnbdRIN918qWIck7kIWlTGEIJlmTwCmkZlnY7hAqpK+ZvtUSheX++ X-Received: by 2002:a17:903:645:b0:1a6:387a:6572 with SMTP id kh5-20020a170903064500b001a6387a6572mr2035863plb.13.1681390858723; Thu, 13 Apr 2023 06:00:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681390858; cv=none; d=google.com; s=arc-20160816; b=SWMl1qSbO2iAA8oHLrUMqYrjWHKzSSJu4Nl64YZcemspJQ74BruG46ahuk908UzPT3 mFiTSBvEpaW8/OYMbRdwLNcMHaEKZ7ubuMeRDPVZJHX/gNtEpZUR4naG2kkf9rOA5aHP 2SMPrHmNhaUuwqOlahSjI4j/LFgUOh/hx9UGoJOOQ2kKyUxlurJ/m2lGwmQlDc1bxJc8 ZHPQfWKMeJEs+XQfZ+njvZsNIllvGz/8K8sR29lHN7OapCT8u9CJIb15mLHiebCoTDri J/Mo1eXEz9paz6tJUeXIlRDH/vQpxrz1JuMl7fg54QhnoXTVKvzIep94dc9Ngsgdfsj1 Oplw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=pfiB0dyNF5IN+dDnQ49hhgOP3vgf9O+J5xAGBbme+xg=; b=JMm2ynNsFRzsonmoeUG/ngjxDZDfo61SIJvnVR0CItA9lojVdiD7rcCpGg0+fVXjDC 59f9TBIm1CGxJCFN4cHljTvv6BImfGQtLQJaZOdpgW8VypMi4QP6RWunaYG6vUkuT5XN dvNFip6L8nXYr3eEZQeTxp5KTshSqmU4p8P4oHZplU3HuVcHUtPqr8ao1xBfyzkmXxQk CfcnbEy8555BTleW+vfd7KWbrQLQQZSciWY8NenGpkmsn9+wXaL+Pf2XwNMyKhRlf+3I TPhL9XiO24boe/oe+qKyXRZKEnMpd3HF/L2TEA1edvg6GRNZUtF8CvjkxuYZG3eEGdql ADpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=jt9lPv4l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h10-20020a170902f54a00b0019a9f8bdba0si2186958plf.62.2023.04.13.06.00.45; Thu, 13 Apr 2023 06:00:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=jt9lPv4l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230033AbjDMMvt (ORCPT <rfc822;peter110.wang@gmail.com> + 99 others); Thu, 13 Apr 2023 08:51:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230057AbjDMMvn (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 13 Apr 2023 08:51:43 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8B6CA266 for <linux-kernel@vger.kernel.org>; Thu, 13 Apr 2023 05:51:41 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id k36-20020a05600c1ca400b003f0a7c483feso1021862wms.4 for <linux-kernel@vger.kernel.org>; Thu, 13 Apr 2023 05:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681390300; x=1683982300; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=pfiB0dyNF5IN+dDnQ49hhgOP3vgf9O+J5xAGBbme+xg=; b=jt9lPv4lNrVGnYs0/3pm0ZbWLL22vClDmV9Mi1AjKNPGPhp2Z1qGKvnTZxfZ2IH6Va kdWB9Vni+Q2YbR5aVEZCe1q10+kzpEoLsR96keXGahTbBCxs1Gw4Rf4FvtwtSZ7HVKN3 C81hq4PEchuYqdXF9E0329vVtPniqlkTwnJJ+uxVfTuZcKBHUJIiO6LOLKb21khCxIfq KaSXyJEqR4mqIBxAuPCklrrhmsA+bnWVtMAjwFperuNLjMPZ2+tDlEdIBc5Io+l0ofVe E9obFN/51kCQ1pDsVpsDL0sTjweGDhw6VzcDBOGCHtbPxDwugox0FApsENkM9nt4vwjQ tf2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681390300; x=1683982300; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pfiB0dyNF5IN+dDnQ49hhgOP3vgf9O+J5xAGBbme+xg=; b=L9U8JWvTjfuS6DUoHaf/8Tk/mo99hSlwClu1FYICF9qVIlLAAzlRWfatm5MztFwY55 kv57CFTJobm5nwxpElAzBx7QErnQ2yZly0AcD+eGXdz+uk7aJQehrdPUUa0qSWo0LP/H UlDdcNAe//xKZYxW2I5FFrTRk2Zl8MAC3hH8c1zLRcOLy7VZEQ8+IqdKI340vgHONAXI 0lbAbySpH3u5FvXbc4NimcHOCA9l5BVSNtQVKFNO+jyQAOBO3BHKcVD8pyv+RhYZbd4i UgS7J4BMqBm3kgPQu0x1gYFMj7bbaVwXX/ptSVZs513cI1rCSODnrUbZ/BQQkCSBulIT 65wA== X-Gm-Message-State: AAQBX9d2P1UQovyMxQ7hmTbpuSU0J0xy01NAQPGMXtk2h6juoNjzeLgr eRgcVY5CbsY8pGreUn2mlxFRMg== X-Received: by 2002:a7b:ca57:0:b0:3ed:4685:4618 with SMTP id m23-20020a7bca57000000b003ed46854618mr1728570wml.34.1681390300370; Thu, 13 Apr 2023 05:51:40 -0700 (PDT) Received: from [127.0.0.1] ([82.66.159.240]) by smtp.gmail.com with ESMTPSA id k17-20020a5d66d1000000b002f67e4d1c63sm156356wrw.12.2023.04.13.05.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Apr 2023 05:51:40 -0700 (PDT) From: Guillaume Ranquet <granquet@baylibre.com> Date: Thu, 13 Apr 2023 14:46:25 +0200 Subject: [PATCH 1/2] phy: mediatek: hdmi: mt8195: fix uninitialized variable usage in pll_calc MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230413-fixes-for-mt8195-hdmi-phy-v1-1-b8482458df0d@baylibre.com> References: <20230413-fixes-for-mt8195-hdmi-phy-v1-0-b8482458df0d@baylibre.com> In-Reply-To: <20230413-fixes-for-mt8195-hdmi-phy-v1-0-b8482458df0d@baylibre.com> To: Chun-Kuang Hu <chunkuang.hu@kernel.org>, Philipp Zabel <p.zabel@pengutronix.de>, Chunfeng Yun <chunfeng.yun@mediatek.com>, Vinod Koul <vkoul@kernel.org>, Kishon Vijay Abraham I <kishon@kernel.org>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Cc: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Guillaume Ranquet <granquet@baylibre.com>, kernel test robot <lkp@intel.com> X-Mailer: b4 0.13-dev X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763066100705346286?= X-GMAIL-MSGID: =?utf-8?q?1763066100705346286?= |
Series |
Fix mtk-hdmi-mt8195 unitialized variable usage and clock rate calculation
|
|
Commit Message
Guillaume Ranquet
April 13, 2023, 12:46 p.m. UTC
The ret variable in mtk_hdmi_pll_calc() was used unitialized as reported
by the kernel test robot.
Fix the issue by removing the variable altogether and testing out the
return value of mtk_hdmi_pll_set_hw()
Fixes: 45810d486bb44 ("phy: mediatek: add support for phy-mtk-hdmi-mt8195")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>
---
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
Comments
Il 13/04/23 14:46, Guillaume Ranquet ha scritto: > The ret variable in mtk_hdmi_pll_calc() was used unitialized as reported > by the kernel test robot. > > Fix the issue by removing the variable altogether and testing out the > return value of mtk_hdmi_pll_set_hw() > > Fixes: 45810d486bb44 ("phy: mediatek: add support for phy-mtk-hdmi-mt8195") > Reported-by: kernel test robot <lkp@intel.com> > Signed-off-by: Guillaume Ranquet <granquet@baylibre.com> > --- > drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c b/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c > index abfc077fb0a8..e10da6c4147e 100644 > --- a/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c > +++ b/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c > @@ -213,7 +213,7 @@ static int mtk_hdmi_pll_calc(struct mtk_hdmi_phy *hdmi_phy, struct clk_hw *hw, > u64 tmds_clk, pixel_clk, da_hdmitx21_ref_ck, ns_hdmipll_ck, pcw; > u8 txpredivs[4] = { 2, 4, 6, 12 }; > u32 fbkdiv_low; > - int i, ret; > + int i; > > pixel_clk = rate; > tmds_clk = pixel_clk; > @@ -292,10 +292,9 @@ static int mtk_hdmi_pll_calc(struct mtk_hdmi_phy *hdmi_phy, struct clk_hw *hw, > if (!(digital_div <= 32 && digital_div >= 1)) > return -EINVAL; > > - mtk_hdmi_pll_set_hw(hw, PLL_PREDIV, fbkdiv_high, fbkdiv_low, > + if (mtk_hdmi_pll_set_hw(hw, PLL_PREDIV, fbkdiv_high, fbkdiv_low, > PLL_FBKDIV_HS3, posdiv1, posdiv2, txprediv, > - txposdiv, digital_div); > - if (ret) > + txposdiv, digital_div)) > return -EINVAL; > I don't get why we're returning -EINVAL unconditionally in the first place, here. Function mtk_hdmi_pll_set_hw() should return zero or a negative error number: in that case, the previous *intention* was fine, so this should be ret = mtk_hdmi_pll_set_hw(....) if (ret) return ret; return 0; Regards, Angelo
On Fri, 14 Apr 2023 12:31, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> wrote: >Il 13/04/23 14:46, Guillaume Ranquet ha scritto: >> The ret variable in mtk_hdmi_pll_calc() was used unitialized as reported >> by the kernel test robot. >> >> Fix the issue by removing the variable altogether and testing out the >> return value of mtk_hdmi_pll_set_hw() >> >> Fixes: 45810d486bb44 ("phy: mediatek: add support for phy-mtk-hdmi-mt8195") >> Reported-by: kernel test robot <lkp@intel.com> >> Signed-off-by: Guillaume Ranquet <granquet@baylibre.com> >> --- >> drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c | 7 +++---- >> 1 file changed, 3 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c b/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c >> index abfc077fb0a8..e10da6c4147e 100644 >> --- a/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c >> +++ b/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c >> @@ -213,7 +213,7 @@ static int mtk_hdmi_pll_calc(struct mtk_hdmi_phy *hdmi_phy, struct clk_hw *hw, >> u64 tmds_clk, pixel_clk, da_hdmitx21_ref_ck, ns_hdmipll_ck, pcw; >> u8 txpredivs[4] = { 2, 4, 6, 12 }; >> u32 fbkdiv_low; >> - int i, ret; >> + int i; >> >> pixel_clk = rate; >> tmds_clk = pixel_clk; >> @@ -292,10 +292,9 @@ static int mtk_hdmi_pll_calc(struct mtk_hdmi_phy *hdmi_phy, struct clk_hw *hw, >> if (!(digital_div <= 32 && digital_div >= 1)) >> return -EINVAL; >> >> - mtk_hdmi_pll_set_hw(hw, PLL_PREDIV, fbkdiv_high, fbkdiv_low, >> + if (mtk_hdmi_pll_set_hw(hw, PLL_PREDIV, fbkdiv_high, fbkdiv_low, >> PLL_FBKDIV_HS3, posdiv1, posdiv2, txprediv, >> - txposdiv, digital_div); >> - if (ret) >> + txposdiv, digital_div)) >> return -EINVAL; >> > >I don't get why we're returning -EINVAL unconditionally in the first place, here. > >Function mtk_hdmi_pll_set_hw() should return zero or a negative error number: in >that case, the previous *intention* was fine, so this should be > Hi Angelo, I was maybe a bit too quick on fixing this that way. Anyway it doesn't change a thing as mtk_hdmi_pll_set_hw() eitheir returns 0 or -EINVAL. But I agree that the logic is dubious and propagating the return value is the right thing to do. I see that Arnd and Tom posted versions that you might prefer: https://lore.kernel.org/linux-phy/20230414075842.4006164-1-arnd@kernel.org/ https://lore.kernel.org/linux-phy/20230414122253.3171524-1-trix@redhat.com/ Thx, Guillaume. > ret = mtk_hdmi_pll_set_hw(....) > if (ret) > return ret; > > return 0; > > >Regards, >Angelo
diff --git a/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c b/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c index abfc077fb0a8..e10da6c4147e 100644 --- a/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c +++ b/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c @@ -213,7 +213,7 @@ static int mtk_hdmi_pll_calc(struct mtk_hdmi_phy *hdmi_phy, struct clk_hw *hw, u64 tmds_clk, pixel_clk, da_hdmitx21_ref_ck, ns_hdmipll_ck, pcw; u8 txpredivs[4] = { 2, 4, 6, 12 }; u32 fbkdiv_low; - int i, ret; + int i; pixel_clk = rate; tmds_clk = pixel_clk; @@ -292,10 +292,9 @@ static int mtk_hdmi_pll_calc(struct mtk_hdmi_phy *hdmi_phy, struct clk_hw *hw, if (!(digital_div <= 32 && digital_div >= 1)) return -EINVAL; - mtk_hdmi_pll_set_hw(hw, PLL_PREDIV, fbkdiv_high, fbkdiv_low, + if (mtk_hdmi_pll_set_hw(hw, PLL_PREDIV, fbkdiv_high, fbkdiv_low, PLL_FBKDIV_HS3, posdiv1, posdiv2, txprediv, - txposdiv, digital_div); - if (ret) + txposdiv, digital_div)) return -EINVAL; return 0;