Skip to contentSkip to conversation

Fixes issue with bit shift in rf69_get_modulation

PATCH In review Marcus Wolf 3 participants 4 messages Nov 8, 2017 – Dec 6, 2017 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fixes issue with bit shift in rf69_get_modulation

Fixes issue with bit shift in rf69_get_modulation

---
 drivers/staging/pi433/rf69.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/pi433/rf69.c +1 -1
index 290b419..c945b4b 100644
@@ -102,7 +102,7 @@ enum modulation rf69_get_modulation(struct spi_device *spi)
 
 	currentValue = READ_REG(REG_DATAMODUL);
 
-	switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE >> 3) { // TODO improvement: change 3 to define
+	switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE) {
 	case DATAMODUL_MODULATION_TYPE_OOK: return OOK;
 	case DATAMODUL_MODULATION_TYPE_FSK: return FSK;
 	default:			    return undefined;
Signature · 1 line
1.7.10.4
maintainer
#1 lore raw

Re: [PATCH] staging: pi433: Fixes issue with bit shift in rf69_get_modulation

Quoted 1 line · Marcus Wolf

Fixes issue with bit shift in rf69_get_modulation

What "issue"?

Quoted 11 lines
---
 drivers/staging/pi433/rf69.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/pi433/rf69.c +0 -0
index 290b419..c945b4b 100644

drivers/staging/pi433/rf69.c enum modulation rf69_get_modulation(struct spi_device *spi) · line 105

Quoted 5 lines
drivers/staging/pi433/rf69.c +1 -1
@@ -102,7 +102,7 @@ enum modulation rf69_get_modulation(struct spi_device *spi)
 
 	currentValue = READ_REG(REG_DATAMODUL);
 
-	switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE >> 3) { // TODO improvement: change 3 to define
+	switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE) {

Doesn't this change the logic here?

thanks,

greg k-h

#2 lore raw

Re: [PATCH] staging: pi433: Fixes issue with bit shift in rf69_get_modulation

Am 06.12.2017 um 11:02 schrieb Greg KH:

Quoted 19 lines · Marcus Wolf
Quoted 1 line

Fixes issue with bit shift in rf69_get_modulation

What "issue"?

Quoted 14 lines
---
  drivers/staging/pi433/rf69.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/pi433/rf69.c +0 -0
index 290b419..c945b4b 100644
@@ -102,7 +102,7 @@ enum modulation rf69_get_modulation(struct spi_device *spi)
 
  	currentValue = READ_REG(REG_DATAMODUL);
 
Quoted 9 lines

drivers/staging/pi433/rf69.c enum modulation rf69_get_modulation(struct spi_device *spi) · line 105

Quoted 2 lines
drivers/staging/pi433/rf69.c +1 -1
-	switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE >> 3) { // TODO improvement: change 3 to define
+	switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE) {

Doesn't this change the logic here?

thanks,

greg k-h

Hi Greg,

yes, it does.

This is one of the very few changes to pi433 driver, that does not modify the architecture or optics of the code, but really fixes a bug. This function wasn't working from the very beginning, and we had already several reports and patches (from me and otheres), announcing or trying to fix the bug. But so far all patches were skipped for some reason.

Please take the patch.

Marcus

maintainer
#3 lore raw

Re: [PATCH] staging: pi433: Fixes issue with bit shift in rf69_get_modulation

Quoted 34 lines · Marcus Wolf

Am 06.12.2017 um 11:02 schrieb Greg KH:

Quoted 22 lines · Marcus Wolf
Quoted 1 line

Fixes issue with bit shift in rf69_get_modulation

What "issue"?

Quoted 11 lines
---
  drivers/staging/pi433/rf69.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/pi433/rf69.c +0 -0
index 290b419..c945b4b 100644

drivers/staging/pi433/rf69.c enum modulation rf69_get_modulation(struct spi_device *spi) · line 103

Quoted 3 lines
drivers/staging/pi433/rf69.c +1 -1
@@ -102,7 +102,7 @@ enum modulation rf69_get_modulation(struct spi_device *spi)
  	currentValue = READ_REG(REG_DATAMODUL);
-	switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE >> 3) { // TODO improvement: change 3 to define
+	switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE) {

Doesn't this change the logic here?

Quoted 4 lines

thanks,

greg k-h

Hi Greg,

yes, it does.

Quoted 8 lines

This is one of the very few changes to pi433 driver, that does not modify the architecture or optics of the code, but really fixes a bug. This function wasn't working from the very beginning, and we had already several reports and patches (from me and otheres), announcing or trying to fix the bug. But so far all patches were skipped for some reason.

Please take the patch.

Ok, then this should go into 4.15-final, I'll queue it up to that tree.

thanks,

greg k-h