-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i2c: deprecate use of union dev_config #4254
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if it's fine with sanitycheck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, with some minor comments.
include/i2c.h
Outdated
#define I2C_SPEED_SHIFT (1) | ||
#define I2C_SPEED_SET(speed) ((speed) << I2C_SPEED_SHIFT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's customary to write _SET macros as
#define I2C_SPEED_SET(speed) (((speed) << I2C_SPEED_SHIFT) & I2C_SPEED_MASK)
to avoid unintentional overwriting of neighboring bit-fields.
include/i2c.h
Outdated
#define I2C_SPEED_SHIFT (1) | ||
#define I2C_SPEED_SET(speed) ((speed) << I2C_SPEED_SHIFT) | ||
/** @cond INTERNAL_HIDDEN */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should remove @cond INTERNAL_HIDDEN
? If _SET macro is visible/documented then _GET should be too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There are several issues with the dev_config union used as a convenience when calling the i2c_configure api. One, the union is well name spaced protected and doesn't convey use with just i2c. Second there are assumptions of how the bits might get packed by the union which can't be guaranteed. Since the API takes a u32_t lets change in tree uses to using the macros to setup a u32_t and make the union as deprecated. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
459f5bc
to
1fd65f0
Compare
There are several issues with the dev_config union used as a
convenience when calling the i2c_configure api. One, the union is well
name spaced protected and doesn't convey use with just i2c. Second
there are assumptions of how the bits might get packed by the union
which can't be guaranteed. Since the API takes a u32_t lets change in
tree uses to using the macros to setup a u32_t and make the union as
deprecated.
Signed-off-by: Kumar Gala kumar.gala@linaro.org