* [PATCH] staging: pi433: allow max bit rate of 300kps
@ 2022-03-15 18:08 Nam Cao
2022-03-15 18:14 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Nam Cao @ 2022-03-15 18:08 UTC (permalink / raw)
To: gregkh, dan.carpenter, paulo.miguel.almeida.rodenas,
linux-staging, linux-kernel, realwakka
Cc: Nam Cao
bit_rate data type is u16 which cannot support max bit rate of 300kps.
Change bit_rate data type to u32.
Signed-off-by: Nam Cao <cvn249@gmail.com>
---
drivers/staging/pi433/TODO | 2 --
drivers/staging/pi433/pi433_if.h | 4 ++--
drivers/staging/pi433/rf69.c | 6 ++++--
drivers/staging/pi433/rf69.h | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/pi433/TODO b/drivers/staging/pi433/TODO
index 5cf3fd99d521..8530bbe61d70 100644
--- a/drivers/staging/pi433/TODO
+++ b/drivers/staging/pi433/TODO
@@ -1,5 +1,3 @@
* 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/pi433_if.h b/drivers/staging/pi433/pi433_if.h
index 25ee0b77a32c..c958dcfa9f96 100644
--- a/drivers/staging/pi433/pi433_if.h
+++ b/drivers/staging/pi433/pi433_if.h
@@ -51,7 +51,7 @@ enum option_on_off {
#define PI433_TX_CFG_IOCTL_NR 0
struct pi433_tx_cfg {
__u32 frequency;
- __u16 bit_rate;
+ __u32 bit_rate;
__u32 dev_frequency;
enum modulation modulation;
enum mod_shaping mod_shaping;
@@ -99,7 +99,7 @@ struct pi433_tx_cfg {
#define PI433_RX_CFG_IOCTL_NR 1
struct pi433_rx_cfg {
__u32 frequency;
- __u16 bit_rate;
+ __u32 bit_rate;
__u32 dev_frequency;
enum modulation modulation;
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 659c8c1b38fd..0590db841dd8 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -185,7 +185,7 @@ int rf69_set_modulation_shaping(struct spi_device *spi,
}
}
-int rf69_set_bit_rate(struct spi_device *spi, u16 bit_rate)
+int rf69_set_bit_rate(struct spi_device *spi, u32 bit_rate)
{
int retval;
u32 bit_rate_reg;
@@ -201,7 +201,9 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bit_rate)
}
// check input value
- if (bit_rate < 1200 || (mod == OOK && bit_rate > 32768)) {
+ if (bit_rate < 1200 ||
+ (mod == FSK && bit_rate > 300000) ||
+ (mod == OOK && bit_rate > 32768)) {
dev_dbg(&spi->dev, "setBitRate: illegal input param\n");
return -EINVAL;
}
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index 78fa0b8bab8b..46a1fb2d5329 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -24,7 +24,7 @@ int rf69_set_data_mode(struct spi_device *spi, u8 data_mode);
int rf69_set_modulation(struct spi_device *spi, enum modulation modulation);
int rf69_set_modulation_shaping(struct spi_device *spi,
enum mod_shaping mod_shaping);
-int rf69_set_bit_rate(struct spi_device *spi, u16 bit_rate);
+int rf69_set_bit_rate(struct spi_device *spi, u32 bit_rate);
int rf69_set_deviation(struct spi_device *spi, u32 deviation);
int rf69_set_frequency(struct spi_device *spi, u32 frequency);
int rf69_enable_amplifier(struct spi_device *spi, u8 amplifier_mask);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] staging: pi433: allow max bit rate of 300kps
2022-03-15 18:08 [PATCH] staging: pi433: allow max bit rate of 300kps Nam Cao
@ 2022-03-15 18:14 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2022-03-15 18:14 UTC (permalink / raw)
To: Nam Cao
Cc: gregkh, paulo.miguel.almeida.rodenas, linux-staging, linux-kernel,
realwakka
On Tue, Mar 15, 2022 at 07:08:20PM +0100, Nam Cao wrote:
> diff --git a/drivers/staging/pi433/TODO b/drivers/staging/pi433/TODO
> index 5cf3fd99d521..8530bbe61d70 100644
> --- a/drivers/staging/pi433/TODO
> +++ b/drivers/staging/pi433/TODO
> @@ -1,5 +1,3 @@
> * 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/pi433_if.h b/drivers/staging/pi433/pi433_if.h
> index 25ee0b77a32c..c958dcfa9f96 100644
> --- a/drivers/staging/pi433/pi433_if.h
> +++ b/drivers/staging/pi433/pi433_if.h
> @@ -51,7 +51,7 @@ enum option_on_off {
> #define PI433_TX_CFG_IOCTL_NR 0
> struct pi433_tx_cfg {
> __u32 frequency;
> - __u16 bit_rate;
> + __u32 bit_rate;
> __u32 dev_frequency;
> enum modulation modulation;
> enum mod_shaping mod_shaping;
> @@ -99,7 +99,7 @@ struct pi433_tx_cfg {
> #define PI433_RX_CFG_IOCTL_NR 1
> struct pi433_rx_cfg {
> __u32 frequency;
> - __u16 bit_rate;
> + __u32 bit_rate;
> __u32 dev_frequency;
>
> enum modulation modulation;
You cannot change this because it is part of the UAPI.
Also this API is rubbish. Instead you should create sysfs files to
set the bit_rate.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-15 18:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-15 18:08 [PATCH] staging: pi433: allow max bit rate of 300kps Nam Cao
2022-03-15 18:14 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).