-
Notifications
You must be signed in to change notification settings - Fork 858
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
Conversation
b6584bc
to
9b859c5
Compare
V2
|
drivers/iio/adc/adrv902x/adrv9025.c
Outdated
u64 tmask, mask; | ||
int val, ret = 0; | ||
u32 txchan = 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.
i think explicit initialization is not needed here.
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.
removed
drivers/iio/adc/adrv902x/adrv9025.c
Outdated
|
||
adi_adrv9025_RxQecStatus_t rxQecStatus = { 0 }; | ||
|
||
if (chan->channel < 4) |
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.
magic number
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.
replaced with macro
drivers/iio/adc/adrv902x/adrv9025.c
Outdated
ret = adi_adrv9025_TrackingCalRxQecStatusGet(phy->madDevice, rxchan, &rxQecStatus); | ||
else | ||
ret = adi_adrv9025_TrackingCalOrxQecStatusGet(phy->madDevice, rxchan, (adi_adrv9025_OrxQecStatus_t *)&rxQecStatus); | ||
if (ret == 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.
if (!ret)
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.
done
dcbdd21
to
9c5111a
Compare
V3
|
drivers/iio/adc/adrv902x/adrv9025.c
Outdated
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; |
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 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.
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.
done
drivers/iio/adc/adrv902x/adrv9025.c
Outdated
case RX_QEC_STATUS: | ||
rxchan = ADI_ADRV9025_RX1 << chan->channel; | ||
|
||
adi_adrv9025_RxQecStatus_t rxQecStatus = { 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.
although c11 already allows for mixed code declarations, it is still not an encouraged style in the kernel...
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.
Thank you for the observation. Replaced in the new version.
9c5111a
to
9a11f26
Compare
V4
|
@@ -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) |
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.
Do not use tabs in here...
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 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; |
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 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...
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 error in case status cannot be read.
drivers/iio/adc/adrv902x/adrv9025.c
Outdated
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; |
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.
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(...);
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.
V4
- return error in case status cannot be read
- reorganize to better handle error cases
f2e9c6e
to
f674a0e
Compare
V5
|
Add RX_QEC, ORX_QEC, TX_QEC, TX_LOL status IIO attributes. Signed-off-by: George Mois <george.mois@analog.com>
f674a0e
to
a63dc02
Compare
V6
|
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.
Looks much better to me now
PR Description
Add RX_QEC, ORX_QEC, TX_QEC, TX_LOL status IIO attributes.
PR Type
PR Checklist