From patchwork Tue Mar 26 18:07:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13604826 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B44D2C54E67 for ; Tue, 26 Mar 2024 18:11:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pm5g+rJ/mY9kR6AnrdYmMkJCj1zScTJ/9nUoIHeUvh4=; b=0tLdYehc05eQi0 9K2Z1JwINMHiD+nXBnlvWSRM/usBHf56kUQgKiw6H9Jg6J7GafNvb+Cxxo7UEmHa+6QNSsSXwpojC xOS5GLvBasztjRATnWdh7gtCuogQGRtsO01+ExoBgFPIaWYF31uZc+Dg7qa0sHRy7C89BwUBJVS5F 1Coq9jIM1jr2mXhnnpR6k/Dd1ZRjMin50mqmNP/UZY/6+6qhcP8xESD0rho9HiASigS5F9gFic3t0 jWmS7qupfxBhZf1/gM61cergrk+pe6wVo3iJv0MYeefQZCBlWawn4xeDCPMMnCL7y4Z6Wjw228YcY 9Fyni9rIGSW1Bd/ZCK0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpBGz-00000005sw0-2M1c; Tue, 26 Mar 2024 18:11:45 +0000 Received: from mgamail.intel.com ([192.198.163.12]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpBG0-00000005sP2-0oQI for linux-arm-kernel@lists.infradead.org; Tue, 26 Mar 2024 18:10:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711476644; x=1743012644; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/NCY6D6sJSA8qtx+EX1W99OV2q8Lk5IqUKEVfKBSw0Q=; b=Mq35EfJDNFUqcV78+MC7aBDtoQJzx8hjYjirEuVWbD8uu81JsgACt9x8 8ijXxhqJlYmEuby3haXL93FRX8bqXSqUgKcBze1Mcm5ppg0Kt28qygNx1 VpDolCjHyMAPExc/NTUbSE4+wTnU6zgtgqI+7f0yOzh98MzxEp4LkBJGW OhqhTbJ4Ocx6xnL3f5Fpx6X8NVFnFJEz7HscIRn2LAhgZWQz2sGmzN0I3 aFt71ovgPU61q4KOzILkQPks3WFIwAf3DCmoa02XAYuNwtJqVV79blPaB mfVuwf9dIoQUpv9T8U61KHS/lbRjdh/+0cAVTMj6ZAkD5NZd+Jgj6UoLd A==; X-CSE-ConnectionGUID: gBP2x2IfSQqQUzzu9UvrOA== X-CSE-MsgGUID: dJ/CUks1Tt2JDZYI7r5TkA== X-IronPort-AV: E=McAfee;i="6600,9927,11025"; a="10325691" X-IronPort-AV: E=Sophos;i="6.07,156,1708416000"; d="scan'208";a="10325691" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2024 11:10:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11025"; a="937072939" X-IronPort-AV: E=Sophos;i="6.07,156,1708416000"; d="scan'208";a="937072939" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Mar 2024 11:10:35 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 015F2643; Tue, 26 Mar 2024 20:10:34 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Mark Brown , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Russell King Subject: [PATCH v1 04/10] spi: pxa2xx: Extract pxa2xx_spi_init_ssp() helper Date: Tue, 26 Mar 2024 20:07:54 +0200 Message-ID: <20240326181027.1418989-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240326181027.1418989-1-andriy.shevchenko@linux.intel.com> References: <20240326181027.1418989-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240326_111044_314579_97700557 X-CRM114-Status: GOOD ( 16.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Refactor pxa2xx_spi_init_pdata() by extracting a new pxa2xx_spi_init_ssp() helper which makes code less twisted. It will be easier to continue refactoring for a new coming modification. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 66 +++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 75d208087748..e7072727c25c 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1314,19 +1314,50 @@ static bool pxa2xx_spi_idma_filter(struct dma_chan *chan, void *param) return param == chan->device->dev; } +static int +pxa2xx_spi_init_ssp(struct platform_device *pdev, struct ssp_device *ssp, enum pxa_ssp_type type) +{ + struct device *dev = &pdev->dev; + struct resource *res; + int status; + u64 uid; + + ssp->mmio_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); + if (IS_ERR(ssp->mmio_base)) + return PTR_ERR(ssp->mmio_base); + + ssp->phys_base = res->start; + + ssp->clk = devm_clk_get(dev, NULL); + if (IS_ERR(ssp->clk)) + return PTR_ERR(ssp->clk); + + ssp->irq = platform_get_irq(pdev, 0); + if (ssp->irq < 0) + return ssp->irq; + + ssp->type = type; + ssp->dev = dev; + + status = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &uid); + if (status) + ssp->port_id = -1; + else + ssp->port_id = uid; + + return 0; +} + static struct pxa2xx_spi_controller * pxa2xx_spi_init_pdata(struct platform_device *pdev) { struct pxa2xx_spi_controller *pdata; struct device *dev = &pdev->dev; struct device *parent = dev->parent; - struct ssp_device *ssp; - struct resource *res; enum pxa_ssp_type type = SSP_UNDEFINED; const void *match; bool is_lpss_priv; int status; - u64 uid; is_lpss_priv = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lpss_priv"); @@ -1351,14 +1382,6 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) if (!pdata) return ERR_PTR(-ENOMEM); - ssp = &pdata->ssp; - - ssp->mmio_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); - if (IS_ERR(ssp->mmio_base)) - return ERR_CAST(ssp->mmio_base); - - ssp->phys_base = res->start; - /* Platforms with iDMA 64-bit */ if (is_lpss_priv) { pdata->tx_param = parent; @@ -1366,28 +1389,15 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) pdata->dma_filter = pxa2xx_spi_idma_filter; } - ssp->clk = devm_clk_get(dev, NULL); - if (IS_ERR(ssp->clk)) - return ERR_CAST(ssp->clk); - - ssp->irq = platform_get_irq(pdev, 0); - if (ssp->irq < 0) - return ERR_PTR(ssp->irq); - - ssp->type = type; - ssp->dev = dev; - - status = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &uid); - if (status) - ssp->port_id = -1; - else - ssp->port_id = uid; - pdata->is_target = device_property_read_bool(dev, "spi-slave"); pdata->num_chipselect = 1; pdata->enable_dma = true; pdata->dma_burst_size = 1; + status = pxa2xx_spi_init_ssp(pdev, &pdata->ssp, type); + if (status) + return ERR_PTR(status); + return pdata; }