Skip to contentSkip to conversation

media: rc: define RC_BIT_ALL as ~0

PATCH In review Heiner Kallweit 3 participants 4 messages Nov 16, 2015 – Nov 19, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 8/8 media: rc: define RC_BIT_ALL as ~0

RC_BIT_ALL explicitely lists each single currently defined protocol bit. To simplify the code and make adding a protocol easier set each bit no matter whether the respective protocol is defined yet.

RC_BIT_ALL is only used in checks whether a particular protocol is allowed therefore it has no impact if bits for not (yet) defined protocols are set.

---
 drivers/media/rc/rc-main.c |  1 -
 include/media/rc-map.h     | 10 +---------
 2 files changed, 1 insertion(+), 10 deletions(-)
drivers/media/rc/rc-main.c +0 -1
index d1611f1..d7055e1 100644
@@ -1447,7 +1447,6 @@ int rc_register_device(struct rc_dev *dev)
 	kfree(path);
 
 	if (dev->driver_type == RC_DRIVER_IR_RAW) {
-		dev->allowed_protocols |= RC_BIT_LIRC;
 		/* calls ir_register_device so unlock mutex here*/
 		mutex_unlock(&dev->lock);
 		rc = ir_raw_event_register(dev);
include/media/rc-map.h +1 -9
index 7844e98..27aaf6b 100644
@@ -54,15 +54,7 @@ enum rc_type {
 #define RC_BIT_SHARP		(1ULL << RC_TYPE_SHARP)
 #define RC_BIT_XMP		(1ULL << RC_TYPE_XMP)
 
-#define RC_BIT_ALL	(RC_BIT_UNKNOWN | RC_BIT_OTHER | \
-			 RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ | \
-			 RC_BIT_JVC | \
-			 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \
-			 RC_BIT_NEC | RC_BIT_SANYO | RC_BIT_MCE_KBD | \
-			 RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \
-			 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SHARP | \
-			 RC_BIT_XMP)
-
+#define RC_BIT_ALL		~RC_BIT_NONE
 
 #define RC_SCANCODE_UNKNOWN(x)			(x)
 #define RC_SCANCODE_OTHER(x)			(x)
Signature · 1 line
2.6.2
#1 lore raw
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…

Hi Heiner,

[auto build test WARNING on linuxtv-media/master] [also build test WARNING on v4.4-rc1 next-20151116]

url:    https://github.com/0day-ci/linux/commits/Heiner-Kallweit/media-rc-fix-decoder-module-unloading/20151117-035809
base:   git://linuxtv.org/media_tree.git master
config: parisc-allmodconfig (attached as .config)

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=parisc

All warnings (new ones prefixed by >>):

In file included from include/media/rc-core.h:23:0,

                    from drivers/media/pci/cx23885/cx23885-input.c:34:
   drivers/media/pci/cx23885/cx23885-input.c: In function 'cx23885_input_init':
>> include/media/rc-map.h:57:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]
    #define RC_BIT_ALL  ~RC_BIT_NONE
                        ^
>> drivers/media/pci/cx23885/cx23885-input.c:289:20: note: in expansion of macro 'RC_BIT_ALL'
      allowed_protos = RC_BIT_ALL;
                       ^
>> include/media/rc-map.h:57:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]
    #define RC_BIT_ALL  ~RC_BIT_NONE
                        ^
   drivers/media/pci/cx23885/cx23885-input.c:303:20: note: in expansion of macro 'RC_BIT_ALL'
      allowed_protos = RC_BIT_ALL;
                       ^
>> include/media/rc-map.h:57:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]
    #define RC_BIT_ALL  ~RC_BIT_NONE
                        ^
   drivers/media/pci/cx23885/cx23885-input.c:310:20: note: in expansion of macro 'RC_BIT_ALL'
      allowed_protos = RC_BIT_ALL;
                       ^
>> include/media/rc-map.h:57:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]
    #define RC_BIT_ALL  ~RC_BIT_NONE
                        ^
   drivers/media/pci/cx23885/cx23885-input.c:318:20: note: in expansion of macro 'RC_BIT_ALL'
      allowed_protos = RC_BIT_ALL;
                       ^
>> include/media/rc-map.h:57:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]
    #define RC_BIT_ALL  ~RC_BIT_NONE
                        ^
   drivers/media/pci/cx23885/cx23885-input.c:330:20: note: in expansion of macro 'RC_BIT_ALL'
      allowed_protos = RC_BIT_ALL;
                       ^
>> include/media/rc-map.h:57:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]
    #define RC_BIT_ALL  ~RC_BIT_NONE
                        ^
   drivers/media/pci/cx23885/cx23885-input.c:336:20: note: in expansion of macro 'RC_BIT_ALL'
      allowed_protos = RC_BIT_ALL;
                       ^

vim +57 include/media/rc-map.h

    41	#define RC_BIT_RC5_SZ		(1ULL << RC_TYPE_RC5_SZ)
    42	#define RC_BIT_JVC		(1ULL << RC_TYPE_JVC)
    43	#define RC_BIT_SONY12		(1ULL << RC_TYPE_SONY12)
    44	#define RC_BIT_SONY15		(1ULL << RC_TYPE_SONY15)
    45	#define RC_BIT_SONY20		(1ULL << RC_TYPE_SONY20)
    46	#define RC_BIT_NEC		(1ULL << RC_TYPE_NEC)
    47	#define RC_BIT_SANYO		(1ULL << RC_TYPE_SANYO)
    48	#define RC_BIT_MCE_KBD		(1ULL << RC_TYPE_MCE_KBD)
    49	#define RC_BIT_RC6_0		(1ULL << RC_TYPE_RC6_0)
    50	#define RC_BIT_RC6_6A_20	(1ULL << RC_TYPE_RC6_6A_20)
    51	#define RC_BIT_RC6_6A_24	(1ULL << RC_TYPE_RC6_6A_24)
    52	#define RC_BIT_RC6_6A_32	(1ULL << RC_TYPE_RC6_6A_32)
    53	#define RC_BIT_RC6_MCE		(1ULL << RC_TYPE_RC6_MCE)
    54	#define RC_BIT_SHARP		(1ULL << RC_TYPE_SHARP)
    55	#define RC_BIT_XMP		(1ULL << RC_TYPE_XMP)
    56	
  > 57	#define RC_BIT_ALL		~RC_BIT_NONE
    58	
    59	#define RC_SCANCODE_UNKNOWN(x)			(x)
    60	#define RC_SCANCODE_OTHER(x)			(x)
    61	#define RC_SCANCODE_NEC(addr, cmd)		(((addr) << 8) | (cmd))
    62	#define RC_SCANCODE_NECX(addr, cmd)		(((addr) << 8) | (cmd))
    63	#define RC_SCANCODE_NEC32(data)			((data) & 0xffffffff)
    64	#define RC_SCANCODE_RC5(sys, cmd)		(((sys) << 8) | (cmd))
    65	#define RC_SCANCODE_RC5_SZ(sys, cmd)		(((sys) << 8) | (cmd))

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#2 lore raw

Am 16.11.2015 um 21:47 schrieb kbuild test robot:

Quoted 84 lines

Hi Heiner,

[auto build test WARNING on linuxtv-media/master] [also build test WARNING on v4.4-rc1 next-20151116]

url:    https://github.com/0day-ci/linux/commits/Heiner-Kallweit/media-rc-fix-decoder-module-unloading/20151117-035809
base:   git://linuxtv.org/media_tree.git master
config: parisc-allmodconfig (attached as .config)

reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=parisc

All warnings (new ones prefixed by >>):

   In file included from include/media/rc-core.h:23:0,
                    from drivers/media/pci/cx23885/cx23885-input.c:34:
   drivers/media/pci/cx23885/cx23885-input.c: In function 'cx23885_input_init':
Quoted 1 line
Quoted 1 line

include/media/rc-map.h:57:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]

    #define RC_BIT_ALL  ~RC_BIT_NONE
                        ^
Quoted 1 line
Quoted 1 line

drivers/media/pci/cx23885/cx23885-input.c:289:20: note: in expansion of macro 'RC_BIT_ALL'

      allowed_protos = RC_BIT_ALL;
                       ^
Quoted 1 line
Quoted 1 line

include/media/rc-map.h:57:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]

    #define RC_BIT_ALL  ~RC_BIT_NONE
                        ^
   drivers/media/pci/cx23885/cx23885-input.c:303:20: note: in expansion of macro 'RC_BIT_ALL'
      allowed_protos = RC_BIT_ALL;
                       ^
Quoted 1 line
Quoted 1 line

include/media/rc-map.h:57:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]

    #define RC_BIT_ALL  ~RC_BIT_NONE
                        ^
   drivers/media/pci/cx23885/cx23885-input.c:310:20: note: in expansion of macro 'RC_BIT_ALL'
      allowed_protos = RC_BIT_ALL;
                       ^
Quoted 1 line
Quoted 1 line

include/media/rc-map.h:57:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]

    #define RC_BIT_ALL  ~RC_BIT_NONE
                        ^
   drivers/media/pci/cx23885/cx23885-input.c:318:20: note: in expansion of macro 'RC_BIT_ALL'
      allowed_protos = RC_BIT_ALL;
                       ^
Quoted 1 line
Quoted 1 line

include/media/rc-map.h:57:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]

    #define RC_BIT_ALL  ~RC_BIT_NONE
                        ^
   drivers/media/pci/cx23885/cx23885-input.c:330:20: note: in expansion of macro 'RC_BIT_ALL'
      allowed_protos = RC_BIT_ALL;
                       ^
Quoted 1 line
Quoted 1 line

include/media/rc-map.h:57:21: warning: large integer implicitly truncated to unsigned type [-Woverflow]

    #define RC_BIT_ALL  ~RC_BIT_NONE
                        ^
   drivers/media/pci/cx23885/cx23885-input.c:336:20: note: in expansion of macro 'RC_BIT_ALL'
      allowed_protos = RC_BIT_ALL;
                       ^

vim +57 include/media/rc-map.h

    41	#define RC_BIT_RC5_SZ		(1ULL << RC_TYPE_RC5_SZ)
    42	#define RC_BIT_JVC		(1ULL << RC_TYPE_JVC)
    43	#define RC_BIT_SONY12		(1ULL << RC_TYPE_SONY12)
    44	#define RC_BIT_SONY15		(1ULL << RC_TYPE_SONY15)
    45	#define RC_BIT_SONY20		(1ULL << RC_TYPE_SONY20)
    46	#define RC_BIT_NEC		(1ULL << RC_TYPE_NEC)
    47	#define RC_BIT_SANYO		(1ULL << RC_TYPE_SANYO)
    48	#define RC_BIT_MCE_KBD		(1ULL << RC_TYPE_MCE_KBD)
    49	#define RC_BIT_RC6_0		(1ULL << RC_TYPE_RC6_0)
    50	#define RC_BIT_RC6_6A_20	(1ULL << RC_TYPE_RC6_6A_20)
    51	#define RC_BIT_RC6_6A_24	(1ULL << RC_TYPE_RC6_6A_24)
    52	#define RC_BIT_RC6_6A_32	(1ULL << RC_TYPE_RC6_6A_32)
    53	#define RC_BIT_RC6_MCE		(1ULL << RC_TYPE_RC6_MCE)
    54	#define RC_BIT_SHARP		(1ULL << RC_TYPE_SHARP)
    55	#define RC_BIT_XMP		(1ULL << RC_TYPE_XMP)
    56	
Quoted 1 line

57 #define RC_BIT_ALL ~RC_BIT_NONE

    58	
    59	#define RC_SCANCODE_UNKNOWN(x)			(x)
    60	#define RC_SCANCODE_OTHER(x)			(x)
    61	#define RC_SCANCODE_NEC(addr, cmd)		(((addr) << 8) | (cmd))
    62	#define RC_SCANCODE_NECX(addr, cmd)		(((addr) << 8) | (cmd))
    63	#define RC_SCANCODE_NEC32(data)			((data) & 0xffffffff)
    64	#define RC_SCANCODE_RC5(sys, cmd)		(((sys) << 8) | (cmd))
    65	#define RC_SCANCODE_RC5_SZ(sys, cmd)		(((sys) << 8) | (cmd))
Quoted 4 lines

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

To me this seems to be a bug in cx23885.
Variable allowed_protos should be of type u64 instead of unsigned long because its value later is assigned to rc->allowed_protocols which is of type u64.
If you agree I'd send a patch.

#3 lore raw
In reply to Heiner Kallweit

Em Mon, 16 Nov 2015 20:53:52 +0100
Heiner Kallweit <[email protected]> escreveu:

Quoted 7 lines

RC_BIT_ALL explicitely lists each single currently defined protocol bit. To simplify the code and make adding a protocol easier set each bit no matter whether the respective protocol is defined yet.

RC_BIT_ALL is only used in checks whether a particular protocol is allowed therefore it has no impact if bits for not (yet) defined protocols are set.

I guess we used to do that, but we decided to explicitly define all protocols there. Can't remember why.

So, for now, I'm not applying this one. Also, it depends on patch 6/8, due to RC_BIT_LIRC.

So, I'm not applying this one.

Quoted 40 lines
---
 drivers/media/rc/rc-main.c |  1 -
 include/media/rc-map.h     | 10 +---------
 2 files changed, 1 insertion(+), 10 deletions(-)
drivers/media/rc/rc-main.c +0 -1
index d1611f1..d7055e1 100644
@@ -1447,7 +1447,6 @@ int rc_register_device(struct rc_dev *dev)
 	kfree(path);
 
 	if (dev->driver_type == RC_DRIVER_IR_RAW) {
-		dev->allowed_protocols |= RC_BIT_LIRC;
 		/* calls ir_register_device so unlock mutex here*/
 		mutex_unlock(&dev->lock);
 		rc = ir_raw_event_register(dev);
include/media/rc-map.h +1 -9
index 7844e98..27aaf6b 100644
@@ -54,15 +54,7 @@ enum rc_type {
 #define RC_BIT_SHARP		(1ULL << RC_TYPE_SHARP)
 #define RC_BIT_XMP		(1ULL << RC_TYPE_XMP)
 
-#define RC_BIT_ALL	(RC_BIT_UNKNOWN | RC_BIT_OTHER | \
-			 RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ | \
-			 RC_BIT_JVC | \
-			 RC_BIT_SONY12 | RC_BIT_SONY15 | RC_BIT_SONY20 | \
-			 RC_BIT_NEC | RC_BIT_SANYO | RC_BIT_MCE_KBD | \
-			 RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \
-			 RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SHARP | \
-			 RC_BIT_XMP)
-
+#define RC_BIT_ALL		~RC_BIT_NONE
 
 #define RC_SCANCODE_UNKNOWN(x)			(x)
 #define RC_SCANCODE_OTHER(x)			(x)