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

adc: adrv902x: adrv9025.c: Tracking cals status #2705

Merged
merged 1 commit into from
Feb 10, 2025
Merged

Conversation

danmois
Copy link
Contributor

@danmois danmois commented Jan 27, 2025

PR Description

Add RX_QEC, ORX_QEC, TX_QEC, TX_LOL status IIO attributes.

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)

@danmois danmois changed the title adc: adrv902x: adrv9025.c: Tracking calls status adc: adrv902x: adrv9025.c: Tracking cals status Jan 27, 2025
@danmois
Copy link
Contributor Author

danmois commented Jan 27, 2025

V2

  • correct commit title

u64 tmask, mask;
int val, ret = 0;
u32 txchan = 0;
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 explicit initialization is not needed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed


adi_adrv9025_RxQecStatus_t rxQecStatus = { 0 };

if (chan->channel < 4)
Copy link
Contributor

Choose a reason for hiding this comment

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

magic number

Copy link
Contributor Author

Choose a reason for hiding this comment

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

replaced with macro

ret = adi_adrv9025_TrackingCalRxQecStatusGet(phy->madDevice, rxchan, &rxQecStatus);
else
ret = adi_adrv9025_TrackingCalOrxQecStatusGet(phy->madDevice, rxchan, (adi_adrv9025_OrxQecStatus_t *)&rxQecStatus);
if (ret == 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

if (!ret)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@danmois danmois force-pushed the madura_tr_calls branch 2 times, most recently from dcbdd21 to 9c5111a Compare January 28, 2025 13:15
@danmois
Copy link
Contributor Author

danmois commented Jan 28, 2025

V3

  • implement review changes

case TX_LOL_STATUS:
ret = sprintf(buf, "err %d %% %d perf %d iter cnt %d update cnt %d\n", txLolStatus.errorCode, txLolStatus.percentComplete,
txLolStatus.varianceMetric, txLolStatus.iterCount, txLolStatus.updateCount);
break;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not really how sysfs attrs should be handled. It's a value per file (yes, we do have driver doing the same kind of abuse but we should avoid it). This looks like debug information so I would move it to debugfs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

case RX_QEC_STATUS:
rxchan = ADI_ADRV9025_RX1 << chan->channel;

adi_adrv9025_RxQecStatus_t rxQecStatus = { 0 };
Copy link
Collaborator

Choose a reason for hiding this comment

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

although c11 already allows for mixed code declarations, it is still not an encouraged style in the kernel...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the observation. Replaced in the new version.

@danmois
Copy link
Contributor Author

danmois commented Jan 29, 2025

V4

  • move status read to debugfs

@@ -1345,13 +1345,63 @@ static const struct iio_info adrv9025_phy_info = {
.attrs = &adrv9025_phy_attribute_group,
};

static ssize_t adrv9025_rx_qec_status_read(adi_adrv9025_Device_t *device,
adi_adrv9025_RxChannels_e rxChannel,
char *buf)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not use tabs in here...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hope I got this right (spaces for the second line and new line for the last).

case DBGFS_TX3_LOL_STATUS:
chan = ADI_ADRV9025_TX1 << (entry->cmd - DBGFS_TX0_LOL_STATUS);
len = adrv9025_tx_lol_status_read(phy->madDevice, chan, buf);
break;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This also does not look good. What if you fail to get the status? Right now you return 0 and then print val (which is 0) to userspace and that value is meaningless. This needs some refactor (at least for the new attrs). Properly return error codes when they happen...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Return error in case status cannot be read.

len = sprintf(buf, "err %d %% %d perf %d iter cnt %d update cnt %d\n", rxQecStatus.errorCode, rxQecStatus.percentComplete,
rxQecStatus.selfcheckIrrDb, rxQecStatus.iterCount, rxQecStatus.updateCount);

return len;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Flip the. You can get rid of len and the typical pattern is to first look for errors... You're also ignoring errors...

if (ret)
    return ret;

return sprintf(...);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

V4

  • return error in case status cannot be read
  • reorganize to better handle error cases

@danmois danmois force-pushed the madura_tr_calls branch 2 times, most recently from f2e9c6e to f674a0e Compare February 7, 2025 07:24
@danmois
Copy link
Contributor Author

danmois commented Feb 7, 2025

V5

  • replace spaces with tabs in function definitions

Add RX_QEC, ORX_QEC, TX_QEC, TX_LOL status IIO attributes.

Signed-off-by: George Mois <george.mois@analog.com>
@danmois
Copy link
Contributor Author

danmois commented Feb 7, 2025

V6

  • fix whitespace errors

Copy link
Collaborator

@nunojsa nunojsa left a comment

Choose a reason for hiding this comment

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

Looks much better to me now

@nunojsa nunojsa merged commit 1c561ce into main Feb 10, 2025
13 checks passed
@nunojsa nunojsa deleted the madura_tr_calls branch February 10, 2025 08:31
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