[U-Boot] [PATCH] power: extend prefix match to regulator-name property

Felix Brack fb at ltec.ch
Fri Oct 13 15:02:28 UTC 2017


Hello Simon,

On 12.10.2017 04:07, Simon Glass wrote:
> Hi Felix,
> 
> On 9 October 2017 at 03:04, Felix Brack <fb at ltec.ch> wrote:
>>
>> This patch extends pmic_bind_children prefix matching. In addition to
>> the node name the property regulator-name is used while trying to match
>> prefixes. This allows assigning different drivers to regulator nodes
>> named regulator at 1 and regulator at 10 for example.
>> Signed-off-by: Felix Brack <fb at ltec.ch>
>> ---
>>
>>  drivers/power/pmic/pmic-uclass.c | 15 +++++++++++++--
>>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> Can you please add a sandbox test and documentation for this?
> 
I just forgot to extend the documentation. I will do so of course as
soon as the node property for matching has been fixed.

I think the test itself does already exist (test/dm/regulator.c). I will
have to add a regulator to arch/sandbox/dts/sandbox_pmic.dtsi. This
regulator will have a node name prefix other then 'buck' or 'ldo' for my
code to do the matching. Some other files will also need modifications
for the test to work correctly.

> See:
> 
> test/dm/pmic.c
> doc/driver-model/pmic-framework.txt
> 
>>
>> diff --git a/drivers/power/pmic/pmic-uclass.c b/drivers/power/pmic/pmic-uclass.c
>> index 64964e4..5a034f0 100644
>> --- a/drivers/power/pmic/pmic-uclass.c
>> +++ b/drivers/power/pmic/pmic-uclass.c
>> @@ -26,6 +26,7 @@ int pmic_bind_children(struct udevice *pmic, ofnode parent,
>>         struct driver *drv;
>>         struct udevice *child;
>>         const char *node_name;
>> +       const char *reg_name;
>>         int bind_count = 0;
>>         ofnode node;
>>         int prefix_len;
>> @@ -44,8 +45,18 @@ int pmic_bind_children(struct udevice *pmic, ofnode parent,
>>                         debug("  - compatible prefix: '%s'\n", info->prefix);
>>
>>                         prefix_len = strlen(info->prefix);
>> -                       if (strncmp(info->prefix, node_name, prefix_len))
>> -                               continue;
>> +                       if (strncmp(info->prefix, node_name, prefix_len)) {
>> +                               reg_name = ofnode_read_string(node,
>> +                                                             "regulator-name");
>> +                               if (reg_name) {
>> +                                       if (strncmp(info->prefix, reg_name,
>> +                                                   prefix_len)) {
>> +                                               continue;
>> +                                       }
>> +                               } else {
>> +                                       continue;
>> +                               }
>> +                       }
>>
>>                         drv = lists_driver_lookup_name(info->driver);
>>                         if (!drv) {
>> --
>> 2.7.4
>>
> 
> Regards,
> Simon
> 

regards, Felix


More information about the U-Boot mailing list