[PATCH 0/3] spi: s3c64xx: use "cs-gpios" in spi node instead of "cs-gpio"

STALE4471d

7 messages, 3 authors, 2014-06-10 · open the first message on its own page

[PATCH 0/3] spi: s3c64xx: use "cs-gpios" in spi node instead of "cs-gpio"

From: Naveen Krishna Chatradhi <hidden>
Date: 2014-06-10 09:00:56

Currently, spi-s3c64xx.c needs "cs-gpio" chip select GPIO to be
defined under "controller-data" node under each slave node.

&spi_x {
	cs-gpios <>;
	...
	slave_node {

		controller-data {
			cs-gpio = <>;
			...
		};
		...
	};
	...
};

Where as, SPI core and many other drivers uses "cs-gpios" for
from device tree node.

Hence, make changes in spi-s3c64xx.c driver to make use of
"cs-gpios" from SPI node(parent) instead of "cs-gpio" defined in
slaves "controller-data"(child) node.

Also, fixes a compilation warning and corrects the DTS nodes for
Exynos4210 based SMDKv310, Exynos4412 based Trats2, Exynos5250 based
SMDK5250 boards.

Naveen Krishna Chatradhi (3):
based on for-next branch of spi.git
  spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio"
  spi: s3c64xx: remove a compilation warning with an assignment

based on for-next branch of linuxsamsung.git
  ARM: DTS: move "cs-gpio" from "controller-data" to under spi node

 arch/arm/boot/dts/exynos4210-smdkv310.dts |    2 +-
 arch/arm/boot/dts/exynos4412-trats2.dts   |    2 +-
 arch/arm/boot/dts/exynos5250-smdk5250.dts |    2 +-
 drivers/spi/spi-s3c64xx.c                 |   56 ++++++++++++++++++-----------
 4 files changed, 38 insertions(+), 24 deletions(-)

-- 
1.7.9.5

[PATCH 1/3] spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio"

From: Naveen Krishna Chatradhi <hidden>
Date: 2014-06-10 09:00:57

This patch makes the changes in spi-s3c64xx.c driver to make use of
"cs-gpios" from SPI node(parent) instead of "cs-gpio" defined in
slaves "controller-data"(child) node.

Signed-off-by: Naveen Krishna Chatradhi <redacted>
Cc: Javier Martinez Canillas <redacted>
Cc: Doug Anderson <dianders@chromium.org>
---
 drivers/spi/spi-s3c64xx.c |   56 ++++++++++++++++++++++++++++-----------------
 1 file changed, 35 insertions(+), 21 deletions(-)
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 75a5696..0c6013f 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -750,47 +750,56 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master,
 }
 
 static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata(
-				struct spi_device *spi)
+				struct spi_device *spi,
+				struct s3c64xx_spi_csinfo *cs)
 {
-	struct s3c64xx_spi_csinfo *cs;
-	struct device_node *slave_np, *data_np = NULL;
-	struct s3c64xx_spi_driver_data *sdd;
+	struct device_node *data_np = NULL;
 	u32 fb_delay = 0;
 
-	sdd = spi_master_get_devdata(spi->master);
-	slave_np = spi->dev.of_node;
-	if (!slave_np) {
-		dev_err(&spi->dev, "device node not found\n");
+	data_np = of_get_child_by_name(spi->dev.of_node, "controller-data");
+	if (!data_np) {
+		dev_err(&spi->dev, "child node 'controller-data' not found\n");
 		return ERR_PTR(-EINVAL);
 	}
 
-	data_np = of_get_child_by_name(slave_np, "controller-data");
-	if (!data_np) {
-		dev_err(&spi->dev, "child node 'controller-data' not found\n");
+	of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay);
+	cs->fb_delay = fb_delay;
+	of_node_put(data_np);
+
+	return cs;
+}
+
+static struct s3c64xx_spi_csinfo *s3c64xx_get_cs_gpios(struct spi_device *spi)
+{
+	struct device_node *parent_np = NULL;
+	struct s3c64xx_spi_driver_data *sdd;
+	struct s3c64xx_spi_csinfo *cs;
+
+	parent_np = of_get_parent(spi->dev.of_node);
+	if (!parent_np) {
+		dev_err(&spi->dev, "Parent node not found\n");
 		return ERR_PTR(-EINVAL);
 	}
 
+	sdd = spi_master_get_devdata(spi->master);
+
 	cs = kzalloc(sizeof(*cs), GFP_KERNEL);
 	if (!cs) {
-		of_node_put(data_np);
+		of_node_put(parent_np);
 		return ERR_PTR(-ENOMEM);
 	}
 
 	/* The CS line is asserted/deasserted by the gpio pin */
 	if (sdd->cs_gpio)
-		cs->line = of_get_named_gpio(data_np, "cs-gpio", 0);
+		cs->line = of_get_named_gpio(parent_np, "cs-gpios", 0);
 
 	if (!gpio_is_valid(cs->line)) {
 		dev_err(&spi->dev, "chip select gpio is not specified or invalid\n");
-		kfree(cs);
-		of_node_put(data_np);
+		of_node_put(parent_np);
 		return ERR_PTR(-EINVAL);
 	}
 
-	of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay);
-	cs->fb_delay = fb_delay;
-	of_node_put(data_np);
-	return cs;
+	return s3c64xx_get_slave_ctrldata(spi, cs);
 }
 
 /*
@@ -806,9 +815,14 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
 	struct s3c64xx_spi_info *sci;
 	int err;
 
+	if (!spi->dev.of_node) {
+		dev_err(&spi->dev, "device node not found\n");
+		return ERR_PTR(-EINVAL);
+	}
+
 	sdd = spi_master_get_devdata(spi->master);
 	if (!cs && spi->dev.of_node) {
-		cs = s3c64xx_get_slave_ctrldata(spi);
+		cs = s3c64xx_get_cs_gpios(spi);
 		spi->controller_data = cs;
 	}
 
@@ -1077,7 +1091,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
 	sdd->sfr_start = mem_res->start;
 	sdd->cs_gpio = true;
 	if (pdev->dev.of_node) {
-		if (!of_find_property(pdev->dev.of_node, "cs-gpio", NULL))
+		if (!of_find_property(pdev->dev.of_node, "cs-gpios", NULL))
 			sdd->cs_gpio = false;
 
 		ret = of_alias_get_id(pdev->dev.of_node, "spi");
-- 
1.7.9.5

[PATCH 2/3] spi: s3c64xx: remove a compilation warning with an assignment

From: Naveen Krishna Chatradhi <hidden>
Date: 2014-06-10 09:00:58

This patch returns an integer error value instead of the
pointer.

"warning: return makes integer from pointer without a cast"

Signed-off-by: Naveen Krishna Chatradhi <redacted>
Cc: Javier Martinez Canillas <redacted>
Cc: Doug Anderson <dianders@chromium.org>
---
 drivers/spi/spi-s3c64xx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 0c6013f..4594dde 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -817,7 +817,7 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
 
 	if (!spi->dev.of_node) {
 		dev_err(&spi->dev, "device node not found\n");
-		return ERR_PTR(-EINVAL);
+		return -EINVAL;
 	}
 
 	sdd = spi_master_get_devdata(spi->master);
-- 
1.7.9.5

[PATCH 3/3] ARM: DTS: move "cs-gpio" from "controller-data" to under spi node

From: Naveen Krishna Chatradhi <hidden>
Date: 2014-06-10 09:00:59

This patch moves the "cs-gpio" field from "controller-data" child
node to under the spi device node.

Respective changes are preposed to spi-s3c64xx.c driver.

Signed-off-by: Naveen Krishna Chatradhi <redacted>
Cc: Javier Martinez Canillas <redacted>
Cc: Doug Anderson <dianders@chromium.org>
---
 arch/arm/boot/dts/exynos4210-smdkv310.dts |    2 +-
 arch/arm/boot/dts/exynos4412-trats2.dts   |    2 +-
 arch/arm/boot/dts/exynos5250-smdk5250.dts |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm/boot/dts/exynos4210-smdkv310.dts b/arch/arm/boot/dts/exynos4210-smdkv310.dts
index 636d166..9191491 100644
--- a/arch/arm/boot/dts/exynos4210-smdkv310.dts
+++ b/arch/arm/boot/dts/exynos4210-smdkv310.dts
@@ -169,6 +169,7 @@
 
 	spi_2: spi at 13940000 {
 		status = "okay";
+		cs-gpios = <&gpc1 2 0>;
 
 		w25x80 at 0 {
 			#address-cells = <1>;
@@ -178,7 +179,6 @@
 			spi-max-frequency = <1000000>;
 
 			controller-data {
-				cs-gpio = <&gpc1 2 0>;
 				samsung,spi-feedback-delay = <0>;
 			};
 
diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts b/arch/arm/boot/dts/exynos4412-trats2.dts
index 8a558b7..204b0de 100644
--- a/arch/arm/boot/dts/exynos4412-trats2.dts
+++ b/arch/arm/boot/dts/exynos4412-trats2.dts
@@ -512,6 +512,7 @@
 	spi_1: spi at 13930000 {
 		pinctrl-names = "default";
 		pinctrl-0 = <&spi1_bus>;
+		cs-gpios = <&gpb 5 0>;
 		status = "okay";
 
 		s5c73m3_spi: s5c73m3 {
@@ -519,7 +520,6 @@
 			spi-max-frequency = <50000000>;
 			reg = <0>;
 			controller-data {
-				cs-gpio = <&gpb 5 0>;
 				samsung,spi-feedback-delay = <2>;
 			};
 		};
diff --git a/arch/arm/boot/dts/exynos5250-smdk5250.dts b/arch/arm/boot/dts/exynos5250-smdk5250.dts
index a794a70..0c6433a 100644
--- a/arch/arm/boot/dts/exynos5250-smdk5250.dts
+++ b/arch/arm/boot/dts/exynos5250-smdk5250.dts
@@ -316,6 +316,7 @@
 	};
 
 	spi_1: spi at 12d30000 {
+		cs-gpios = <&gpa2 5 0>;
 		status = "okay";
 
 		w25q80bw at 0 {
@@ -326,7 +327,6 @@
 			spi-max-frequency = <1000000>;
 
 			controller-data {
-				cs-gpio = <&gpa2 5 0>;
 				samsung,spi-feedback-delay = <0>;
 			};
 
-- 
1.7.9.5

[PATCH 2/3] spi: s3c64xx: remove a compilation warning with an assignment

From: Sachin Kamat <hidden>
Date: 2014-06-10 09:45:03

Hi Naveen,

On Tue, Jun 10, 2014 at 2:30 PM, Naveen Krishna Chatradhi
[off-list ref] wrote:
quoted hunk
This patch returns an integer error value instead of the
pointer.

"warning: return makes integer from pointer without a cast"

Signed-off-by: Naveen Krishna Chatradhi <redacted>
Cc: Javier Martinez Canillas <redacted>
Cc: Doug Anderson <dianders@chromium.org>
---
 drivers/spi/spi-s3c64xx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 0c6013f..4594dde 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -817,7 +817,7 @@ static int s3c64xx_spi_setup(struct spi_device *spi)

        if (!spi->dev.of_node) {
                dev_err(&spi->dev, "device node not found\n");
-               return ERR_PTR(-EINVAL);
+               return -EINVAL;
Isn't this warning introduced by the previous patch (patch1/3)?
If so then this patch should be squashed into that.

-- 
Regards,
Sachin.

[PATCH 1/3] spi: s3c64xx: use "cs-gpios" from spi node instead of "cs-gpio"

From: Naveen Krishna Ch <hidden>
Date: 2014-06-10 09:48:30

Hello All,


On 10 June 2014 14:30, Naveen Krishna Chatradhi [off-list ref] wrote:
quoted hunk
This patch makes the changes in spi-s3c64xx.c driver to make use of
"cs-gpios" from SPI node(parent) instead of "cs-gpio" defined in
slaves "controller-data"(child) node.

Signed-off-by: Naveen Krishna Chatradhi <redacted>
Cc: Javier Martinez Canillas <redacted>
Cc: Doug Anderson <dianders@chromium.org>
---
 drivers/spi/spi-s3c64xx.c |   56 ++++++++++++++++++++++++++++-----------------
 1 file changed, 35 insertions(+), 21 deletions(-)
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 75a5696..0c6013f 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -750,47 +750,56 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master,
 }

 static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata(
-                               struct spi_device *spi)
+                               struct spi_device *spi,
+                               struct s3c64xx_spi_csinfo *cs)
 {
-       struct s3c64xx_spi_csinfo *cs;
-       struct device_node *slave_np, *data_np = NULL;
-       struct s3c64xx_spi_driver_data *sdd;
+       struct device_node *data_np = NULL;
        u32 fb_delay = 0;

-       sdd = spi_master_get_devdata(spi->master);
-       slave_np = spi->dev.of_node;
-       if (!slave_np) {
-               dev_err(&spi->dev, "device node not found\n");
+       data_np = of_get_child_by_name(spi->dev.of_node, "controller-data");
+       if (!data_np) {
+               dev_err(&spi->dev, "child node 'controller-data' not found\n");
                return ERR_PTR(-EINVAL);
        }

-       data_np = of_get_child_by_name(slave_np, "controller-data");
-       if (!data_np) {
-               dev_err(&spi->dev, "child node 'controller-data' not found\n");
+       of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay);
+       cs->fb_delay = fb_delay;
+       of_node_put(data_np);
+
+       return cs;
+}
+
+static struct s3c64xx_spi_csinfo *s3c64xx_get_cs_gpios(struct spi_device *spi)
+{
+       struct device_node *parent_np = NULL;
+       struct s3c64xx_spi_driver_data *sdd;
+       struct s3c64xx_spi_csinfo *cs;
+
+       parent_np = of_get_parent(spi->dev.of_node);
+       if (!parent_np) {
+               dev_err(&spi->dev, "Parent node not found\n");
                return ERR_PTR(-EINVAL);
        }

+       sdd = spi_master_get_devdata(spi->master);
+
        cs = kzalloc(sizeof(*cs), GFP_KERNEL);
        if (!cs) {
-               of_node_put(data_np);
+               of_node_put(parent_np);
                return ERR_PTR(-ENOMEM);
        }

        /* The CS line is asserted/deasserted by the gpio pin */
        if (sdd->cs_gpio)
-               cs->line = of_get_named_gpio(data_np, "cs-gpio", 0);
+               cs->line = of_get_named_gpio(parent_np, "cs-gpios", 0);

        if (!gpio_is_valid(cs->line)) {
                dev_err(&spi->dev, "chip select gpio is not specified or invalid\n");
-               kfree(cs);
-               of_node_put(data_np);
+               of_node_put(parent_np);
                return ERR_PTR(-EINVAL);
        }

-       of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay);
-       cs->fb_delay = fb_delay;
-       of_node_put(data_np);
-       return cs;
+       return s3c64xx_get_slave_ctrldata(spi, cs);
 }

 /*
@@ -806,9 +815,14 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
        struct s3c64xx_spi_info *sci;
        int err;

+       if (!spi->dev.of_node) {
+               dev_err(&spi->dev, "device node not found\n");
+               return ERR_PTR(-EINVAL);
+       }
+
        sdd = spi_master_get_devdata(spi->master);
        if (!cs && spi->dev.of_node) {
-               cs = s3c64xx_get_slave_ctrldata(spi);
+               cs = s3c64xx_get_cs_gpios(spi);
                spi->controller_data = cs;
        }
@@ -1077,7 +1091,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
        sdd->sfr_start = mem_res->start;
        sdd->cs_gpio = true;
        if (pdev->dev.of_node) {
-               if (!of_find_property(pdev->dev.of_node, "cs-gpio", NULL))
+               if (!of_find_property(pdev->dev.of_node, "cs-gpios", NULL))
                        sdd->cs_gpio = false;

                ret = of_alias_get_id(pdev->dev.of_node, "spi");
--
1.7.9.5
Forgot to add the DTS documentation.
Will quickly respin. Thanks.


-- 
Shine bright,
(: Nav :)

[PATCH 2/3] spi: s3c64xx: remove a compilation warning with an assignment

From: Naveen Krishna Ch <hidden>
Date: 2014-06-10 09:53:20

Hello Sachin,

On 10 June 2014 15:15, Sachin Kamat [off-list ref] wrote:
Hi Naveen,

On Tue, Jun 10, 2014 at 2:30 PM, Naveen Krishna Chatradhi
[off-list ref] wrote:
quoted
This patch returns an integer error value instead of the
pointer.

"warning: return makes integer from pointer without a cast"

Signed-off-by: Naveen Krishna Chatradhi <redacted>
Cc: Javier Martinez Canillas <redacted>
Cc: Doug Anderson <dianders@chromium.org>
---
 drivers/spi/spi-s3c64xx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 0c6013f..4594dde 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -817,7 +817,7 @@ static int s3c64xx_spi_setup(struct spi_device *spi)

        if (!spi->dev.of_node) {
                dev_err(&spi->dev, "device node not found\n");
-               return ERR_PTR(-EINVAL);
+               return -EINVAL;
Isn't this warning introduced by the previous patch (patch1/3)?
If so then this patch should be squashed into that.
You are right, I've introduced this warning in the 1st patch.
But, realized it only latter. Will spin along with the documentation.
--
Regards,
Sachin.


-- 
Shine bright,
(: Nav :)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help