All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] staging: pi433: validate min/max bit rate settings
@ 2022-01-16  0:17 Paulo Miguel Almeida
  2022-01-16  0:21 ` [PATCH 1/3] staging: pi433: fix validation for min bit rate supported by the device Paulo Miguel Almeida
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Paulo Miguel Almeida @ 2022-01-16  0:17 UTC (permalink / raw)
  To: gregkh, paulo.miguel.almeida.rodenas, realwakka
  Cc: linux-staging, linux-kernel

RF69 chip supports different bit rate settings depending on which frequency
modulation is used. Failing to correctly validate bit rate can lead to a 
silently failure and cause packets not to be read/sent.

This series changes the order in which the rf69 chip is configured and adds
max bit rate validation.

This series depend on these patches as they change the same set of files:

- https://lore.kernel.org/lkml/20220108212728.GA7784@mail.google.com/
- https://lore.kernel.org/lkml/20220114221643.GA7843@mail.google.com/

Paulo Miguel Almeida (3):
  staging: pi433: fix validation for min bit rate supported by the
    device
  staging: pi433: change order in which driver config the rf69 chip
  staging: pi433: validate max bit_rate based on modulation used

 drivers/staging/pi433/pi433_if.c |  8 ++++----
 drivers/staging/pi433/rf69.c     | 14 +++++++++++---
 2 files changed, 15 insertions(+), 7 deletions(-)

-- 
2.25.4


^ permalink raw reply	[flat|nested] 21+ messages in thread
* Re: [PATCH 3/3] staging: pi433: validate max bit_rate based on modulation used
@ 2022-01-16 15:58 kernel test robot
  0 siblings, 0 replies; 21+ messages in thread
From: kernel test robot @ 2022-01-16 15:58 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4554 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20220116002333.GA23305@mail.google.com>
References: <20220116002333.GA23305@mail.google.com>
TO: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
TO: gregkh(a)linuxfoundation.org
TO: paulo.miguel.almeida.rodenas(a)gmail.com
TO: realwakka(a)gmail.com
CC: linux-staging(a)lists.linux.dev
CC: linux-kernel(a)vger.kernel.org

Hi Paulo,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on staging/staging-testing]

url:    https://github.com/0day-ci/linux/commits/Paulo-Miguel-Almeida/staging-pi433-validate-min-max-bit-rate-settings/20220116-082432
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git fa783154524a71ab74e293cd8251155e5971952b
:::::: branch date: 16 hours ago
:::::: commit date: 16 hours ago
config: m68k-randconfig-m031-20220116 (https://download.01.org/0day-ci/archive/20220116/202201162347.q7kqawfx-lkp(a)intel.com/config)
compiler: m68k-linux-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/staging/pi433/rf69.c:238 rf69_set_bit_rate() warn: impossible condition '(bit_rate > 300000) => (0-u16max > 300000)'

vim +238 drivers/staging/pi433/rf69.c

874bcba65f9a3a Marcus Wolf          2017-07-16  220  
31e045ab546fa6 Valentin Vidic       2018-03-14  221  int rf69_set_bit_rate(struct spi_device *spi, u16 bit_rate)
874bcba65f9a3a Marcus Wolf          2017-07-16  222  {
874bcba65f9a3a Marcus Wolf          2017-07-16  223  	int retval;
31e045ab546fa6 Valentin Vidic       2018-03-14  224  	u32 bit_rate_reg;
874bcba65f9a3a Marcus Wolf          2017-07-16  225  	u8 msb;
874bcba65f9a3a Marcus Wolf          2017-07-16  226  	u8 lsb;
4bbc9e444fd3ba Paulo Miguel Almeida 2022-01-16  227  	enum modulation mod;
4bbc9e444fd3ba Paulo Miguel Almeida 2022-01-16  228  
4bbc9e444fd3ba Paulo Miguel Almeida 2022-01-16  229  	// check if modulation is configured
4bbc9e444fd3ba Paulo Miguel Almeida 2022-01-16  230  	mod = rf69_get_modulation(spi);
4bbc9e444fd3ba Paulo Miguel Almeida 2022-01-16  231  	if (mod == UNDEF) {
4bbc9e444fd3ba Paulo Miguel Almeida 2022-01-16  232  		dev_dbg(&spi->dev, "setBitRate: modulation is undefined");
4bbc9e444fd3ba Paulo Miguel Almeida 2022-01-16  233  		return -EINVAL;
4bbc9e444fd3ba Paulo Miguel Almeida 2022-01-16  234  	}
874bcba65f9a3a Marcus Wolf          2017-07-16  235  
874bcba65f9a3a Marcus Wolf          2017-07-16  236  	// check input value
4bbc9e444fd3ba Paulo Miguel Almeida 2022-01-16  237  	if (bit_rate < 1200 ||
4bbc9e444fd3ba Paulo Miguel Almeida 2022-01-16 @238  	    (mod == FSK && bit_rate > 300000) ||
4bbc9e444fd3ba Paulo Miguel Almeida 2022-01-16  239  	    (mod == OOK && bit_rate > 32768)) {
874bcba65f9a3a Marcus Wolf          2017-07-16  240  		dev_dbg(&spi->dev, "setBitRate: illegal input param");
e221b2b11bdc3f Marcin Ciupak        2017-08-17  241  		return -EINVAL;
874bcba65f9a3a Marcus Wolf          2017-07-16  242  	}
874bcba65f9a3a Marcus Wolf          2017-07-16  243  
874bcba65f9a3a Marcus Wolf          2017-07-16  244  	// calculate reg settings
31e045ab546fa6 Valentin Vidic       2018-03-14  245  	bit_rate_reg = (F_OSC / bit_rate);
874bcba65f9a3a Marcus Wolf          2017-07-16  246  
31e045ab546fa6 Valentin Vidic       2018-03-14  247  	msb = (bit_rate_reg & 0xff00) >> 8;
31e045ab546fa6 Valentin Vidic       2018-03-14  248  	lsb = (bit_rate_reg & 0xff);
874bcba65f9a3a Marcus Wolf          2017-07-16  249  
874bcba65f9a3a Marcus Wolf          2017-07-16  250  	// transmit to RF 69
d7b8943cf44d46 Marcus Wolf          2017-12-04  251  	retval = rf69_write_reg(spi, REG_BITRATE_MSB, msb);
4a74749a50a8f1 Marcin Ciupak        2017-10-11  252  	if (retval)
4a74749a50a8f1 Marcin Ciupak        2017-10-11  253  		return retval;
d7b8943cf44d46 Marcus Wolf          2017-12-04  254  	retval = rf69_write_reg(spi, REG_BITRATE_LSB, lsb);
4a74749a50a8f1 Marcin Ciupak        2017-10-11  255  	if (retval)
4a74749a50a8f1 Marcin Ciupak        2017-10-11  256  		return retval;
874bcba65f9a3a Marcus Wolf          2017-07-16  257  
874bcba65f9a3a Marcus Wolf          2017-07-16  258  	return 0;
874bcba65f9a3a Marcus Wolf          2017-07-16  259  }
874bcba65f9a3a Marcus Wolf          2017-07-16  260  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-01-24  8:54 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-16  0:17 [PATCH 0/3] staging: pi433: validate min/max bit rate settings Paulo Miguel Almeida
2022-01-16  0:21 ` [PATCH 1/3] staging: pi433: fix validation for min bit rate supported by the device Paulo Miguel Almeida
2022-01-16  0:22 ` [PATCH 2/3] staging: pi433: change order in which driver config the rf69 chip Paulo Miguel Almeida
2022-01-16  0:23 ` [PATCH 3/3] staging: pi433: validate max bit_rate based on modulation used Paulo Miguel Almeida
2022-01-16 14:06   ` kernel test robot
2022-01-16 14:06     ` kernel test robot
2022-01-17  5:58     ` [PATCH v2 0/3] staging: pi433: validate min/max bit rate settings Paulo Miguel Almeida
2022-01-17  6:00       ` [PATCH v2 1/3] staging: pi433: fix validation for min bit rate supported by the device Paulo Miguel Almeida
2022-01-17  6:01       ` [PATCH v2 2/3] staging: pi433: change order in which driver config the rf69 chip Paulo Miguel Almeida
2022-01-17  6:02       ` [PATCH v2 3/3] staging: pi433: validate max bit_rate based on modulation used Paulo Miguel Almeida
2022-01-18 13:59         ` Dan Carpenter
2022-01-18 19:34           ` Paulo Miguel Almeida
2022-01-18 23:03             ` [PATCH v3 0/3] staging: pi433: validate min/max bit rate settings Paulo Miguel Almeida
2022-01-18 23:04               ` [PATCH v3 1/3] staging: pi433: fix validation for min bit rate supported by the device Paulo Miguel Almeida
2022-01-18 23:05               ` [PATCH v3 2/3] staging: pi433: change order in which driver config the rf69 chip Paulo Miguel Almeida
2022-01-18 23:05               ` [PATCH v3 3/3] staging: pi433: validate max bit_rate based on modulation used Paulo Miguel Almeida
2022-01-19  6:04               ` [PATCH v3 0/3] staging: pi433: validate min/max bit rate settings Dan Carpenter
2022-01-23  7:43                 ` Paulo Miguel Almeida
2022-01-24  8:53                   ` Dan Carpenter
2022-01-19  5:34             ` [PATCH v2 3/3] staging: pi433: validate max bit_rate based on modulation used Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2022-01-16 15:58 [PATCH " kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.