mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 4/9] OF: import bus/device related functions from Linux OF API
Date: Tue, 25 Jun 2013 14:55:37 +0200	[thread overview]
Message-ID: <51C99349.1010207@gmail.com> (raw)
In-Reply-To: <1372152047-28134-5-git-send-email-sebastian.hesselbarth@gmail.com>

On 06/25/13 11:20, Sebastian Hesselbarth wrote:
> This imports some bus and device related functions from Linux OF API
> with some modifcations for Barebox.
>
> Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> ---
> Cc: barebox@lists.infradead.org
> ---
>   drivers/of/Makefile   |    2 +-
>   drivers/of/platform.c |  294 +++++++++++++++++++++++++++++++++++++++++++++++++
>   include/of.h          |   18 +++
>   3 files changed, 313 insertions(+), 1 deletions(-)
>   create mode 100644 drivers/of/platform.c
[...]
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> new file mode 100644
> index 0000000..450d770
> --- /dev/null
> +++ b/drivers/of/platform.c
> @@ -0,0 +1,294 @@
> +/*
> + * platform.c - bus/device related devicetree functions
> + *
> + * Copyright (c) 2012 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
> + *
> + * based on Linux devicetree support
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2
> + * as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
[...]
> +/**
> + * of_platform_device_create - Alloc, initialize and register an of_device
> + * @np: pointer to node to create device for
> + * @parent: device model parent device.
> + *
> + * Returns pointer to created platform device, or NULL if a device was not
> + * registered. Unavailable devices will not get registered.
> + */
> +static struct device_d *of_platform_device_create(struct device_node *np,
> +						struct device_d *parent)
> +{
> +	struct device_d *dev;
> +	struct resource *res, temp_res;
> +	int i, ret, num_reg = 0;
> +
> +	if (!of_device_is_available(np))
> +		return NULL;
> +
> +	dev = xzalloc(sizeof(*dev));
> +
> +	/* setup generic device info */
> +	dev->id = DEVICE_ID_SINGLE;
> +	dev->device_node = np;
> +	dev->parent = parent;
> +	of_device_make_bus_id(dev);
> +
> +	/* count the io resources */
> +	if (of_can_translate_address(np))
> +		while (of_address_to_resource(np, num_reg, &temp_res) == 0)
> +			num_reg++;
> +
> +	/* Populate the resource table */
> +	if (num_reg) {
> +		res = xzalloc(sizeof(*res) * num_reg);
> +
> +		dev->num_resources = num_reg;
> +		dev->resource = res;
> +		for (i = 0; i < num_reg; i++, res++) {
> +			ret = of_address_to_resource(np, i, res);
> +			if (ret)
> +				goto err_free;
> +		}
> +	}
> +
> +	debug("register device 0x%08x\n", (num_reg) ? dev->resource[0].start : (-1));
> +
> +	ret = platform_device_register(dev);
> +	if (ret)
> +		goto err_free;
> +
> +	return dev;
> +
> +err_free:
> +	free(dev);
> +	return NULL;
> +}

of_platform_device_create is missing a check for already existing
devices. I have added a check that tries to match all mem resources
of the node with existing devices.

[...]
> +/**
> + * of_platform_populate() - Populate platform_devices from device tree data
> + * @root: parent of the first level to probe or NULL for the root of the tree
> + * @matches: match table, NULL to use the default
> + * @lookup: auxdata table for matching id and platform_data with device nodes

Removed the line above, as lookup auxdata is not used on barebox.

Sebastian

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-06-25 12:56 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-25  9:20 [PATCH 0/9] OF: address and device related sync and cleanup Sebastian Hesselbarth
2013-06-25  9:20 ` [PATCH 1/9] OF: import address related functions from Linux OF API Sebastian Hesselbarth
2013-06-25  9:20 ` [PATCH 2/9] OF: convert of_translate_address to new API Sebastian Hesselbarth
2013-06-25  9:20 ` [PATCH 3/9] OF: base: move OF_ROOT_NODE_ defines to local OF code Sebastian Hesselbarth
2013-06-25  9:20 ` [PATCH 4/9] OF: import bus/device related functions from Linux OF API Sebastian Hesselbarth
2013-06-25 12:55   ` Sebastian Hesselbarth [this message]
2013-06-26  6:11   ` Sascha Hauer
2013-06-26  8:23     ` Sebastian Hesselbarth
2013-06-26  8:43   ` [PATCH v2 " Sebastian Hesselbarth
2013-06-25  9:20 ` [PATCH 5/9] OF: base: use of_platform_populate for probing Sebastian Hesselbarth
2013-06-29 14:22   ` Sascha Hauer
2013-06-25  9:20 ` [PATCH 6/9] OF: base: remove dead device related functions Sebastian Hesselbarth
2013-06-25  9:20 ` [PATCH 7/9] OF: remove device and resource pointer from struct device_node Sebastian Hesselbarth
2013-06-29 14:28   ` Sascha Hauer
2013-06-29 14:31     ` Sascha Hauer
2013-06-29 16:03       ` Sebastian Hesselbarth
2013-06-29 16:09         ` Sascha Hauer
2013-06-25  9:20 ` [PATCH 8/9] OF: base: convert of_add_memory to OF API Sebastian Hesselbarth
2013-06-25 19:48   ` Sascha Hauer
2013-06-25 19:57     ` Sebastian Hesselbarth
2013-06-25 21:38     ` Sebastian Hesselbarth
2013-06-26  8:43   ` [PATCH v2 " Sebastian Hesselbarth
2013-06-25  9:20 ` [PATCH 9/9] OF: base: rename of_free to of_delete_node Sebastian Hesselbarth
2013-06-27  6:51 ` [PATCH 0/9] OF: address and device related sync and cleanup Sascha Hauer
2013-06-27  7:50   ` Sebastian Hesselbarth
2013-06-27  8:58     ` Sascha Hauer
2013-06-27  9:00       ` Sebastian Hesselbarth
2013-06-27 18:19         ` Sascha Hauer
2013-06-27 18:27           ` Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 00/10] " Sebastian Hesselbarth
2013-07-05  6:45   ` Sascha Hauer
2013-07-02 18:14 ` [PATCH v3 01/10] OF: import address related functions from Linux OF API Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 02/10] OF: convert of_translate_address to new API Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 03/10] OF: base: move OF_ROOT_NODE_ defines to local OF code Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 04/10] OF: import bus/device related functions from Linux OF API Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 05/10] OF: gpio: convert DT based gpio handling to new " Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 06/10] OF: base: use of_platform_populate for probing Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 07/10] OF: base: remove dead device related functions Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 08/10] OF: remove device and resource pointer from struct device_node Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 09/10] OF: base: convert of_add_memory to OF API Sebastian Hesselbarth
2013-07-02 18:14 ` [PATCH v3 10/10] OF: base: rename of_free to of_delete_node 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=51C99349.1010207@gmail.com \
    --to=sebastian.hesselbarth@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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