From a6f5897e21a67379e48bcdfd340b5f227b5083d2 Mon Sep 17 00:00:00 2001 From: James Roy Date: Wed, 5 Mar 2025 09:18:10 +0800 Subject: [PATCH] drivers: i2c: Add an i2c_configure_dt function Add an i2c_configure_dt function, that is equivalent to calling i2c_configure(spec->bus, dev_config) to simplify the calling. Signed-off-by: James Roy --- include/zephyr/drivers/i2c.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/zephyr/drivers/i2c.h b/include/zephyr/drivers/i2c.h index 689a4ae6748..756cc8dc049 100644 --- a/include/zephyr/drivers/i2c.h +++ b/include/zephyr/drivers/i2c.h @@ -723,6 +723,25 @@ static inline int z_impl_i2c_configure(const struct device *dev, return api->configure(dev, dev_config); } +/** + * @brief Configure operation of a host controller. + * + * This is equivalent to: + * + * i2c_configure(spec->bus, dev_config); + * + * @param spec I2C specification from devicetree. + * @param dev_config Bit-packed 32-bit value to the device runtime configuration + * for the I2C controller. + * + * @return a value from i2c_configure() + */ +static inline int i2c_configure_dt(const struct i2c_dt_spec *spec, + uint32_t dev_config) +{ + return i2c_configure(spec->bus, dev_config); +} + /** * @brief Get configuration of a host controller. *