Skip to content

Conversation

amiclaus
Copy link
Contributor

@amiclaus amiclaus commented Sep 1, 2025

Pull Request Description

mux: adg2404: add initial driver support
mux: adg2404: add driver documentation

PR Type

  • Bug fix (change that fixes an issue)
  • New feature (change that adds new functionality)
  • Breaking change (has dependencies in other repos or will cause CI to fail)

PR Checklist

  • I have followed the Coding style guidelines
  • I have complied with the Submission Checklist
  • I have performed a self-review of the changes
  • I have commented my code, at least hard-to-understand parts
  • I have build all projects affected by the changes in this PR
  • I have tested in hardware affected projects, at the relevant boards
  • I have signed off all commits from this PR
  • I have updated the documentation (wiki pages, ReadMe etc), if applies

Comment on lines 58 to 61
ret = adg2404_enable(dev, ADG2404_DISABLE);
if (ret)
return ret;
return 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return directly

Comment on lines 105 to 103
dev = (struct adg2404_dev *)no_os_malloc(sizeof(*dev));
if (!dev)
return -ENOMEM;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use calloc() instead

* @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)
Copy link
Contributor

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

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;
Copy link
Contributor

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

if (!dev)
return -EINVAL;

return no_os_gpio_set_value(dev->gpio_en, state);
Copy link
Contributor

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 ?

if (!dev)
return -ENOMEM;

ret = no_os_gpio_init(&dev->gpio_a0, &init_param->gpio_a0);
Copy link
Contributor

@CiprianRegus CiprianRegus Sep 1, 2025

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]>
Copy link
Contributor Author

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

@CiprianRegus CiprianRegus merged commit a04efa3 into main Sep 8, 2025
14 checks passed
@CiprianRegus CiprianRegus deleted the staging/adg2404 branch September 8, 2025 12:41
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.

3 participants