From patchwork Wed Mar 8 02:27:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Zhong X-Patchwork-Id: 9610205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 05FEA6016C for ; Wed, 8 Mar 2017 02:29:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E97552855B for ; Wed, 8 Mar 2017 02:29:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCC4128574; Wed, 8 Mar 2017 02:29:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9F76C2855B for ; Wed, 8 Mar 2017 02:29:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Pq1AS7KPEWp0X7waduDAN+GWj2fcWhCRDWQoQOwrADg=; b=CpV+47iRqipQzuxu/+wYCVrJ+m pPeVPyD2VSdtsoYJ/PqY4M0ooOvGcAsQid4t4P4huGQ4ekPiV66Jo0wzK/3VysA8mljtBMmW/ATSP Y69GXtteMB3wbMVLDjPLi5avP4HIhtkrbd+aevfWU/xUkLnviAo2iPmVicKzupaAx+lQlw10Fb7Oi U4h8cDwjqbsv/+KH3OC0mhcgrLdg32T7xLgWXKnGfuKUaiaeu8PWaFBDzY/wIvaIweBBuAB9zFUL4 CFpFHRXfCENEkZtYX3ey7Y3cHVr1f5HkWNUltiOQutrt7o7BTvuOFVe3czbgTC9Kv/TSiHKdQbuu0 HbVa1gNA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1clRLa-00033m-3O; Wed, 08 Mar 2017 02:29:02 +0000 Received: from mail-pf0-f196.google.com ([209.85.192.196]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1clRL4-0002ln-6F; Wed, 08 Mar 2017 02:28:31 +0000 Received: by mail-pf0-f196.google.com with SMTP id o126so2001196pfb.1; Tue, 07 Mar 2017 18:28:09 -0800 (PST) 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:in-reply-to :references; bh=v+JupE/TSUgtVeaDDp1LGqNIVAm50gHUeCamlH7QbLI=; b=tDw9nE2bHuFfVBHIixve/sgzKMjBJ4l3w0xOTgyn2ovxWgn+V17wUYgH6HYrOnRwSb MeQPI8T8lwm3g3BYNsCxWqew8FHQFCat0Z1ptIWaU0D+9DmnMcsWpW2KfXL0SDZXhPQK 4Y81FDUNr7qOuN+Io5yokITFLrwHJ2nvoi63RTUFH5ksot/1lEEyxhx6n8cObSqNXgc5 YXfQ1daqZBSoXorGI7iXl+GgnquN+VZkxqyJ1EN4Az8ymm+qbzHB4PNq74gM6vNftdt2 yyzh7bLzneSUc9CFt4NMKIUEtlBGcF7GcoNoxmStbp7rwxB8dWPDQHQaWcucindf7VM5 znvA== X-Gm-Message-State: AMke39nOYvWr5p/qz44dM009Zk32INYf4/8X6Zzoj/9Wpaik7e5pT2zVHnxOjZII/dSGoA== X-Received: by 10.99.109.138 with SMTP id i132mr4020707pgc.11.1488940088986; Tue, 07 Mar 2017 18:28:08 -0800 (PST) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id a16sm2142194pgd.62.2017.03.07.18.28.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Mar 2017 18:28:08 -0800 (PST) From: Chris Zhong To: linux-rockchip@lists.infradead.org, seanpaul@chromium.org, mark.yao@rock-chips.com, heiko@sntech.de, dianders@chromium.org Subject: [PATCH 1/3] drm/rockchip: cdn-dp: return error code when clk_get_rate failed Date: Wed, 8 Mar 2017 10:27:55 +0800 Message-Id: <1488940077-22297-2-git-send-email-zyw@rock-chips.com> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1488940077-22297-1-git-send-email-zyw@rock-chips.com> References: <1488940077-22297-1-git-send-email-zyw@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170307_182830_258861_06C68537 X-CRM114-Status: GOOD ( 11.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Zhong , David Airlie , linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The clk_get_rate return 0 if something goes wrong, so it can never be less then zero, the ret should be set a error code, otherwise the cdn_dp_clk_enable will return 0 when it failed at clk_get_rate. In addition, clk_get_rate() returns an "unsigned long", so use "unsigned long" instead of "u32" is better. Signed-off-by: Chris Zhong --- drivers/gpu/drm/rockchip/cdn-dp-core.c | 5 +++-- drivers/gpu/drm/rockchip/cdn-dp-reg.c | 2 +- drivers/gpu/drm/rockchip/cdn-dp-reg.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c index fd79a70..9edb8dc 100644 --- a/drivers/gpu/drm/rockchip/cdn-dp-core.c +++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c @@ -94,7 +94,7 @@ static int cdn_dp_grf_write(struct cdn_dp_device *dp, static int cdn_dp_clk_enable(struct cdn_dp_device *dp) { int ret; - u32 rate; + unsigned long rate; ret = clk_prepare_enable(dp->pclk); if (ret < 0) { @@ -123,7 +123,8 @@ static int cdn_dp_clk_enable(struct cdn_dp_device *dp) rate = clk_get_rate(dp->core_clk); if (!rate) { - DRM_DEV_ERROR(dp->dev, "get clk rate failed: %d\n", rate); + DRM_DEV_ERROR(dp->dev, "get clk rate failed\n"); + ret = -EINVAL; goto err_set_rate; } diff --git a/drivers/gpu/drm/rockchip/cdn-dp-reg.c b/drivers/gpu/drm/rockchip/cdn-dp-reg.c index 319dbba..963d8ab 100644 --- a/drivers/gpu/drm/rockchip/cdn-dp-reg.c +++ b/drivers/gpu/drm/rockchip/cdn-dp-reg.c @@ -29,7 +29,7 @@ #define LINK_TRAINING_RETRY_MS 20 #define LINK_TRAINING_TIMEOUT_MS 500 -void cdn_dp_set_fw_clk(struct cdn_dp_device *dp, u32 clk) +void cdn_dp_set_fw_clk(struct cdn_dp_device *dp, unsigned long clk) { writel(clk / 1000000, dp->regs + SW_CLK_H); } diff --git a/drivers/gpu/drm/rockchip/cdn-dp-reg.h b/drivers/gpu/drm/rockchip/cdn-dp-reg.h index b5f2153..3507be3 100644 --- a/drivers/gpu/drm/rockchip/cdn-dp-reg.h +++ b/drivers/gpu/drm/rockchip/cdn-dp-reg.h @@ -462,7 +462,7 @@ enum vic_bt_type { void cdn_dp_clock_reset(struct cdn_dp_device *dp); -void cdn_dp_set_fw_clk(struct cdn_dp_device *dp, u32 clk); +void cdn_dp_set_fw_clk(struct cdn_dp_device *dp, unsigned long clk); int cdn_dp_load_firmware(struct cdn_dp_device *dp, const u32 *i_mem, u32 i_size, const u32 *d_mem, u32 d_size); int cdn_dp_set_firmware_active(struct cdn_dp_device *dp, bool enable);