[U-Boot] [PATCH 04/13] dm: pinctrl: migrate pinctrl-generic to livetree

2019-10-23 Thread Patrick Delaunay
Migrate pinctrl-generic to livetree:
- ofnode_get_first_property
- ofnode_get_next_property
- ofnode_get_property_by_prop
- ofnode_read_string_count
- ofnode_read_string_index
and get rid of DECLARE_GLOBAL_DATA_PTR.

This solve parsing issue during test in sandbox for pin
configuration (OF_LIVE is activated in sandbox_defconfig
and sub node are not correctly parsed in
pinctrl_generic_set_state_subnode with fdt lib API).

Signed-off-by: Patrick Delaunay 
---

 drivers/pinctrl/pinctrl-generic.c | 36 +++
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-generic.c 
b/drivers/pinctrl/pinctrl-generic.c
index eecf0f5dc1..474a2e65ca 100644
--- a/drivers/pinctrl/pinctrl-generic.c
+++ b/drivers/pinctrl/pinctrl-generic.c
@@ -8,8 +8,6 @@
 #include 
 #include 
 
-DECLARE_GLOBAL_DATA_PTR;
-
 /**
  * pinctrl_pin_name_to_selector() - return the pin selector for a pin
  *
@@ -243,18 +241,18 @@ static int pinctrl_generic_set_state_one(struct udevice 
*dev,
 struct udevice *config,
 bool is_group, unsigned selector)
 {
-   const void *fdt = gd->fdt_blob;
-   int node_offset = dev_of_offset(config);
const char *propname;
const void *value;
-   int prop_offset, len, func_selector, param, ret;
+   const void *property;
+   int len, func_selector, param, ret;
u32 arg, default_val;
 
-   for (prop_offset = fdt_first_property_offset(fdt, node_offset);
-prop_offset > 0;
-prop_offset = fdt_next_property_offset(fdt, prop_offset)) {
-   value = fdt_getprop_by_offset(fdt, prop_offset,
- &propname, &len);
+   for (property = ofnode_get_first_property(dev_ofnode(config));
+property;
+property = ofnode_get_next_property(dev_ofnode(config),
+property)) {
+   value = ofnode_get_property_by_prop(dev_ofnode(config),
+   property, &propname, &len);
if (!value)
return -EINVAL;
 
@@ -298,19 +296,18 @@ static int pinctrl_generic_set_state_one(struct udevice 
*dev,
 static int pinctrl_generic_set_state_subnode(struct udevice *dev,
 struct udevice *config)
 {
-   const void *fdt = gd->fdt_blob;
-   int node = dev_of_offset(config);
const char *subnode_target_type = "pins";
bool is_group = false;
const char *name;
int strings_count, selector, i, ret;
 
-   strings_count = fdt_stringlist_count(fdt, node, subnode_target_type);
+   strings_count = ofnode_read_string_count(dev_ofnode(config),
+subnode_target_type);
if (strings_count < 0) {
subnode_target_type = "groups";
is_group = true;
-   strings_count = fdt_stringlist_count(fdt, node,
-subnode_target_type);
+   strings_count = ofnode_read_string_count(dev_ofnode(config),
+subnode_target_type);
if (strings_count < 0) {
/* skip this node; may contain config child nodes */
return 0;
@@ -318,10 +315,11 @@ static int pinctrl_generic_set_state_subnode(struct 
udevice *dev,
}
 
for (i = 0; i < strings_count; i++) {
-   name = fdt_stringlist_get(fdt, node, subnode_target_type, i,
- NULL);
-   if (!name)
-   return -EINVAL;
+   ret = ofnode_read_string_index(dev_ofnode(config),
+  subnode_target_type, i,
+  &name);
+   if (ret)
+   return ret;
 
if (is_group)
selector = pinctrl_group_name_to_selector(dev, name);
-- 
2.17.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 04/13] dm: pinctrl: migrate pinctrl-generic to livetree

2019-10-29 Thread Simon Glass
Hi Patrick,

On Wed, 23 Oct 2019 at 07:45, Patrick Delaunay  wrote:
>
> Migrate pinctrl-generic to livetree:
> - ofnode_get_first_property
> - ofnode_get_next_property
> - ofnode_get_property_by_prop
> - ofnode_read_string_count
> - ofnode_read_string_index
> and get rid of DECLARE_GLOBAL_DATA_PTR.
>
> This solve parsing issue during test in sandbox for pin
> configuration (OF_LIVE is activated in sandbox_defconfig
> and sub node are not correctly parsed in
> pinctrl_generic_set_state_subnode with fdt lib API).
>
> Signed-off-by: Patrick Delaunay 
> ---
>
>  drivers/pinctrl/pinctrl-generic.c | 36 +++
>  1 file changed, 17 insertions(+), 19 deletions(-)
>

It looks like this should use dev_read_...() too.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 04/13] dm: pinctrl: migrate pinctrl-generic to livetree

2019-10-31 Thread Patrick DELAUNAY
Hi Simon

> From: Simon Glass 
> Sent: mercredi 30 octobre 2019 02:48
> 
> Hi Patrick,
> 
> On Wed, 23 Oct 2019 at 07:45, Patrick Delaunay 
> wrote:
> >
> > Migrate pinctrl-generic to livetree:
> > - ofnode_get_first_property
> > - ofnode_get_next_property
> > - ofnode_get_property_by_prop
> > - ofnode_read_string_count
> > - ofnode_read_string_index
> > and get rid of DECLARE_GLOBAL_DATA_PTR.
> >
> > This solve parsing issue during test in sandbox for pin configuration
> > (OF_LIVE is activated in sandbox_defconfig and sub node are not
> > correctly parsed in pinctrl_generic_set_state_subnode with fdt lib
> > API).
> >
> > Signed-off-by: Patrick Delaunay 
> > ---
> >
> >  drivers/pinctrl/pinctrl-generic.c | 36
> > +++
> >  1 file changed, 17 insertions(+), 19 deletions(-)
> >
> 
> It looks like this should use dev_read_...() too.

Yes I miss it.

Thanks

 
> Regards,
> Simon

Regards
Patrick
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot