From: Sascha Hauer <s.hauer@pengutronix.de>
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 06/22] OF: base: sync of_find_property with linux OF API
Date: Thu, 20 Jun 2013 10:57:43 +0200 [thread overview]
Message-ID: <20130620085743.GR32299@pengutronix.de> (raw)
In-Reply-To: <1371632991-1504-7-git-send-email-sebastian.hesselbarth@gmail.com>
On Wed, Jun 19, 2013 at 11:09:35AM +0200, Sebastian Hesselbarth wrote:
> To start synchronizing OF API of barebox with linux OF API, this adds
> a length pointer to of_find_property. Also all current users of that
> function are updated to reflect the API change.
>
> Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> ---
> Cc: barebox@lists.infradead.org
> ---
> commands/of_property.c | 2 +-
> drivers/of/base.c | 38 ++++++++++++++++++--------------------
> drivers/of/fdt.c | 5 ++++-
> drivers/of/of_net.c | 6 +++---
> drivers/pinctrl/pinctrl.c | 4 ++--
> drivers/spi/spi.c | 10 +++++-----
> drivers/usb/imx/chipidea-imx.c | 3 ++-
> include/of.h | 12 ++++++++++--
> 8 files changed, 45 insertions(+), 35 deletions(-)
>
> diff --git a/commands/of_property.c b/commands/of_property.c
> index 44bb388..d1a9a17 100644
> --- a/commands/of_property.c
> +++ b/commands/of_property.c
> @@ -212,7 +212,7 @@ static int do_of_property(int argc, char *argv[])
> if (optind + 1 < argc) {
> propname = argv[optind + 1];
>
> - pp = of_find_property(node, propname);
> + pp = of_find_property(node, propname, NULL);
> if (!set && !pp) {
> printf("Cannot find property %s\n", propname);
> return -ENOENT;
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 1c9ef58..85199b6 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -102,16 +102,20 @@ static void of_bus_count_cells(struct device_node *dev,
> of_bus_default_count_cells(dev, addrc, sizec);
> }
>
> -struct property *of_find_property(const struct device_node *node, const char *name)
> +struct property *of_find_property(const struct device_node *np,
> + const char *name, int *lenp)
> {
> struct property *pp;
>
> - if (!node)
> + if (!np)
> return NULL;
>
> - list_for_each_entry(pp, &node->properties, list)
> - if (of_prop_cmp(pp->name, name) == 0)
> + list_for_each_entry(pp, &np->properties, list)
> + if (of_prop_cmp(pp->name, name) == 0) {
> + if (lenp)
> + *lenp = pp->length;
> return pp;
> + }
>
> return NULL;
> }
> @@ -242,7 +246,7 @@ u64 of_translate_address(struct device_node *node, const __be32 *in_addr)
> return addr;
>
> node = node->parent;
> - p = of_find_property(node, "ranges");
> + p = of_find_property(node, "ranges", NULL);
> if (!p && node->parent)
> return OF_BAD_ADDR;
> of_bus_count_cells(node, &na, &nc);
> @@ -277,13 +281,7 @@ EXPORT_SYMBOL(of_find_node_by_phandle);
> const void *of_get_property(const struct device_node *np, const char *name,
> int *lenp)
> {
> - struct property *pp = of_find_property(np, name);
> -
> - if (!pp)
> - return NULL;
> -
> - if (lenp)
> - *lenp = pp->length;
> + struct property *pp = of_find_property(np, name, lenp);
>
> return pp ? pp->value : NULL;
> }
> @@ -368,7 +366,7 @@ int of_property_read_u32_array(const struct device_node *np,
> const char *propname, u32 *out_values,
> size_t sz)
> {
> - struct property *prop = of_find_property(np, propname);
> + struct property *prop = of_find_property(np, propname, NULL);
> const __be32 *val;
>
> if (!prop)
> @@ -404,7 +402,7 @@ int of_property_write_u32_array(struct device_node *np,
> const char *propname, const u32 *values,
> size_t sz)
> {
> - struct property *prop = of_find_property(np, propname);
> + struct property *prop = of_find_property(np, propname, NULL);
> __be32 *val;
>
> if (!prop)
> @@ -619,7 +617,7 @@ EXPORT_SYMBOL(of_find_node_by_path);
> int of_property_read_string(struct device_node *np, const char *propname,
> const char **out_string)
> {
> - struct property *prop = of_find_property(np, propname);
> + struct property *prop = of_find_property(np, propname, NULL);
> if (!prop)
> return -EINVAL;
> if (!prop->value)
> @@ -652,7 +650,7 @@ EXPORT_SYMBOL_GPL(of_property_read_string);
> int of_property_read_string_index(struct device_node *np, const char *propname,
> int index, const char **output)
> {
> - struct property *prop = of_find_property(np, propname);
> + struct property *prop = of_find_property(np, propname, NULL);
> int i = 0;
> size_t l = 0, total = 0;
> const char *p;
> @@ -725,7 +723,7 @@ static int of_node_disabled(struct device_node *node)
> {
> struct property *p;
>
> - p = of_find_property(node, "status");
> + p = of_find_property(node, "status", NULL);
> if (p) {
> if (!strcmp("disabled", p->value))
> return 1;
> @@ -833,7 +831,7 @@ int of_set_property(struct device_node *np, const char *name, const void *val, i
> if (!np)
> return -ENOENT;
>
> - pp = of_find_property(np, name);
> + pp = of_find_property(np, name, NULL);
> if (pp) {
> void *data;
>
> @@ -1278,11 +1276,11 @@ int of_add_initrd(struct device_node *root, resource_size_t start,
> } else {
> struct property *pp;
>
> - pp = of_find_property(chosen, "linux,initrd-start");
> + pp = of_find_property(chosen, "linux,initrd-start", NULL);
> if (pp)
> of_delete_property(pp);
>
> - pp = of_find_property(chosen, "linux,initrd-end");
> + pp = of_find_property(chosen, "linux,initrd-end", NULL);
> if (pp)
> of_delete_property(pp);
> }
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index a3ec576..a76396e 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -178,7 +178,10 @@ struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt)
> goto err;
> }
>
> - if (merge && (p = of_find_property(node, name))) {
> + p = NULL;
> + if (merge)
> + p = of_find_property(node, name, NULL);
> + if (merge && p) {
> free(p->value);
> p->value = xzalloc(len);
> memcpy(p->value, nodep, len);
> diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
> index de93fbc..2bf05e2 100644
> --- a/drivers/of/of_net.c
> +++ b/drivers/of/of_net.c
> @@ -76,15 +76,15 @@ const void *of_get_mac_address(struct device_node *np)
> {
> struct property *pp;
>
> - pp = of_find_property(np, "mac-address");
> + pp = of_find_property(np, "mac-address", NULL);
> if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
> return pp->value;
>
> - pp = of_find_property(np, "local-mac-address");
> + pp = of_find_property(np, "local-mac-address", NULL);
> if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
> return pp->value;
>
> - pp = of_find_property(np, "address");
> + pp = of_find_property(np, "address", NULL);
> if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
> return pp->value;
>
> diff --git a/drivers/pinctrl/pinctrl.c b/drivers/pinctrl/pinctrl.c
> index fa979a1..7c797d3 100644
> --- a/drivers/pinctrl/pinctrl.c
> +++ b/drivers/pinctrl/pinctrl.c
> @@ -64,14 +64,14 @@ int pinctrl_select_state(struct device_d *dev, const char *name)
> if (!np)
> return 0;
>
> - if (!of_find_property(np, "pinctrl-0"))
> + if (!of_find_property(np, "pinctrl-0", NULL))
> return 0;
>
> /* For each defined state ID */
> for (state = 0; ; state++) {
> /* Retrieve the pinctrl-* property */
> propname = asprintf("pinctrl-%d", state);
> - prop = of_find_property(np, propname);
> + prop = of_find_property(np, propname, NULL);
> free(propname);
>
> if (!prop) {
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index f460a7a..eebf64c 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -112,17 +112,17 @@ void spi_of_register_slaves(struct spi_master *master, struct device_node *node)
> chip.name = xstrdup(n->name);
> chip.bus_num = master->bus_num;
> /* Mode (clock phase/polarity/etc.) */
> - if (of_find_property(n, "spi-cpha"))
> + if (of_find_property(n, "spi-cpha", NULL))
> chip.mode |= SPI_CPHA;
> - if (of_find_property(n, "spi-cpol"))
> + if (of_find_property(n, "spi-cpol", NULL))
> chip.mode |= SPI_CPOL;
> - if (of_find_property(n, "spi-cs-high"))
> + if (of_find_property(n, "spi-cs-high", NULL))
> chip.mode |= SPI_CS_HIGH;
> - if (of_find_property(n, "spi-3wire"))
> + if (of_find_property(n, "spi-3wire", NULL))
> chip.mode |= SPI_3WIRE;
> of_property_read_u32(n, "spi-max-frequency",
> &chip.max_speed_hz);
> - reg = of_find_property(n, "reg");
> + reg = of_find_property(n, "reg", NULL);
> if (!reg)
> continue;
> chip.chip_select = of_read_number(reg->value, 1);
> diff --git a/drivers/usb/imx/chipidea-imx.c b/drivers/usb/imx/chipidea-imx.c
> index 4ee7610..32b05aa 100644
> --- a/drivers/usb/imx/chipidea-imx.c
> +++ b/drivers/usb/imx/chipidea-imx.c
> @@ -108,7 +108,8 @@ static int imx_chipidea_probe_dt(struct imx_chipidea *ci)
> return -EINVAL;
> }
>
> - if (of_find_property(ci->dev->device_node, "disable-over-current"))
> + if (of_find_property(ci->dev->device_node,
> + "disable-over-current"), NULL)
This needs to be:
+ if (of_find_property(ci->dev->device_node,
+ "disable-over-current", NULL))
(I'll fix this up while applying if there's no other showstopper for this
series)
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-06-20 8:58 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 17:29 [PATCH 00/22] Barebox OF API fixes, sync, and cleanup Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 01/22] lib: string: import case-insensitive string compare Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 02/22] OF: base: bail out early on missing matches for of_match_node Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 03/22] OF: base: also update property length on of_property_write_u32 Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 04/22] OF: base: export of_alias_scan Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 05/22] OF: base: convert strcmp to default string compare functions Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 06/22] OF: base: sync of_find_property with linux OF API Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 07/22] OF: base: sync of_find_node_by_path " Sebastian Hesselbarth
2013-06-18 20:13 ` Sascha Hauer
2013-06-18 20:19 ` Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 08/22] OF: base: rename of_node_disabled to of_device_is_available Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 09/22] OF: base: import of_find_node_by_name from Linux OF API Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 10/22] OF: base: import of_find_compatible_node " Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 11/22] OF: base: import of_find_matching_node_and_match " Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 12/22] OF: base: import of_find_node_with_property " Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 13/22] OF: base: import parent/child functions " Sebastian Hesselbarth
2013-06-18 20:18 ` Sascha Hauer
2013-06-18 20:29 ` Sascha Hauer
2013-06-18 20:34 ` Sebastian Hesselbarth
2013-06-18 17:29 ` [PATCH 14/22] OF: base: import of_property_read_* helpers " Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 15/22] OF: base: import of_parse_phandle " Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 16/22] OF: base: import parse phandle functions " Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 17/22] OF: base: introduce property write for bool, u8, u16, and u64 Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 18/22] OF: base: import property iterators from Linux OF API Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 19/22] OF: base: remove of_tree_for_each_node from public API Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 20/22] OF: base: remove of_find_child_by_name Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 21/22] OF: base: convert and remove device_node_for_nach_child Sebastian Hesselbarth
2013-06-18 17:30 ` [PATCH 22/22] OF: base: cleanup base function include Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 00/22] Barebox OF API fixes, sync, and cleanup Sebastian Hesselbarth
2013-06-20 9:18 ` Sascha Hauer
2013-06-19 9:09 ` [PATCH v2 01/22] lib: string: import case-insensitive string compare Sebastian Hesselbarth
2013-06-20 9:04 ` Sascha Hauer
2013-06-19 9:09 ` [PATCH v2 02/22] OF: base: bail out early on missing matches for of_match_node Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 03/22] OF: base: also update property length on of_property_write_u32 Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 04/22] OF: base: export of_alias_scan Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 05/22] OF: base: convert strcmp to default string compare functions Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 06/22] OF: base: sync of_find_property with linux OF API Sebastian Hesselbarth
2013-06-20 8:57 ` Sascha Hauer [this message]
2013-06-19 9:09 ` [PATCH v2 07/22] OF: base: sync of_find_node_by_path " Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 08/22] OF: base: rename of_node_disabled to of_device_is_available Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 09/22] OF: base: import of_find_node_by_name from Linux OF API Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 10/22] OF: base: import of_find_compatible_node " Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 11/22] OF: base: import of_find_matching_node_and_match " Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 12/22] OF: base: import of_find_node_with_property " Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 13/22] OF: base: import parent/child functions " Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 14/22] OF: base: import of_property_read_* helpers " Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 15/22] OF: base: import of_parse_phandle " Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 16/22] OF: base: import parse phandle functions " Sebastian Hesselbarth
2013-06-20 8:33 ` Sascha Hauer
2013-06-19 9:09 ` [PATCH v2 17/22] OF: base: introduce property write for bool, u8, u16, and u64 Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 18/22] OF: base: import property iterators from Linux OF API Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 19/22] OF: base: remove of_tree_for_each_node from public API Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 20/22] OF: base: remove of_find_child_by_name Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 21/22] OF: base: convert and remove device_node_for_nach_child Sebastian Hesselbarth
2013-06-19 9:09 ` [PATCH v2 22/22] OF: base: cleanup base function include Sebastian Hesselbarth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130620085743.GR32299@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=sebastian.hesselbarth@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox