i2c: Inline i2c_chip_of_to_plat() into i2c_child_post_bind()

The i2c_chip_of_to_plat() is called only from i2c_child_post_bind(),
inline i2c_chip_of_to_plat() into i2c_child_post_bind(). Drop the
if CONFIG_IS_ENABLED(OF_REAL) and depend on if (!dev_has_ofnode(dev))
which does check CONFIG_IS_ENABLED(OF_REAL) internally too.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
This commit is contained in:
Marek Vasut
2025-11-24 15:51:00 +01:00
committed by Tom Rini
parent 00967665f6
commit 5b968372e2
2 changed files with 14 additions and 38 deletions

View File

@@ -701,26 +701,6 @@ int i2c_deblock(struct udevice *bus)
return ops->deblock(bus);
}
#if CONFIG_IS_ENABLED(OF_REAL)
int i2c_chip_of_to_plat(struct udevice *dev, struct dm_i2c_chip *chip)
{
int addr;
chip->offset_len = dev_read_u32_default(dev, "u-boot,i2c-offset-len",
1);
chip->flags = 0;
addr = dev_read_u32_default(dev, "reg", -1);
if (addr == -1) {
debug("%s: I2C Node '%s' has no 'reg' property %s\n", __func__,
dev_read_name(dev), dev->name);
return log_ret(-EINVAL);
}
chip->chip_addr = addr;
return 0;
}
#endif
static int i2c_pre_probe(struct udevice *dev)
{
#if CONFIG_IS_ENABLED(OF_REAL)
@@ -760,15 +740,24 @@ static int i2c_post_probe(struct udevice *dev)
static int i2c_child_post_bind(struct udevice *dev)
{
#if CONFIG_IS_ENABLED(OF_REAL)
struct dm_i2c_chip *plat = dev_get_parent_plat(dev);
struct dm_i2c_chip *chip = dev_get_parent_plat(dev);
int addr;
if (!dev_has_ofnode(dev))
return 0;
return i2c_chip_of_to_plat(dev, plat);
#else
chip->offset_len = dev_read_u32_default(dev, "u-boot,i2c-offset-len",
1);
chip->flags = 0;
addr = dev_read_u32_default(dev, "reg", -1);
if (addr == -1) {
debug("%s: I2C Node '%s' has no 'reg' property %s\n", __func__,
dev_read_name(dev), dev->name);
return log_ret(-EINVAL);
}
chip->chip_addr = addr;
return 0;
#endif
}
static int i2c_post_bind(struct udevice *dev)

View File

@@ -549,19 +549,6 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len,
int i2c_get_chip_by_phandle(const struct udevice *parent, const char *prop_name,
struct udevice **devp);
/**
* i2c_chip_of_to_plat() - Decode standard I2C platform data
*
* This decodes the chip address from a device tree node and puts it into
* its dm_i2c_chip structure. This should be called in your driver's
* of_to_plat() method.
*
* @blob: Device tree blob
* @node: Node offset to read from
* @spi: Place to put the decoded information
*/
int i2c_chip_of_to_plat(struct udevice *dev, struct dm_i2c_chip *chip);
/**
* i2c_dump_msgs() - Dump a list of I2C messages
*