summaryrefslogtreecommitdiff
path: root/drivers/staging/pi433
diff options
context:
space:
mode:
authorPaulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>2022-01-19 02:05:55 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-01-25 18:33:55 +0300
commitca532a56ada46c206ea4a7f87ce34b38c274e57a (patch)
tree68815279bd6228b9c2c13c99bfe36e8f5c0eda2a /drivers/staging/pi433
parent14dbdad1f1a142f2c5d5dde6f671c18ac6763e30 (diff)
downloadlinux-ca532a56ada46c206ea4a7f87ce34b38c274e57a.tar.xz
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 Acked-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com> Link: https://lore.kernel.org/r/20220118230555.GA4961@mail.google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/pi433')
-rw-r--r--drivers/staging/pi433/TODO2
-rw-r--r--drivers/staging/pi433/rf69.c10
2 files changed, 11 insertions, 1 deletions
diff --git a/drivers/staging/pi433/TODO b/drivers/staging/pi433/TODO
index 63a40bfcc67e..b9e6c01a02e0 100644
--- a/drivers/staging/pi433/TODO
+++ b/drivers/staging/pi433/TODO
@@ -3,3 +3,5 @@
* currently the code introduces new IOCTLs. I'm afraid this is a bad idea.
-> Replace this with another interface, hints are welcome!
* Some missing data (marked with ###) needs to be added in the documentation
+* Change (struct pi433_tx_cfg)->bit_rate to be a u32 so that we can support
+ bit rates up to 300kbps per the spec.
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index f4ac17adcd83..d60514a840c2 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -229,9 +229,17 @@ 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 == OOK && bit_rate > 32768)) {
dev_dbg(&spi->dev, "setBitRate: illegal input param");
return -EINVAL;
}