Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions drivers/iio/adc/adrv902x/adrv9025.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
adrv9025_JESD204_FSM_STATE,
adrv9025_JESD204_FSM_RESUME,
adrv9025_JESD204_FSM_CTRL,
ADRV9025_INIT_CALS_COMPLETE_CHECK,
ADRV9025_INIT_STATUS_ALL,
ADRV9025_TRACKING_STATUS_ALL
};

static int __adrv9025_dev_err(struct adrv9025_rf_phy *phy, const char *function,
Expand Down Expand Up @@ -561,6 +564,67 @@

ret = sysfs_emit(buf, "%d\n", phy->is_initialized);
break;

case ADRV9025_INIT_CALS_COMPLETE_CHECK:
uint8_t status;

Check warning on line 569 in drivers/iio/adc/adrv902x/adrv9025.c

View workflow job for this annotation

GitHub Actions / checks / checks

checkpatch: Prefer kernel type 'u8' over 'uint8_t' + uint8_t status;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Variables declared mid-block violate kernel style. Move all declarations to the top of the switch case

uint8_t ARMflag;

Check warning on line 570 in drivers/iio/adc/adrv902x/adrv9025.c

View workflow job for this annotation

GitHub Actions / checks / checks

checkpatch: Prefer kernel type 'u8' over 'uint8_t' + uint8_t ARMflag;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same comment as above

ret = adi_adrv9025_InitCalsCheckCompleteGet(phy->madDevice, &status, &ARMflag);

Check warning on line 571 in drivers/iio/adc/adrv902x/adrv9025.c

View workflow job for this annotation

GitHub Actions / checks / checks

checkpatch: Missing a blank line after declarations + uint8_t ARMflag; + ret = adi_adrv9025_InitCalsCheckCompleteGet(phy->madDevice, &status, &ARMflag);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The naming of the ARMflag is inconsistent, as it uses CamelCase. The kernel preferred style is arm_flag.

if (ret)
adrv9025_dev_err(phy);

ret = sysfs_emit(buf, "Status: %d, ARM is error?: %d\n", status, ARMflag);

break;
case ADRV9025_INIT_STATUS_ALL:
adi_adrv9025_InitCalStatus_t initStatus;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same comment, move declaration to the top of the switch case.

ret = adi_adrv9025_InitCalsDetailedStatusGet(phy->madDevice, &initStatus);

Check warning on line 580 in drivers/iio/adc/adrv902x/adrv9025.c

View workflow job for this annotation

GitHub Actions / checks / checks

checkpatch: Missing a blank line after declarations + adi_adrv9025_InitCalStatus_t initStatus; + ret = adi_adrv9025_InitCalsDetailedStatusGet(phy->madDevice, &initStatus);
if (ret)
adrv9025_dev_err(phy);

ret = sysfs_emit(buf,
"initErrCode: 0x%08x (objId=0x%02x err=0x%02x)\n"
"initErrCal: 0x%08x, durationUsec: %u\n"
"calsSincePowerUp: [0x%08x 0x%08x 0x%08x 0x%08x]\n"
"calsLastRun: [0x%08x 0x%08x 0x%08x 0x%08x]\n",
initStatus.initErrCode,
(initStatus.initErrCode >> 8) & 0xFF, initStatus.initErrCode & 0xFF,
initStatus.initErrCal, initStatus.calsDurationUsec,
initStatus.calsSincePowerUp[0], initStatus.calsSincePowerUp[1],
initStatus.calsSincePowerUp[2], initStatus.calsSincePowerUp[3],
initStatus.calsLastRun[0], initStatus.calsLastRun[1],
initStatus.calsLastRun[2], initStatus.calsLastRun[3]);
break;

case ADRV9025_TRACKING_STATUS_ALL:
adi_adrv9025_TrackingCalState_t st;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

another mid-block declaration. Move declaration to the top or wrap each case body in braces to create a new scope.


ret = adi_adrv9025_TrackingCalAllStateGet(phy->madDevice, &st);
if (ret)
adrv9025_dev_err(phy);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hmm... Should you return ret or return adrv9025_dev_err(phy)?

if (ret) {
    adrv9025_dev_err(phy);
    return ret;
}

or

if (ret)
    return adrv9025_dev_err(phy);

please check this everywhere in the code.


ret = sysfs_emit(buf,
"calError: 0x%016llx\n"
"rxQec: [%u %u %u %u]\n"
"orxQec: [%u %u %u %u]\n"
"txLol: [%u %u %u %u]\n"
"txQec: [%u %u %u %u]\n"
"txDpd: [%u %u %u %u]\n"
"txClgc: [%u %u %u %u]\n"
"txVswr: [%u %u %u %u]\n"
"rxHd2: [%u %u %u %u]\n"
"deserializer: %u\n",
(unsigned long long)st.calError,
st.rx1Qec, st.rx2Qec, st.rx3Qec, st.rx4Qec,
st.orx1Qec, st.orx2Qec, st.orx3Qec, st.orx4Qec,
st.tx1Lol, st.tx2Lol, st.tx3Lol, st.tx4Lol,
st.tx1Qec, st.tx2Qec, st.tx3Qec, st.tx4Qec,
st.tx1Dpd, st.tx2Dpd, st.tx3Dpd, st.tx4Dpd,
st.tx1Clgc, st.tx2Clgc, st.tx3Clgc, st.tx4Clgc,
st.tx1Vswr, st.tx2Vswr, st.tx3Vswr, st.tx4Vswr,
st.rx1Hd2, st.rx2Hd2, st.rx3Hd2, st.rx4Hd2,
st.deserializer);
break;

default:
ret = -EINVAL;
}
Expand All @@ -585,6 +649,10 @@
ADRV9025_INIT_CAL |
(ADI_ADRV9025_TX_LO_LEAKAGE_INTERNAL << 8));

static IIO_DEVICE_ATTR(init_cals_complete_check, 0444,
adrv9025_phy_show, NULL,
ADRV9025_INIT_CALS_COMPLETE_CHECK);

static IIO_DEVICE_ATTR(calibrate_tx_lol_ext_en, 0644,
adrv9025_phy_show, adrv9025_phy_store,
ADRV9025_INIT_CAL |
Expand All @@ -594,9 +662,31 @@
adrv9025_phy_show, adrv9025_phy_store,
ADRV9025_INIT_CAL | (ADI_ADRV9025_EXTERNAL_PATH_DELAY << 8));

static IIO_DEVICE_ATTR(calibrate_orx_qec_en, 0644,
adrv9025_phy_show, adrv9025_phy_store,
ADRV9025_INIT_CAL | (ADI_ADRV9025_ORX_QEC_INIT << 8));

static IIO_DEVICE_ATTR(calibrate_orx_lo_delay_en, 0644,
adrv9025_phy_show, adrv9025_phy_store,
ADRV9025_INIT_CAL | (ADI_ADRV9025_ORX_LO_DELAY << 8));

static IIO_DEVICE_ATTR(calibrate_adc_en, 0644,
adrv9025_phy_show, adrv9025_phy_store,
ADRV9025_INIT_CAL | (ADI_ADRV9025_ADC_TUNER << 8));

static IIO_DEVICE_ATTR(calibrate_orx_adc_en, 0644,
adrv9025_phy_show, adrv9025_phy_store,
ADRV9025_INIT_CAL | (ADI_ADRV9025_ORX_TIA << 8));

static IIO_DEVICE_ATTR(calibrate_mask, 0644, adrv9025_phy_show,
adrv9025_phy_store, ADRV9025_CAL_MASK);

static IIO_DEVICE_ATTR(init_cals_all_status, 0644, adrv9025_phy_show,
NULL, ADRV9025_INIT_STATUS_ALL);

static IIO_DEVICE_ATTR(tracking_cals_all_status, 0644, adrv9025_phy_show,
NULL, ADRV9025_TRACKING_STATUS_ALL);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks like wrong permissions. init_cals_all_status and tracking_cals_all_status are declared with mode 0644 but pass NULL for the store function. Probably it should be 0444

static IIO_DEVICE_ATTR(dpd_tx_mask, 0644, adrv9025_phy_show,
adrv9025_phy_store, ADRV9025_DPD_TX_MASK);

Expand Down Expand Up @@ -633,12 +723,19 @@

static struct attribute *adrv9026_phy_attributes[] = {
&iio_dev_attr_calibrate.dev_attr.attr,
&iio_dev_attr_init_cals_complete_check.dev_attr.attr,
&iio_dev_attr_calibrate_rx_qec_en.dev_attr.attr,
&iio_dev_attr_calibrate_tx_qec_en.dev_attr.attr,
&iio_dev_attr_calibrate_tx_lol_en.dev_attr.attr,
&iio_dev_attr_calibrate_tx_lol_ext_en.dev_attr.attr,
&iio_dev_attr_calibrate_ext_path_delay_en.dev_attr.attr,
&iio_dev_attr_calibrate_orx_qec_en.dev_attr.attr,
&iio_dev_attr_calibrate_orx_lo_delay_en.dev_attr.attr,
&iio_dev_attr_calibrate_adc_en.dev_attr.attr,
&iio_dev_attr_calibrate_orx_adc_en.dev_attr.attr,
&iio_dev_attr_calibrate_mask.dev_attr.attr,
&iio_dev_attr_init_cals_all_status.dev_attr.attr,
&iio_dev_attr_tracking_cals_all_status.dev_attr.attr,
&iio_dev_attr_jesd204_fsm_error.dev_attr.attr,
&iio_dev_attr_jesd204_fsm_state.dev_attr.attr,
&iio_dev_attr_jesd204_fsm_paused.dev_attr.attr,
Expand All @@ -649,12 +746,19 @@

static struct attribute *adrv9029_phy_attributes[] = {
&iio_dev_attr_calibrate.dev_attr.attr,
&iio_dev_attr_init_cals_complete_check.dev_attr.attr,
&iio_dev_attr_calibrate_rx_qec_en.dev_attr.attr,
&iio_dev_attr_calibrate_tx_qec_en.dev_attr.attr,
&iio_dev_attr_calibrate_tx_lol_en.dev_attr.attr,
&iio_dev_attr_calibrate_tx_lol_ext_en.dev_attr.attr,
&iio_dev_attr_calibrate_ext_path_delay_en.dev_attr.attr,
&iio_dev_attr_calibrate_orx_qec_en.dev_attr.attr,
&iio_dev_attr_calibrate_orx_lo_delay_en.dev_attr.attr,
&iio_dev_attr_calibrate_adc_en.dev_attr.attr,
&iio_dev_attr_calibrate_orx_adc_en.dev_attr.attr,
&iio_dev_attr_calibrate_mask.dev_attr.attr,
&iio_dev_attr_init_cals_all_status.dev_attr.attr,
&iio_dev_attr_tracking_cals_all_status.dev_attr.attr,
&iio_dev_attr_dpd_tx_mask.dev_attr.attr,
&iio_dev_attr_dpd_reset.dev_attr.attr,
&iio_dev_attr_dpd_tracking_config_set.dev_attr.attr,
Expand Down Expand Up @@ -2442,7 +2546,7 @@
static long adrv9025_bb_round_rate(struct clk_hw *hw, unsigned long rate,
unsigned long *prate)
{
struct adrv9025_clock *clk_priv = to_clk_priv(hw);

Check warning on line 2549 in drivers/iio/adc/adrv902x/adrv9025.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'clk_priv' during its initialization is never read [deadcode.DeadStores] 2549 | struct adrv9025_clock *clk_priv = to_clk_priv(hw); | ^~~~~~~~ ~~~~~~~~~~~~~~~

dev_dbg(&clk_priv->spi->dev, "%s: Rate %lu Hz", __func__, rate);

Expand Down Expand Up @@ -2580,7 +2684,7 @@
static int adrv9025_jesd204_link_pre_setup(struct jesd204_dev *jdev,
enum jesd204_state_op_reason reason)
{
struct device *dev = jesd204_dev_to_device(jdev);

Check warning on line 2687 in drivers/iio/adc/adrv902x/adrv9025.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'dev' during its initialization is never read [deadcode.DeadStores] 2687 | struct device *dev = jesd204_dev_to_device(jdev); | ^~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev);
struct adrv9025_rf_phy *phy = priv->phy;
long dev_clk;
Expand Down Expand Up @@ -2615,7 +2719,7 @@
enum jesd204_state_op_reason reason,
struct jesd204_link *lnk)
{
struct device *dev = jesd204_dev_to_device(jdev);

Check warning on line 2722 in drivers/iio/adc/adrv902x/adrv9025.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'dev' during its initialization is never read [deadcode.DeadStores] 2722 | struct device *dev = jesd204_dev_to_device(jdev); | ^~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev);
struct adrv9025_rf_phy *phy = priv->phy;
adi_adrv9025_FrmCfg_t *framer = NULL;
Expand Down Expand Up @@ -2725,7 +2829,7 @@
static int adrv9025_jesd204_link_setup(struct jesd204_dev *jdev,
enum jesd204_state_op_reason reason)
{
struct device *dev = jesd204_dev_to_device(jdev);

Check warning on line 2832 in drivers/iio/adc/adrv902x/adrv9025.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'dev' during its initialization is never read [deadcode.DeadStores] 2832 | struct device *dev = jesd204_dev_to_device(jdev); | ^~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev);
struct adrv9025_rf_phy *phy = priv->phy;
int ret;
Expand Down Expand Up @@ -2783,7 +2887,7 @@
static int adrv9025_jesd204_setup_stage1(struct jesd204_dev *jdev,
enum jesd204_state_op_reason reason)
{
struct device *dev = jesd204_dev_to_device(jdev);

Check warning on line 2890 in drivers/iio/adc/adrv902x/adrv9025.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'dev' during its initialization is never read [deadcode.DeadStores] 2890 | struct device *dev = jesd204_dev_to_device(jdev); | ^~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev);
struct adrv9025_rf_phy *phy = priv->phy;
int ret, i;
Expand Down Expand Up @@ -2822,7 +2926,7 @@
static int adrv9025_jesd204_setup_stage2(struct jesd204_dev *jdev,
enum jesd204_state_op_reason reason)
{
struct device *dev = jesd204_dev_to_device(jdev);

Check warning on line 2929 in drivers/iio/adc/adrv902x/adrv9025.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'dev' during its initialization is never read [deadcode.DeadStores] 2929 | struct device *dev = jesd204_dev_to_device(jdev); | ^~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev);
struct adrv9025_rf_phy *phy = priv->phy;
int ret;
Expand Down Expand Up @@ -2856,7 +2960,7 @@
enum jesd204_state_op_reason reason,
struct jesd204_link *lnk)
{
struct device *dev = jesd204_dev_to_device(jdev);

Check warning on line 2963 in drivers/iio/adc/adrv902x/adrv9025.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'dev' during its initialization is never read [deadcode.DeadStores] 2963 | struct device *dev = jesd204_dev_to_device(jdev); | ^~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev);
struct adrv9025_rf_phy *phy = priv->phy;
int ret;
Expand Down Expand Up @@ -2964,7 +3068,7 @@
enum jesd204_state_op_reason reason,
struct jesd204_link *lnk)
{
struct device *dev = jesd204_dev_to_device(jdev);

Check warning on line 3071 in drivers/iio/adc/adrv902x/adrv9025.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'dev' during its initialization is never read [deadcode.DeadStores] 3071 | struct device *dev = jesd204_dev_to_device(jdev); | ^~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev);
struct adrv9025_rf_phy *phy = priv->phy;
int ret;
Expand Down Expand Up @@ -3019,7 +3123,7 @@
enum jesd204_state_op_reason reason,
struct jesd204_link *lnk)
{
struct device *dev = jesd204_dev_to_device(jdev);

Check warning on line 3126 in drivers/iio/adc/adrv902x/adrv9025.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'dev' during its initialization is never read [deadcode.DeadStores] 3126 | struct device *dev = jesd204_dev_to_device(jdev); | ^~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev);
struct adrv9025_rf_phy *phy = priv->phy;
int ret;
Expand Down Expand Up @@ -3094,7 +3198,7 @@
static int adrv9025_jesd204_post_running_stage(struct jesd204_dev *jdev,
enum jesd204_state_op_reason reason)
{
struct device *dev = jesd204_dev_to_device(jdev);

Check warning on line 3201 in drivers/iio/adc/adrv902x/adrv9025.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: Value stored to 'dev' during its initialization is never read [deadcode.DeadStores] 3201 | struct device *dev = jesd204_dev_to_device(jdev); | ^~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev);
struct adrv9025_rf_phy *phy = priv->phy;
int ret;
Expand Down
Loading