@@ -66,8 +66,12 @@ static s32 snto32(__u32 value, unsigned int n)
6666
6767static u32 s32ton (__s32 value , unsigned int n )
6868{
69- s32 a = value >> ( n - 1 ) ;
69+ s32 a ;
7070
71+ if (!value || !n )
72+ return 0 ;
73+
74+ a = value >> (n - 1 );
7175 if (a && a != -1 )
7276 return value < 0 ? 1 << (n - 1 ) : (1 << (n - 1 )) - 1 ;
7377 return value & ((1 << n ) - 1 );
@@ -659,9 +663,9 @@ static int hid_parser_main(struct hid_parser *parser, struct hid_item *item)
659663 default :
660664 if (item -> tag >= HID_MAIN_ITEM_TAG_RESERVED_MIN &&
661665 item -> tag <= HID_MAIN_ITEM_TAG_RESERVED_MAX )
662- hid_warn (parser -> device , "reserved main item tag 0x%x\n" , item -> tag );
666+ hid_warn_ratelimited (parser -> device , "reserved main item tag 0x%x\n" , item -> tag );
663667 else
664- hid_warn (parser -> device , "unknown main item tag 0x%x\n" , item -> tag );
668+ hid_warn_ratelimited (parser -> device , "unknown main item tag 0x%x\n" , item -> tag );
665669 ret = 0 ;
666670 }
667671
@@ -2806,7 +2810,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
28062810{
28072811 struct hid_device * hdev = container_of (dev , struct hid_device , dev );
28082812
2809- return scnprintf (buf , PAGE_SIZE , "hid:b%04Xg%04Xv%08Xp%08X\n" ,
2813+ return sysfs_emit (buf , "hid:b%04Xg%04Xv%08Xp%08X\n" ,
28102814 hdev -> bus , hdev -> group , hdev -> vendor , hdev -> product );
28112815}
28122816static DEVICE_ATTR_RO (modalias );
0 commit comments