[U-Boot] [PATCH v2 02/19] dm: i2c: Make API accessible even without CONFIG_DM
Heiko Schocher
hs at denx.de
Fri Feb 6 08:15:14 CET 2015
Hello Simon,
Am 06.02.2015 05:41, schrieb Simon Glass:
> Make the driver model I2C API available always, even if driver model
> is not enabled. This allows for a 'soft' switch-over, where drivers can
> use the new structures in code which is compiled but not yet used. This
> makes migration easier in some cases.
>
> Fix up the existing drivers which define their own 'struct i2c_msg'.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> Changes in v2:
> - Add a patch to squash use of 'struct i2c_msg' in drivers
>
> drivers/i2c/adi_i2c.c | 6 +++---
> drivers/i2c/kona_i2c.c | 16 ++++++++--------
> drivers/i2c/mv_i2c.c | 10 +++++-----
> include/i2c.h | 5 +----
> 4 files changed, 17 insertions(+), 20 deletions(-)
Acked-by: Heiko Schocher <hs at denx.de>
bye,
Heiko
>
> diff --git a/drivers/i2c/adi_i2c.c b/drivers/i2c/adi_i2c.c
> index 20495b1..c58f14a 100644
> --- a/drivers/i2c/adi_i2c.c
> +++ b/drivers/i2c/adi_i2c.c
> @@ -63,7 +63,7 @@ struct twi_regs {
> #endif
>
> /* All transfers are described by this data structure */
> -struct i2c_msg {
> +struct adi_i2c_msg {
> u8 flags;
> #define I2C_M_COMBO 0x4
> #define I2C_M_STOP 0x2
> @@ -81,7 +81,7 @@ struct i2c_msg {
> * wait_for_completion - manage the actual i2c transfer
> * @msg: the i2c msg
> */
> -static int wait_for_completion(struct twi_regs *twi, struct i2c_msg *msg)
> +static int wait_for_completion(struct twi_regs *twi, struct adi_i2c_msg *msg)
> {
> u16 int_stat, ctl;
> ulong timebase = get_timer(0);
> @@ -151,7 +151,7 @@ static int i2c_transfer(struct i2c_adapter *adap, uint8_t chip, uint addr,
> (addr >> 8),
> (addr >> 16),
> };
> - struct i2c_msg msg = {
> + struct adi_i2c_msg msg = {
> .flags = flags | (len >= 0xff ? I2C_M_STOP : 0),
> .buf = buffer,
> .len = len,
> diff --git a/drivers/i2c/kona_i2c.c b/drivers/i2c/kona_i2c.c
> index 5eab338..9af496b 100644
> --- a/drivers/i2c/kona_i2c.c
> +++ b/drivers/i2c/kona_i2c.c
> @@ -156,7 +156,7 @@ static struct bcm_kona_i2c_dev g_i2c_devs[CONFIG_SYS_MAX_I2C_BUS] = {
> #define I2C_M_RD 0x0001 /* read data */
> #define I2C_M_NOSTART 0x4000 /* no restart between msgs */
>
> -struct i2c_msg {
> +struct kona_i2c_msg {
> uint16_t addr;
> uint16_t flags;
> uint16_t len;
> @@ -297,7 +297,7 @@ static int bcm_kona_i2c_read_fifo_single(struct bcm_kona_i2c_dev *dev,
>
> /* Read any amount of data using the RX FIFO from the i2c bus */
> static int bcm_kona_i2c_read_fifo(struct bcm_kona_i2c_dev *dev,
> - struct i2c_msg *msg)
> + struct kona_i2c_msg *msg)
> {
> unsigned int bytes_to_read = MAX_RX_FIFO_SIZE;
> unsigned int last_byte_nak = 0;
> @@ -392,7 +392,7 @@ static int bcm_kona_i2c_write_fifo_single(struct bcm_kona_i2c_dev *dev,
>
> /* Write any amount of data using TX FIFO to the i2c bus */
> static int bcm_kona_i2c_write_fifo(struct bcm_kona_i2c_dev *dev,
> - struct i2c_msg *msg)
> + struct kona_i2c_msg *msg)
> {
> unsigned int bytes_to_write = MAX_TX_FIFO_SIZE;
> unsigned int bytes_written = 0;
> @@ -418,7 +418,7 @@ static int bcm_kona_i2c_write_fifo(struct bcm_kona_i2c_dev *dev,
>
> /* Send i2c address */
> static int bcm_kona_i2c_do_addr(struct bcm_kona_i2c_dev *dev,
> - struct i2c_msg *msg)
> + struct kona_i2c_msg *msg)
> {
> unsigned char addr;
>
> @@ -480,9 +480,9 @@ static void bcm_kona_i2c_config_timing(struct bcm_kona_i2c_dev *dev)
>
> /* Master transfer function */
> static int bcm_kona_i2c_xfer(struct bcm_kona_i2c_dev *dev,
> - struct i2c_msg msgs[], int num)
> + struct kona_i2c_msg msgs[], int num)
> {
> - struct i2c_msg *pmsg;
> + struct kona_i2c_msg *pmsg;
> int rc = 0;
> int i;
>
> @@ -635,7 +635,7 @@ static int kona_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
> int alen, uchar *buffer, int len)
> {
> /* msg[0] writes the addr, msg[1] reads the data */
> - struct i2c_msg msg[2];
> + struct kona_i2c_msg msg[2];
> unsigned char msgbuf0[64];
> struct bcm_kona_i2c_dev *dev = kona_get_dev(adap);
>
> @@ -663,7 +663,7 @@ static int kona_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
> static int kona_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
> int alen, uchar *buffer, int len)
> {
> - struct i2c_msg msg[1];
> + struct kona_i2c_msg msg[1];
> unsigned char msgbuf0[64];
> unsigned int i;
> struct bcm_kona_i2c_dev *dev = kona_get_dev(adap);
> diff --git a/drivers/i2c/mv_i2c.c b/drivers/i2c/mv_i2c.c
> index dac3463..e65cce0 100644
> --- a/drivers/i2c/mv_i2c.c
> +++ b/drivers/i2c/mv_i2c.c
> @@ -31,7 +31,7 @@
> #endif
>
> /* All transfers are described by this data structure */
> -struct i2c_msg {
> +struct mv_i2c_msg {
> u8 condition;
> u8 acknack;
> u8 direction;
> @@ -157,7 +157,7 @@ static int i2c_isr_set_cleared(unsigned long set_mask,
> * -5: illegal parameters
> * -6: bus is busy and couldn't be aquired
> */
> -int i2c_transfer(struct i2c_msg *msg)
> +int i2c_transfer(struct mv_i2c_msg *msg)
> {
> int ret;
>
> @@ -286,7 +286,7 @@ void i2c_init(int speed, int slaveaddr)
> */
> int i2c_probe(uchar chip)
> {
> - struct i2c_msg msg;
> + struct mv_i2c_msg msg;
>
> i2c_reset();
>
> @@ -322,7 +322,7 @@ int i2c_probe(uchar chip)
> */
> int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
> {
> - struct i2c_msg msg;
> + struct mv_i2c_msg msg;
> u8 addr_bytes[3]; /* lowest...highest byte of data address */
>
> PRINTD(("i2c_read(chip=0x%02x, addr=0x%02x, alen=0x%02x, "
> @@ -410,7 +410,7 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
> */
> int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
> {
> - struct i2c_msg msg;
> + struct mv_i2c_msg msg;
> u8 addr_bytes[3]; /* lowest...highest byte of data address */
>
> PRINTD(("i2c_write(chip=0x%02x, addr=0x%02x, alen=0x%02x, "
> diff --git a/include/i2c.h b/include/i2c.h
> index 1635e9a..31b0389 100644
> --- a/include/i2c.h
> +++ b/include/i2c.h
> @@ -25,14 +25,13 @@
> * enough as to be incompatible for compilation purposes.
> */
>
> -#ifdef CONFIG_DM_I2C
> -
> enum dm_i2c_chip_flags {
> DM_I2C_CHIP_10BIT = 1 << 0, /* Use 10-bit addressing */
> DM_I2C_CHIP_RD_ADDRESS = 1 << 1, /* Send address for each read byte */
> DM_I2C_CHIP_WR_ADDRESS = 1 << 2, /* Send address for each write byte */
> };
>
> +struct udevice;
> /**
> * struct dm_i2c_chip - information about an i2c chip
> *
> @@ -439,8 +438,6 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len,
> int i2c_chip_ofdata_to_platdata(const void *blob, int node,
> struct dm_i2c_chip *chip);
>
> -#endif
> -
> #ifndef CONFIG_DM_I2C
>
> /*
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
More information about the U-Boot
mailing list