mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
mmc: atmel-mci: Simplify with scoped for each OF child loop
Use scoped for-each loop when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Reviewed-by: Nicolas Ferre <nicolas.ferre@microchip.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
parent
0621d52b1d
commit
e8c23b466b
|
|
@ -629,14 +629,13 @@ static int atmci_of_init(struct atmel_mci *host)
|
|||
{
|
||||
struct device *dev = host->dev;
|
||||
struct device_node *np = dev->of_node;
|
||||
struct device_node *cnp;
|
||||
u32 slot_id;
|
||||
int err;
|
||||
|
||||
if (!np)
|
||||
return dev_err_probe(dev, -EINVAL, "device node not found\n");
|
||||
|
||||
for_each_child_of_node(np, cnp) {
|
||||
for_each_child_of_node_scoped(np, cnp) {
|
||||
if (of_property_read_u32(cnp, "reg", &slot_id)) {
|
||||
dev_warn(dev, "reg property is missing for %pOF\n", cnp);
|
||||
continue;
|
||||
|
|
@ -645,7 +644,6 @@ static int atmci_of_init(struct atmel_mci *host)
|
|||
if (slot_id >= ATMCI_MAX_NR_SLOTS) {
|
||||
dev_warn(dev, "can't have more than %d slots\n",
|
||||
ATMCI_MAX_NR_SLOTS);
|
||||
of_node_put(cnp);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -658,10 +656,8 @@ static int atmci_of_init(struct atmel_mci *host)
|
|||
"cd", GPIOD_IN, "cd-gpios");
|
||||
err = PTR_ERR_OR_ZERO(host->pdata[slot_id].detect_pin);
|
||||
if (err) {
|
||||
if (err != -ENOENT) {
|
||||
of_node_put(cnp);
|
||||
if (err != -ENOENT)
|
||||
return err;
|
||||
}
|
||||
host->pdata[slot_id].detect_pin = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -673,10 +669,8 @@ static int atmci_of_init(struct atmel_mci *host)
|
|||
"wp", GPIOD_IN, "wp-gpios");
|
||||
err = PTR_ERR_OR_ZERO(host->pdata[slot_id].wp_pin);
|
||||
if (err) {
|
||||
if (err != -ENOENT) {
|
||||
of_node_put(cnp);
|
||||
if (err != -ENOENT)
|
||||
return err;
|
||||
}
|
||||
host->pdata[slot_id].wp_pin = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user