Skip to content

Conversation

@nunojsa
Copy link
Collaborator

@nunojsa nunojsa commented Oct 9, 2025

PR Description

Minor code simplifications for the adrv9002 driver.

PR Type

  • Bug fix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly (if there is the case)

There's no reason for that buffer to not be const. Furthermore
jsmn_parse() indeed expects a const buffer.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Given that adi_adrv9001_profileutil_Parse() now accepts a const buffer
and that the bounce buffer was mainly to avoid hacky casts from const to
non const buffers, simplify adrv9002_profile_load() by directly passing
the fw->data to adi_adrv9001_profileutil_Parse().

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
ADRV9002_PORT_MASK() already takes care between RX vs TX differences
when dealing with port masks. Hence the if() else is useless and in fact
the statements in each branch are the same.

Caught by coccinelle (through CI).

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
@nunojsa nunojsa requested a review from machschmitt as a code owner October 9, 2025 14:52
Use __free(firmware) in order to automatically release the requested
firmware and simplify code paths.

Note that adrv9002_init_cals_handle() we do not use as that functions
makes use of goto jumps which does not properly work with the cleanup
stuff (see cleanup.h for more details).

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
@nunojsa nunojsa changed the title Staging/xlnx/adrv9002 improvements Small adrv9002 improvements Oct 9, 2025
@nunojsa nunojsa force-pushed the staging/xlnx/adrv9002-improvements branch from 814f894 to ae5d019 Compare October 9, 2025 15:22
Copy link
Contributor

@gastmaier gastmaier left a comment

Choose a reason for hiding this comment

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

  • iio: adc: adrv9002: profileutil: Constify jsonbuffer
    OK, Constify is just a weird word
  • iio: adc: adrv9002: Drop profile bounce buffer
    OK
  • iio: adc: adrv9002: Drop useless if() condition
    OK, yes, the lines in the if are identical, probably older than the macron itself.
  • iio: adc: adrv9002: Use firmware auto cleanup
    OK, makes things simpler

unsigned long *prate)
{
struct adrv9002_clock *clk_priv = to_clk_priv(hw);

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 the deadcode for dev_dbg occurs for if the DEBUG symbols are missing and the method is optimized away.
Adding to the todo-list to see if really the case, and enable in adi_ci_defconfig if so.
The already enabled flags are

CONFIG_MODULE_DEBUG=y
CONFIG_DEBUG_DRIVER=y
CONFIG_DEBUG_KERNEL=y
CONFIG_DEBUG_FS=y

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, most likely. I'll actually evaluate to drop those dev_dbg(). Not that useful anyways

else
profile = phy->chip->lvd_profile;

const struct firmware *fw __free(firmware) = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

cool

#define ADI_ADRV9001_TOKEN_MAX_LENGTH 32

int32_t adi_adrv9001_profileutil_Parse(adi_adrv9001_Device_t *device, adi_adrv9001_Init_t *init, char * jsonBuffer, uint32_t length)
int32_t adi_adrv9001_profileutil_Parse(adi_adrv9001_Device_t *device, adi_adrv9001_Init_t *init, const char * jsonBuffer, uint32_t length)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since already fixing trailing whitespace, could fix the space between the pointer operator and the var name

Suggested change
int32_t adi_adrv9001_profileutil_Parse(adi_adrv9001_Device_t *device, adi_adrv9001_Init_t *init, const char * jsonBuffer, uint32_t length)
int32_t adi_adrv9001_profileutil_Parse(adi_adrv9001_Device_t *device, adi_adrv9001_Init_t *init, const char *jsonBuffer, uint32_t length)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is API stuff and all the white spaces will be lost anyways (since when I send the PR to the BU I only take the real change into account). The whites spaces in here is because I have my editor to automatically trim them on save and I'm lazy to care about it 😅

@nunojsa nunojsa merged commit 2a95b60 into main Oct 27, 2025
58 of 70 checks passed
@nunojsa nunojsa deleted the staging/xlnx/adrv9002-improvements branch October 27, 2025 14:34
github-actions bot pushed a commit that referenced this pull request Oct 27, 2025
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