public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 07/16] dm: Add base driver model support
Date: Fri, 28 Jun 2013 22:53:12 +0200	[thread overview]
Message-ID: <201306282253.12306.marex@denx.de> (raw)
In-Reply-To: <1371613960-28678-8-git-send-email-sjg@chromium.org>

Dear Simon Glass,

> Add driver model functionality for generic board.
> 
> This includes data structures and base code for registering devices and
> uclasses (groups of devices with the same purpose, e.g. all I2C ports will
> be in the same uclass).
> 
> The feature is enabled with CONFIG_DM.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Signed-off-by: Pavel Herrmann <morpheus.ibis@gmail.com>
> Signed-off-by: Viktor K?iv?k <viktor.krivak@gmail.com>
> Signed-off-by: Tomas Hlavacek <tmshlvck@gmail.com>
> ---
> Changes in v3:
> - Tidy up commenting of functions and structures
> - Rename per_device_priv_size to per_device_auto_alloc_size, etc.
> - Add a flag for tracking whether DM allocates/frees platform_data
> 
> Changes in v2: None
> 
>  Makefile                          |   2 +
>  common/dm/Makefile                |  43 +++++
>  common/dm/device.c                | 331
> ++++++++++++++++++++++++++++++++++++++ common/dm/lists.c                 |
> 168 +++++++++++++++++++
>  common/dm/root.c                  | 115 +++++++++++++
>  common/dm/uclass.c                | 298 ++++++++++++++++++++++++++++++++++
>  common/dm/util.c                  |  50 ++++++

Maybe we should move these into drivers/core like Linux has it ?

[...]

> +#include <common.h>
> +#include <malloc.h>
> +#include <dm/device.h>
> +#include <dm/device-internal.h>
> +#include <dm/lists.h>
> +#include <dm/platform_data.h>
> +#include <dm/uclass.h>
> +#include <dm/uclass-internal.h>
> +#include <dm/util.h>
> +#include <linux/err.h>
> +#include <linux/list.h>
> +
> +/**
> + * device_chld_unbind() - Unbind all device's children from the device
> + * @dev:	The device that is to be stripped of its children
> + * @return 0 on success, -ve on error
> + */
> +static int device_chld_unbind(struct device *dev)
> +{
> +	struct device *pos, *n;
> +	int ret;
> +
> +	assert(dev);
> +
> +	list_for_each_entry_safe(pos, n, &dev->child_head, sibling_node) {
> +		ret = device_unbind(pos);
> +		if (ret)
> +			return ret;
> +	}

This is used for stuff like destroying USB bus topology after running "usb 
rescan" for the second time, right? We might want to continue unbinding and only 
report the error instead of returning on the first error.

> +	return 0;
> +}
> +
> +/**
> + * device_chld_remove() - Stop all device's children
> + * @dev:	The device whose children are to be removed
> + * @return 0 on success, -ve on error
> + */
> +static int device_chld_remove(struct device *dev)
> +{
> +	struct device *pos, *n;
> +	int ret;
> +
> +	assert(dev);
> +
> +	list_for_each_entry_safe(pos, n, &dev->child_head, sibling_node) {
> +		ret = device_remove(pos);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	return 0;
> +}

[...]

We might really want to document these.

> +int device_bind_by_name(struct device *parent, const struct driver_info
> *info, +			struct device **devp)

[...]

> +struct uclass *uclass_find(enum uclass_id key)
> +{
> +	struct uclass *uc;
> +
> +	/*
> +	 * TODO(sjg at chromium.org): Optimise this, perhaps moving the found
> +	 * node to the start of the list, or creating a linear array mapping
> +	 * id to node.
> +	 */

We better do this later, after it's all in place.

> +	list_for_each_entry(uc, &gd->uclass_root, sibling_node) {
> +		if (uc->uc_drv->id == key)
> +			return uc;
> +	}
> +
> +	return NULL;
> +}
> +
> +/**
> + * uclass_add() - Create new uclass in list
> + * @id: Id number to create
> + * @ucp: Returns pointer to uclass, or NULL on error
> + * @return 0 on success, -ve on error
> + *
> + * The new uclass is added to the list. There must be only one uclass for
> + * each id.
> + */
> +static int uclass_add(enum uclass_id id, struct uclass **ucp)
> +{

I might be a bit lost here. Do we now support adding uclass at runtime ?

Best regards,

  reply	other threads:[~2013-06-28 20:53 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-19  3:52 [U-Boot] [PATCH v3 0/16] Driver model implementation, tests, demo and GPIO Simon Glass
2013-06-19  3:52 ` [U-Boot] [PATCH v3 01/16] sandbox: Make map_to_sysmem() use a constant pointer Simon Glass
2013-06-19  3:52 ` [U-Boot] [PATCH v3 02/16] sandbox: Correct data sizes and printf() strings in fdtdec.c Simon Glass
2013-06-19  3:52 ` [U-Boot] [PATCH v3 03/16] sandbox: config: Don't use 64-bit physical memory Simon Glass
2013-06-19  3:52 ` [U-Boot] [PATCH v3 04/16] sandbox: Build a device tree file for sandbox Simon Glass
2013-06-19  3:52 ` [U-Boot] [PATCH v3 05/16] Add cmd_process_error() to report and process errors Simon Glass
2013-06-19  3:52 ` [U-Boot] [PATCH v3 06/16] sandbox: config: Enable driver model Simon Glass
2013-06-19  3:52 ` [U-Boot] [PATCH v3 07/16] dm: Add base driver model support Simon Glass
2013-06-28 20:53   ` Marek Vasut [this message]
2013-10-18 16:44     ` Simon Glass
2013-06-19  3:52 ` [U-Boot] [PATCH v3 08/16] dm: Set up driver model after relocation Simon Glass
2013-06-28 20:53   ` Marek Vasut
2013-10-18 16:45     ` Simon Glass
2013-10-19  0:45       ` Marek Vasut
2013-06-19  3:52 ` [U-Boot] [PATCH v3 09/16] dm: Add basic tests Simon Glass
2013-06-19  3:52 ` [U-Boot] [PATCH v3 10/16] dm: Add a 'dm' command for testing Simon Glass
2013-06-28 20:57   ` Marek Vasut
2013-10-18 17:00     ` Simon Glass
2013-06-19  3:52 ` [U-Boot] [PATCH v3 11/16] dm: Add a demonstration/example driver Simon Glass
2013-06-28 21:46   ` Marek Vasut
2013-10-18 19:44     ` Simon Glass
2013-06-19  3:52 ` [U-Boot] [PATCH v3 12/16] dm: Add GPIO support and tests Simon Glass
2013-06-28 21:51   ` Marek Vasut
2013-10-18 19:46     ` Simon Glass
2013-06-19  3:52 ` [U-Boot] [PATCH v3 13/16] sandbox: Convert GPIOs to use driver model Simon Glass
2013-06-19  3:52 ` [U-Boot] [PATCH v3 14/16] dm: Enable gpio command to support " Simon Glass
2013-06-19  3:52 ` [U-Boot] [PATCH v3 15/16] dm: Add README for " Simon Glass
2013-06-28 21:26   ` Marek Vasut
2013-10-18 17:05     ` Simon Glass
2013-06-19  3:52 ` [U-Boot] [PATCH v3 16/16] dm: Move old driver model documentation into an 'old-docs' directory Simon Glass

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=201306282253.12306.marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /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