Skip to content

Commit

Permalink
iio: adc: ad9631: add ad9361_uses_rx2tx2() accessor
Browse files Browse the repository at this point in the history
The rx2tx2 field from platform data is accessed a few times in
`ad9361_conv.c`.
This change adds an accessor func to help make the platform data more
opaque.

Signed-off-by: Alexandru Ardelean <[email protected]>
  • Loading branch information
commodo committed Apr 18, 2018
1 parent e0f37fc commit 8d30532
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions drivers/iio/adc/ad9361.c
Original file line number Diff line number Diff line change
Expand Up @@ -4024,6 +4024,12 @@ int ad9361_set_trx_clock_chain_default(struct ad9361_rf_phy *phy)
}
EXPORT_SYMBOL(ad9361_set_trx_clock_chain_default);

bool ad9361_uses_rx2tx2(struct ad9361_rf_phy *phy)
{
return phy && phy->pdata && phy->pdata->rx2tx2;
}
EXPORT_SYMBOL(ad9361_uses_rx2tx2);

static int ad9361_get_trx_clock_chain(struct ad9361_rf_phy *phy, unsigned long *rx_path_clks,
unsigned long *tx_path_clks)
{
Expand Down
1 change: 1 addition & 0 deletions drivers/iio/adc/ad9361.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ int ad9361_dig_tune(struct ad9361_rf_phy *phy, unsigned long max_freq,
enum dig_tune_flags flags);
int ad9361_tx_mute(struct ad9361_rf_phy *phy, u32 state);
int ad9361_write_bist_reg(struct ad9361_rf_phy *phy, u32 val);
bool ad9361_uses_rx2tx2(struct ad9361_rf_phy *phy);

#endif

6 changes: 3 additions & 3 deletions drivers/iio/adc/ad9361_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ static int ad9361_dig_tune_delay(struct ad9361_rf_phy *phy,
u8 field[2][16];

if (((phy->pdata->port_ctrl.pp_conf[2] & LVDS_MODE) ||
!phy->pdata->rx2tx2))
!ad9361_uses_rx2tx2(phy)))
half_data_rate = false;
else
half_data_rate = true;
Expand Down Expand Up @@ -681,7 +681,7 @@ static int ad9361_post_setup(struct iio_dev *indio_dev)
struct axiadc_state *st = iio_priv(indio_dev);
struct axiadc_converter *conv = iio_device_get_drvdata(indio_dev);
struct ad9361_rf_phy *phy = conv->phy;
unsigned rx2tx2 = phy->pdata->rx2tx2;
bool rx2tx2 = ad9361_uses_rx2tx2(phy);
unsigned tmp, num_chan, flags;
int i, ret;

Expand Down Expand Up @@ -757,7 +757,7 @@ int ad9361_register_axi_converter(struct ad9361_rf_phy *phy)

conv->chip_info = &axiadc_chip_info_tbl[
(spi_get_device_id(spi)->driver_data == ID_AD9361_2) ?
ID_AD9361_2 : phy->pdata->rx2tx2 ? ID_AD9361 : ID_AD9364];
ID_AD9361_2 : ad9361_uses_rx2tx2(phy) ? ID_AD9361 : ID_AD9364];
conv->write_raw = ad9361_write_raw;
conv->read_raw = ad9361_read_raw;
conv->post_setup = ad9361_post_setup;
Expand Down

0 comments on commit 8d30532

Please sign in to comment.