linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup()
@ 2022-02-25 17:23 Andy Shevchenko
  2022-02-25 17:23 ` [PATCH v1 02/11] spi: pxa2xx-pci: Refactor Quark X1000 " Andy Shevchenko
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Andy Shevchenko @ 2022-02-25 17:23 UTC (permalink / raw)
  To: Andy Shevchenko, linux-arm-kernel, linux-spi, linux-kernel
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown

Refactor CE4100 handling code to use ->setup() instead of spreading
potentially confusing conditional.

Besides that, it will allow to refactor further to avoid intermediate
storage for the used configuration parameters.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-pxa2xx-pci.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index 6d60972e4e20..bd20379d9342 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -30,7 +30,7 @@ enum {
 struct pxa_spi_info {
 	enum pxa_ssp_type type;
 	int port_id;
-	int num_chipselect;
+	unsigned int num_chipselect;
 	unsigned long max_clk_rate;
 
 	/* DMA channel request parameters */
@@ -114,6 +114,14 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 	return 0;
 }
 
+static int ce4100_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
+{
+	c->num_chipselect = dev->devfn;
+	c->max_clk_rate = 3686400;
+
+	return 0;
+}
+
 static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 {
 	struct dw_dma_slave *tx, *rx;
@@ -163,8 +171,7 @@ static struct pxa_spi_info spi_info_configs[] = {
 	[PORT_CE4100] = {
 		.type = PXA25x_SSP,
 		.port_id =  -1,
-		.num_chipselect = -1,
-		.max_clk_rate = 3686400,
+		.setup = ce4100_spi_setup,
 	},
 	[PORT_BYT] = {
 		.type = LPSS_BYT_SSP,
@@ -248,7 +255,7 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 	}
 
 	memset(&spi_pdata, 0, sizeof(spi_pdata));
-	spi_pdata.num_chipselect = (c->num_chipselect > 0) ? c->num_chipselect : dev->devfn;
+	spi_pdata.num_chipselect = c->num_chipselect;
 	spi_pdata.dma_filter = c->dma_filter;
 	spi_pdata.tx_param = c->tx_param;
 	spi_pdata.rx_param = c->rx_param;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v1 02/11] spi: pxa2xx-pci: Refactor Quark X1000 to use ->setup()
  2022-02-25 17:23 [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup() Andy Shevchenko
@ 2022-02-25 17:23 ` Andy Shevchenko
  2022-02-25 17:23 ` [PATCH v1 03/11] spi: pxa2xx-pci: Drop redundant NULL check in ->probe() Andy Shevchenko
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2022-02-25 17:23 UTC (permalink / raw)
  To: Andy Shevchenko, linux-arm-kernel, linux-spi, linux-kernel
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown

Refactor Quark X1000 handling code to use ->setup() instead of using
the configuration data structure directly.

It will allow to refactor further to avoid intermediate storage for
the used configuration parameters.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-pxa2xx-pci.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index bd20379d9342..4d617ad72bca 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -167,6 +167,14 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 	return 0;
 }
 
+static int qrk_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
+{
+	c->num_chipselect = 1;
+	c->max_clk_rate = 50000000;
+
+	return 0;
+}
+
 static struct pxa_spi_info spi_info_configs[] = {
 	[PORT_CE4100] = {
 		.type = PXA25x_SSP,
@@ -209,8 +217,7 @@ static struct pxa_spi_info spi_info_configs[] = {
 	[PORT_QUARK_X1000] = {
 		.type = QUARK_X1000_SSP,
 		.port_id = -1,
-		.num_chipselect = 1,
-		.max_clk_rate = 50000000,
+		.setup = qrk_spi_setup,
 	},
 	[PORT_LPT0] = {
 		.type = LPSS_LPT_SSP,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v1 03/11] spi: pxa2xx-pci: Drop redundant NULL check in ->probe()
  2022-02-25 17:23 [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup() Andy Shevchenko
  2022-02-25 17:23 ` [PATCH v1 02/11] spi: pxa2xx-pci: Refactor Quark X1000 " Andy Shevchenko
@ 2022-02-25 17:23 ` Andy Shevchenko
  2022-02-25 17:23 ` [PATCH v1 04/11] spi: pxa2xx-pci: Move port_id assignment to ->setup() Andy Shevchenko
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2022-02-25 17:23 UTC (permalink / raw)
  To: Andy Shevchenko, linux-arm-kernel, linux-spi, linux-kernel
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown

Since all platforms are using ->setup() function, drop unneeded check.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-pxa2xx-pci.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index 4d617ad72bca..90b95e49a164 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -255,11 +255,9 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 		return ret;
 
 	c = &spi_info_configs[ent->driver_data];
-	if (c->setup) {
-		ret = c->setup(dev, c);
-		if (ret)
-			return ret;
-	}
+	ret = c->setup(dev, c);
+	if (ret)
+		return ret;
 
 	memset(&spi_pdata, 0, sizeof(spi_pdata));
 	spi_pdata.num_chipselect = c->num_chipselect;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v1 04/11] spi: pxa2xx-pci: Move port_id assignment to ->setup()
  2022-02-25 17:23 [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup() Andy Shevchenko
  2022-02-25 17:23 ` [PATCH v1 02/11] spi: pxa2xx-pci: Refactor Quark X1000 " Andy Shevchenko
  2022-02-25 17:23 ` [PATCH v1 03/11] spi: pxa2xx-pci: Drop redundant NULL check in ->probe() Andy Shevchenko
@ 2022-02-25 17:23 ` Andy Shevchenko
  2022-02-25 17:23 ` [PATCH v1 05/11] spi: pxa2xx-pci: Move dma_burst_size " Andy Shevchenko
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2022-02-25 17:23 UTC (permalink / raw)
  To: Andy Shevchenko, linux-arm-kernel, linux-spi, linux-kernel
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown

Instead of using conditional, move port_id to the corresponding
->setup() functions.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-pxa2xx-pci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index 90b95e49a164..87629da3e544 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -29,7 +29,7 @@ enum {
 
 struct pxa_spi_info {
 	enum pxa_ssp_type type;
-	int port_id;
+	unsigned int port_id;
 	unsigned int num_chipselect;
 	unsigned long max_clk_rate;
 
@@ -116,6 +116,7 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 
 static int ce4100_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 {
+	c->port_id = dev->devfn;
 	c->num_chipselect = dev->devfn;
 	c->max_clk_rate = 3686400;
 
@@ -169,6 +170,7 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 
 static int qrk_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 {
+	c->port_id = dev->devfn;
 	c->num_chipselect = 1;
 	c->max_clk_rate = 50000000;
 
@@ -178,7 +180,6 @@ static int qrk_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 static struct pxa_spi_info spi_info_configs[] = {
 	[PORT_CE4100] = {
 		.type = PXA25x_SSP,
-		.port_id =  -1,
 		.setup = ce4100_spi_setup,
 	},
 	[PORT_BYT] = {
@@ -216,7 +217,6 @@ static struct pxa_spi_info spi_info_configs[] = {
 	},
 	[PORT_QUARK_X1000] = {
 		.type = QUARK_X1000_SSP,
-		.port_id = -1,
 		.setup = qrk_spi_setup,
 	},
 	[PORT_LPT0] = {
@@ -271,8 +271,8 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 	ssp->dev = &dev->dev;
 	ssp->phys_base = pci_resource_start(dev, 0);
 	ssp->mmio_base = pcim_iomap_table(dev)[0];
-	ssp->port_id = (c->port_id >= 0) ? c->port_id : dev->devfn;
 	ssp->type = c->type;
+	ssp->port_id = c->port_id;
 
 	pci_set_master(dev);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v1 05/11] spi: pxa2xx-pci: Move dma_burst_size assignment to ->setup()
  2022-02-25 17:23 [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup() Andy Shevchenko
                   ` (2 preceding siblings ...)
  2022-02-25 17:23 ` [PATCH v1 04/11] spi: pxa2xx-pci: Move port_id assignment to ->setup() Andy Shevchenko
@ 2022-02-25 17:23 ` Andy Shevchenko
  2022-02-25 17:23 ` [PATCH v1 06/11] spi: pxa2xx-pci: Move max_clk_rate " Andy Shevchenko
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2022-02-25 17:23 UTC (permalink / raw)
  To: Andy Shevchenko, linux-arm-kernel, linux-spi, linux-kernel
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown

Instead of using conditional, move dma_burst_size to the corresponding
->setup() function.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-pxa2xx-pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index 87629da3e544..c2cbb002784a 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -38,7 +38,7 @@ struct pxa_spi_info {
 	void *tx_param;
 	void *rx_param;
 
-	int dma_burst_size;
+	unsigned int dma_burst_size;
 
 	int (*setup)(struct pci_dev *pdev, struct pxa_spi_info *c);
 };
@@ -111,6 +111,7 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 	}
 
 	c->dma_filter = lpss_dma_filter;
+	c->dma_burst_size = 1;
 	return 0;
 }
 
@@ -265,7 +266,7 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 	spi_pdata.tx_param = c->tx_param;
 	spi_pdata.rx_param = c->rx_param;
 	spi_pdata.enable_dma = c->rx_param && c->tx_param;
-	spi_pdata.dma_burst_size = c->dma_burst_size ? c->dma_burst_size : 1;
+	spi_pdata.dma_burst_size = c->dma_burst_size;
 
 	ssp = &spi_pdata.ssp;
 	ssp->dev = &dev->dev;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v1 06/11] spi: pxa2xx-pci: Move max_clk_rate assignment to ->setup()
  2022-02-25 17:23 [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup() Andy Shevchenko
                   ` (3 preceding siblings ...)
  2022-02-25 17:23 ` [PATCH v1 05/11] spi: pxa2xx-pci: Move dma_burst_size " Andy Shevchenko
@ 2022-02-25 17:23 ` Andy Shevchenko
  2022-02-25 17:23 ` [PATCH v1 07/11] spi: pxa2xx-pci: Replace enum with direct use of PCI IDs Andy Shevchenko
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2022-02-25 17:23 UTC (permalink / raw)
  To: Andy Shevchenko, linux-arm-kernel, linux-spi, linux-kernel
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown

Move max_clk_rate to the corresponding ->setup() function to unify
with the rest.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-pxa2xx-pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index c2cbb002784a..5ac1487c9b3f 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -153,6 +153,8 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 		return -ENODEV;
 	}
 
+	c->max_clk_rate = 25000000;
+
 	dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(21, 0));
 	ret = devm_add_action_or_reset(&dev->dev, lpss_dma_put_device, dma_dev);
 	if (ret)
@@ -213,7 +215,6 @@ static struct pxa_spi_info spi_info_configs[] = {
 	},
 	[PORT_MRFLD] = {
 		.type = MRFLD_SSP,
-		.max_clk_rate = 25000000,
 		.setup = mrfld_spi_setup,
 	},
 	[PORT_QUARK_X1000] = {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v1 07/11] spi: pxa2xx-pci: Replace enum with direct use of PCI IDs
  2022-02-25 17:23 [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup() Andy Shevchenko
                   ` (4 preceding siblings ...)
  2022-02-25 17:23 ` [PATCH v1 06/11] spi: pxa2xx-pci: Move max_clk_rate " Andy Shevchenko
@ 2022-02-25 17:23 ` Andy Shevchenko
  2022-02-25 17:23 ` [PATCH v1 08/11] spi: pxa2xx-pci: Drop unneeded checks in lpss_spi_setup() Andy Shevchenko
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2022-02-25 17:23 UTC (permalink / raw)
  To: Andy Shevchenko, linux-arm-kernel, linux-spi, linux-kernel
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown

Instead of creating an abstraction on top of PCI IDs, just use them directly.
The corresponding enum can be dropped.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-pxa2xx-pci.c | 161 ++++++++++++++++++-----------------
 1 file changed, 83 insertions(+), 78 deletions(-)

diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index 5ac1487c9b3f..a0f24e811e9f 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -15,17 +15,17 @@
 #include <linux/dmaengine.h>
 #include <linux/platform_data/dma-dw.h>
 
-enum {
-	PORT_QUARK_X1000,
-	PORT_BYT,
-	PORT_MRFLD,
-	PORT_BSW0,
-	PORT_BSW1,
-	PORT_BSW2,
-	PORT_CE4100,
-	PORT_LPT0,
-	PORT_LPT1,
-};
+#define PCI_DEVICE_ID_INTEL_QUARK_X1000		0x0935
+#define PCI_DEVICE_ID_INTEL_BYT			0x0f0e
+#define PCI_DEVICE_ID_INTEL_MRFLD		0x1194
+#define PCI_DEVICE_ID_INTEL_BSW0		0x228e
+#define PCI_DEVICE_ID_INTEL_BSW1		0x2290
+#define PCI_DEVICE_ID_INTEL_BSW2		0x22ac
+#define PCI_DEVICE_ID_INTEL_CE4100		0x2e6a
+#define PCI_DEVICE_ID_INTEL_LPT0_0		0x9c65
+#define PCI_DEVICE_ID_INTEL_LPT0_1		0x9c66
+#define PCI_DEVICE_ID_INTEL_LPT1_0		0x9ce5
+#define PCI_DEVICE_ID_INTEL_LPT1_1		0x9ce6
 
 struct pxa_spi_info {
 	enum pxa_ssp_type type;
@@ -86,6 +86,49 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 	struct pci_dev *dma_dev;
 	int ret;
 
+	switch (dev->device) {
+	case PCI_DEVICE_ID_INTEL_BYT:
+		c->type = LPSS_BYT_SSP;
+		c->port_id = 0;
+		c->tx_param = &byt_tx_param;
+		c->rx_param = &byt_rx_param;
+		break;
+	case PCI_DEVICE_ID_INTEL_BSW0:
+		c->type = LPSS_BSW_SSP;
+		c->port_id = 0;
+		c->tx_param = &bsw0_tx_param;
+		c->rx_param = &bsw0_rx_param;
+		break;
+	case PCI_DEVICE_ID_INTEL_BSW1:
+		c->type = LPSS_BSW_SSP;
+		c->port_id = 1;
+		c->tx_param = &bsw1_tx_param;
+		c->rx_param = &bsw1_rx_param;
+		break;
+	case PCI_DEVICE_ID_INTEL_BSW2:
+		c->type = LPSS_BSW_SSP;
+		c->port_id = 2;
+		c->tx_param = &bsw2_tx_param;
+		c->rx_param = &bsw2_rx_param;
+		break;
+	case PCI_DEVICE_ID_INTEL_LPT0_0:
+	case PCI_DEVICE_ID_INTEL_LPT1_0:
+		c->type = LPSS_LPT_SSP;
+		c->port_id = 0;
+		c->tx_param = &lpt0_tx_param;
+		c->rx_param = &lpt0_rx_param;
+		break;
+	case PCI_DEVICE_ID_INTEL_LPT0_1:
+	case PCI_DEVICE_ID_INTEL_LPT1_1:
+		c->type = LPSS_LPT_SSP;
+		c->port_id = 1;
+		c->tx_param = &lpt1_tx_param;
+		c->rx_param = &lpt1_rx_param;
+		break;
+	default:
+		return -ENODEV;
+	}
+
 	c->num_chipselect = 1;
 	c->max_clk_rate = 50000000;
 
@@ -115,8 +158,13 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 	return 0;
 }
 
+static struct pxa_spi_info lpss_info_config = {
+	.setup = lpss_spi_setup,
+};
+
 static int ce4100_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 {
+	c->type = PXA25x_SSP;
 	c->port_id = dev->devfn;
 	c->num_chipselect = dev->devfn;
 	c->max_clk_rate = 3686400;
@@ -124,6 +172,10 @@ static int ce4100_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 	return 0;
 }
 
+static struct pxa_spi_info ce4100_info_config = {
+	.setup = ce4100_spi_setup,
+};
+
 static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 {
 	struct dw_dma_slave *tx, *rx;
@@ -153,6 +205,7 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 		return -ENODEV;
 	}
 
+	c->type = MRFLD_SSP;
 	c->max_clk_rate = 25000000;
 
 	dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(21, 0));
@@ -171,8 +224,13 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 	return 0;
 }
 
+static struct pxa_spi_info mrfld_info_config = {
+	.setup = mrfld_spi_setup,
+};
+
 static int qrk_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 {
+	c->type = QUARK_X1000_SSP;
 	c->port_id = dev->devfn;
 	c->num_chipselect = 1;
 	c->max_clk_rate = 50000000;
@@ -180,61 +238,8 @@ static int qrk_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 	return 0;
 }
 
-static struct pxa_spi_info spi_info_configs[] = {
-	[PORT_CE4100] = {
-		.type = PXA25x_SSP,
-		.setup = ce4100_spi_setup,
-	},
-	[PORT_BYT] = {
-		.type = LPSS_BYT_SSP,
-		.port_id = 0,
-		.setup = lpss_spi_setup,
-		.tx_param = &byt_tx_param,
-		.rx_param = &byt_rx_param,
-	},
-	[PORT_BSW0] = {
-		.type = LPSS_BSW_SSP,
-		.port_id = 0,
-		.setup = lpss_spi_setup,
-		.tx_param = &bsw0_tx_param,
-		.rx_param = &bsw0_rx_param,
-	},
-	[PORT_BSW1] = {
-		.type = LPSS_BSW_SSP,
-		.port_id = 1,
-		.setup = lpss_spi_setup,
-		.tx_param = &bsw1_tx_param,
-		.rx_param = &bsw1_rx_param,
-	},
-	[PORT_BSW2] = {
-		.type = LPSS_BSW_SSP,
-		.port_id = 2,
-		.setup = lpss_spi_setup,
-		.tx_param = &bsw2_tx_param,
-		.rx_param = &bsw2_rx_param,
-	},
-	[PORT_MRFLD] = {
-		.type = MRFLD_SSP,
-		.setup = mrfld_spi_setup,
-	},
-	[PORT_QUARK_X1000] = {
-		.type = QUARK_X1000_SSP,
-		.setup = qrk_spi_setup,
-	},
-	[PORT_LPT0] = {
-		.type = LPSS_LPT_SSP,
-		.port_id = 0,
-		.setup = lpss_spi_setup,
-		.tx_param = &lpt0_tx_param,
-		.rx_param = &lpt0_rx_param,
-	},
-	[PORT_LPT1] = {
-		.type = LPSS_LPT_SSP,
-		.port_id = 1,
-		.setup = lpss_spi_setup,
-		.tx_param = &lpt1_tx_param,
-		.rx_param = &lpt1_rx_param,
-	},
+static struct pxa_spi_info qrk_info_config = {
+	.setup = qrk_spi_setup,
 };
 
 static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
@@ -256,7 +261,7 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 	if (ret)
 		return ret;
 
-	c = &spi_info_configs[ent->driver_data];
+	c = (struct pxa_spi_info *)ent->driver_data;
 	ret = c->setup(dev, c);
 	if (ret)
 		return ret;
@@ -320,17 +325,17 @@ static void pxa2xx_spi_pci_remove(struct pci_dev *dev)
 }
 
 static const struct pci_device_id pxa2xx_spi_pci_devices[] = {
-	{ PCI_VDEVICE(INTEL, 0x0935), PORT_QUARK_X1000 },
-	{ PCI_VDEVICE(INTEL, 0x0f0e), PORT_BYT },
-	{ PCI_VDEVICE(INTEL, 0x1194), PORT_MRFLD },
-	{ PCI_VDEVICE(INTEL, 0x228e), PORT_BSW0 },
-	{ PCI_VDEVICE(INTEL, 0x2290), PORT_BSW1 },
-	{ PCI_VDEVICE(INTEL, 0x22ac), PORT_BSW2 },
-	{ PCI_VDEVICE(INTEL, 0x2e6a), PORT_CE4100 },
-	{ PCI_VDEVICE(INTEL, 0x9c65), PORT_LPT0 },
-	{ PCI_VDEVICE(INTEL, 0x9c66), PORT_LPT1 },
-	{ PCI_VDEVICE(INTEL, 0x9ce5), PORT_LPT0 },
-	{ PCI_VDEVICE(INTEL, 0x9ce6), PORT_LPT1 },
+	{ PCI_DEVICE_DATA(INTEL, QUARK_X1000, &qrk_info_config) },
+	{ PCI_DEVICE_DATA(INTEL, BYT, &lpss_info_config) },
+	{ PCI_DEVICE_DATA(INTEL, MRFLD, &mrfld_info_config) },
+	{ PCI_DEVICE_DATA(INTEL, BSW0, &lpss_info_config) },
+	{ PCI_DEVICE_DATA(INTEL, BSW1, &lpss_info_config) },
+	{ PCI_DEVICE_DATA(INTEL, BSW2, &lpss_info_config) },
+	{ PCI_DEVICE_DATA(INTEL, CE4100, &ce4100_info_config) },
+	{ PCI_DEVICE_DATA(INTEL, LPT0_0, &lpss_info_config) },
+	{ PCI_DEVICE_DATA(INTEL, LPT0_1, &lpss_info_config) },
+	{ PCI_DEVICE_DATA(INTEL, LPT1_0, &lpss_info_config) },
+	{ PCI_DEVICE_DATA(INTEL, LPT1_1, &lpss_info_config) },
 	{ }
 };
 MODULE_DEVICE_TABLE(pci, pxa2xx_spi_pci_devices);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v1 08/11] spi: pxa2xx-pci: Drop unneeded checks in lpss_spi_setup()
  2022-02-25 17:23 [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup() Andy Shevchenko
                   ` (5 preceding siblings ...)
  2022-02-25 17:23 ` [PATCH v1 07/11] spi: pxa2xx-pci: Replace enum with direct use of PCI IDs Andy Shevchenko
@ 2022-02-25 17:23 ` Andy Shevchenko
  2022-02-25 17:23 ` [PATCH v1 09/11] spi: pxa2xx-pci: Extract pxa2xx_spi_pci_clk_register() Andy Shevchenko
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2022-02-25 17:23 UTC (permalink / raw)
  To: Andy Shevchenko, linux-arm-kernel, linux-spi, linux-kernel
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown

All of the LPSS devices are using DMA and set the parameters up,
hence no need to test for that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-pxa2xx-pci.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index a0f24e811e9f..c041a9288d0c 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -83,6 +83,7 @@ static void lpss_dma_put_device(void *dma_dev)
 
 static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 {
+	struct dw_dma_slave *tx, *rx;
 	struct pci_dev *dma_dev;
 	int ret;
 
@@ -137,21 +138,15 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 	if (ret)
 		return ret;
 
-	if (c->tx_param) {
-		struct dw_dma_slave *slave = c->tx_param;
-
-		slave->dma_dev = &dma_dev->dev;
-		slave->m_master = 0;
-		slave->p_master = 1;
-	}
-
-	if (c->rx_param) {
-		struct dw_dma_slave *slave = c->rx_param;
+	tx = c->tx_param;
+	tx->dma_dev = &dma_dev->dev;
+	tx->m_master = 0;
+	tx->p_master = 1;
 
-		slave->dma_dev = &dma_dev->dev;
-		slave->m_master = 0;
-		slave->p_master = 1;
-	}
+	rx = c->rx_param;
+	rx->dma_dev = &dma_dev->dev;
+	rx->m_master = 0;
+	rx->p_master = 1;
 
 	c->dma_filter = lpss_dma_filter;
 	c->dma_burst_size = 1;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v1 09/11] spi: pxa2xx-pci: Extract pxa2xx_spi_pci_clk_register()
  2022-02-25 17:23 [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup() Andy Shevchenko
                   ` (6 preceding siblings ...)
  2022-02-25 17:23 ` [PATCH v1 08/11] spi: pxa2xx-pci: Drop unneeded checks in lpss_spi_setup() Andy Shevchenko
@ 2022-02-25 17:23 ` Andy Shevchenko
  2022-02-25 17:23 ` [PATCH v1 10/11] spi: pxa2xx-pci: Drop temporary storage use for a handful of members Andy Shevchenko
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2022-02-25 17:23 UTC (permalink / raw)
  To: Andy Shevchenko, linux-arm-kernel, linux-spi, linux-kernel
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown

Extract pxa2xx_spi_pci_clk_register() from ->probe() in order to reuse it
later on for getting rid of max_clk_rate temporary storage.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-pxa2xx-pci.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index c041a9288d0c..2dbe08034ad0 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -65,6 +65,24 @@ static struct dw_dma_slave lpt1_rx_param = { .src_id = 1 };
 static struct dw_dma_slave lpt0_tx_param = { .dst_id = 2 };
 static struct dw_dma_slave lpt0_rx_param = { .src_id = 3 };
 
+static void pxa2xx_spi_pci_clk_unregister(void *clk)
+{
+	clk_unregister(clk);
+}
+
+static int pxa2xx_spi_pci_clk_register(struct pci_dev *dev, struct ssp_device *ssp,
+				       unsigned long rate)
+{
+	char buf[40];
+
+	snprintf(buf, sizeof(buf), "pxa2xx-spi.%d", ssp->port_id);
+	ssp->clk = clk_register_fixed_rate(&dev->dev, buf, NULL, 0, rate);
+	if (IS_ERR(ssp->clk))
+		return PTR_ERR(ssp->clk);
+
+	return devm_add_action_or_reset(&dev->dev, pxa2xx_spi_pci_clk_unregister, ssp->clk);
+}
+
 static bool lpss_dma_filter(struct dma_chan *chan, void *param)
 {
 	struct dw_dma_slave *dws = param;
@@ -246,7 +264,6 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 	struct pxa2xx_spi_controller spi_pdata;
 	struct ssp_device *ssp;
 	struct pxa_spi_info *c;
-	char buf[40];
 
 	ret = pcim_enable_device(dev);
 	if (ret)
@@ -283,11 +300,9 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 		return ret;
 	ssp->irq = pci_irq_vector(dev, 0);
 
-	snprintf(buf, sizeof(buf), "pxa2xx-spi.%d", ssp->port_id);
-	ssp->clk = clk_register_fixed_rate(&dev->dev, buf, NULL, 0,
-					   c->max_clk_rate);
-	if (IS_ERR(ssp->clk))
-		return PTR_ERR(ssp->clk);
+	ret = pxa2xx_spi_pci_clk_register(dev, ssp, c->max_clk_rate);
+	if (ret)
+		return ret;
 
 	memset(&pi, 0, sizeof(pi));
 	pi.fwnode = dev_fwnode(&dev->dev);
@@ -298,10 +313,8 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 	pi.size_data = sizeof(spi_pdata);
 
 	pdev = platform_device_register_full(&pi);
-	if (IS_ERR(pdev)) {
-		clk_unregister(ssp->clk);
+	if (IS_ERR(pdev))
 		return PTR_ERR(pdev);
-	}
 
 	pci_set_drvdata(dev, pdev);
 
@@ -311,12 +324,8 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 static void pxa2xx_spi_pci_remove(struct pci_dev *dev)
 {
 	struct platform_device *pdev = pci_get_drvdata(dev);
-	struct pxa2xx_spi_controller *spi_pdata;
-
-	spi_pdata = dev_get_platdata(&pdev->dev);
 
 	platform_device_unregister(pdev);
-	clk_unregister(spi_pdata->ssp.clk);
 }
 
 static const struct pci_device_id pxa2xx_spi_pci_devices[] = {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v1 10/11] spi: pxa2xx-pci: Drop temporary storage use for a handful of members
  2022-02-25 17:23 [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup() Andy Shevchenko
                   ` (7 preceding siblings ...)
  2022-02-25 17:23 ` [PATCH v1 09/11] spi: pxa2xx-pci: Extract pxa2xx_spi_pci_clk_register() Andy Shevchenko
@ 2022-02-25 17:23 ` Andy Shevchenko
  2022-02-25 17:23 ` [PATCH v1 11/11] spi: pxa2xx-pci: Constify struct pxa_spi_info variables Andy Shevchenko
  2022-02-28 22:00 ` [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup() Mark Brown
  10 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2022-02-25 17:23 UTC (permalink / raw)
  To: Andy Shevchenko, linux-arm-kernel, linux-spi, linux-kernel
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown

Instead of using temporary storage, assign the values directly
to the corresponding struct pxa2xx_spi_controller members.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-pxa2xx-pci.c | 110 ++++++++++++++++-------------------
 1 file changed, 49 insertions(+), 61 deletions(-)

diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index 2dbe08034ad0..3c5d14affa95 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -28,19 +28,7 @@
 #define PCI_DEVICE_ID_INTEL_LPT1_1		0x9ce6
 
 struct pxa_spi_info {
-	enum pxa_ssp_type type;
-	unsigned int port_id;
-	unsigned int num_chipselect;
-	unsigned long max_clk_rate;
-
-	/* DMA channel request parameters */
-	bool (*dma_filter)(struct dma_chan *chan, void *param);
-	void *tx_param;
-	void *rx_param;
-
-	unsigned int dma_burst_size;
-
-	int (*setup)(struct pci_dev *pdev, struct pxa_spi_info *c);
+	int (*setup)(struct pci_dev *pdev, struct pxa2xx_spi_controller *c);
 };
 
 static struct dw_dma_slave byt_tx_param = { .dst_id = 0 };
@@ -99,48 +87,49 @@ static void lpss_dma_put_device(void *dma_dev)
 	pci_dev_put(dma_dev);
 }
 
-static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
+static int lpss_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c)
 {
+	struct ssp_device *ssp = &c->ssp;
 	struct dw_dma_slave *tx, *rx;
 	struct pci_dev *dma_dev;
 	int ret;
 
 	switch (dev->device) {
 	case PCI_DEVICE_ID_INTEL_BYT:
-		c->type = LPSS_BYT_SSP;
-		c->port_id = 0;
+		ssp->type = LPSS_BYT_SSP;
+		ssp->port_id = 0;
 		c->tx_param = &byt_tx_param;
 		c->rx_param = &byt_rx_param;
 		break;
 	case PCI_DEVICE_ID_INTEL_BSW0:
-		c->type = LPSS_BSW_SSP;
-		c->port_id = 0;
+		ssp->type = LPSS_BSW_SSP;
+		ssp->port_id = 0;
 		c->tx_param = &bsw0_tx_param;
 		c->rx_param = &bsw0_rx_param;
 		break;
 	case PCI_DEVICE_ID_INTEL_BSW1:
-		c->type = LPSS_BSW_SSP;
-		c->port_id = 1;
+		ssp->type = LPSS_BSW_SSP;
+		ssp->port_id = 1;
 		c->tx_param = &bsw1_tx_param;
 		c->rx_param = &bsw1_rx_param;
 		break;
 	case PCI_DEVICE_ID_INTEL_BSW2:
-		c->type = LPSS_BSW_SSP;
-		c->port_id = 2;
+		ssp->type = LPSS_BSW_SSP;
+		ssp->port_id = 2;
 		c->tx_param = &bsw2_tx_param;
 		c->rx_param = &bsw2_rx_param;
 		break;
 	case PCI_DEVICE_ID_INTEL_LPT0_0:
 	case PCI_DEVICE_ID_INTEL_LPT1_0:
-		c->type = LPSS_LPT_SSP;
-		c->port_id = 0;
+		ssp->type = LPSS_LPT_SSP;
+		ssp->port_id = 0;
 		c->tx_param = &lpt0_tx_param;
 		c->rx_param = &lpt0_rx_param;
 		break;
 	case PCI_DEVICE_ID_INTEL_LPT0_1:
 	case PCI_DEVICE_ID_INTEL_LPT1_1:
-		c->type = LPSS_LPT_SSP;
-		c->port_id = 1;
+		ssp->type = LPSS_LPT_SSP;
+		ssp->port_id = 1;
 		c->tx_param = &lpt1_tx_param;
 		c->rx_param = &lpt1_rx_param;
 		break;
@@ -149,7 +138,10 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 	}
 
 	c->num_chipselect = 1;
-	c->max_clk_rate = 50000000;
+
+	ret = pxa2xx_spi_pci_clk_register(dev, ssp, 50000000);
+	if (ret)
+		return ret;
 
 	dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
 	ret = devm_add_action_or_reset(&dev->dev, lpss_dma_put_device, dma_dev);
@@ -168,6 +160,7 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 
 	c->dma_filter = lpss_dma_filter;
 	c->dma_burst_size = 1;
+	c->enable_dma = 1;
 	return 0;
 }
 
@@ -175,41 +168,45 @@ static struct pxa_spi_info lpss_info_config = {
 	.setup = lpss_spi_setup,
 };
 
-static int ce4100_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
+static int ce4100_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c)
 {
-	c->type = PXA25x_SSP;
-	c->port_id = dev->devfn;
+	struct ssp_device *ssp = &c->ssp;
+
+	ssp->type = PXA25x_SSP;
+	ssp->port_id = dev->devfn;
 	c->num_chipselect = dev->devfn;
-	c->max_clk_rate = 3686400;
 
-	return 0;
+	return pxa2xx_spi_pci_clk_register(dev, ssp, 3686400);
 }
 
 static struct pxa_spi_info ce4100_info_config = {
 	.setup = ce4100_spi_setup,
 };
 
-static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
+static int mrfld_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c)
 {
+	struct ssp_device *ssp = &c->ssp;
 	struct dw_dma_slave *tx, *rx;
 	struct pci_dev *dma_dev;
 	int ret;
 
+	ssp->type = MRFLD_SSP;
+
 	switch (PCI_FUNC(dev->devfn)) {
 	case 0:
-		c->port_id = 3;
+		ssp->port_id = 3;
 		c->num_chipselect = 1;
 		c->tx_param = &mrfld3_tx_param;
 		c->rx_param = &mrfld3_rx_param;
 		break;
 	case 1:
-		c->port_id = 5;
+		ssp->port_id = 5;
 		c->num_chipselect = 4;
 		c->tx_param = &mrfld5_tx_param;
 		c->rx_param = &mrfld5_rx_param;
 		break;
 	case 2:
-		c->port_id = 6;
+		ssp->port_id = 6;
 		c->num_chipselect = 1;
 		c->tx_param = &mrfld6_tx_param;
 		c->rx_param = &mrfld6_rx_param;
@@ -218,8 +215,9 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 		return -ENODEV;
 	}
 
-	c->type = MRFLD_SSP;
-	c->max_clk_rate = 25000000;
+	ret = pxa2xx_spi_pci_clk_register(dev, ssp, 25000000);
+	if (ret)
+		return ret;
 
 	dma_dev = pci_get_slot(dev->bus, PCI_DEVFN(21, 0));
 	ret = devm_add_action_or_reset(&dev->dev, lpss_dma_put_device, dma_dev);
@@ -234,6 +232,7 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
 
 	c->dma_filter = lpss_dma_filter;
 	c->dma_burst_size = 8;
+	c->enable_dma = 1;
 	return 0;
 }
 
@@ -241,14 +240,15 @@ static struct pxa_spi_info mrfld_info_config = {
 	.setup = mrfld_spi_setup,
 };
 
-static int qrk_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)
+static int qrk_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c)
 {
-	c->type = QUARK_X1000_SSP;
-	c->port_id = dev->devfn;
+	struct ssp_device *ssp = &c->ssp;
+
+	ssp->type = QUARK_X1000_SSP;
+	ssp->port_id = dev->devfn;
 	c->num_chipselect = 1;
-	c->max_clk_rate = 50000000;
 
-	return 0;
+	return pxa2xx_spi_pci_clk_register(dev, ssp, 50000000);
 }
 
 static struct pxa_spi_info qrk_info_config = {
@@ -262,8 +262,8 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 	int ret;
 	struct platform_device *pdev;
 	struct pxa2xx_spi_controller spi_pdata;
+	struct pxa_spi_info *info;
 	struct ssp_device *ssp;
-	struct pxa_spi_info *c;
 
 	ret = pcim_enable_device(dev);
 	if (ret)
@@ -273,25 +273,17 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 	if (ret)
 		return ret;
 
-	c = (struct pxa_spi_info *)ent->driver_data;
-	ret = c->setup(dev, c);
-	if (ret)
-		return ret;
-
 	memset(&spi_pdata, 0, sizeof(spi_pdata));
-	spi_pdata.num_chipselect = c->num_chipselect;
-	spi_pdata.dma_filter = c->dma_filter;
-	spi_pdata.tx_param = c->tx_param;
-	spi_pdata.rx_param = c->rx_param;
-	spi_pdata.enable_dma = c->rx_param && c->tx_param;
-	spi_pdata.dma_burst_size = c->dma_burst_size;
 
 	ssp = &spi_pdata.ssp;
 	ssp->dev = &dev->dev;
 	ssp->phys_base = pci_resource_start(dev, 0);
 	ssp->mmio_base = pcim_iomap_table(dev)[0];
-	ssp->type = c->type;
-	ssp->port_id = c->port_id;
+
+	info = (struct pxa_spi_info *)ent->driver_data;
+	ret = info->setup(dev, &spi_pdata);
+	if (ret)
+		return ret;
 
 	pci_set_master(dev);
 
@@ -300,10 +292,6 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev,
 		return ret;
 	ssp->irq = pci_irq_vector(dev, 0);
 
-	ret = pxa2xx_spi_pci_clk_register(dev, ssp, c->max_clk_rate);
-	if (ret)
-		return ret;
-
 	memset(&pi, 0, sizeof(pi));
 	pi.fwnode = dev_fwnode(&dev->dev);
 	pi.parent = &dev->dev;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v1 11/11] spi: pxa2xx-pci: Constify struct pxa_spi_info variables
  2022-02-25 17:23 [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup() Andy Shevchenko
                   ` (8 preceding siblings ...)
  2022-02-25 17:23 ` [PATCH v1 10/11] spi: pxa2xx-pci: Drop temporary storage use for a handful of members Andy Shevchenko
@ 2022-02-25 17:23 ` Andy Shevchenko
  2022-02-28 22:00 ` [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup() Mark Brown
  10 siblings, 0 replies; 12+ messages in thread
From: Andy Shevchenko @ 2022-02-25 17:23 UTC (permalink / raw)
  To: Andy Shevchenko, linux-arm-kernel, linux-spi, linux-kernel
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Mark Brown

Now when there are no dynamical changes required, we may
constify struct pxa_spi_info variables.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-pxa2xx-pci.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c
index 3c5d14affa95..861b21c63504 100644
--- a/drivers/spi/spi-pxa2xx-pci.c
+++ b/drivers/spi/spi-pxa2xx-pci.c
@@ -164,7 +164,7 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c)
 	return 0;
 }
 
-static struct pxa_spi_info lpss_info_config = {
+static const struct pxa_spi_info lpss_info_config = {
 	.setup = lpss_spi_setup,
 };
 
@@ -179,7 +179,7 @@ static int ce4100_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c
 	return pxa2xx_spi_pci_clk_register(dev, ssp, 3686400);
 }
 
-static struct pxa_spi_info ce4100_info_config = {
+static const struct pxa_spi_info ce4100_info_config = {
 	.setup = ce4100_spi_setup,
 };
 
@@ -236,7 +236,7 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c)
 	return 0;
 }
 
-static struct pxa_spi_info mrfld_info_config = {
+static const struct pxa_spi_info mrfld_info_config = {
 	.setup = mrfld_spi_setup,
 };
 
@@ -251,18 +251,18 @@ static int qrk_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c)
 	return pxa2xx_spi_pci_clk_register(dev, ssp, 50000000);
 }
 
-static struct pxa_spi_info qrk_info_config = {
+static const struct pxa_spi_info qrk_info_config = {
 	.setup = qrk_spi_setup,
 };
 
 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 pxa_spi_info *info;
 	struct ssp_device *ssp;
 
 	ret = pcim_enable_device(dev);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup()
  2022-02-25 17:23 [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup() Andy Shevchenko
                   ` (9 preceding siblings ...)
  2022-02-25 17:23 ` [PATCH v1 11/11] spi: pxa2xx-pci: Constify struct pxa_spi_info variables Andy Shevchenko
@ 2022-02-28 22:00 ` Mark Brown
  10 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2022-02-28 22:00 UTC (permalink / raw)
  To: linux-kernel, Andy Shevchenko, linux-arm-kernel, linux-spi
  Cc: Haojian Zhuang, Daniel Mack, Robert Jarzmik

On Fri, 25 Feb 2022 19:23:40 +0200, Andy Shevchenko wrote:
> Refactor CE4100 handling code to use ->setup() instead of spreading
> potentially confusing conditional.
> 
> Besides that, it will allow to refactor further to avoid intermediate
> storage for the used configuration parameters.
> 
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup()
        commit: 78e27f970f73a4ee57dc050a6233e09a56963391
[02/11] spi: pxa2xx-pci: Refactor Quark X1000 to use ->setup()
        commit: 71ea0e3ac70a50b0c56105e116ed903f8e504e8f
[03/11] spi: pxa2xx-pci: Drop redundant NULL check in ->probe()
        commit: 1d9d62959f1b52eb939df38b9fda8beea455c751
[04/11] spi: pxa2xx-pci: Move port_id assignment to ->setup()
        commit: 108607ce4e39a51caca51aa97c44c31041a597d1
[05/11] spi: pxa2xx-pci: Move dma_burst_size assignment to ->setup()
        commit: bd2e24de10da015147b02f8c2c4b8ebea8fa9574
[06/11] spi: pxa2xx-pci: Move max_clk_rate assignment to ->setup()
        commit: 03f8e04e9f9be8d28c52ae801f37d49988f02ce4
[07/11] spi: pxa2xx-pci: Replace enum with direct use of PCI IDs
        commit: 7e425c3c3d15241aa5b6c442a83f11b8bc4fee91
[08/11] spi: pxa2xx-pci: Drop unneeded checks in lpss_spi_setup()
        commit: cb50f3f32a044ea45192a43e756b26048d35ba95
[09/11] spi: pxa2xx-pci: Extract pxa2xx_spi_pci_clk_register()
        commit: c3f4fc096b37bc2e4535f16ac3d65d517bbc14eb
[10/11] spi: pxa2xx-pci: Drop temporary storage use for a handful of members
        commit: ba8d1353d9c2d9190a523860e37bd7cb7b9de31b
[11/11] spi: pxa2xx-pci: Constify struct pxa_spi_info variables
        commit: fcaaf76ed5f3bbf346db9e49d9d9c0978d8f8dce

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-02-28 22:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-25 17:23 [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup() Andy Shevchenko
2022-02-25 17:23 ` [PATCH v1 02/11] spi: pxa2xx-pci: Refactor Quark X1000 " Andy Shevchenko
2022-02-25 17:23 ` [PATCH v1 03/11] spi: pxa2xx-pci: Drop redundant NULL check in ->probe() Andy Shevchenko
2022-02-25 17:23 ` [PATCH v1 04/11] spi: pxa2xx-pci: Move port_id assignment to ->setup() Andy Shevchenko
2022-02-25 17:23 ` [PATCH v1 05/11] spi: pxa2xx-pci: Move dma_burst_size " Andy Shevchenko
2022-02-25 17:23 ` [PATCH v1 06/11] spi: pxa2xx-pci: Move max_clk_rate " Andy Shevchenko
2022-02-25 17:23 ` [PATCH v1 07/11] spi: pxa2xx-pci: Replace enum with direct use of PCI IDs Andy Shevchenko
2022-02-25 17:23 ` [PATCH v1 08/11] spi: pxa2xx-pci: Drop unneeded checks in lpss_spi_setup() Andy Shevchenko
2022-02-25 17:23 ` [PATCH v1 09/11] spi: pxa2xx-pci: Extract pxa2xx_spi_pci_clk_register() Andy Shevchenko
2022-02-25 17:23 ` [PATCH v1 10/11] spi: pxa2xx-pci: Drop temporary storage use for a handful of members Andy Shevchenko
2022-02-25 17:23 ` [PATCH v1 11/11] spi: pxa2xx-pci: Constify struct pxa_spi_info variables Andy Shevchenko
2022-02-28 22:00 ` [PATCH v1 01/11] spi: pxa2xx-pci: Refactor CE4100 to use ->setup() Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).