
Hi Masahiro,
On 23 January 2015 at 05:32, Masahiro Yamada yamada.m@jp.panasonic.com wrote:
Hi Simon,
On Mon, 19 Jan 2015 20:12:48 -0700 Simon Glass sjg@chromium.org 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 ?
I think it might still be useful to call it from a driver in some cases. Certainly it is better than having the driver duplicate code.
On the other hand, I hope that the uclass can do this 'default' processing and the driver can just add to it. We will see.
Regards, Simon