From patchwork Thu May 30 15:09:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680531 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 20C12C27C43 for ; Thu, 30 May 2024 15:12:00 +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=Hl58+FYIWUt/Mmk7WaTl6ZhaxnrAZYiZWuNljSMN654=; b=ib+PCbnpSKkPWe 319BT6bFxFaZfCPmA/hl89mzCeMTfEawDRW3/dsmnS4qQb/0W/Ixs6xDAz1bvyW2zodCrlYlWiTLg 9iBVO4XGZ2NAGK5tco548YnpEQhI2R6rvRlUt+Cto9Q9PoyoWCMEaT4hLDYQdmnZf4ybywnuMRl/f gbsKeRoF3UFKGaBKh5VkK97Iunhd9p4x9pvBMyivPO/ScQvYTNQfn9ifysbnWFLnBz/YF7A/xF+kn PTTSNraThY7s36uEvlW9/jGDSitHLt3D+FrAmyBBKvw25IbXkzqMgjMkRqmav1p98ZxdPBB/ZzY0x rOrdD5qWtA/LUuuQk77A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRT-00000007exY-0tOr; Thu, 30 May 2024 15:11:47 +0000 Received: from mgamail.intel.com ([198.175.65.10]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChR8-00000007enA-1lSQ for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2024 15:11:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081886; x=1748617886; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k3Jy0JpJWn+p7UbeUn2JOtEhZjdt6wmsCwt1uObyvpA=; b=EBwD7GQT6N4O88Obviog+wL4CK/mNC9w9T6b/IFtoL12bAJtH394eWwi ZZmvvW5IasK1bPKyPYSim02KhpoToNSyB7y0NgnyIK26tieC4PM8ngxbW U6ieuPRvG9NAaivuuwSBPanqcRxBjjV4mhKk5N/53WYSW7k8ayouxvYMT r2/UX4rgKFC3JPZUPKSL46lDA8huG11oI9tqPW35bbMxSeEhdohFQ31vR Tm/iCJ+FlwYvKkzttUFkhsqVJHPkBs28Q7eLdmGbVQtX8uAF2fmmRVbtl Cf3dsrLPucIA5oTz5tHx5x9vOuAEps0QjxxzH6LJUVj5Xhrb7dAc3xd6R g==; X-CSE-ConnectionGUID: yHpp3c7RRf6X/OsjnhMDQg== X-CSE-MsgGUID: unry9+6EQ2ahrn+o/9ynLA== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31067915" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31067915" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:22 -0700 X-CSE-ConnectionGUID: ygWNtsUCSgCvlGSapsJ15A== X-CSE-MsgGUID: PLdcGkwCRzas9WXXnyuVnQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="73329420" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 30 May 2024 08:11:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2268B184; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 01/11] spi: pxa2xx: Wrap pxa_ssp_request() to be device managed resource Date: Thu, 30 May 2024 18:09:57 +0300 Message-ID: <20240530151117.1130792-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-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-20240530_081126_527828_1FB0BACA X-CRM114-Status: GOOD ( 17.32 ) 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 In the error path or remove path the reference counter in PXA SSP driver may be dropped before the other resources, that were allocated after bumbing the reference counter. This breaks reversed order of freeing and might have an undesired side effects. Prevent this from happening by wrapping pxa_ssp_request() to be device managed resource. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 50 +++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index efe76d0c21bb..820a3702447a 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1304,6 +1304,27 @@ pxa2xx_spi_init_ssp(struct platform_device *pdev, struct ssp_device *ssp, enum p return 0; } +static void pxa2xx_spi_ssp_release(void *ssp) +{ + pxa_ssp_free(ssp); +} + +static struct ssp_device *pxa2xx_spi_ssp_request(struct platform_device *pdev) +{ + struct ssp_device *ssp; + int status; + + ssp = pxa_ssp_request(pdev->id, pdev->name); + if (!ssp) + return ssp; + + status = devm_add_action_or_reset(&pdev->dev, pxa2xx_spi_ssp_release, ssp); + if (status) + return ERR_PTR(status); + + return ssp; +} + static struct pxa2xx_spi_controller * pxa2xx_spi_init_pdata(struct platform_device *pdev) { @@ -1331,11 +1352,11 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) type = (enum pxa_ssp_type)value; } else { - ssp = pxa_ssp_request(pdev->id, pdev->name); - if (ssp) { + ssp = pxa2xx_spi_ssp_request(pdev); + if (IS_ERR(ssp)) + return ERR_CAST(ssp); + if (ssp) type = ssp->type; - pxa_ssp_free(ssp); - } } /* Validate the SSP type correctness */ @@ -1420,7 +1441,9 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) } dev_dbg(dev, "DMA burst size set to %u\n", platform_info->dma_burst_size); - ssp = pxa_ssp_request(pdev->id, pdev->name); + ssp = pxa2xx_spi_ssp_request(pdev); + if (IS_ERR(ssp)) + return PTR_ERR(ssp); if (!ssp) ssp = &platform_info->ssp; @@ -1431,11 +1454,9 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) controller = devm_spi_alloc_target(dev, sizeof(*drv_data)); else controller = devm_spi_alloc_host(dev, sizeof(*drv_data)); + if (!controller) + return dev_err_probe(dev, -ENOMEM, "cannot alloc spi_controller\n"); - if (!controller) { - status = dev_err_probe(dev, -ENOMEM, "cannot alloc spi_controller\n"); - goto out_error_controller_alloc; - } drv_data = spi_controller_get_devdata(controller); drv_data->controller = controller; drv_data->controller_info = platform_info; @@ -1486,10 +1507,8 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) status = request_irq(ssp->irq, ssp_int, IRQF_SHARED, dev_name(dev), drv_data); - if (status < 0) { - dev_err_probe(dev, status, "cannot get IRQ %d\n", ssp->irq); - goto out_error_controller_alloc; - } + if (status < 0) + return dev_err_probe(dev, status, "cannot get IRQ %d\n", ssp->irq); /* Setup DMA if requested */ if (platform_info->enable_dma) { @@ -1619,8 +1638,6 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) pxa2xx_spi_dma_release(drv_data); free_irq(ssp->irq, drv_data); -out_error_controller_alloc: - pxa_ssp_free(ssp); return status; } @@ -1646,9 +1663,6 @@ static void pxa2xx_spi_remove(struct platform_device *pdev) /* Release IRQ */ free_irq(ssp->irq, drv_data); - - /* Release SSP */ - pxa_ssp_free(ssp); } static int pxa2xx_spi_suspend(struct device *dev) From patchwork Thu May 30 15:09:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680534 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 8698AC25B74 for ; Thu, 30 May 2024 15:12:04 +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=f7+5Srr8D47nRh1nELrA3VB1fjHJuQGqpkG85PngIgM=; b=VBswvmVKEZWKMX NQKim/jJvrJOGlPZBmeTmeZROHSrfpg4/Q3VHMaLLhc1Ej1S3fRhM/CVS88o3kI4caWj9PzTvoC3+ cJuSX91xY97jQ98HmLlokL80bsKqW3raiQ8DlgzCT/uPXxCzabDyjsHIGCGLeC1zwbWRDrJjvPSIY Aa//JTXXQkSkXzgtK08cnHfjLM4ETbof/V0Vs5YKzKgwOzOB0oV47Q9z4xbJtpIhVbfNFIwgtoZ6X YVsFb8kikeH2dqEjlnRMBDR4lbEDWJTRf3rkZVVf6hA22c0SP+n2mjOi4ViKdYobmZAWXUuFZaooi kgmU+tyBf3ydEUIJOGww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRW-00000007f0u-29kw; Thu, 30 May 2024 15:11:50 +0000 Received: from mgamail.intel.com ([198.175.65.10]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRB-00000007emk-0dUQ for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2024 15:11:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081889; x=1748617889; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xuQ6DZkTEDRxFoGQhloOJPIufIaUVMudZOmQbEL7V4Q=; b=QKtfBXqi8Gd5zl+ONzw/eUZoRpm7dDc4NKrUfYHXYREVUiRv5DomPw2M 8rrS38QCa4vOz0KF+pXyygf1uG1cV/iU0fT3TPzcytmRcahZy1UreLOIF 6gUiflCdxtoRBaXuy6yHHX5yMw6IyJI44gwSgYBfFmm3JmEmpi3FBkfwD X3TBexnzhyQfYbeUoQGlnESsE8Jzry0qxtqI5rd6DpnlTE7QnKy1WYa21 M0BCQFda4QPkSNxupslwHKhKbsc0vtDYGhiq96C71ScQRRfrYD3tcvfOU Qmpimy+8mH08AUI7TSrS1335bEtbzBpLLPWcN7bQsOoowWK7jDAl3pT+L w==; X-CSE-ConnectionGUID: CZtTQ1h8Si6bnxK+kUXxdg== X-CSE-MsgGUID: +jt0x/nuTh2CngpqTufzqQ== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31067928" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31067928" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:22 -0700 X-CSE-ConnectionGUID: RHkbdXUlRvKwVAoxgpxB+g== X-CSE-MsgGUID: wsKMsGyIQ363d/2wS2JSeA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="73329421" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 30 May 2024 08:11:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2C1252DC; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 02/11] spi: pxa2xx: Reorganize the SSP type retrieval Date: Thu, 30 May 2024 18:09:58 +0300 Message-ID: <20240530151117.1130792-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-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-20240530_081129_369476_10119155 X-CRM114-Status: GOOD ( 15.04 ) 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 The old Intel platforms, such as Intel Braswell, also provide the property of SSP type. Reorganize the pxa2xx_spi_init_pdata() to take that into account. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 820a3702447a..f4dc113768cd 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1331,19 +1331,21 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) struct pxa2xx_spi_controller *pdata; struct device *dev = &pdev->dev; struct device *parent = dev->parent; + const void *match = device_get_match_data(dev); enum pxa_ssp_type type = SSP_UNDEFINED; - struct ssp_device *ssp = NULL; - const void *match; + struct ssp_device *ssp; bool is_lpss_priv; u32 num_cs = 1; int status; - is_lpss_priv = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lpss_priv"); - - match = device_get_match_data(dev); - if (match) - type = (uintptr_t)match; - else if (is_lpss_priv) { + ssp = pxa2xx_spi_ssp_request(pdev); + if (IS_ERR(ssp)) + return ERR_CAST(ssp); + if (ssp) { + type = ssp->type; + } else if (match) { + type = (enum pxa_ssp_type)(uintptr_t)match; + } else { u32 value; status = device_property_read_u32(dev, "intel,spi-pxa2xx-type", &value); @@ -1351,12 +1353,6 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) return ERR_PTR(status); type = (enum pxa_ssp_type)value; - } else { - ssp = pxa2xx_spi_ssp_request(pdev); - if (IS_ERR(ssp)) - return ERR_CAST(ssp); - if (ssp) - type = ssp->type; } /* Validate the SSP type correctness */ @@ -1368,6 +1364,7 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) return ERR_PTR(-ENOMEM); /* Platforms with iDMA 64-bit */ + is_lpss_priv = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lpss_priv"); if (is_lpss_priv) { pdata->tx_param = parent; pdata->rx_param = parent; From patchwork Thu May 30 15:09:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680528 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 39F6BC25B74 for ; Thu, 30 May 2024 15:11:47 +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=Cy1UwMaTmuxk1pJIjtF6bTeh9cZgIPVw8YJkiU8t9oo=; b=ws826y9U3msn+Y 20/Z9gVXTrIxYLxXF4IyUT8JHqspKR+YXGKyUAuZC2vu1CUTNZhIP+RE3D4GOcx0vKMrlSJBJTFrg P5UbqHYtWg9JahaiIisKiHObnUyBmIU+h3Fh2yEinXuF9drwUdyyrCko+EJV6nffFlJK5FISaP921 PcEx55iICyH9TJvS7x2DiIXeRgT8bawxgtbSdKF+ONAD9vrvT5n3MviJG/q0+Y0A5hSWunOSz5krA FhjhNiV8u1yu3H5eZhzWigxrm2LRmCqu14JbG95u4i2hotbx1nkpx3fVjtOBF3xxcMYJoK3zxkDLb Wbv1WB6oEDjHcbhPYQuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRD-00000007erT-1joN; Thu, 30 May 2024 15:11:31 +0000 Received: from mgamail.intel.com ([192.198.163.8]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChR8-00000007emi-1CzY for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2024 15:11:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081886; x=1748617886; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TQxj52QzB21T4oND+oGj5zj9iueR9JjcCvK8NiCC4XM=; b=AjtadZFvoN1KpSwr6dm4RhQ0i8roaunzCUpIUVVZ4AWUqkca4SJXDMYY unvqWjqBaNA+QEexeiaOkZoqiTxmee25T1SpeXp+jygcUCtQIceJhgGvD CE6vRivKkJKKl7p+C8o8VYFpQYXp8ULJapCQUAQPhGjAk8+JSHG4I1r3w gDuuMSvkJ0Q7u/Fa60lPoYFDWyzUev0a6afIxwtzAkkYP2f/4W9tmtkcv 8wc+p1uiCfuZoSHl4uR6nBnXCg1Txk34Y/ExnsqN3RthyVQnfHx2lLcGR LhlzmR0POZp9d1ibbaGWOwnJdkZ2TFn4WsTcsZgPzv4NZCoO3+BcCNhRq w==; X-CSE-ConnectionGUID: omAOhos4Tg2l4WdR55CdYw== X-CSE-MsgGUID: 3lC+rnxXREituMjuOz8kpQ== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31093030" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31093030" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:22 -0700 X-CSE-ConnectionGUID: /FZZb/pJSWy8TGVnqxXSMA== X-CSE-MsgGUID: XT/+hSA9QyKUq3odAWBusg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="40288501" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa005.fm.intel.com with ESMTP; 30 May 2024 08:11:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3D9C44DE; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 03/11] spi: pxa2xx: Remove no more needed driver data Date: Thu, 30 May 2024 18:09:59 +0300 Message-ID: <20240530151117.1130792-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-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-20240530_081126_370766_8F4AE364 X-CRM114-Status: GOOD ( 12.29 ) 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 Since the ACPI enumerated devices provide a property with SSP type, there is no more necessity to bear the copy of them in the ID table. Drop the driver data in ACPI ID table. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index f4dc113768cd..b62a613378e0 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1718,12 +1718,12 @@ static const struct dev_pm_ops pxa2xx_spi_pm_ops = { }; static const struct acpi_device_id pxa2xx_spi_acpi_match[] = { - { "80860F0E", LPSS_BYT_SSP }, - { "8086228E", LPSS_BSW_SSP }, - { "INT33C0", LPSS_LPT_SSP }, - { "INT33C1", LPSS_LPT_SSP }, - { "INT3430", LPSS_LPT_SSP }, - { "INT3431", LPSS_LPT_SSP }, + { "80860F0E" }, + { "8086228E" }, + { "INT33C0" }, + { "INT33C1" }, + { "INT3430" }, + { "INT3431" }, {} }; MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match); From patchwork Thu May 30 15:10:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680529 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 7AF8AC27C44 for ; Thu, 30 May 2024 15:11:49 +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=FZmLlCP/cVgfHthJgx074HL5KIC/QqZ5DhYFZQEMVu0=; b=pXbLSlyzzBzAzZ cwbFYcNxWCXF2s9GopQ1PBa5lu/vcDg9fKIe/Ckw/Kh3aOwejJePVtQQZ+HT0G8d2ADR/iyjrFYn+ vJPgB+/AEcxC22GZeoj1YT94db5etCbRFmk9mqAMIPTEYhr7IOliviZn0J6irhGfKpR6D8JiDHmYF xzQWljE52SXnWc3e618mUxaVlvlWNSZMk2t9doqtYRng7el4cgyJBWc/p1l9aSJk7pxYr5Bcq6Npx rKhVIjqTQDj7nWjzHTmw/X5LbTq3en+lYCCth6U4kTQK8UTswn1S79fuCIEPY3xxa561rc7FFqppg 2nqEOkSWr/2gjpDyMeCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRC-00000007eqA-0BLi; Thu, 30 May 2024 15:11:30 +0000 Received: from mgamail.intel.com ([192.198.163.8]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChR8-00000007en1-1G6Z for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2024 15:11:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081886; x=1748617886; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Iq9RkCVt6cK9FjvsEVBSiepSsecDquk00YCQe7trEiE=; b=glmv71E/LrOiaAsnLDpfyZJNyIajmztOndG666brTPqYcm3ZGeh3de3b DKr7tl4mPiOpo8oux2rlq9qXfTxktlUBlZSZIgx4Lq7X7qfUcWEU/8/o8 wjwywvgP6oMNwBc+d7/KWF3V4ng7/Gc8uWIqgq+HQy4XfnB2BnqRCJzbQ QbRDKdPWCcA7PqLaWTUUIQm52MbD0PjOHsUW6q76bl64ni/ByagrBBHoD 3955qHe/NJWQ7A5XZbHNiLQzoCT+uotYnTSIoiUsBXsHljiWHhUulKRLB oIlOPZ2LxZk0+s9v9mTwkhDUaGYAGgefx11smVc3G1tXqzO1P4iS6OPvx g==; X-CSE-ConnectionGUID: CK2Mv83PQS2O/6Ll1q3jcw== X-CSE-MsgGUID: L2NfNoiyQ8WZI2qt2fbsQA== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31093037" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31093037" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:22 -0700 X-CSE-ConnectionGUID: G8o5fUUqTo2Es22qCMzxKg== X-CSE-MsgGUID: /TE0xF6cRluJM0rR4Vu7wg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="40288500" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa005.fm.intel.com with ESMTP; 30 May 2024 08:11:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4322937D; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 04/11] spi: pxa2xx: Remove hard coded number of chip select pins Date: Thu, 30 May 2024 18:10:00 +0300 Message-ID: <20240530151117.1130792-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-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-20240530_081126_382848_4615BE40 X-CRM114-Status: GOOD ( 12.88 ) 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 Remove hard coded number of chip select pins for Intel Braswell. This comes via property. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index b62a613378e0..53815aab41aa 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -99,7 +99,6 @@ struct lpss_config { /* Chip select control */ unsigned cs_sel_shift; unsigned cs_sel_mask; - unsigned cs_num; /* Quirks */ unsigned cs_clk_stays_gated : 1; }; @@ -137,7 +136,6 @@ static const struct lpss_config lpss_platforms[] = { .tx_threshold_hi = 224, .cs_sel_shift = 2, .cs_sel_mask = 1 << 2, - .cs_num = 2, }, { /* LPSS_SPT_SSP */ .offset = 0x200, @@ -1594,8 +1592,6 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) tmp &= LPSS_CAPS_CS_EN_MASK; tmp >>= LPSS_CAPS_CS_EN_SHIFT; platform_info->num_chipselect = ffz(tmp); - } else if (config->cs_num) { - platform_info->num_chipselect = config->cs_num; } } controller->num_chipselect = platform_info->num_chipselect; From patchwork Thu May 30 15:10:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680533 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 CA6CAC27C4F for ; Thu, 30 May 2024 15:12:00 +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=vv8IoMMz9Yo5BWUl538K1msmMNTpdyhhrzq+sV2J3BU=; b=gYgdrAMuIOqR+A w9VCm8Su/rrUfBgMGXr6/XRMFdsEKuZjd9QbwtnYDtn/CipXZLw6adWMAlOnEVUTngLv0Om1h7iF1 EvmJacS0E98Fn2tBpFVFunMf7zNNUxGEca28LsseimpKoIAuqVYdXk8KTFhOrNH8/zPuYAPMJNCFn SCne8XGhvyMRMtodvOZAgvouzizI9PwW1TUOQPUzTtyeZHwT62PtAfj0n0F8fxVec6Ctc3KSOUteJ G++Fmfc28UyI6B6M38LenLNH6g2xOGnj7ODye8T54zU0T3HlNqzHx3nZVXSgPUAxnuKMW7ZxbLHgZ GI0mN5rOzHSIZJYQQRvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRV-00000007eyu-0Dza; Thu, 30 May 2024 15:11:49 +0000 Received: from mgamail.intel.com ([192.198.163.8]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChR9-00000007emi-3Eku for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2024 15:11:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081888; x=1748617888; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M+NbhDPEqKAfXCCJumrA9VHagNYen39iF9Q6cbbh/Yc=; b=IHsvJzosSSdsgETKErhEg2/0OyKrl0Wm8lY1USxlbFV0AGP9KSNhUqVF FWb7PZvc1+47FGEalfeqrPAYze+zzucqdwki6h0SxjeAG1oHEHnz54wNB qUZrStMuknp1i37tjKtzdywoNZb/ujYsWd4S9NFSrqN34EUGnltQCzbNZ 7whWD6gp9V15tdlyPu4lisx5YcYn7XyWidC+9M9xKY4RtgwjCFmC6ao4C KiS/bHoBLBfqRucn+QIfwczgFPD8svrCsNztTiMav+k81saAETGlLzPpT FwRcVzjCjuuyQoUoHyKe5Pu7YyVBRhx294QUfA5k9ahdME5tmoZeJ4n9x Q==; X-CSE-ConnectionGUID: fN+zYcHuRySyFx6sE9Yp5Q== X-CSE-MsgGUID: NHBNxFj4RsSAhnFTpUe2Nw== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31093052" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31093052" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:25 -0700 X-CSE-ConnectionGUID: qt//DRy9Sc+BayjLWr0qfw== X-CSE-MsgGUID: 55oDytf2S8+9oqMNTbMdmQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="40288502" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa005.fm.intel.com with ESMTP; 30 May 2024 08:11:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 57AEF6AB; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 05/11] spi: pxa2xx: Utilise temporary variable for struct device Date: Thu, 30 May 2024 18:10:01 +0300 Message-ID: <20240530151117.1130792-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-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-20240530_081128_306053_BEF214E9 X-CRM114-Status: GOOD ( 13.45 ) 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 We have a temporary variable to keep a pointer to struct device. Utilise it where it makes sense. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 53815aab41aa..19ee7739f4bd 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1606,13 +1606,13 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) } } - pm_runtime_set_autosuspend_delay(&pdev->dev, 50); - pm_runtime_use_autosuspend(&pdev->dev); - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); + pm_runtime_set_autosuspend_delay(dev, 50); + pm_runtime_use_autosuspend(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); /* Register with the SPI framework */ - platform_set_drvdata(pdev, drv_data); + dev_set_drvdata(dev, drv_data); status = spi_register_controller(controller); if (status) { dev_err_probe(dev, status, "problem registering SPI controller\n"); @@ -1622,7 +1622,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) return status; out_error_pm_runtime_enabled: - pm_runtime_disable(&pdev->dev); + pm_runtime_disable(dev); out_error_clock_enabled: clk_disable_unprepare(ssp->clk); @@ -1636,10 +1636,11 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) static void pxa2xx_spi_remove(struct platform_device *pdev) { - struct driver_data *drv_data = platform_get_drvdata(pdev); + struct device *dev = &pdev->dev; + struct driver_data *drv_data = dev_get_drvdata(dev); struct ssp_device *ssp = drv_data->ssp; - pm_runtime_get_sync(&pdev->dev); + pm_runtime_get_sync(dev); spi_unregister_controller(drv_data->controller); @@ -1651,8 +1652,8 @@ static void pxa2xx_spi_remove(struct platform_device *pdev) if (drv_data->controller_info->enable_dma) pxa2xx_spi_dma_release(drv_data); - pm_runtime_put_noidle(&pdev->dev); - pm_runtime_disable(&pdev->dev); + pm_runtime_put_noidle(dev); + pm_runtime_disable(dev); /* Release IRQ */ free_irq(ssp->irq, drv_data); From patchwork Thu May 30 15:10:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680530 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 2FFE2C25B74 for ; Thu, 30 May 2024 15:12:00 +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=5cIDWs9ThAOTCh5hPlpfxUef1olcC716FBSORYEozv0=; b=wHhA2o+xOq0Z0z CoCJIg9GypCitNC5FywXUKmH5+FuhbNPHq8f9T2BfrSPfxPqCBaKreSs1XKSbXrBvo+2XSlVlOoXd KgpKI0A6pXpWZalmg3BRQLf9uB1Qfak3MKocNrdtuSeaYt1GYNYhBj6K6a9ptGUEszTsDfi60fdlU WAV2LAziGOIeIhgJoTgjv3+FSJgbn6/Jt4QTrr8SidNn/4I5fZg1bYVC0umNCwoorgu0rTaUPucdV n7RA4mohLpsAM+N4oe9xW7iJM3TxmKUu8iSA8eiQqhPo+jUjYXcOn5ZWRRshI/h5s07/aGmAF3dlo WIqxGgXQDLqeTUQeb9XA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRU-00000007eyG-0g4z; Thu, 30 May 2024 15:11:48 +0000 Received: from mgamail.intel.com ([192.198.163.8]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChR9-00000007en1-3GZw for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2024 15:11:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081888; x=1748617888; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VtuiMejnZILT/hyIjcNOY30dlVGcZI/pZvafnR2kTW0=; b=D+LQz5XeABHvQK+aNs9r6RNpK2ai8375nhTb07irgKjCtBgwXbN6Ewqv PoBdxlYBXU+WqsbCtRqiv0b+d4YfB1eIndVu3tGyCQS3WJdbnc7r5CV9Q Pvk1OnCLorCbMKUBrPP7x6oyg1wnHt/nW94heHNtAlzCTDGRh9OjPque/ uoXous4VwHuSnNOGBMPo7rISvQHINTFZ8PCCRndfKAtCGnP6+maPSWrS/ ELb7fMEyNy9CQqkxrFrHUWWe98BjV8zEiM24nv/8WG5RPIPmYsDTWiM8w j8s/reAQW/aNZSNgi0x6HXzHIT48zz4+69ZtrVIpC9GWDWywE+JWlgufu Q==; X-CSE-ConnectionGUID: 4qwYnouyT3i+EgCAX/NDEg== X-CSE-MsgGUID: E8VXUxzjSk26J96faBYzqQ== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31093059" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31093059" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:26 -0700 X-CSE-ConnectionGUID: UfNqA/KvRC27iVrFMnKkuA== X-CSE-MsgGUID: rivNWmNoRDSgY/osG8FgRg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="40288503" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa005.fm.intel.com with ESMTP; 30 May 2024 08:11:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 62AE46CB; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 06/11] spi: pxa2xx: Print DMA burst size only when DMA is enabled Date: Thu, 30 May 2024 18:10:02 +0300 Message-ID: <20240530151117.1130792-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-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-20240530_081128_273976_C8CFFDE4 X-CRM114-Status: GOOD ( 12.28 ) 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 Print DMA burst size only when DMA is enabled to avoid making a false impression that DMA is enabled when it may be not. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 19ee7739f4bd..30a829b74a22 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1434,7 +1434,6 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) if (IS_ERR(platform_info)) return dev_err_probe(dev, PTR_ERR(platform_info), "missing platform data\n"); } - dev_dbg(dev, "DMA burst size set to %u\n", platform_info->dma_burst_size); ssp = pxa2xx_spi_ssp_request(pdev); if (IS_ERR(ssp)) @@ -1516,6 +1515,8 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) controller->max_dma_len = MAX_DMA_LEN; controller->max_transfer_size = pxa2xx_spi_max_dma_transfer_size; + + dev_dbg(dev, "DMA burst size set to %u\n", platform_info->dma_burst_size); } } From patchwork Thu May 30 15:10:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680539 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 F404AC27C43 for ; Thu, 30 May 2024 15:12:23 +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=f+U4jF7lhUVAgnKvKHFLBVy66SRXs2hbrSs0VsPIeUA=; b=arEDKMQ360s/UQ yReJqUKQYd+qY3iIC73TpcxdC2OmC+Lgsy4JZNBEtS8vqbYb01X6nTj/HhGqnpdXkN/oOQ7fKTBAc H6yGeIHsTYwuh/3L1g6WuvxX6zdSvVbdkXrQGsFtTpe4Gnv5vABeWH6qcJLN8mxLOAd5FSBjrDRWa RYU712vd1Cre4rnr3Ya4gjY5MdyG5x57uqnEHzjEqrko40PJVJ/Xu899/KsBM+NoAv1t0Kv2QUhxV 0w1/weitSefXv8OWA9dTjSGgFEkr//q3+ecIGzXzsK7xcvZzwd3eszgYdg8NcNhe3FF+YQSGCYBEn 86I0+4G1aWf/7zz46LgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRp-00000007fH5-0W3S; Thu, 30 May 2024 15:12:09 +0000 Received: from mgamail.intel.com ([198.175.65.10]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRE-00000007enA-1yaF for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2024 15:11:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081892; x=1748617892; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KHmkxGTrimggz5XiV2P+I49lCexUOiH4Nb0XpNE5VMs=; b=LVAXYQo6Yjo2U4A9OnfifagR2QpOTNLidBPrkcZDKj2WpJ3jPQXCyu41 eMHAgtWCRr9LIpvIRTouhgvGLdTrMXlHD0rFRsDD9JfF7nNy6gd47l8YL +F6EM+4kiuk5AjpyW5fVMfiJRjJNBa3MZa37UR/G2qDIHtgThf9o8f7hg z81RHWprcWAELBLZOpbiLXwmWZ/tYyMykhcZNkCRtnNbM3L4G58yIIZtj 7vEPG9WNDdNANQ9CBOVjgUj6CRRJZPZ9bTklo9L1kbE9hElrIwR/16dhn xksh8yzJ5kZ9/tbHizkGGSKBTwfm0D6aMbtJO/cIC8tIgMOH+zAlwEN7l Q==; X-CSE-ConnectionGUID: jOLpiQgKRkKRM6mJ7IK2kg== X-CSE-MsgGUID: SQoIH6jySO+LOvdFbIbQxQ== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31067962" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31067962" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:25 -0700 X-CSE-ConnectionGUID: ZmLvxdsRRH2XteUsnIoQpw== X-CSE-MsgGUID: t+vO54S1RdSW0kg0YoLNBg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="73329439" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 30 May 2024 08:11:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 68409679; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 07/11] spi: pxa2xx: Remove duplicate check Date: Thu, 30 May 2024 18:10:03 +0300 Message-ID: <20240530151117.1130792-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-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-20240530_081132_746493_D6D8D6B3 X-CRM114-Status: GOOD ( 10.44 ) 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 The mmio_base can't be NULL at this point. It's either checked in both pxa_ssp_probe() and pxa2xx_spi_init_ssp() or correctly provided by PCI core. Hence, remove duplicate check which is a dead code. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 30a829b74a22..9724d9455837 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1441,9 +1441,6 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) if (!ssp) ssp = &platform_info->ssp; - if (!ssp->mmio_base) - return dev_err_probe(dev, -ENODEV, "failed to get SSP\n"); - if (platform_info->is_target) controller = devm_spi_alloc_target(dev, sizeof(*drv_data)); else From patchwork Thu May 30 15:10:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680535 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 7303CC25B74 for ; Thu, 30 May 2024 15:12:09 +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=dnZBWsBTcCaikMCz8APIlMnxr4VR7/ZrtZ0smHcUiwY=; b=N3sAlq0A56wLXW 6qEwAc0Wa+AzCRdzciAWWrwFDEJyBWMRWhZFdwxf0YE0BrcwxokmpKtCmA4XThVVQHk7v2385rney dbxuwZ5O3TwBCPtfm8Cl29GCArUKNw/lgbVkjTFCFU7uvh7yc6YrgBBy6+7Sr1zTmWK9nbi+82lD+ L1P/rK50mtW85n8mF9wrkjeEERU4dtJ872r/fDklLd6Kfq9Ph52rYU0n2FCcsZniwV9V4wjyVG/6P j0KuS97NPQ0/QkoTHP5vbMgspSyFBwnCzAlD07EYTpxxO4F1MfzW+qwSesrW2qlXV/iHcMqNCj2QP q69GJo6S1/ffdYN24syA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRd-00000007f6F-2e2T; Thu, 30 May 2024 15:11:57 +0000 Received: from mgamail.intel.com ([198.175.65.10]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRB-00000007enA-1JTt for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2024 15:11:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081889; x=1748617889; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YN44JYZqoEKQIIQ+HPXBPHzx9SDRMV97fZqyIcUXYdE=; b=mJZeP/URwGMSnCpWylvdoe29ekyhbltR25yERAZzAlbrbPGsqzxgmyey wYqnP9c8MsD8tjmtfGAf1N5V5720zmBm3HTzlyHfH25AWZin7URD2ittE Et/VhiZGWCDif4rbgfJFd9EoV++KsoFS7HhuGvVt0+leeaCng5aLaYulM A7+WK6aVYdjywERiLqCLfCxzZAlrAkiIcC+yqq4OFhbpxIuXN8Qv3LTt0 0WUVxuW/bP12eU/yGq2o7mcfcdKKrb8iI2mrBqgOLKP3FlWSVWkHTAZrs wtH4vH2xbrNBVnmRKlYi5beGI3xo7XDFZVBUWt/oCp8E2bPJ3cjCaS+4K w==; X-CSE-ConnectionGUID: 1Imkd0SYRh6gi32IgbcBvw== X-CSE-MsgGUID: uUBZI/jpTy6NKZKONj+fkQ== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31067950" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31067950" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:25 -0700 X-CSE-ConnectionGUID: s1k/pvsFTLmW63bqcbIURg== X-CSE-MsgGUID: ZULTayxvTv6OSYz0zy9cQA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="73329437" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 30 May 2024 08:11:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7677D700; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 08/11] spi: pxa2xx: Remove superflous check for Intel Atom SoCs Date: Thu, 30 May 2024 18:10:04 +0300 Message-ID: <20240530151117.1130792-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-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-20240530_081129_688556_8305CE89 X-CRM114-Status: GOOD ( 14.83 ) 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 pxa2xx_spi_fw_translate_cs() checks for the ACPI companion device presence along with the SSP type. But the SSP type is uniquely determines the case. Hence remove the superflous check. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 9724d9455837..3c03a8cd9ee6 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1393,23 +1393,19 @@ static int pxa2xx_spi_fw_translate_cs(struct spi_controller *controller, { struct driver_data *drv_data = spi_controller_get_devdata(controller); - if (has_acpi_companion(drv_data->ssp->dev)) { - switch (drv_data->ssp_type) { - /* - * For Atoms the ACPI DeviceSelection used by the Windows - * driver starts from 1 instead of 0 so translate it here - * to match what Linux expects. - */ - case LPSS_BYT_SSP: - case LPSS_BSW_SSP: - return cs - 1; + switch (drv_data->ssp_type) { + /* + * For some of Intel Atoms the ACPI DeviceSelection used by the Windows + * driver starts from 1 instead of 0 so translate it here to match what + * Linux expects. + */ + case LPSS_BYT_SSP: + case LPSS_BSW_SSP: + return cs - 1; - default: - break; - } + default: + return cs; } - - return cs; } static size_t pxa2xx_spi_max_dma_transfer_size(struct spi_device *spi) From patchwork Thu May 30 15:10:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680537 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 09A33C27C4F for ; Thu, 30 May 2024 15:12:14 +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=kN4SRcUzRLVZ401V2rZEI/DZUcDpNtcSVl/BG/L3q6c=; b=cVcpj0TqO9AQWU 29JvNSiKsUFkQlLf5jkmAHhUBP+EOxp7Q+Ss7JD/elg7jQuqWXy2Ov+gXnIm3wrQrQ92+/FCqdTg0 6q4axDtACeglHkhQr9Nc5zzjdQCOQjz//WVUmS4rF4D6zFEAH/1TfeOsiaCxwb3nCcVY3vqTbDxZ0 jSRlZEDbrnf8syu7NVU+uc6Ee295MFcU7J4EOTx4DtwDgnqhdmhA3sCgnniQsrTgKc9QcYDoY+kvf LHsn5p2HXZ57/xTte2mNVAxjBVlO4HsPlT71jAulYNTNayHn8zW00PYFoIaTt7sjyqpp3Mvr8X0xd ALKs0kdp/sbOL2T801gw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRf-00000007f8L-2jiN; Thu, 30 May 2024 15:11:59 +0000 Received: from mgamail.intel.com ([198.175.65.10]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRB-00000007epg-1nqN for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2024 15:11:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081889; x=1748617889; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cyTnsqcupVXst0FyS+yA1egD0GK0RbG+Gy/mnXGgt3g=; b=MZWqtXt9xpQkDDGLhEMixt7SuRtG9JLkmOo/7BrBeSN3vI1NMxsPMTmZ RHF+dX1Ip0C7REyXcwnD4RbZydq6jEZVNGAxpRFw+E8MdMxNGVpqwYbG7 vSkVfK70k+ZxUvVNS74WbeNzIO6YPf0nc85zIBN4RVGuflwDku+x49au1 7NpRvw5QyW+OBEl8+QAXHWATrTp1eFeT2pQXlGe+nsfmmnAUpKlTXIHuk KfGJD6sku6D+g8OQauhhv1bW6xxSJk9mqJCqp17gSmSBA4+SLRJV/CELm qqCRqhx632PC+lNMDKlM1ReLPfnZTyadUV+2Ugs4yBGFBK+qN53CtR6F2 w==; X-CSE-ConnectionGUID: TwNgiue1Ssq1+hBkAQT72w== X-CSE-MsgGUID: 01Tko0JnQ+OPtlJzjbvWrQ== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31067956" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31067956" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:25 -0700 X-CSE-ConnectionGUID: TJQT913DSqmlAiaG5MJS2Q== X-CSE-MsgGUID: OvvpV2LGRful5O8h0mDMvg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="73329441" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 30 May 2024 08:11:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 793CA6F1; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 09/11] spi: pxa2xx: Extract pxa2xx_spi_platform_*() callbacks Date: Thu, 30 May 2024 18:10:05 +0300 Message-ID: <20240530151117.1130792-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-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-20240530_081129_746795_3BB8C9E5 X-CRM114-Status: GOOD ( 17.36 ) 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 In preparation of the extracting platform driver from spi-pxa2xx.c split the probe and remove functions so we have bus independent and platform device ones. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 52 +++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 3c03a8cd9ee6..74f242e652df 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -1413,30 +1413,16 @@ static size_t pxa2xx_spi_max_dma_transfer_size(struct spi_device *spi) return MAX_DMA_LEN; } -static int pxa2xx_spi_probe(struct platform_device *pdev) +static int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp) { - struct device *dev = &pdev->dev; struct pxa2xx_spi_controller *platform_info; struct spi_controller *controller; struct driver_data *drv_data; - struct ssp_device *ssp; const struct lpss_config *config; int status; u32 tmp; platform_info = dev_get_platdata(dev); - if (!platform_info) { - platform_info = pxa2xx_spi_init_pdata(pdev); - if (IS_ERR(platform_info)) - return dev_err_probe(dev, PTR_ERR(platform_info), "missing platform data\n"); - } - - ssp = pxa2xx_spi_ssp_request(pdev); - if (IS_ERR(ssp)) - return PTR_ERR(ssp); - if (!ssp) - ssp = &platform_info->ssp; - if (platform_info->is_target) controller = devm_spi_alloc_target(dev, sizeof(*drv_data)); else @@ -1628,9 +1614,8 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) return status; } -static void pxa2xx_spi_remove(struct platform_device *pdev) +static void pxa2xx_spi_remove(struct device *dev) { - struct device *dev = &pdev->dev; struct driver_data *drv_data = dev_get_drvdata(dev); struct ssp_device *ssp = drv_data->ssp; @@ -1708,6 +1693,35 @@ static const struct dev_pm_ops pxa2xx_spi_pm_ops = { RUNTIME_PM_OPS(pxa2xx_spi_runtime_suspend, pxa2xx_spi_runtime_resume, NULL) }; +static int pxa2xx_spi_platform_probe(struct platform_device *pdev) +{ + struct pxa2xx_spi_controller *platform_info; + struct device *dev = &pdev->dev; + struct ssp_device *ssp; + + platform_info = dev_get_platdata(dev); + if (!platform_info) { + platform_info = pxa2xx_spi_init_pdata(pdev); + if (IS_ERR(platform_info)) + return dev_err_probe(dev, PTR_ERR(platform_info), "missing platform data\n"); + + dev->platform_data = platform_info; + } + + ssp = pxa2xx_spi_ssp_request(pdev); + if (IS_ERR(ssp)) + return PTR_ERR(ssp); + if (!ssp) + ssp = &platform_info->ssp; + + return pxa2xx_spi_probe(dev, ssp); +} + +static void pxa2xx_spi_platform_remove(struct platform_device *pdev) +{ + pxa2xx_spi_remove(&pdev->dev); +} + static const struct acpi_device_id pxa2xx_spi_acpi_match[] = { { "80860F0E" }, { "8086228E" }, @@ -1732,8 +1746,8 @@ static struct platform_driver driver = { .acpi_match_table = pxa2xx_spi_acpi_match, .of_match_table = pxa2xx_spi_of_match, }, - .probe = pxa2xx_spi_probe, - .remove_new = pxa2xx_spi_remove, + .probe = pxa2xx_spi_platform_probe, + .remove_new = pxa2xx_spi_platform_remove, }; static int __init pxa2xx_spi_init(void) From patchwork Thu May 30 15:10:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680538 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 2BDCCC27C43 for ; Thu, 30 May 2024 15:12:16 +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=k2Bd1Y6AiQFrKbvMZMTCQndnOXmfFwOAOd9yvaR6Pmo=; b=R0RbT9jjPuh314 fF0i1c7om9QpPXfOkQfrso8GvQtu1iNOMUgUYwnz6xQfah/+4AiAw+kIaaCgfRYqO7+8ePo4N2pcr NuRYEu5FoddSdEZtEZPFrW9gQJZA6bl5d3fI0ibksjdslMIjYNXjCP7sdb9zpd3mnMOf30kkYrdGD LCwkJzyBffI5/8ncJ8tv24XcWFVMtEtips1dfJCWYEzbJwMMyVlmqK/LKWfhI7TuMpJQOJ0QFB+N6 k6n0r68uuEWRs0pChZxgNEqhwtTzFv/rSBR1JAr+suAyojp6HIxfVyxxauERYmx0XzJIvzdPD4Wk+ B3IghcwvCP11JLMs+YnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRl-00000007fDM-1B0I; Thu, 30 May 2024 15:12:05 +0000 Received: from mgamail.intel.com ([198.175.65.10]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRD-00000007emk-22DA for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2024 15:11:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081891; x=1748617891; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HYlrU3UBrVhjvXqz3+lbjc1NAwS2xeDgiIYUu3mQpXA=; b=Bm5Fu7jdv+MoDa2DNf+E0Wgq2oADHNrYZhKxq2P0TPewVkJkLj6nOmoX 2buuGQBzrlBjiMshxnnc2UMWb4yfTHYYSEEdrBiCZGSSCpu8SSluvQ8wH gm9110imERWkEr6sBtiiVVOigVu3hnvMS12QbA7R5vHpK7LK3mF+ycmes 9aGfV5tvPX+m1uKqSdNgPOBdouTByrgfraNyIdGtELqv4R3EKpwHMgfdj JABYy7TW1ymFz0dYlPMkttzdgOrwjPoMxJUyT55n7ZVrg5d4bAt03T8tS rRcVrLxJ6u4Ykzn/eaCMLI6h5bZMY5cmXjnamx5gKMOT6g+J9QjW6RTMe Q==; X-CSE-ConnectionGUID: J1/JGI3JRF2TFs5KOcaZpw== X-CSE-MsgGUID: XlF0w1+wTgeAQa3Rt7Ca0g== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31067970" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31067970" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:26 -0700 X-CSE-ConnectionGUID: GLCTZRnDTYmRXgBP/9I+5A== X-CSE-MsgGUID: VOD612wUSKSb/EIN8wlzzQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="73329440" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 30 May 2024 08:11:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 82AB072B; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 10/11] spi: pxa2xx: Move platform driver to a separate file Date: Thu, 30 May 2024 18:10:06 +0300 Message-ID: <20240530151117.1130792-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-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-20240530_081131_814285_62776564 X-CRM114-Status: GOOD ( 28.63 ) 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 The spi-pxa2xx.c is bloated with a platform driver code while pretending to provide a core functionality. Make it real core library by splitting out the platform driver to a separate file. Signed-off-by: Andy Shevchenko --- drivers/spi/Makefile | 3 +- drivers/spi/spi-pxa2xx-platform.c | 214 +++++++++++++++++++++++++++++ drivers/spi/spi-pxa2xx.c | 215 ++---------------------------- drivers/spi/spi-pxa2xx.h | 6 + 4 files changed, 230 insertions(+), 208 deletions(-) create mode 100644 drivers/spi/spi-pxa2xx-platform.c diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index e694254dec04..bcfb6efd88e0 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -107,7 +107,8 @@ obj-$(CONFIG_SPI_PIC32) += spi-pic32.o obj-$(CONFIG_SPI_PIC32_SQI) += spi-pic32-sqi.o obj-$(CONFIG_SPI_PL022) += spi-pl022.o obj-$(CONFIG_SPI_PPC4xx) += spi-ppc4xx.o -spi-pxa2xx-platform-objs := spi-pxa2xx.o spi-pxa2xx-dma.o +obj-$(CONFIG_SPI_PXA2XX) += spi-pxa2xx-core.o +spi-pxa2xx-core-y := spi-pxa2xx.o spi-pxa2xx-dma.o obj-$(CONFIG_SPI_PXA2XX) += spi-pxa2xx-platform.o obj-$(CONFIG_SPI_PXA2XX_PCI) += spi-pxa2xx-pci.o obj-$(CONFIG_SPI_QCOM_GENI) += spi-geni-qcom.o diff --git a/drivers/spi/spi-pxa2xx-platform.c b/drivers/spi/spi-pxa2xx-platform.c new file mode 100644 index 000000000000..98a8ceb7db6f --- /dev/null +++ b/drivers/spi/spi-pxa2xx-platform.c @@ -0,0 +1,214 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "spi-pxa2xx.h" + +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 void pxa2xx_spi_ssp_release(void *ssp) +{ + pxa_ssp_free(ssp); +} + +static struct ssp_device *pxa2xx_spi_ssp_request(struct platform_device *pdev) +{ + struct ssp_device *ssp; + int status; + + ssp = pxa_ssp_request(pdev->id, pdev->name); + if (!ssp) + return ssp; + + status = devm_add_action_or_reset(&pdev->dev, pxa2xx_spi_ssp_release, ssp); + if (status) + return ERR_PTR(status); + + return ssp; +} + +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; + const void *match = device_get_match_data(dev); + enum pxa_ssp_type type = SSP_UNDEFINED; + struct ssp_device *ssp; + bool is_lpss_priv; + u32 num_cs = 1; + int status; + + ssp = pxa2xx_spi_ssp_request(pdev); + if (IS_ERR(ssp)) + return ERR_CAST(ssp); + if (ssp) { + type = ssp->type; + } else if (match) { + type = (enum pxa_ssp_type)(uintptr_t)match; + } else { + u32 value; + + status = device_property_read_u32(dev, "intel,spi-pxa2xx-type", &value); + if (status) + return ERR_PTR(status); + + type = (enum pxa_ssp_type)value; + } + + /* Validate the SSP type correctness */ + if (!(type > SSP_UNDEFINED && type < SSP_MAX)) + return ERR_PTR(-EINVAL); + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); + + /* Platforms with iDMA 64-bit */ + is_lpss_priv = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lpss_priv"); + if (is_lpss_priv) { + pdata->tx_param = parent; + pdata->rx_param = parent; + pdata->dma_filter = pxa2xx_spi_idma_filter; + } + + /* Read number of chip select pins, if provided */ + device_property_read_u32(dev, "num-cs", &num_cs); + + pdata->num_chipselect = num_cs; + pdata->is_target = device_property_read_bool(dev, "spi-slave"); + pdata->enable_dma = true; + pdata->dma_burst_size = 1; + + /* If SSP has been already enumerated, use it */ + if (ssp) + return pdata; + + status = pxa2xx_spi_init_ssp(pdev, &pdata->ssp, type); + if (status) + return ERR_PTR(status); + + return pdata; +} + +static int pxa2xx_spi_platform_probe(struct platform_device *pdev) +{ + struct pxa2xx_spi_controller *platform_info; + struct device *dev = &pdev->dev; + struct ssp_device *ssp; + + platform_info = dev_get_platdata(dev); + if (!platform_info) { + platform_info = pxa2xx_spi_init_pdata(pdev); + if (IS_ERR(platform_info)) + return dev_err_probe(dev, PTR_ERR(platform_info), "missing platform data\n"); + + dev->platform_data = platform_info; + } + + ssp = pxa2xx_spi_ssp_request(pdev); + if (IS_ERR(ssp)) + return PTR_ERR(ssp); + if (!ssp) + ssp = &platform_info->ssp; + + return pxa2xx_spi_probe(dev, ssp); +} + +static void pxa2xx_spi_platform_remove(struct platform_device *pdev) +{ + pxa2xx_spi_remove(&pdev->dev); +} + +static const struct acpi_device_id pxa2xx_spi_acpi_match[] = { + { "80860F0E" }, + { "8086228E" }, + { "INT33C0" }, + { "INT33C1" }, + { "INT3430" }, + { "INT3431" }, + {} +}; +MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match); + +static const struct of_device_id pxa2xx_spi_of_match[] = { + { .compatible = "marvell,mmp2-ssp", .data = (void *)MMP2_SSP }, + {} +}; +MODULE_DEVICE_TABLE(of, pxa2xx_spi_of_match); + +static struct platform_driver driver = { + .driver = { + .name = "pxa2xx-spi", + .pm = pm_ptr(&pxa2xx_spi_pm_ops), + .acpi_match_table = pxa2xx_spi_acpi_match, + .of_match_table = pxa2xx_spi_of_match, + }, + .probe = pxa2xx_spi_platform_probe, + .remove_new = pxa2xx_spi_platform_remove, +}; + +static int __init pxa2xx_spi_init(void) +{ + return platform_driver_register(&driver); +} +subsys_initcall(pxa2xx_spi_init); + +static void __exit pxa2xx_spi_exit(void) +{ + platform_driver_unregister(&driver); +} +module_exit(pxa2xx_spi_exit); + +MODULE_AUTHOR("Stephen Street"); +MODULE_DESCRIPTION("PXA2xx SSP SPI Controller platform driver"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(SPI_PXA2xx); +MODULE_ALIAS("platform:pxa2xx-spi"); +MODULE_SOFTDEP("pre: dw_dmac"); diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 74f242e652df..1fb30201459f 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -4,7 +4,6 @@ * Copyright (C) 2013, 2021 Intel Corporation */ -#include #include #include #include @@ -14,15 +13,12 @@ #include #include #include -#include #include #include #include #include #include -#include #include -#include #include #include #include @@ -32,11 +28,6 @@ #include "spi-pxa2xx.h" -MODULE_AUTHOR("Stephen Street"); -MODULE_DESCRIPTION("PXA2xx SSP SPI Controller"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:pxa2xx-spi"); - #define TIMOUT_DFLT 1000 /* @@ -1263,131 +1254,6 @@ static void cleanup(struct spi_device *spi) kfree(chip); } -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 void pxa2xx_spi_ssp_release(void *ssp) -{ - pxa_ssp_free(ssp); -} - -static struct ssp_device *pxa2xx_spi_ssp_request(struct platform_device *pdev) -{ - struct ssp_device *ssp; - int status; - - ssp = pxa_ssp_request(pdev->id, pdev->name); - if (!ssp) - return ssp; - - status = devm_add_action_or_reset(&pdev->dev, pxa2xx_spi_ssp_release, ssp); - if (status) - return ERR_PTR(status); - - return ssp; -} - -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; - const void *match = device_get_match_data(dev); - enum pxa_ssp_type type = SSP_UNDEFINED; - struct ssp_device *ssp; - bool is_lpss_priv; - u32 num_cs = 1; - int status; - - ssp = pxa2xx_spi_ssp_request(pdev); - if (IS_ERR(ssp)) - return ERR_CAST(ssp); - if (ssp) { - type = ssp->type; - } else if (match) { - type = (enum pxa_ssp_type)(uintptr_t)match; - } else { - u32 value; - - status = device_property_read_u32(dev, "intel,spi-pxa2xx-type", &value); - if (status) - return ERR_PTR(status); - - type = (enum pxa_ssp_type)value; - } - - /* Validate the SSP type correctness */ - if (!(type > SSP_UNDEFINED && type < SSP_MAX)) - return ERR_PTR(-EINVAL); - - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return ERR_PTR(-ENOMEM); - - /* Platforms with iDMA 64-bit */ - is_lpss_priv = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lpss_priv"); - if (is_lpss_priv) { - pdata->tx_param = parent; - pdata->rx_param = parent; - pdata->dma_filter = pxa2xx_spi_idma_filter; - } - - /* Read number of chip select pins, if provided */ - device_property_read_u32(dev, "num-cs", &num_cs); - - pdata->num_chipselect = num_cs; - pdata->is_target = device_property_read_bool(dev, "spi-slave"); - pdata->enable_dma = true; - pdata->dma_burst_size = 1; - - /* If SSP has been already enumerated, use it */ - if (ssp) - return pdata; - - status = pxa2xx_spi_init_ssp(pdev, &pdata->ssp, type); - if (status) - return ERR_PTR(status); - - return pdata; -} - static int pxa2xx_spi_fw_translate_cs(struct spi_controller *controller, unsigned int cs) { @@ -1413,7 +1279,7 @@ static size_t pxa2xx_spi_max_dma_transfer_size(struct spi_device *spi) return MAX_DMA_LEN; } -static int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp) +int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp) { struct pxa2xx_spi_controller *platform_info; struct spi_controller *controller; @@ -1613,8 +1479,9 @@ static int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp) return status; } +EXPORT_SYMBOL_NS_GPL(pxa2xx_spi_probe, SPI_PXA2xx); -static void pxa2xx_spi_remove(struct device *dev) +void pxa2xx_spi_remove(struct device *dev) { struct driver_data *drv_data = dev_get_drvdata(dev); struct ssp_device *ssp = drv_data->ssp; @@ -1637,6 +1504,7 @@ static void pxa2xx_spi_remove(struct device *dev) /* Release IRQ */ free_irq(ssp->irq, drv_data); } +EXPORT_SYMBOL_NS_GPL(pxa2xx_spi_remove, SPI_PXA2xx); static int pxa2xx_spi_suspend(struct device *dev) { @@ -1688,78 +1556,11 @@ static int pxa2xx_spi_runtime_resume(struct device *dev) return clk_prepare_enable(drv_data->ssp->clk); } -static const struct dev_pm_ops pxa2xx_spi_pm_ops = { +EXPORT_NS_GPL_DEV_PM_OPS(pxa2xx_spi_pm_ops, SPI_PXA2xx) = { SYSTEM_SLEEP_PM_OPS(pxa2xx_spi_suspend, pxa2xx_spi_resume) RUNTIME_PM_OPS(pxa2xx_spi_runtime_suspend, pxa2xx_spi_runtime_resume, NULL) }; -static int pxa2xx_spi_platform_probe(struct platform_device *pdev) -{ - struct pxa2xx_spi_controller *platform_info; - struct device *dev = &pdev->dev; - struct ssp_device *ssp; - - platform_info = dev_get_platdata(dev); - if (!platform_info) { - platform_info = pxa2xx_spi_init_pdata(pdev); - if (IS_ERR(platform_info)) - return dev_err_probe(dev, PTR_ERR(platform_info), "missing platform data\n"); - - dev->platform_data = platform_info; - } - - ssp = pxa2xx_spi_ssp_request(pdev); - if (IS_ERR(ssp)) - return PTR_ERR(ssp); - if (!ssp) - ssp = &platform_info->ssp; - - return pxa2xx_spi_probe(dev, ssp); -} - -static void pxa2xx_spi_platform_remove(struct platform_device *pdev) -{ - pxa2xx_spi_remove(&pdev->dev); -} - -static const struct acpi_device_id pxa2xx_spi_acpi_match[] = { - { "80860F0E" }, - { "8086228E" }, - { "INT33C0" }, - { "INT33C1" }, - { "INT3430" }, - { "INT3431" }, - {} -}; -MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match); - -static const struct of_device_id pxa2xx_spi_of_match[] = { - { .compatible = "marvell,mmp2-ssp", .data = (void *)MMP2_SSP }, - {} -}; -MODULE_DEVICE_TABLE(of, pxa2xx_spi_of_match); - -static struct platform_driver driver = { - .driver = { - .name = "pxa2xx-spi", - .pm = pm_ptr(&pxa2xx_spi_pm_ops), - .acpi_match_table = pxa2xx_spi_acpi_match, - .of_match_table = pxa2xx_spi_of_match, - }, - .probe = pxa2xx_spi_platform_probe, - .remove_new = pxa2xx_spi_platform_remove, -}; - -static int __init pxa2xx_spi_init(void) -{ - return platform_driver_register(&driver); -} -subsys_initcall(pxa2xx_spi_init); - -static void __exit pxa2xx_spi_exit(void) -{ - platform_driver_unregister(&driver); -} -module_exit(pxa2xx_spi_exit); - -MODULE_SOFTDEP("pre: dw_dmac"); +MODULE_AUTHOR("Stephen Street"); +MODULE_DESCRIPTION("PXA2xx SSP SPI Controller core driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/spi/spi-pxa2xx.h b/drivers/spi/spi-pxa2xx.h index 93e1e471e1c6..a470d3d634d3 100644 --- a/drivers/spi/spi-pxa2xx.h +++ b/drivers/spi/spi-pxa2xx.h @@ -14,6 +14,7 @@ #include +struct device; struct gpio_desc; /* @@ -131,4 +132,9 @@ extern void pxa2xx_spi_dma_stop(struct driver_data *drv_data); extern int pxa2xx_spi_dma_setup(struct driver_data *drv_data); extern void pxa2xx_spi_dma_release(struct driver_data *drv_data); +int pxa2xx_spi_probe(struct device *dev, struct ssp_device *ssp); +void pxa2xx_spi_remove(struct device *dev); + +extern const struct dev_pm_ops pxa2xx_spi_pm_ops; + #endif /* SPI_PXA2XX_H */ From patchwork Thu May 30 15:10:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13680536 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 814C2C27C44 for ; Thu, 30 May 2024 15:12:11 +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=KJGA2fymK30JVeT67Q//JR8DBJ/yraE/Pf3LqFDdIiI=; b=YMeoaaW1nK4ubs pHAlyuBpDsQIK1JdtD9ktVJlOblulGMCWYbvIA1ou+L680e5CG7+RVtrDW7VZTd4J0TmFav10VTnd qoFRMA8UtauRZwiCuzBHVdkzSTrF31I6xb6WDiDwXcsbYi29bMtBR34/+af+aGqveEJ3EJRbhhQNl /gvgpnZzHoH0I5JeQeNDcYVIo8OuZViYcyZNONc7hKo0CTfNZ0l3z2iOQitpL1fGKeWNngSzuEMi5 gidqdop2E1YfGMIB7fCmIUBEC7ILDqFyoKEwtxCK4qC8yiisPE220dMAezarg3Ix5C4JjHPP/WuUk IZgl9Vx34CdzQg9LzOww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRa-00000007f3V-2CHQ; Thu, 30 May 2024 15:11:54 +0000 Received: from mgamail.intel.com ([192.198.163.8]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sChRA-00000007eoT-1WnV for linux-arm-kernel@lists.infradead.org; Thu, 30 May 2024 15:11:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717081888; x=1748617888; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7g0FrtRJTKHe6RD7B4mm9xOD9+Ic1TmeKGG546OwPqo=; b=M1/c2tLJGgUyPOMOzPvKptWOnKEHzcZUJPOsab9Qv40a4ZT3ee2tnIeJ lLK4PIv0X9aAzsw2g41YzoUUKqYb3V0TxNltPdcQDvHFvLZw3wHTtuj6C CD+ZqVGlO4KoWuEFxPIXBvfao3eNRtfnY58hRBbdg2duBrXnjH8ujcXVY oxyhpczhN5Yz2UZ6j9yMW3ONECgWytXqIFme0iz7bnUrpQG8aozriG9wJ Wr6fXGAU7jRBF6TaIHcwmtOHvxvxCqwKMHmd0a1tm/EluofXx9z5lcZes qELeD9yHF58VlkXpHHC6fteT5sCLrpVkG0dYidiWTfhDZuRB5L2EQOHTT w==; X-CSE-ConnectionGUID: a5UM50ueSkKyfoVyhvPEmw== X-CSE-MsgGUID: 66Qw6s2WQtalaqcjxGaGCQ== X-IronPort-AV: E=McAfee;i="6600,9927,11088"; a="31093068" X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="31093068" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2024 08:11:26 -0700 X-CSE-ConnectionGUID: k9Eha/fGTpeqrsW1X+0gig== X-CSE-MsgGUID: G+4ZTQb/TfC1x49tTGutPQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,201,1712646000"; d="scan'208";a="40288504" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa005.fm.intel.com with ESMTP; 30 May 2024 08:11:23 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8E19774F; Thu, 30 May 2024 18:11:19 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , Linus Walleij , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik Subject: [PATCH v2 11/11] spi: pxa2xx: Convert PCI driver to use spi-pxa2xx code directly Date: Thu, 30 May 2024 18:10:07 +0300 Message-ID: <20240530151117.1130792-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240530151117.1130792-1-andriy.shevchenko@linux.intel.com> References: <20240530151117.1130792-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-20240530_081128_495008_5E64CF15 X-CRM114-Status: GOOD ( 16.10 ) 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 PCI driver has an additional device layer for enumeration. Remove that layer and use spi-pxa2xx code directly. Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx-pci.c | 39 ++++++++++++------------------------ 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c index 6d2efdb0e95f..616d032f1a89 100644 --- a/drivers/spi/spi-pxa2xx-pci.c +++ b/drivers/spi/spi-pxa2xx-pci.c @@ -10,8 +10,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -265,10 +264,8 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) { const struct pxa_spi_info *info; - struct platform_device_info pi; int ret; - struct platform_device *pdev; - struct pxa2xx_spi_controller spi_pdata; + struct pxa2xx_spi_controller *pdata; struct ssp_device *ssp; ret = pcim_enable_device(dev); @@ -279,15 +276,17 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev, if (ret) return ret; - memset(&spi_pdata, 0, sizeof(spi_pdata)); + pdata = devm_kzalloc(&dev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return -ENOMEM; - ssp = &spi_pdata.ssp; + ssp = &pdata->ssp; ssp->dev = &dev->dev; ssp->phys_base = pci_resource_start(dev, 0); ssp->mmio_base = pcim_iomap_table(dev)[0]; info = (struct pxa_spi_info *)ent->driver_data; - ret = info->setup(dev, &spi_pdata); + ret = info->setup(dev, pdata); if (ret) return ret; @@ -298,28 +297,12 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev, return ret; ssp->irq = pci_irq_vector(dev, 0); - memset(&pi, 0, sizeof(pi)); - pi.fwnode = dev_fwnode(&dev->dev); - pi.parent = &dev->dev; - pi.name = "pxa2xx-spi"; - pi.id = ssp->port_id; - pi.data = &spi_pdata; - pi.size_data = sizeof(spi_pdata); - - pdev = platform_device_register_full(&pi); - if (IS_ERR(pdev)) - return PTR_ERR(pdev); - - pci_set_drvdata(dev, pdev); - - return 0; + return pxa2xx_spi_probe(&dev->dev, ssp); } static void pxa2xx_spi_pci_remove(struct pci_dev *dev) { - struct platform_device *pdev = pci_get_drvdata(dev); - - platform_device_unregister(pdev); + pxa2xx_spi_remove(&dev->dev); } static const struct pci_device_id pxa2xx_spi_pci_devices[] = { @@ -341,6 +324,9 @@ MODULE_DEVICE_TABLE(pci, pxa2xx_spi_pci_devices); static struct pci_driver pxa2xx_spi_pci_driver = { .name = "pxa2xx_spi_pci", .id_table = pxa2xx_spi_pci_devices, + .driver = { + .pm = pm_ptr(&pxa2xx_spi_pm_ops), + }, .probe = pxa2xx_spi_pci_probe, .remove = pxa2xx_spi_pci_remove, }; @@ -349,4 +335,5 @@ module_pci_driver(pxa2xx_spi_pci_driver); MODULE_DESCRIPTION("CE4100/LPSS PCI-SPI glue code for PXA's driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(SPI_PXA2xx); MODULE_AUTHOR("Sebastian Andrzej Siewior ");