Thread (1 message) 1 message, 1 author, 2010-06-08

Re: [PATCH 6/6] of/device: populate platform_device (of_device) resource table on allocation

From: Grant Likely <hidden>
Date: 2010-06-08 16:02:49
Also in: linux-devicetree

On Tue, Jun 8, 2010 at 9:57 AM, Anton Vorontsov [off-list ref] wr=
ote:
On Tue, Jun 08, 2010 at 08:26:43AM -0600, Grant Likely wrote:
[...]
quoted
+ =A0 =A0 dev =3D kzalloc(sizeof(*dev) + (sizeof(struct resource) * i), =
GFP_KERNEL);
quoted
=A0 =A0 =A0 if (!dev)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 return NULL;
-
=A0 =A0 =A0 dev->dev.of_node =3D of_node_get(np);
=A0 =A0 =A0 dev->dev.dma_mask =3D &dev->archdata.dma_mask;
=A0 =A0 =A0 dev->dev.parent =3D parent;
=A0 =A0 =A0 dev->dev.release =3D of_release_dev;

+ =A0 =A0 /* Populate the resource table */
+ =A0 =A0 if (num_irq || num_reg) {
+ =A0 =A0 =A0 =A0 =A0 =A0 dev->resource =3D (void*)&dev[1];
This is ugly. Why not allocate the memory specifically for
dev->resource? Is this because you plan to get rid of
of_release_dev(), and the generic release_dev() won't
know if it should free the dev->resource? There must
be a better way to handle this.
Allocating in one big block means less potential memory fragmentation,
and the kernel can free it all at once.  This is a common pattern.
p.s.

Just wonder what happened to of_gpio stuff? You blocked it
in 2.6.34 for no reason saying "I'll pick it into my OF
tree before the 2.6.35 merge window" and it's 2.6.36 merge
window quite soon.
It's in my test-devicetree branch.  I'll be posting for 2nd review in
the next few days and then adding to my devicetree-next branch
probably before the end of the week.

g.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help