Skip to content

Commit e18dae2

Browse files
committed
iio: adc: adrv9002: rearrange 'adrv9002_attr_show'
Follow the logic of the rest of the driver and just lock() the complete function. This makes it simpler (and most of the settings need to be locked anyways) in a following patch to add support for the initial calibrations attribute. Signed-off-by: Nuno Sa <nuno.sa@analog.com>
1 parent 1e555d9 commit e18dae2

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

drivers/iio/adc/navassa/adrv9002.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -552,46 +552,49 @@ static int adrv9002_fh_table_show(struct adrv9002_rf_phy *phy, char *buf, u64 ad
552552
{
553553
adi_adrv9001_FhMode_e mode = phy->fh.mode;
554554
adi_adrv9001_FhHopTable_e table;
555-
int ret = -ENOTSUPP;
555+
int ret;
556556

557-
mutex_lock(&phy->lock);
558557
if (!phy->curr_profile->sysConfig.fhModeOn) {
559558
dev_err(&phy->spi->dev, "Frequency hopping not enabled\n");
560-
goto out_unlock;
559+
return -ENOTSUPP;
561560
}
562561

563562
if (address && mode != ADI_ADRV9001_FHMODE_LO_RETUNE_REALTIME_PROCESS_DUAL_HOP) {
564563
dev_err(&phy->spi->dev, "HOP2 not supported! FH mode not in dual hop.\n");
565-
goto out_unlock;
564+
return -ENOTSUPP;
566565
}
567566

568567
ret = api_call(phy, adi_adrv9001_fh_HopTable_Get, address, &table);
569568
if (ret)
570-
goto out_unlock;
571-
mutex_unlock(&phy->lock);
569+
return ret;
572570

573571
if (table >= ADRV9002_FH_TABLES_NR)
574572
table = ADRV9002_FH_TABLES_NR;
575573

576574
return sysfs_emit(buf, "%s\n", adrv9002_hop_table[table]);
577-
out_unlock:
578-
mutex_unlock(&phy->lock);
579-
return ret;
580575
}
581576

582577
static ssize_t adrv9002_attr_show(struct device *dev, struct device_attribute *attr, char *buf)
583578
{
584579
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
585580
struct adrv9002_rf_phy *phy = iio_priv(indio_dev);
586581
struct iio_dev_attr *iio_attr = to_iio_dev_attr(attr);
582+
int ret;
583+
584+
mutex_lock(&phy->lock);
587585

588586
switch (iio_attr->address) {
589587
case ADRV9002_HOP_1_TABLE_SEL:
590588
case ADRV9002_HOP_2_TABLE_SEL:
591-
return adrv9002_fh_table_show(phy, buf, iio_attr->address);
589+
ret = adrv9002_fh_table_show(phy, buf, iio_attr->address);
590+
break;
592591
default:
593-
return -EINVAL;
592+
ret = -EINVAL;
594593
}
594+
595+
mutex_unlock(&phy->lock);
596+
597+
return ret;
595598
}
596599

597600
static int adrv9002_fh_set(const struct adrv9002_rf_phy *phy, const char *buf, u64 address)

0 commit comments

Comments
 (0)