[PATCH v1 01/10] spi: pxa2xx: Reorganize the SSP type retrieval

Andy Shevchenko andriy.shevchenko at linux.intel.com
Fri May 17 12:47:35 PDT 2024


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 <andriy.shevchenko at linux.intel.com>
---
 drivers/spi/spi-pxa2xx.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index efe76d0c21bb..877fb6d01cd1 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -1310,19 +1310,20 @@ 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;
 	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 = pxa_ssp_request(pdev->id, pdev->name);
+	if (ssp) {
+		type = ssp->type;
+		pxa_ssp_free(ssp);
+	} 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);
@@ -1330,12 +1331,6 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)
 			return ERR_PTR(status);
 
 		type = (enum pxa_ssp_type)value;
-	} else {
-		ssp = pxa_ssp_request(pdev->id, pdev->name);
-		if (ssp) {
-			type = ssp->type;
-			pxa_ssp_free(ssp);
-		}
 	}
 
 	/* Validate the SSP type correctness */
@@ -1347,6 +1342,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;
-- 
2.43.0.rc1.1336.g36b5255a03ac




More information about the linux-arm-kernel mailing list