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 02/11] DM: add support for scanning DOS partitions to blockdev core
Date: Fri, 21 Sep 2012 14:47:24 +0200	[thread overview]
Message-ID: <201209211447.24513.marex@denx.de> (raw)
In-Reply-To: <4092011.oPyBLZ8jbN@bloomfield>

Dear Pavel Herrmann,

[...]

> > > +static int init(struct core_instance *core)
> > 
> > I'd say, rename it to block_core_init() or something, so the syms in
> > u-boot.map are unique.
> 
> thic being static, how could it show in u-boot.map?

Argh, not u-boot.map, sorry. But it's much easier for git grep to look up unique 
syms than this.

> > > +{
> > > +	INIT_LIST_HEAD(&core->succ);
> > > +	core->private_data = NULL;
> > > +
> > > +	return 0;
> > > +}
> > > +
> > > +static int reloc(struct core_instance *core, struct core_instance
> > > *old) +{
> > > +	struct blockdev_core_entry *entry, *new;
> > > +
> > > +	/* no private_data to copy, yet */
> > > +
> > > +	/* fixup links in old list and prepare new list head */
> > > +	/* FIXME */
> > > +	/* list_fix_reloc(&old->succ); */
> > > +	INIT_LIST_HEAD(&core->succ);
> > > +	core->private_data = NULL;
> > > +
> > > +	/* copy list entries to new memory */
> > > +	list_for_each_entry(entry, &old->succ, list) {
> > > +		new = malloc(sizeof(*new));
> > > +		if (!new)
> > > +			return -ENOMEM;
> > > +
> > > +		INIT_LIST_HEAD(&new->list);
> > > +		new->instance = entry->instance;
> > > +		new->ops = entry->ops;
> > > +		new->name = entry->name;
> > > +		list_add_tail(&new->list, &core->succ);
> > > +		/*no free at this point, old memory should not be freed*/
> > > +	}
> > > +
> > > +	return 0;
> > > +}
> > > +
> > > +static int destroy(struct core_instance *core)
> > > +{
> > > +	struct blockdev_core_entry *entry, *n;
> > > +
> > > +	/* destroy private data */
> > > +	free(core->private_data);
> > > +	core->private_data = NULL;
> > > +
> > > +	/* destroy successor list */
> > > +	list_for_each_entry_safe(entry, n, &core->succ, list) {
> > > +		list_del(&entry->list);
> > > +		free(entry);
> > > +	}
> > > +
> > > +	return 0;
> > > +}
> > > +
> > > +U_BOOT_CORE(CORE_BLOCKDEV,
> > > +	init,
> > > +	reloc,
> > > +	destroy,
> > > +	get_count,
> > > +	get_child,
> > > +	bind,
> > > +	unbind,
> > > +	replace);
> > 
> > Sep the stuff below away into separate file. Conditionally compile in one
> > or the other.
> 
> I distinctly remember you saying to put all this into one file (as opposed
> to 3 it was before), so why the turn-around now?

Well, I didn't see the code before, so I couldn't make a firm decision, sorry.

> No idea what you mean by "one or the other" - you need all this code for it
> to work.

You need the "driver wrapping API" if DM is enabled? I do not understand this, 
please elaborate!

What about having a common part for both cases and then compile either the DM 
part or non-DM part conditionally?

> > > +/* Driver wrapping API */
> > > +lbaint_t blockdev_read(struct instance *i, lbaint_t start, lbaint_t
> > > blkcnt, +	void *buffer)
> > > +{
> > > +	struct blockdev_core_entry *entry = NULL;
> > > +	struct blockdev_ops *device_ops = NULL;
> > > +	int error;
> > > +
> > > +	entry = get_entry_by_instance(i);
> > > +	if (!entry)
> > > +		return -ENOENT;
> > > +
> > > +	error = driver_activate(i);
> > > +	if (error)
> > > +		return error;
> > > +
> > > +	device_ops = entry->ops;
> > > +	if (!device_ops || !device_ops->read)
> > > +		return -EINVAL;
> > > +
> > > +	return device_ops->read(i, start, blkcnt, buffer);
> > > +}
> 
> Pavel Herrmann

Best regards,
Marek Vasut

  reply	other threads:[~2012-09-21 12:47 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-20 19:37 [U-Boot] [PATCH 00/11] Add DM blockdev subsystem Pavel Herrmann
2012-09-20 19:37 ` [U-Boot] [PATCH 01/11] DM: add block device core Pavel Herrmann
2012-09-20 19:58   ` Marek Vasut
2012-09-21  7:11     ` Pavel Herrmann
2012-09-21 12:39       ` Marek Vasut
2012-09-21 13:27         ` Pavel Herrmann
2012-09-21 13:53           ` Marek Vasut
2012-09-21 14:57             ` Pavel Herrmann
2012-09-21 15:34               ` Marek Vasut
2012-09-21 15:48                 ` Pavel Herrmann
2012-09-21 15:55                   ` Marek Vasut
2012-09-21 17:19                     ` Pavel Herrmann
2012-09-21 18:00                       ` Marek Vasut
2012-09-21 18:53                         ` Pavel Herrmann
2012-09-21 19:17                           ` Marek Vasut
2012-09-21 19:29                             ` Pavel Herrmann
2012-09-21 21:11                               ` Marek Vasut
2012-09-21 23:43                                 ` Pavel Herrmann
2012-09-22  0:09                                   ` Marek Vasut
2012-09-22  9:39                                     ` Pavel Herrmann
2012-09-22 13:33                                       ` Marek Vasut
2012-09-22 13:59                                         ` Pavel Herrmann
2012-09-24 12:23                                           ` Pavel Herrmann
2012-09-20 20:49   ` [U-Boot] [U-Boot-DM] " Vikram Narayanan
2012-09-21  7:09     ` Pavel Herrmann
2012-09-21 12:39       ` Marek Vasut
2012-09-20 19:37 ` [U-Boot] [PATCH 02/11] DM: add support for scanning DOS partitions to blockdev core Pavel Herrmann
2012-09-20 20:03   ` Marek Vasut
2012-09-21  7:22     ` Pavel Herrmann
2012-09-21 12:47       ` Marek Vasut [this message]
2012-09-21 13:18         ` Pavel Herrmann
2012-09-21 13:54           ` Marek Vasut
2012-09-20 19:37 ` [U-Boot] [PATCH 03/11] DM: add block controller core Pavel Herrmann
2012-09-20 20:05   ` Marek Vasut
2012-09-21  7:21     ` Pavel Herrmann
2012-09-21 12:51       ` Marek Vasut
2012-09-21 13:14         ` Pavel Herrmann
2012-09-21 13:56           ` Marek Vasut
2012-09-21 15:04             ` Pavel Herrmann
2012-09-21 13:33         ` Pavel Herrmann
2012-09-21 13:58           ` Marek Vasut
2012-09-21 15:09             ` Pavel Herrmann
2012-09-21 15:39               ` Marek Vasut
2012-09-21 15:46                 ` Pavel Herrmann
2012-09-21 16:08                   ` Marek Vasut
2012-09-21 17:22                     ` Pavel Herrmann
2012-09-21 18:01                       ` Marek Vasut
2012-09-21 19:15                         ` Pavel Herrmann
2012-09-21 19:22                           ` Marek Vasut
2012-09-20 19:37 ` [U-Boot] [PATCH 04/11] DM: add sata_legacy driver for blockctrl Pavel Herrmann
2012-09-20 19:37 ` [U-Boot] [PATCH 05/11] DM: add ata and partition blockdev drivers Pavel Herrmann
2012-09-20 19:37 ` [U-Boot] [PATCH 06/11] DM: add cmd_block command Pavel Herrmann
2012-09-20 19:37 ` [U-Boot] [PATCH 07/11] DM: use new blockdev API in FAT Pavel Herrmann
2012-09-20 19:37 ` [U-Boot] [PATCH 08/11] DM: use new blockdev API in ext2 Pavel Herrmann
2012-09-20 19:37 ` [U-Boot] [PATCH 09/11] DM: use new blockdev API in reiserfs Pavel Herrmann
2012-09-20 19:37 ` [U-Boot] [PATCH 10/11] DM: use new blockdev API in ZFS Pavel Herrmann
2012-09-20 19:37 ` [U-Boot] [PATCH 11/11] DM: switch sandbox to DM blockdev Pavel Herrmann

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=201209211447.24513.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