aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@st.com>2012-09-18 03:10:49 -0400
committerRob Herring <rob.herring@calxeda.com>2012-10-01 11:50:26 -0400
commit06455bbcab76e5f5225de5f38ab948d37a1c3587 (patch)
tree65102813735352fc40a31fca68edca5e5fec2b29 /drivers/spi
parent9c19761a7ecdc86abb2fba0feb81e8952eccc1f1 (diff)
dt/s3c64xx/spi: Use of_get_child_by_name to get a named child
As follow-up to "dt: introduce of_get_child_by_name to get child node by name." patch, This patch removes some of the code duplication in the driver by replacing it with of_get_child_by_name instead. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-s3c64xx.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 646a7657fe62..12b8c9c608ed 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -835,9 +835,7 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata(
835 return ERR_PTR(-EINVAL); 835 return ERR_PTR(-EINVAL);
836 } 836 }
837 837
838 for_each_child_of_node(slave_np, data_np) 838 data_np = of_get_child_by_name(slave_np, "controller-data");
839 if (!strcmp(data_np->name, "controller-data"))
840 break;
841 if (!data_np) { 839 if (!data_np) {
842 dev_err(&spi->dev, "child node 'controller-data' not found\n"); 840 dev_err(&spi->dev, "child node 'controller-data' not found\n");
843 return ERR_PTR(-EINVAL); 841 return ERR_PTR(-EINVAL);
@@ -847,6 +845,7 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata(
847 if (!cs) { 845 if (!cs) {
848 dev_err(&spi->dev, "could not allocate memory for controller" 846 dev_err(&spi->dev, "could not allocate memory for controller"
849 " data\n"); 847 " data\n");
848 of_node_put(data_np);
850 return ERR_PTR(-ENOMEM); 849 return ERR_PTR(-ENOMEM);
851 } 850 }
852 851
@@ -855,11 +854,13 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata(
855 dev_err(&spi->dev, "chip select gpio is not specified or " 854 dev_err(&spi->dev, "chip select gpio is not specified or "
856 "invalid\n"); 855 "invalid\n");
857 kfree(cs); 856 kfree(cs);
857 of_node_put(data_np);
858 return ERR_PTR(-EINVAL); 858 return ERR_PTR(-EINVAL);
859 } 859 }
860 860
861 of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay); 861 of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay);
862 cs->fb_delay = fb_delay; 862 cs->fb_delay = fb_delay;
863 of_node_put(data_np);
863 return cs; 864 return cs;
864} 865}
865 866