From patchwork Tue Dec 11 20:07:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 10724605 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 00C1C112E for ; Tue, 11 Dec 2018 20:07:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E57EB2B6F2 for ; Tue, 11 Dec 2018 20:07:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9DF12B6FD; Tue, 11 Dec 2018 20:07: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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 727CB2B6F2 for ; Tue, 11 Dec 2018 20:07:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726243AbeLKUHy (ORCPT ); Tue, 11 Dec 2018 15:07:54 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:33888 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbeLKUHx (ORCPT ); Tue, 11 Dec 2018 15:07:53 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 55E0160376; Tue, 11 Dec 2018 20:07:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1544558873; bh=wjbHoUMDnXc0I4cdbZ1+ReT0BAXh5ub2cdFW85uLuGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MxFDkJKtagd14m43pqoCVEt/wcJvb+yI06fGL7cbrxU3n48LPrHY2W26MTlB7kUxu gZqv5RTB1mE1JHtmBiGTemi/SKaVWtED7ekll5uN63Grn8PrvStrThEy2v3whOV8lc IhClFf4NLdRVb5KEPXr8WpNsudQz/jv7eKUAxAm0= Received: from jcrouse-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id DFDF66053B; Tue, 11 Dec 2018 20:07:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1544558872; bh=wjbHoUMDnXc0I4cdbZ1+ReT0BAXh5ub2cdFW85uLuGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RoAhI0K656q6KzgvsNCeDruPPVvrTAVcXMykEenlLwGdG31q+uQ8iu1IaJjaWCjI9 to6JFW+cPLN6foOyfFfRNf07Fz8X5eAAQUU+nHhI+8wfIMXE9xyftAuYWJz7T/1JT0 CvSjkBKktjK6vUFajXazzwZCFzjgN9kDptJQg6yc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org DFDF66053B Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org From: Jordan Crouse To: linux-arm-msm@vger.kernel.org Cc: andy.gross@linaro.org, david.brown@linaro.org, linux-soc@vger.kernel.org, dianders@chromium.org, ckadabi@codeaurora.org, hoegsberg@chromium.org Subject: [PATCH v2 2/2] qcom: soc: llcc-slice: Consolidate some code Date: Tue, 11 Dec 2018 13:07:46 -0700 Message-Id: <20181211200746.9557-3-jcrouse@codeaurora.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181211200746.9557-1-jcrouse@codeaurora.org> References: <20181211200746.9557-1-jcrouse@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make the code a little bit clearer (and use less gotos) by consolidating some of the initialization. Signed-off-by: Jordan Crouse Reviewed-by: Douglas Anderson --- drivers/soc/qcom/llcc-slice.c | 42 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/drivers/soc/qcom/llcc-slice.c b/drivers/soc/qcom/llcc-slice.c index 8390bc006a31..83a263926a25 100644 --- a/drivers/soc/qcom/llcc-slice.c +++ b/drivers/soc/qcom/llcc-slice.c @@ -309,13 +309,28 @@ int qcom_llcc_remove(struct platform_device *pdev) } EXPORT_SYMBOL_GPL(qcom_llcc_remove); +static struct regmap *qcom_llcc_init_mmio(struct platform_device *pdev, + const char *name) +{ + struct resource *res; + void __iomem *base; + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); + if (!res) + return ERR_PTR(-ENODEV); + + base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(base)) + return ERR_CAST(base); + + return devm_regmap_init_mmio(&pdev->dev, base, &llcc_regmap_config); +} + int qcom_llcc_probe(struct platform_device *pdev, const struct llcc_slice_config *llcc_cfg, u32 sz) { u32 num_banks; struct device *dev = &pdev->dev; - struct resource *llcc_banks_res, *llcc_bcast_res; - void __iomem *llcc_banks_base, *llcc_bcast_base; int ret, i; struct platform_device *llcc_edac; @@ -325,31 +340,14 @@ int qcom_llcc_probe(struct platform_device *pdev, goto err; } - llcc_banks_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, - "llcc_base"); - llcc_banks_base = devm_ioremap_resource(&pdev->dev, llcc_banks_res); - if (IS_ERR(llcc_banks_base)) { - ret = PTR_ERR(llcc_banks_base); - goto err; - } - - drv_data->regmap = devm_regmap_init_mmio(dev, llcc_banks_base, - &llcc_regmap_config); + drv_data->regmap = qcom_llcc_init_mmio(pdev, "llcc_base"); if (IS_ERR(drv_data->regmap)) { ret = PTR_ERR(drv_data->regmap); goto err; } - llcc_bcast_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, - "llcc_broadcast_base"); - llcc_bcast_base = devm_ioremap_resource(&pdev->dev, llcc_bcast_res); - if (IS_ERR(llcc_bcast_base)) { - ret = PTR_ERR(llcc_bcast_base); - goto err; - } - - drv_data->bcast_regmap = devm_regmap_init_mmio(dev, llcc_bcast_base, - &llcc_regmap_config); + drv_data->bcast_regmap = + qcom_llcc_init_mmio(pdev, "llcc_broadcast_base"); if (IS_ERR(drv_data->bcast_regmap)) { ret = PTR_ERR(drv_data->bcast_regmap); goto err;