From: Masahiro Yamada Date: Fri, 23 Jan 2015 21:32:51 +0900 Subject: [U-Boot] [PATCH v2 19/26] dm: i2c: Move slave details to child platdata In-Reply-To: <1421723575-4532-20-git-send-email-sjg@chromium.org> References: <1421723575-4532-1-git-send-email-sjg@chromium.org> <1421723575-4532-20-git-send-email-sjg@chromium.org> Message-ID: <20150123213251.4738.AA925319@jp.panasonic.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Simon, On Mon, 19 Jan 2015 20:12:48 -0700 Simon Glass wrote: > if (offset_len > I2C_MAX_OFFSET_LEN) > return -EINVAL; > @@ -450,13 +448,26 @@ int i2c_post_bind(struct udevice *dev) > return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); > } > > +int i2c_child_post_bind(struct udevice *dev) > +{ > + struct dm_i2c_chip *plat = dev_get_parent_platdata(dev); > + > + if (dev->of_offset == -1) > + return 0; > + > + return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, plat); > +} > + Add "static" to i2c_post_bind() and i2c_child_post_bind(). > UCLASS_DRIVER(i2c) = { > .id = UCLASS_I2C, > .name = "i2c", > .flags = DM_UC_FLAG_SEQ_ALIAS, > - .per_device_auto_alloc_size = sizeof(struct dm_i2c_bus), > .post_bind = i2c_post_bind, > .post_probe = i2c_post_probe, > + .per_device_auto_alloc_size = sizeof(struct dm_i2c_bus), > + .per_child_auto_alloc_size = sizeof(struct dm_i2c_chip), > + .per_child_platdata_auto_alloc_size = sizeof(struct dm_i2c_chip), > + .child_post_bind = i2c_child_post_bind, > }; Now struct dm_i2c_chip is allocated on both .per_child_auto_alloc_size and .per_child_platdata_auto_alloc_size. The former is probably unused. > UCLASS_DRIVER(i2c_generic) = { > diff --git a/drivers/i2c/i2c-uniphier-f.c b/drivers/i2c/i2c-uniphier-f.c > index b0d30f7..6707edd 100644 > --- a/drivers/i2c/i2c-uniphier-f.c > +++ b/drivers/i2c/i2c-uniphier-f.c > @@ -145,16 +145,6 @@ static int uniphier_fi2c_remove(struct udevice *dev) > return 0; > } > > -static int uniphier_fi2c_child_pre_probe(struct udevice *dev) > -{ > - struct dm_i2c_chip *i2c_chip = dev_get_parentdata(dev); > - > - if (dev->of_offset == -1) > - return 0; > - return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, > - i2c_chip); > -} > - Currently, i2c_chip_ofdata_to_platdata() is only used in i2c-uclass.c Perhaps it can become a "static" function. Or it might be useful to override something ? Best Regards Masahiro Yamada