public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoffer Dall <christoffer.dall@linaro.org>
To: Andrew Jones <drjones@redhat.com>
Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org
Subject: Re: [PATCH 11/17] add support for device trees
Date: Mon, 3 Feb 2014 08:36:44 -0800	[thread overview]
Message-ID: <20140203163644.GE4167@cbox> (raw)
In-Reply-To: <20140203153120.GE6832@hawk.usersys.redhat.com>

On Mon, Feb 03, 2014 at 04:31:24PM +0100, Andrew Jones wrote:
> On Sat, Feb 01, 2014 at 06:27:15PM -0800, Christoffer Dall wrote:
> > On Tue, Jan 21, 2014 at 05:21:57PM +0100, Andrew Jones wrote:

[...]

> > > +
> > > +int dt_get_reg(int nodeoffset, int regidx, u32 *address_cells,
> > > +	       u32 *size_cells, struct dt_reg *reg)
> > > +{
> > > +	const struct fdt_property *prop;
> > > +	u32 *data, regsz, i;
> > > +	int err;
> > > +
> > > +	if (!address_cells || !size_cells || !reg)
> > > +		return -EINVAL;
> > 
> > defensive programming?
> > 
> > > +
> > > +	memset(reg, 0, sizeof(struct dt_reg));
> > 
> > sizeof(*reg)
> > 
> > > +
> > > +	/*
> > > +	 * We assume #size-cells == 0 means translation is impossible,
> > 
> > hmm, this won't work for the cpus' reg properties for example.  I would
> > just assume (and document) that this function always takes valid
> > address_cells and size_cells (as u32 instead of u32 *).  I get that
> > you're trying to do some caching (from reading later patches), but that
> > should still be possible to do externally.
> 
> cpus will need their own 'dt_get_cpuids', built on a 'dt_for_each_cpu',
> or some such, and wouldn't use this function. Other than cpus, I think
> this is a safe convention. Although, that said, I'll look into cleaning
> up the interface a bit, while maintaining ease of use and the ability to
> cache.
> 

well, your function is called dt_get_reg and is generally exported from
lib/devicetree.c, so there's nothing here suggesting this can only be
used for a reg property for a certain type of devices.  cpus is an
example of a node that has #size-cells == 0 and has a perfectly valid
reg property.

The fact that you don't plan on using this function to iterate CPUs
doesn't mean that somebody else will not, or we will add another binding
that will use same convention, and now this funciton has to be
refactored.

If this function was virtio_get_reg, it would be a different story...

> > 
> > If you really really want to, then you should use address_cells, but I'm
> > not sure if it's actually valid for any bindings to have address_cells
> > == 0 and size_cells >0.  If you have conventions like this, it should be
> > clearly documented on the function itself!
> > 

[...]

Thanks,
-Christoffer

  reply	other threads:[~2014-02-03 16:36 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-21 16:21 [PATCH 00/17] kvm-unit-tests/arm: initial drop Andrew Jones
2014-01-21 16:21 ` [PATCH 01/17] remove unused files Andrew Jones
2014-01-21 16:21 ` [PATCH 02/17] makefile and run_tests tweaks Andrew Jones
2014-01-21 16:21 ` [PATCH 03/17] clean root dir of all x86-ness Andrew Jones
2014-01-21 16:21 ` [PATCH 04/17] gitignore: Ignore more Andrew Jones
2014-01-21 16:21 ` [PATCH 05/17] add 'make cscope' support Andrew Jones
2014-02-02  2:22   ` Christoffer Dall
2014-02-03 13:25     ` Andrew Jones
2014-01-21 16:21 ` [PATCH 06/17] Add halt() and some error codes Andrew Jones
2014-02-02  2:23   ` Christoffer Dall
2014-01-21 16:21 ` [PATCH 07/17] move x86's simple heap management to common code Andrew Jones
2014-02-02  2:23   ` Christoffer Dall
2014-01-21 16:21 ` [PATCH 08/17] Introduce libio to common code for io read/write Andrew Jones
2014-02-02  2:24   ` Christoffer Dall
2014-02-03 13:51     ` Andrew Jones
2014-02-03 16:30       ` Christoffer Dall
2014-01-21 16:21 ` [PATCH 10/17] libfdt: get libfdt to build Andrew Jones
2014-02-02  2:25   ` Christoffer Dall
2014-02-03 13:57     ` Andrew Jones
2014-01-21 16:21 ` [PATCH 11/17] add support for device trees Andrew Jones
2014-02-02  2:27   ` Christoffer Dall
2014-02-03 15:31     ` Andrew Jones
2014-02-03 16:36       ` Christoffer Dall [this message]
2014-01-21 16:21 ` [PATCH 12/17] Introduce virtio-testdev Andrew Jones
2014-02-02  2:27   ` Christoffer Dall
2014-02-03 15:44     ` Andrew Jones
2014-02-03 16:41       ` Christoffer Dall
2014-01-21 16:21 ` [PATCH 13/17] arm: initial drop Andrew Jones
2014-02-02  2:28   ` Christoffer Dall
2014-02-03 15:55     ` Andrew Jones
2014-01-21 16:22 ` [PATCH 14/17] arm: Add IO accessors to avoid register-writeback Andrew Jones
2014-01-21 16:22 ` [PATCH 15/17] printf: support field padding Andrew Jones
2014-02-02  2:28   ` Christoffer Dall
2014-01-21 16:22 ` [PATCH 16/17] arm: add useful headers from the linux kernel Andrew Jones
2014-02-02  2:29   ` Christoffer Dall
2014-02-03 16:46     ` Andrew Jones
2014-02-03 17:38       ` Christoffer Dall
2014-01-21 16:22 ` [PATCH 17/17] arm: vectors support Andrew Jones
2014-02-02  2:29   ` Christoffer Dall
2014-02-03 16:50     ` Andrew Jones
2014-02-03 21:19       ` Christoffer Dall
2014-02-04  7:12         ` Andrew Jones
     [not found] ` <CABWnSnPMc_CrH8N28TScBVvQmCk+XD-bVWvdmJAxxVczHsVx_g@mail.gmail.com>
2014-01-29 15:35   ` [PATCH 00/17] kvm-unit-tests/arm: initial drop Andrew Jones
2014-02-02  2:22 ` Christoffer Dall
2014-02-03 13:24   ` Andrew Jones
     [not found]     ` <CALxX4v-h+gOCZDukCnGK_GUQepu07KYw4BGjzjGNgA0SdDcLNw@mail.gmail.com>
2014-02-04  8:33       ` Andrew Jones
     [not found] ` <1390321323-1855-10-git-send-email-drjones@redhat.com>
2014-02-02  2:25   ` [PATCH 09/17] libfdt: Import libfdt source Christoffer Dall

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=20140203163644.GE4167@cbox \
    --to=christoffer.dall@linaro.org \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    /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