[PATCH v2 5/5] regulator: map consumer regulator based on device tree

Nayak, Rajendra rnayak at ti.com
Tue Oct 11 03:08:53 EDT 2011


>
>> +     if (supply) {
>> +             struct regulator_dev *r;
>> +             struct device_node *node;
>> +
>> +             /* first do a dt based lookup */
>> +             if (dev) {
>> +                     node = of_get_regulator(dev, supply);
>> +                     if (node)
>> +                             list_for_each_entry(r, &regulator_list, list)
>> +                                     if (node == r->dev.parent->of_node)
>> +                                             goto found;
>>               }
>>
>> -             if (!found) {
>> -                     dev_err(dev, "Failed to find supply %s\n",
>> -                             init_data->supply_regulator);
>> -                     ret = -ENODEV;
>> -                     goto scrub;
>> -             }
>> +             /* next try doing it non-dt way */
>> +             list_for_each_entry(r, &regulator_list, list)
>> +                     if (strcmp(rdev_get_name(r), supply) == 0)
>> +                             goto found;
>>
>> +             dev_err(dev, "Failed to find supply %s\n", supply);
>> +             ret = -ENODEV;
>> +             goto scrub;
>> +
>> +found:
>
> This is all getting *really* complicated and illegible.  I'm not sure
> what the best way to structure is but erroring out early looks useful.
>

How about this updated patch?



More information about the linux-arm-kernel mailing list