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
39 changes: 20 additions & 19 deletions drivers/iio/adc/navassa/adrv9002.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
static long adrv9002_bb_round_rate(struct clk_hw *hw, unsigned long rate,
unsigned long *prate)
{
struct adrv9002_clock *clk_priv = to_clk_priv(hw);

Check warning on line 336 in drivers/iio/adc/navassa/adrv9002.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] 336 | struct adrv9002_clock *clk_priv = to_clk_priv(hw); | ^~~~~~~~ ~~~~~~~~~~~~~~~

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

Expand Down Expand Up @@ -3008,7 +3008,7 @@
adi_adrv9001_PllLoMode_e modes[] = { clocks->rfPll1LoMode, clocks->rfPll2LoMode };
u16 dividers[] = { clocks->extLo1Divider, clocks->extLo2Divider };
/* -1 since the enums start at 1 */
unsigned int lo = lo_selects[idx * 2 + tx] - 1;

Check warning on line 3011 in drivers/iio/adc/navassa/adrv9002.c

View workflow job for this annotation

GitHub Actions / build_llvm_x86_64 / build

clang_analyzer: The left operand of '-' is a garbage value due to array index out of bounds [core.UndefinedBinaryOperatorResult] 3011 | unsigned int lo = lo_selects[idx COPYING CREDITS Documentation Kbuild Kconfig Kconfig.adi LICENSES MAINTAINERS Makefile Module.symvers README README.md System.map arch azure-pipelines-rpi.yml azure-pipelines.yml block built-in.a certs ci compile_commands.json crypto defconfig dist dist-headers docs drivers firmware fs include init io_uring ipc kernel lib mm modules.builtin modules.builtin.modinfo modules.order net rust samples scripts security sound tools usr virt vmlinux vmlinux.a vmlinux.o 2 + tx] - 1; | ^
struct device *dev = &phy->spi->dev;

if (lo >= ARRAY_SIZE(modes)) {
Expand Down Expand Up @@ -3449,10 +3449,9 @@
return api_call(phy, adi_adrv9001_arm_StartStatus_Check, 5000000);
}

static u64 adrv9002_get_init_carrier(const struct adrv9002_chan *c)
static int adrv9002_get_init_carrier(const struct adrv9002_chan *c, u64 *carrier)
{
const struct adrv9002_rf_phy *phy = chan_to_phy(c);
u64 lo_freq;

if (!c->ext_lo) {
/* If no external LO, keep the same values as before */
Expand All @@ -3462,37 +3461,36 @@
* mode, the carrier needs to be in the given range.
*/
if (c->carrier)
lo_freq = c->carrier;
*carrier = c->carrier;
else
lo_freq = 2400000000ULL;
*carrier = 2400000000ULL;

if (!phy->port_switch.enable || phy->port_switch.manualRxPortSwitch)
return lo_freq;
return 0;

if (ADRV9002_PORT_SWITCH_IN_RANGE(&phy->port_switch, lo_freq))
return lo_freq;
if (ADRV9002_PORT_SWITCH_IN_RANGE(&phy->port_switch, *carrier))
return 0;

dev_dbg(&phy->spi->dev, "RX%u LO(%llu) not in allowed range, Using(%llu)\n",
c->number, lo_freq, phy->port_switch.maxFreqPortA_Hz);
c->number, *carrier, phy->port_switch.maxFreqPortA_Hz);
/* just choose one valid value */
return phy->port_switch.maxFreqPortA_Hz;
*carrier = phy->port_switch.maxFreqPortA_Hz;
return 0;
}

if (c->carrier)
return c->carrier;

return 2450000000ULL;
*carrier = c->carrier ?: 2450000000ULL;
return 0;
}

lo_freq = DIV_ROUND_CLOSEST_ULL(clk_get_rate_scaled(c->ext_lo->clk, &c->ext_lo->scale),
c->ext_lo->divider);
*carrier = DIV_ROUND_CLOSEST_ULL(clk_get_rate_scaled(c->ext_lo->clk, &c->ext_lo->scale),
c->ext_lo->divider);
/* if we have an external LO which does not fit in the port switch ranges just error out */
if (!phy->port_switch.enable || phy->port_switch.manualRxPortSwitch ||
ADRV9002_PORT_SWITCH_IN_RANGE(&phy->port_switch, lo_freq))
return lo_freq;
ADRV9002_PORT_SWITCH_IN_RANGE(&phy->port_switch, *carrier))
return 0;

dev_err(&phy->spi->dev, "Port Switch enabled and RX%u LO(%llu) not in allowed range\n",
c->number, lo_freq);
c->number, *carrier);

return -EINVAL;
}
Expand Down Expand Up @@ -3595,7 +3593,10 @@
if (ret)
return ret;

carrier.carrierFrequency_Hz = adrv9002_get_init_carrier(c);
ret = adrv9002_get_init_carrier(c, &carrier.carrierFrequency_Hz);
if (ret)
return ret;

ret = api_call(phy, adi_adrv9001_Radio_Carrier_Configure,
c->port, c->number, &carrier);
if (ret)
Expand Down Expand Up @@ -4940,8 +4941,8 @@

if (phy->rx2tx2) {
/* just point RX2/TX2 to RX1/TX1*/
phy->rx_channels[c + 1].channel.clk = rx->channel.clk;

Check failure on line 4944 in drivers/iio/adc/navassa/adrv9002.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

kernel_smatch: buffer overflow 'phy->rx_channels' 2 <= 2
phy->tx_channels[c + 1].channel.clk = tx->clk;

Check failure on line 4945 in drivers/iio/adc/navassa/adrv9002.c

View workflow job for this annotation

GitHub Actions / build_gcc_arm / build

kernel_smatch: buffer overflow 'phy->tx_channels' 2 <= 2
break;
}
}
Expand Down Expand Up @@ -4991,7 +4992,7 @@
if (spi->irq) {
const unsigned long mask = IRQF_TRIGGER_RISING | IRQF_ONESHOT;

ret = devm_request_threaded_irq(&spi->dev, spi->irq, NULL,

Check warning on line 4995 in drivers/iio/adc/navassa/adrv9002.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 8-33 WARNING Threaded IRQ with no primary handler requested without IRQF_ONESHOT (unless it is nested IRQ)
adrv9002_irq_handler, mask,
indio_dev->name, indio_dev);
if (ret)
Expand Down
Loading