-
Notifications
You must be signed in to change notification settings - Fork 1.7k
mux: adg2404: add initial driver support #2712
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
Conversation
drivers/mux/adg2404/adg2404.c
Outdated
ret = adg2404_enable(dev, ADG2404_DISABLE); | ||
if (ret) | ||
return ret; | ||
return 0; |
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.
Return directly
drivers/mux/adg2404/adg2404.c
Outdated
dev = (struct adg2404_dev *)no_os_malloc(sizeof(*dev)); | ||
if (!dev) | ||
return -ENOMEM; |
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.
Use calloc()
instead
drivers/mux/adg2404/adg2404.c
Outdated
* @param state - ADG2404_ENABLE or ADG2404_DISABLE. | ||
* @return 0 in case of success, negative error code otherwise. | ||
*/ | ||
int adg2404_enable(struct adg2404_dev *dev, enum adg2404_state state) |
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.
If the state is just enable/disable, you can use bool
for the state's type
drivers/mux/adg2404/adg2404.h
Outdated
struct no_os_gpio_desc *gpio_a0; | ||
struct no_os_gpio_desc *gpio_a1; | ||
struct no_os_gpio_desc *gpio_en; | ||
enum adg2404_type device_type; |
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.
this is stored in adg2404_dev but not used anywhere, so i think it can be dropped
drivers/mux/adg2404/adg2404.c
Outdated
if (!dev) | ||
return -EINVAL; | ||
|
||
return no_os_gpio_set_value(dev->gpio_en, state); |
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.
i think a warning is generated here for casting, maybe try explicit cast ?
drivers/mux/adg2404/adg2404.c
Outdated
if (!dev) | ||
return -ENOMEM; | ||
|
||
ret = no_os_gpio_init(&dev->gpio_a0, &init_param->gpio_a0); |
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.
This function doesn't exist. no_os_gpio_get()
should be used.
Add support for ADG2404 analog 4:1 multiplexer. The ADG2404 switches one of four inputs to a common output, D, as determined by the 3-bit binary address line, A0, A1, and EN. Signed-off-by: Antoniu Miclaus <[email protected]>
Add README.rst for the adg2404 driver and integrate it into the sphinx build. Signed-off-by: Antoniu Miclaus <[email protected]>
bfc8e3f
to
2a678cc
Compare
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.
v2:
- return direcly
- use
no_os_calloc
- use bool for enable/disable
- drop adg2404_dev
- use
no_os_gpio_get
Pull Request Description
mux: adg2404: add initial driver support
mux: adg2404: add driver documentation
PR Type
PR Checklist