[PATCH] spi: imx: Remove the use of property "fsl, spi-num-chipselects"

Alexander Shiyan shc_work at mail.ru
Fri Jun 24 08:04:22 PDT 2016


The "fsl,spi-num-chipselects" property will be marked obsolete soon.
This patch updates the driver to be ready to such changes.

Signed-off-by: Alexander Shiyan <shc_work at mail.ru>
---
 drivers/spi/imx_spi.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c
index 99ec228..dc7a8c8 100644
--- a/drivers/spi/imx_spi.c
+++ b/drivers/spi/imx_spi.c
@@ -515,23 +515,16 @@ static __maybe_unused struct spi_imx_devtype_data spi_imx_devtype_data_2_3 = {
 static int imx_spi_dt_probe(struct imx_spi *imx)
 {
 	struct device_node *node = imx->master.dev->device_node;
-	int ret, i;
-	u32 num_cs;
+	int i;
 
 	if (!node)
 		return -ENODEV;
 
-	ret = of_property_read_u32(node, "fsl,spi-num-chipselects", &num_cs);
-	if (ret)
-		return ret;
-
-	imx->master.num_chipselect = num_cs;
-	imx->cs_array = xzalloc(sizeof(u32) * num_cs);
+	imx->master.num_chipselect = of_gpio_named_count(node, "cs-gpios");
+	imx->cs_array = xzalloc(sizeof(u32) * imx->master.num_chipselect);
 
-	for (i = 0; i < num_cs; i++) {
-		int cs_gpio = of_get_named_gpio(node, "cs-gpios", i);
-		imx->cs_array[i] = cs_gpio;
-	}
+	for (i = 0; i < imx->master.num_chipselect; i++)
+		imx->cs_array[i] = of_get_named_gpio(node, "cs-gpios", i);
 
 	return 0;
 }
-- 
2.4.9




More information about the barebox mailing list