From patchwork Tue May 21 06:09:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 10952921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 751DC112C for ; Tue, 21 May 2019 06:15:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 659E120069 for ; Tue, 21 May 2019 06:15:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59DA628446; Tue, 21 May 2019 06:15:52 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EC0F28445 for ; Tue, 21 May 2019 06:15:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727925AbfEUGPu (ORCPT ); Tue, 21 May 2019 02:15:50 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40303 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725835AbfEUGPt (ORCPT ); Tue, 21 May 2019 02:15:49 -0400 Received: by mail-pg1-f195.google.com with SMTP id d30so8017131pgm.7 for ; Mon, 20 May 2019 23:15:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7zIoh9PTrB07jZj7iAACd9ksENTR45V1gQMx0juES3c=; b=SwGzEp384/HvkIrTU8NYuqCksWK+ZeUMUQuZiITmijbwFe7qqqKdN4VhfTLQeSOeyL bW9hlEc85ItEntQa+5uXTpXbI/BnrgelNJnjl1Arx+Hqy6/FRJFiWGhV3T9x+eGYCzB2 d/DXkLuGjXOgJPa8f2oQ+SkVaB60cEycHgyWojYLccCBhPa+F1pfeq1TrBXcZZ1ezQZW 7IYZzNbDzCShsNQYoKfqIbawvrvhW1bpeipWOHlQ+xtaiOwuWFm4+OFVgKfZ37Z7i6Nb y0JEXkduPLgCT1pj5RIkDjAVBGjSo5N+mXKjFxk7PJ15G0tft56fMjMmj4C9wkgbByMG cQTA== 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=7zIoh9PTrB07jZj7iAACd9ksENTR45V1gQMx0juES3c=; b=SqMti/tc+NvgTFKkCyYxKofr8MtydSH/JmLCovlEDJZRe3w63Gj4YAkPudCa+zuhMm +uw+bosH9cw84OAzqwvfpSsZvgaz10+4BqOW9XWkU1jMmhZDIAU1Uh9XisUUZZZzU1xA g74m17DtIAXt1QGfGLRz5jPMVEC6nNsHhdcdELZBGKHoT0W59TwqXVMcO9FiNmHfgV0J TAz9Wc4KdRA2J4YZfKl/xLmwX5DCvGS/aKuNrC7Y4ltnGE/EX2lcLGR+vRTDIhsuq41M ARoMJjqVJ7BTdearL66gv/be5I3oshtwhatbXQLSPgD21QXk38Gknbl/ZubcYJPr+s8/ is/Q== X-Gm-Message-State: APjAAAUDZxFK//2ll+tOmTmj0ADrB7G6ygqgN507ZIpu0r36prq9YBPP aI+15Ea4MZfm/tjzYQtuD2V/OA== X-Google-Smtp-Source: APXvYqxa0mLPXch4vjgP+lssTETSPwC4ZzEuv0fXXeIOOPMZ5RMwQDzBbs15Sr/D7bTeyHkMfjomsg== X-Received: by 2002:a62:1a0f:: with SMTP id a15mr65093150pfa.111.1558419349191; Mon, 20 May 2019 23:15:49 -0700 (PDT) Received: from ubt.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id k9sm23064259pfa.180.2019.05.20.23.15.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 May 2019 23:15:48 -0700 (PDT) From: Chunyan Zhang To: Stephen Boyd Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Orson Zhai , Chunyan Zhang , Baolin Wang Subject: [PATCH 1/2] clk: sprd: Switch from of_iomap() to devm_ioremap_resource() Date: Tue, 21 May 2019 14:09:51 +0800 Message-Id: <20190521060952.2949-2-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190521060952.2949-1-zhang.chunyan@linaro.org> References: <20190521060952.2949-1-zhang.chunyan@linaro.org> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP devm_ioremap_resources() automatically requests resources and devm_ wrappers do better error handling and unmapping of the I/O region when needed, that would make drivers more clean and simple. Signed-off-by: Chunyan Zhang --- drivers/clk/sprd/common.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/clk/sprd/common.c b/drivers/clk/sprd/common.c index e038b0447206..a5bdca1de5d0 100644 --- a/drivers/clk/sprd/common.c +++ b/drivers/clk/sprd/common.c @@ -42,6 +42,7 @@ int sprd_clk_regmap_init(struct platform_device *pdev, void __iomem *base; struct device_node *node = pdev->dev.of_node; struct regmap *regmap; + struct resource *res; if (of_find_property(node, "sprd,syscon", NULL)) { regmap = syscon_regmap_lookup_by_phandle(node, "sprd,syscon"); @@ -50,10 +51,14 @@ int sprd_clk_regmap_init(struct platform_device *pdev, return PTR_ERR(regmap); } } else { - base = of_iomap(node, 0); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + regmap = devm_regmap_init_mmio(&pdev->dev, base, &sprdclk_regmap_config); - if (IS_ERR_OR_NULL(regmap)) { + if (IS_ERR(regmap)) { pr_err("failed to init regmap\n"); return PTR_ERR(regmap); } From patchwork Tue May 21 06:09:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 10952923 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BCC4112C for ; Tue, 21 May 2019 06:15:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CD1620069 for ; Tue, 21 May 2019 06:15:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 312CA28446; Tue, 21 May 2019 06:15:54 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB12320069 for ; Tue, 21 May 2019 06:15:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727946AbfEUGPx (ORCPT ); Tue, 21 May 2019 02:15:53 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33222 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727867AbfEUGPx (ORCPT ); Tue, 21 May 2019 02:15:53 -0400 Received: by mail-pl1-f194.google.com with SMTP id y3so7930176plp.0 for ; Mon, 20 May 2019 23:15:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4R0Z1avkl5DcwArAEdYF5RKsOqx23+ElfNwQfhlhU8U=; b=rWBEaPbOv0Ze4QP+zKqhgDJLjfQzgBZRlveZ5KKv6jzAPxoKfCAc9mSKLdMx/9jL3v nFmY67X/QCW8SlSFYYtgtr2TOtMrAz6nEGWK5x5dVRjLFh50dq7JDUw3s7bj6SzJ/E8I Himrhy2bu8WjqyccmLGj1r/JBcUBmkSVcN5j03XkSzrLQHubwWAiU/iwEml7Aezz4Rfq iZrUP6ztMtgo70T0vL607ynlVJImepQp5080ijDfWbjzF7kV/qvfOP6gDITJnzPftl63 g1SpLgLn40kDNPNGJq5iNOEPcyabqIhbNJdrg+RJCt1/gxr4Zr+zuxsJQoz/T8vnXL2R LJ2Q== 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=4R0Z1avkl5DcwArAEdYF5RKsOqx23+ElfNwQfhlhU8U=; b=pcxkNfWR+4m3eV4EneH+TAfAAJsBu7hPQeSvPl93HKkXlkfC2FVWqx7cY1OIpipQk9 2l8YCmod6bZo9YdcUBYHpDB1oemKPxoSDCKsFerWfmPAd3at0+ke9mBZKWPVfF244xwM bm0WWNjm7m1yBnIOtgM2oKHfimNeBcQOiF+5QagvyCW3W1W+4HSGmBBYP+bU5HFQNwA8 TA4PClDGBaut7pLP5wHv1Ugq3xxxFP79g8GQR6rkGKDnQs50YuV8elcGZKpedr8dfO/1 /X8RDZCcCkJGsPdR/2O7hQ0WdH/KuhPsaEIKyr9JGujWuz0PwovsU96vZF/HwJRn1Sr6 +KaA== X-Gm-Message-State: APjAAAVKjv2lYpindGxC+4ZZYj91DJQBd4MUyIuSADdrrQrz1nq8ALFQ BjS+jeIDjxKtfDxNOGbf+8vp6w== X-Google-Smtp-Source: APXvYqwBHHtyco4N8WF7epFmyuDSFE9c1OUeIL1j1jNgX30UzSph1JCCf5VP/WOjybTewBj76jSwkA== X-Received: by 2002:a17:902:1cb:: with SMTP id b69mr54576811plb.158.1558419352754; Mon, 20 May 2019 23:15:52 -0700 (PDT) Received: from ubt.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id k9sm23064259pfa.180.2019.05.20.23.15.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 May 2019 23:15:52 -0700 (PDT) From: Chunyan Zhang To: Stephen Boyd Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Orson Zhai , Chunyan Zhang , Baolin Wang Subject: [PATCH 2/2] clk: sprd: Add check for return value of sprd_clk_regmap_init() Date: Tue, 21 May 2019 14:09:52 +0800 Message-Id: <20190521060952.2949-3-zhang.chunyan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190521060952.2949-1-zhang.chunyan@linaro.org> References: <20190521060952.2949-1-zhang.chunyan@linaro.org> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP sprd_clk_regmap_init() doesn't always return success, adding check for its return value should make the code more strong. Signed-off-by: Chunyan Zhang Reviewed-by: Baolin Wang --- drivers/clk/sprd/sc9860-clk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/sprd/sc9860-clk.c b/drivers/clk/sprd/sc9860-clk.c index 9980ab55271b..1ed45b4f2fe8 100644 --- a/drivers/clk/sprd/sc9860-clk.c +++ b/drivers/clk/sprd/sc9860-clk.c @@ -2031,7 +2031,9 @@ static int sc9860_clk_probe(struct platform_device *pdev) } desc = match->data; - sprd_clk_regmap_init(pdev, desc); + ret = sprd_clk_regmap_init(pdev, desc); + if (ret) + return ret; return sprd_clk_probe(&pdev->dev, desc->hw_clks); }