Skip to content
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

Merged
merged 1 commit into from
Oct 11, 2017

Conversation

galak
Copy link
Collaborator

@galak galak commented Oct 10, 2017

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

@galak galak requested review from mnkp and ydamigos October 10, 2017 17:52
Copy link
Collaborator

@lpereira lpereira left a 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

Copy link
Member

@mnkp mnkp left a 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)
Copy link
Member

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 */
Copy link
Member

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.

Copy link
Collaborator

@ydamigos ydamigos left a 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>
@galak galak force-pushed the i2c-remove-bitfield branch from 459f5bc to 1fd65f0 Compare October 11, 2017 14:20
@nashif nashif merged commit 0bfd810 into zephyrproject-rtos:master Oct 11, 2017
@galak galak deleted the i2c-remove-bitfield branch January 26, 2018 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants