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>
This commit is contained in:
committed by
Rob Herring
parent
9c19761a7e
commit
06455bbcab
@@ -835,9 +835,7 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata(
|
|||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_child_of_node(slave_np, data_np)
|
data_np = of_get_child_by_name(slave_np, "controller-data");
|
||||||
if (!strcmp(data_np->name, "controller-data"))
|
|
||||||
break;
|
|
||||||
if (!data_np) {
|
if (!data_np) {
|
||||||
dev_err(&spi->dev, "child node 'controller-data' not found\n");
|
dev_err(&spi->dev, "child node 'controller-data' not found\n");
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
@@ -847,6 +845,7 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata(
|
|||||||
if (!cs) {
|
if (!cs) {
|
||||||
dev_err(&spi->dev, "could not allocate memory for controller"
|
dev_err(&spi->dev, "could not allocate memory for controller"
|
||||||
" data\n");
|
" data\n");
|
||||||
|
of_node_put(data_np);
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -855,11 +854,13 @@ static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata(
|
|||||||
dev_err(&spi->dev, "chip select gpio is not specified or "
|
dev_err(&spi->dev, "chip select gpio is not specified or "
|
||||||
"invalid\n");
|
"invalid\n");
|
||||||
kfree(cs);
|
kfree(cs);
|
||||||
|
of_node_put(data_np);
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay);
|
of_property_read_u32(data_np, "samsung,spi-feedback-delay", &fb_delay);
|
||||||
cs->fb_delay = fb_delay;
|
cs->fb_delay = fb_delay;
|
||||||
|
of_node_put(data_np);
|
||||||
return cs;
|
return cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user