1414 * any later version.
1515 */
1616
17+ #define pr_fmt (fmt ) KBUILD_MODNAME ": " fmt
18+
1719#include <linux/module.h>
1820#include <linux/slab.h>
1921#include <linux/init.h>
@@ -672,7 +674,8 @@ int hid_parse_report(struct hid_device *device, __u8 *start,
672674
673675 if (dispatch_type [item .type ](parser , & item )) {
674676 dbg_hid ("item %u %u %u %u parsing failed\n" ,
675- item .format , (unsigned )item .size , (unsigned )item .type , (unsigned )item .tag );
677+ item .format , (unsigned )item .size ,
678+ (unsigned )item .type , (unsigned )item .tag );
676679 goto err ;
677680 }
678681
@@ -737,13 +740,14 @@ static u32 s32ton(__s32 value, unsigned n)
737740 * Search linux-kernel and linux-usb-devel archives for "hid-core extract".
738741 */
739742
740- static __inline__ __u32 extract (__u8 * report , unsigned offset , unsigned n )
743+ static __inline__ __u32 extract (const struct hid_device * hid , __u8 * report ,
744+ unsigned offset , unsigned n )
741745{
742746 u64 x ;
743747
744748 if (n > 32 )
745- printk ( KERN_WARNING "HID: extract() called with n (%d) > 32! (%s)\n" ,
746- n , current -> comm );
749+ hid_warn ( hid , " extract() called with n (%d) > 32! (%s)\n" ,
750+ n , current -> comm );
747751
748752 report += offset >> 3 ; /* adjust byte index */
749753 offset &= 7 ; /* now only need bit offset into one byte */
@@ -760,18 +764,19 @@ static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n)
760764 * endianness of register values by considering a register
761765 * a "cached" copy of the little endiad bit stream.
762766 */
763- static __inline__ void implement (__u8 * report , unsigned offset , unsigned n , __u32 value )
767+ static __inline__ void implement (const struct hid_device * hid , __u8 * report ,
768+ unsigned offset , unsigned n , __u32 value )
764769{
765770 u64 x ;
766771 u64 m = (1ULL << n ) - 1 ;
767772
768773 if (n > 32 )
769- printk ( KERN_WARNING "HID: implement () called with n (%d) > 32! (%s)\n" ,
770- n , current -> comm );
774+ hid_warn ( hid , "%s () called with n (%d) > 32! (%s)\n" ,
775+ __func__ , n , current -> comm );
771776
772777 if (value > m )
773- printk ( KERN_WARNING "HID: implement () called with too large value %d! (%s)\n" ,
774- value , current -> comm );
778+ hid_warn ( hid , "%s () called with too large value %d! (%s)\n" ,
779+ __func__ , value , current -> comm );
775780 WARN_ON (value > m );
776781 value &= m ;
777782
@@ -892,13 +897,16 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field,
892897
893898 for (n = 0 ; n < count ; n ++ ) {
894899
895- value [n ] = min < 0 ? snto32 (extract (data , offset + n * size , size ), size ) :
896- extract (data , offset + n * size , size );
900+ value [n ] = min < 0 ?
901+ snto32 (extract (hid , data , offset + n * size , size ),
902+ size ) :
903+ extract (hid , data , offset + n * size , size );
897904
898- if (!(field -> flags & HID_MAIN_ITEM_VARIABLE ) /* Ignore report if ErrorRollOver */
899- && value [n ] >= min && value [n ] <= max
900- && field -> usage [value [n ] - min ].hid == HID_UP_KEYBOARD + 1 )
901- goto exit ;
905+ /* Ignore report if ErrorRollOver */
906+ if (!(field -> flags & HID_MAIN_ITEM_VARIABLE ) &&
907+ value [n ] >= min && value [n ] <= max &&
908+ field -> usage [value [n ] - min ].hid == HID_UP_KEYBOARD + 1 )
909+ goto exit ;
902910 }
903911
904912 for (n = 0 ; n < count ; n ++ ) {
@@ -928,7 +936,8 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field,
928936 * Output the field into the report.
929937 */
930938
931- static void hid_output_field (struct hid_field * field , __u8 * data )
939+ static void hid_output_field (const struct hid_device * hid ,
940+ struct hid_field * field , __u8 * data )
932941{
933942 unsigned count = field -> report_count ;
934943 unsigned offset = field -> report_offset ;
@@ -937,9 +946,11 @@ static void hid_output_field(struct hid_field *field, __u8 *data)
937946
938947 for (n = 0 ; n < count ; n ++ ) {
939948 if (field -> logical_minimum < 0 ) /* signed values */
940- implement (data , offset + n * size , size , s32ton (field -> value [n ], size ));
949+ implement (hid , data , offset + n * size , size ,
950+ s32ton (field -> value [n ], size ));
941951 else /* unsigned values */
942- implement (data , offset + n * size , size , field -> value [n ]);
952+ implement (hid , data , offset + n * size , size ,
953+ field -> value [n ]);
943954 }
944955}
945956
@@ -956,7 +967,7 @@ void hid_output_report(struct hid_report *report, __u8 *data)
956967
957968 memset (data , 0 , ((report -> size - 1 ) >> 3 ) + 1 );
958969 for (n = 0 ; n < report -> maxfield ; n ++ )
959- hid_output_field (report -> field [n ], data );
970+ hid_output_field (report -> device , report -> field [n ], data );
960971}
961972EXPORT_SYMBOL_GPL (hid_output_report );
962973
@@ -1169,8 +1180,7 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
11691180 hdev -> claimed |= HID_CLAIMED_HIDRAW ;
11701181
11711182 if (!hdev -> claimed ) {
1172- dev_err (& hdev -> dev , "claimed by neither input, hiddev nor "
1173- "hidraw\n" );
1183+ hid_err (hdev , "claimed by neither input, hiddev nor hidraw\n" );
11741184 return - ENODEV ;
11751185 }
11761186
@@ -1210,9 +1220,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
12101220 bus = "<UNKNOWN>" ;
12111221 }
12121222
1213- dev_info ( & hdev -> dev , "%s: %s HID v%x.%02x %s [%s] on %s\n" ,
1214- buf , bus , hdev -> version >> 8 , hdev -> version & 0xff ,
1215- type , hdev -> name , hdev -> phys );
1223+ hid_info ( hdev , "%s: %s HID v%x.%02x %s [%s] on %s\n" ,
1224+ buf , bus , hdev -> version >> 8 , hdev -> version & 0xff ,
1225+ type , hdev -> name , hdev -> phys );
12161226
12171227 return 0 ;
12181228}
@@ -1956,12 +1966,12 @@ static int __init hid_init(void)
19561966 int ret ;
19571967
19581968 if (hid_debug )
1959- printk ( KERN_WARNING "HID: hid_debug is now used solely for parser and driver debugging.\n"
1960- "HID: debugfs is now used for inspecting the device (report descriptor, reports)\n" );
1969+ pr_warn ( " hid_debug is now used solely for parser and driver debugging.\n"
1970+ " debugfs is now used for inspecting the device (report descriptor, reports)\n" );
19611971
19621972 ret = bus_register (& hid_bus_type );
19631973 if (ret ) {
1964- printk ( KERN_ERR "HID: can't register hid bus\n" );
1974+ pr_err ( " can't register hid bus\n" );
19651975 goto err ;
19661976 }
19671977
0 commit comments