Skip to content
Permalink
Browse files
staging: pi433: validate max bit_rate based on modulation used
Max bit rate is dependent on which modulation is used. Previous
validation routine only took into consideration min bit rate which can
lead a misconfiguration of the rf69 chip causing the packets not to be
sent/read.

This patch enhances that input check in set_bit_rate to account for
modulation values and their respective max bit rate

Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
  • Loading branch information
PauloMigAlmeida authored and intel-lab-lkp committed Jan 16, 2022
1 parent 043fde1 commit 4bbc9e444fd3bab38d93ae4261102db64385a26c
Showing 1 changed file with 11 additions and 1 deletion.
@@ -224,9 +224,19 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bit_rate)
u32 bit_rate_reg;
u8 msb;
u8 lsb;
enum modulation mod;

// check if modulation is configured
mod = rf69_get_modulation(spi);
if (mod == UNDEF) {
dev_dbg(&spi->dev, "setBitRate: modulation is undefined");
return -EINVAL;
}

// check input value
if (bit_rate < 1200) {
if (bit_rate < 1200 ||
(mod == FSK && bit_rate > 300000) ||
(mod == OOK && bit_rate > 32768)) {
dev_dbg(&spi->dev, "setBitRate: illegal input param");
return -EINVAL;
}

0 comments on commit 4bbc9e4

Please sign in to comment.