Message ID | 20200103222650.32592-4-sjg@chromium.org |
---|---|
State | Superseded |
Headers | show |
Series | i2c: designware_ic2: Improvements to timing and general cleanup | expand |
Reviewed-by: Jun Chen <ptchentw at gmail.com> Simon Glass <sjg at chromium.org> 於 2020年1月4日 週六 上午6:27寫道: > Group these #defines into an enum to make it easier to understand the > relationship between them. > > Signed-off-by: Simon Glass <sjg at chromium.org> > --- > > Changes in v2: None > > drivers/i2c/designware_i2c.c | 2 +- > drivers/i2c/designware_i2c.h | 10 +++++++--- > 2 files changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c > index dd1cc0b823..2416ef32f9 100644 > --- a/drivers/i2c/designware_i2c.c > +++ b/drivers/i2c/designware_i2c.c > @@ -57,10 +57,10 @@ static unsigned int __dw_i2c_set_bus_speed(struct > i2c_regs *i2c_base, > unsigned int speed, > unsigned int bus_mhz) > { > + enum i2c_speed_mode i2c_spd; > unsigned int cntl; > unsigned int hcnt, lcnt; > unsigned int ena; > - int i2c_spd; > > /* Allow high speed if there is no config, or the config allows it > */ > if (speed >= I2C_HIGH_SPEED && > diff --git a/drivers/i2c/designware_i2c.h b/drivers/i2c/designware_i2c.h > index fcb7dde83a..06d794ca64 100644 > --- a/drivers/i2c/designware_i2c.h > +++ b/drivers/i2c/designware_i2c.h > @@ -135,9 +135,13 @@ struct i2c_regs { > #define IC_STATUS_ACT 0x0001 > > /* Speed Selection */ > -#define IC_SPEED_MODE_STANDARD 1 > -#define IC_SPEED_MODE_FAST 2 > -#define IC_SPEED_MODE_HIGH 3 > +enum i2c_speed_mode { > + IC_SPEED_MODE_STANDARD, > + IC_SPEED_MODE_FAST, > + IC_SPEED_MODE_HIGH, > + > + IC_SPEED_MODE_COUNT, > +}; > > #define I2C_HIGH_SPEED 3400000 > #define I2C_FAST_SPEED 400000 > -- > 2.24.1.735.g03f4e72817-goog > >
Hello Simon, Am 03.01.2020 um 23:26 schrieb Simon Glass: > Group these #defines into an enum to make it easier to understand the > relationship between them. > > Signed-off-by: Simon Glass <sjg at chromium.org> > --- > > Changes in v2: None > > drivers/i2c/designware_i2c.c | 2 +- > drivers/i2c/designware_i2c.h | 10 +++++++--- > 2 files changed, 8 insertions(+), 4 deletions(-) Reviewed-by: Heiko Schocher <hs at denx.de> bye, Heiko
diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c index dd1cc0b823..2416ef32f9 100644 --- a/drivers/i2c/designware_i2c.c +++ b/drivers/i2c/designware_i2c.c @@ -57,10 +57,10 @@ static unsigned int __dw_i2c_set_bus_speed(struct i2c_regs *i2c_base, unsigned int speed, unsigned int bus_mhz) { + enum i2c_speed_mode i2c_spd; unsigned int cntl; unsigned int hcnt, lcnt; unsigned int ena; - int i2c_spd; /* Allow high speed if there is no config, or the config allows it */ if (speed >= I2C_HIGH_SPEED && diff --git a/drivers/i2c/designware_i2c.h b/drivers/i2c/designware_i2c.h index fcb7dde83a..06d794ca64 100644 --- a/drivers/i2c/designware_i2c.h +++ b/drivers/i2c/designware_i2c.h @@ -135,9 +135,13 @@ struct i2c_regs { #define IC_STATUS_ACT 0x0001 /* Speed Selection */ -#define IC_SPEED_MODE_STANDARD 1 -#define IC_SPEED_MODE_FAST 2 -#define IC_SPEED_MODE_HIGH 3 +enum i2c_speed_mode { + IC_SPEED_MODE_STANDARD, + IC_SPEED_MODE_FAST, + IC_SPEED_MODE_HIGH, + + IC_SPEED_MODE_COUNT, +}; #define I2C_HIGH_SPEED 3400000 #define I2C_FAST_SPEED 400000
Group these #defines into an enum to make it easier to understand the relationship between them. Signed-off-by: Simon Glass <sjg at chromium.org> --- Changes in v2: None drivers/i2c/designware_i2c.c | 2 +- drivers/i2c/designware_i2c.h | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-)