From patchwork Thu Oct 17 19:02:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabien Parent X-Patchwork-Id: 1178951 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="FAVaLxWw"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46vJSz4Cv7z9sP3 for ; Fri, 18 Oct 2019 06:02:41 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 9FA87C21DEC; Thu, 17 Oct 2019 19:02:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id F16B0C21C27; Thu, 17 Oct 2019 19:02:31 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 157C7C21C27; Thu, 17 Oct 2019 19:02:30 +0000 (UTC) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by lists.denx.de (Postfix) with ESMTPS id B312FC21BE5 for ; Thu, 17 Oct 2019 19:02:29 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id b24so3648746wmj.5 for ; Thu, 17 Oct 2019 12:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UXgTjGzyHOFvpsoFfk97nhIH2beAV7nCbpYR2IWhF4I=; b=FAVaLxWwcO5dXiFoCjRnnOQXvwXh7ZQ75C+xp4wOaYeEi1eY+y/p/JWDpjx1APnFTm 8KZgcjmqrgB4yPr+f0RaXqO+6ZntX8csHMKOs9W+cSx+uc7Wr2rjlCU/oYKjpEI0Iudv QhGwo2PgStw7KuGxBI6IT7512lXoI38oo/bW52iHMCfalQVFKmyarPA1gpAkLqepZi/i z3Jbf5YsDo9F9QZ0WnYXHk3n6VIsU45t4XEShPXxl5bfI+xhCcRHE8+tUUN71Ctba5AQ 6t11oXDzbY8iVp4aD3DNd/dNW4IhZp9CD+5xji6MXxAepK1Fgiacs8UuOHor8SLV89T6 G9eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UXgTjGzyHOFvpsoFfk97nhIH2beAV7nCbpYR2IWhF4I=; b=XaawReUhBmhNNswFs7VJ53COryq1vBs3qpSb7icTVIiQT6XlXiQUYBHpSJoacxVFiO DQBBwAox/n1GqunKgEB8+O85MZZkhzXxKQhFo3o6Qo8dHz+DBrDj8d0PN2DLTn9051Hn N8hQ+V77fRm33nIZzDAnYj2vM0twFd61Q1Q4z7R6OJz/7SHj43AEu9A/4PYvW8kILcFd PaaImbbbsx8WBF9fbfL9VnWZ4qOdW2EdFGebKwN8uBE5lnlq0z75a/zFMSkXRGbJpJPz 6t1qVVpoIvvnJIW45qHqkaTAhhWnQ0DYxip+sAHp5MZvIygaXqaSlG3i5x0jcetxF9Nz iuuQ== X-Gm-Message-State: APjAAAUbmmOqU0PAv21ILO2gquCVA4pe4IF+kV2MY7VIUvfrc0udHfsA lmDInieW8YxAuHihZqV3rV8kD42ZPX4= X-Google-Smtp-Source: APXvYqwtrskqQ76K3knnqxRPWq4xuxsjN5mI0cIlJoBIf5aZ4aMzE1sL5c0MVxteDbPIyrXpxn5Wgw== X-Received: by 2002:a7b:cb54:: with SMTP id v20mr3928951wmj.119.1571338948807; Thu, 17 Oct 2019 12:02:28 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:32c:e530:1f62:944f:4c42:96a0]) by smtp.gmail.com with ESMTPSA id z4sm2941105wrh.93.2019.10.17.12.02.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 12:02:27 -0700 (PDT) From: Fabien Parent To: u-boot@lists.denx.de Date: Thu, 17 Oct 2019 21:02:05 +0200 Message-Id: <20191017190205.20612-1-fparent@baylibre.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Cc: ryder.lee@mediatek.com, GSS_MTK_Uboot_upstream@mediatek.com Subject: [U-Boot] [PATCH] clk: mediatek: use unsigned type for returning the clk rate X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" mtk_clk_find_parent_rate is calling clk_get_rate to know the rate of a parent clock. clk_get_rate returns a ulong, while mtk_clk_find_parent_rate returns an int. This implicit cast creates an issue for clock rates big enough to need the full 32 bits to store its data. When that happen the clk rate will become incorrect because of the implicit cast between ulong -> int -> ulong. This commit change the return type of mtk_clk_find_parent_rate to ulong. Signed-off-by: Fabien Parent --- drivers/clk/mediatek/clk-mtk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 6c6b500d9b71..c74766dd22c7 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -39,8 +39,8 @@ * this function is recursively called to find the parent to calculate * the accurate frequency. */ -static int mtk_clk_find_parent_rate(struct clk *clk, int id, - const struct driver *drv) +static ulong mtk_clk_find_parent_rate(struct clk *clk, int id, + const struct driver *drv) { struct clk parent = { .id = id, };