@@ -156,6 +156,7 @@ static struct rc_map_list empty_map = {
156156
157157/**
158158 * ir_create_table() - initializes a scancode table
159+ * @dev: the rc_dev device
159160 * @rc_map: the rc_map to initialize
160161 * @name: name to assign to the table
161162 * @rc_proto: ir type to assign to the new table
@@ -166,7 +167,7 @@ static struct rc_map_list empty_map = {
166167 *
167168 * return: zero on success or a negative error code
168169 */
169- static int ir_create_table (struct rc_map * rc_map ,
170+ static int ir_create_table (struct rc_dev * dev , struct rc_map * rc_map ,
170171 const char * name , u64 rc_proto , size_t size )
171172{
172173 rc_map -> name = kstrdup (name , GFP_KERNEL );
@@ -182,8 +183,8 @@ static int ir_create_table(struct rc_map *rc_map,
182183 return - ENOMEM ;
183184 }
184185
185- IR_dprintk ( 1 , "Allocated space for %u keycode entries (%u bytes)\n" ,
186- rc_map -> size , rc_map -> alloc );
186+ dev_dbg ( & dev -> dev , "Allocated space for %u keycode entries (%u bytes)\n" ,
187+ rc_map -> size , rc_map -> alloc );
187188 return 0 ;
188189}
189190
@@ -205,6 +206,7 @@ static void ir_free_table(struct rc_map *rc_map)
205206
206207/**
207208 * ir_resize_table() - resizes a scancode table if necessary
209+ * @dev: the rc_dev device
208210 * @rc_map: the rc_map to resize
209211 * @gfp_flags: gfp flags to use when allocating memory
210212 *
@@ -213,7 +215,8 @@ static void ir_free_table(struct rc_map *rc_map)
213215 *
214216 * return: zero on success or a negative error code
215217 */
216- static int ir_resize_table (struct rc_map * rc_map , gfp_t gfp_flags )
218+ static int ir_resize_table (struct rc_dev * dev , struct rc_map * rc_map ,
219+ gfp_t gfp_flags )
217220{
218221 unsigned int oldalloc = rc_map -> alloc ;
219222 unsigned int newalloc = oldalloc ;
@@ -226,23 +229,21 @@ static int ir_resize_table(struct rc_map *rc_map, gfp_t gfp_flags)
226229 return - ENOMEM ;
227230
228231 newalloc *= 2 ;
229- IR_dprintk ( 1 , "Growing table to %u bytes\n" , newalloc );
232+ dev_dbg ( & dev -> dev , "Growing table to %u bytes\n" , newalloc );
230233 }
231234
232235 if ((rc_map -> len * 3 < rc_map -> size ) && (oldalloc > IR_TAB_MIN_SIZE )) {
233236 /* Less than 1/3 of entries in use -> shrink keytable */
234237 newalloc /= 2 ;
235- IR_dprintk ( 1 , "Shrinking table to %u bytes\n" , newalloc );
238+ dev_dbg ( & dev -> dev , "Shrinking table to %u bytes\n" , newalloc );
236239 }
237240
238241 if (newalloc == oldalloc )
239242 return 0 ;
240243
241244 newscan = kmalloc (newalloc , gfp_flags );
242- if (!newscan ) {
243- IR_dprintk (1 , "Failed to kmalloc %u bytes\n" , newalloc );
245+ if (!newscan )
244246 return - ENOMEM ;
245- }
246247
247248 memcpy (newscan , rc_map -> scan , rc_map -> len * sizeof (struct rc_map_table ));
248249 rc_map -> scan = newscan ;
@@ -275,16 +276,16 @@ static unsigned int ir_update_mapping(struct rc_dev *dev,
275276
276277 /* Did the user wish to remove the mapping? */
277278 if (new_keycode == KEY_RESERVED || new_keycode == KEY_UNKNOWN ) {
278- IR_dprintk ( 1 , "#%d: Deleting scan 0x%04x\n" ,
279- index , rc_map -> scan [index ].scancode );
279+ dev_dbg ( & dev -> dev , "#%d: Deleting scan 0x%04x\n" ,
280+ index , rc_map -> scan [index ].scancode );
280281 rc_map -> len -- ;
281282 memmove (& rc_map -> scan [index ], & rc_map -> scan [index + 1 ],
282283 (rc_map -> len - index ) * sizeof (struct rc_map_table ));
283284 } else {
284- IR_dprintk ( 1 , "#%d: %s scan 0x%04x with key 0x%04x\n" ,
285- index ,
286- old_keycode == KEY_RESERVED ? "New" : "Replacing" ,
287- rc_map -> scan [index ].scancode , new_keycode );
285+ dev_dbg ( & dev -> dev , "#%d: %s scan 0x%04x with key 0x%04x\n" ,
286+ index ,
287+ old_keycode == KEY_RESERVED ? "New" : "Replacing" ,
288+ rc_map -> scan [index ].scancode , new_keycode );
288289 rc_map -> scan [index ].keycode = new_keycode ;
289290 __set_bit (new_keycode , dev -> input_dev -> keybit );
290291 }
@@ -301,7 +302,7 @@ static unsigned int ir_update_mapping(struct rc_dev *dev,
301302 }
302303
303304 /* Possibly shrink the keytable, failure is not a problem */
304- ir_resize_table (rc_map , GFP_ATOMIC );
305+ ir_resize_table (dev , rc_map , GFP_ATOMIC );
305306 }
306307
307308 return old_keycode ;
@@ -352,7 +353,7 @@ static unsigned int ir_establish_scancode(struct rc_dev *dev,
352353
353354 /* No previous mapping found, we might need to grow the table */
354355 if (rc_map -> size == rc_map -> len ) {
355- if (!resize || ir_resize_table (rc_map , GFP_ATOMIC ))
356+ if (!resize || ir_resize_table (dev , rc_map , GFP_ATOMIC ))
356357 return -1U ;
357358 }
358359
@@ -431,8 +432,8 @@ static int ir_setkeytable(struct rc_dev *dev,
431432 unsigned int i , index ;
432433 int rc ;
433434
434- rc = ir_create_table (rc_map , from -> name ,
435- from -> rc_proto , from -> size );
435+ rc = ir_create_table (dev , rc_map , from -> name , from -> rc_proto ,
436+ from -> size );
436437 if (rc )
437438 return rc ;
438439
@@ -576,8 +577,8 @@ u32 rc_g_keycode_from_table(struct rc_dev *dev, u32 scancode)
576577 spin_unlock_irqrestore (& rc_map -> lock , flags );
577578
578579 if (keycode != KEY_RESERVED )
579- IR_dprintk ( 1 , "%s: scancode 0x%04x keycode 0x%02x\n" ,
580- dev -> device_name , scancode , keycode );
580+ dev_dbg ( & dev -> dev , "%s: scancode 0x%04x keycode 0x%02x\n" ,
581+ dev -> device_name , scancode , keycode );
581582
582583 return keycode ;
583584}
@@ -596,7 +597,7 @@ static void ir_do_keyup(struct rc_dev *dev, bool sync)
596597 if (!dev -> keypressed )
597598 return ;
598599
599- IR_dprintk ( 1 , "keyup key 0x%04x\n" , dev -> last_keycode );
600+ dev_dbg ( & dev -> dev , "keyup key 0x%04x\n" , dev -> last_keycode );
600601 del_timer (& dev -> timer_repeat );
601602 input_report_key (dev -> input_dev , dev -> last_keycode , 0 );
602603 led_trigger_event (led_feedback , LED_OFF );
@@ -751,8 +752,8 @@ static void ir_do_keydown(struct rc_dev *dev, enum rc_proto protocol,
751752 /* Register a keypress */
752753 dev -> keypressed = true;
753754
754- IR_dprintk ( 1 , "%s: key down event, key 0x%04x, protocol 0x%04x, scancode 0x%08x\n" ,
755- dev -> device_name , keycode , protocol , scancode );
755+ dev_dbg ( & dev -> dev , "%s: key down event, key 0x%04x, protocol 0x%04x, scancode 0x%08x\n" ,
756+ dev -> device_name , keycode , protocol , scancode );
756757 input_report_key (dev -> input_dev , keycode , 1 );
757758
758759 led_trigger_event (led_feedback , LED_FULL );
@@ -1056,8 +1057,8 @@ static ssize_t show_protocols(struct device *device,
10561057
10571058 mutex_unlock (& dev -> lock );
10581059
1059- IR_dprintk ( 1 , "%s: allowed - 0x%llx, enabled - 0x%llx\n" ,
1060- __func__ , (long long )allowed , (long long )enabled );
1060+ dev_dbg ( & dev -> dev , "%s: allowed - 0x%llx, enabled - 0x%llx\n" ,
1061+ __func__ , (long long )allowed , (long long )enabled );
10611062
10621063 for (i = 0 ; i < ARRAY_SIZE (proto_names ); i ++ ) {
10631064 if (allowed & enabled & proto_names [i ].type )
@@ -1083,6 +1084,7 @@ static ssize_t show_protocols(struct device *device,
10831084
10841085/**
10851086 * parse_protocol_change() - parses a protocol change request
1087+ * @dev: rc_dev device
10861088 * @protocols: pointer to the bitmask of current protocols
10871089 * @buf: pointer to the buffer with a list of changes
10881090 *
@@ -1092,7 +1094,8 @@ static ssize_t show_protocols(struct device *device,
10921094 * Writing "none" will disable all protocols.
10931095 * Returns the number of changes performed or a negative error code.
10941096 */
1095- static int parse_protocol_change (u64 * protocols , const char * buf )
1097+ static int parse_protocol_change (struct rc_dev * dev , u64 * protocols ,
1098+ const char * buf )
10961099{
10971100 const char * tmp ;
10981101 unsigned count = 0 ;
@@ -1128,7 +1131,8 @@ static int parse_protocol_change(u64 *protocols, const char *buf)
11281131 if (!strcasecmp (tmp , "lirc" ))
11291132 mask = 0 ;
11301133 else {
1131- IR_dprintk (1 , "Unknown protocol: '%s'\n" , tmp );
1134+ dev_dbg (& dev -> dev , "Unknown protocol: '%s'\n" ,
1135+ tmp );
11321136 return - EINVAL ;
11331137 }
11341138 }
@@ -1144,7 +1148,7 @@ static int parse_protocol_change(u64 *protocols, const char *buf)
11441148 }
11451149
11461150 if (!count ) {
1147- IR_dprintk ( 1 , "Protocol not specified\n" );
1151+ dev_dbg ( & dev -> dev , "Protocol not specified\n" );
11481152 return - EINVAL ;
11491153 }
11501154
@@ -1217,27 +1221,27 @@ static ssize_t store_protocols(struct device *device,
12171221 u64 old_protocols , new_protocols ;
12181222 ssize_t rc ;
12191223
1220- IR_dprintk ( 1 , "Normal protocol change requested\n" );
1224+ dev_dbg ( & dev -> dev , "Normal protocol change requested\n" );
12211225 current_protocols = & dev -> enabled_protocols ;
12221226 filter = & dev -> scancode_filter ;
12231227
12241228 if (!dev -> change_protocol ) {
1225- IR_dprintk ( 1 , "Protocol switching not supported\n" );
1229+ dev_dbg ( & dev -> dev , "Protocol switching not supported\n" );
12261230 return - EINVAL ;
12271231 }
12281232
12291233 mutex_lock (& dev -> lock );
12301234
12311235 old_protocols = * current_protocols ;
12321236 new_protocols = old_protocols ;
1233- rc = parse_protocol_change (& new_protocols , buf );
1237+ rc = parse_protocol_change (dev , & new_protocols , buf );
12341238 if (rc < 0 )
12351239 goto out ;
12361240
12371241 rc = dev -> change_protocol (dev , & new_protocols );
12381242 if (rc < 0 ) {
1239- IR_dprintk ( 1 , "Error setting protocols to 0x%llx\n" ,
1240- (long long )new_protocols );
1243+ dev_dbg ( & dev -> dev , "Error setting protocols to 0x%llx\n" ,
1244+ (long long )new_protocols );
12411245 goto out ;
12421246 }
12431247
@@ -1246,8 +1250,8 @@ static ssize_t store_protocols(struct device *device,
12461250
12471251 if (new_protocols != old_protocols ) {
12481252 * current_protocols = new_protocols ;
1249- IR_dprintk ( 1 , "Protocols changed to 0x%llx\n" ,
1250- (long long )new_protocols );
1253+ dev_dbg ( & dev -> dev , "Protocols changed to 0x%llx\n" ,
1254+ (long long )new_protocols );
12511255 }
12521256
12531257 /*
@@ -1435,8 +1439,8 @@ static ssize_t show_wakeup_protocols(struct device *device,
14351439
14361440 mutex_unlock (& dev -> lock );
14371441
1438- IR_dprintk ( 1 , "%s: allowed - 0x%llx, enabled - %d\n" ,
1439- __func__ , (long long )allowed , enabled );
1442+ dev_dbg ( & dev -> dev , "%s: allowed - 0x%llx, enabled - %d\n" ,
1443+ __func__ , (long long )allowed , enabled );
14401444
14411445 for (i = 0 ; i < ARRAY_SIZE (protocols ); i ++ ) {
14421446 if (allowed & (1ULL << i )) {
@@ -1511,7 +1515,7 @@ static ssize_t store_wakeup_protocols(struct device *device,
15111515
15121516 if (dev -> wakeup_protocol != protocol ) {
15131517 dev -> wakeup_protocol = protocol ;
1514- IR_dprintk ( 1 , "Wakeup protocol changed to %d\n" , protocol );
1518+ dev_dbg ( & dev -> dev , "Wakeup protocol changed to %d\n" , protocol );
15151519
15161520 if (protocol == RC_PROTO_RC6_MCE )
15171521 dev -> scancode_wakeup_filter .data = 0x800f0000 ;
@@ -1874,9 +1878,8 @@ int rc_register_device(struct rc_dev *dev)
18741878
18751879 dev -> registered = true;
18761880
1877- IR_dprintk (1 , "Registered rc%u (driver: %s)\n" ,
1878- dev -> minor ,
1879- dev -> driver_name ? dev -> driver_name : "unknown" );
1881+ dev_dbg (& dev -> dev , "Registered rc%u (driver: %s)\n" , dev -> minor ,
1882+ dev -> driver_name ? dev -> driver_name : "unknown" );
18801883
18811884 return 0 ;
18821885
@@ -1994,9 +1997,5 @@ static void __exit rc_core_exit(void)
19941997subsys_initcall (rc_core_init );
19951998module_exit (rc_core_exit );
19961999
1997- int rc_core_debug ; /* ir_debug level (0,1,2) */
1998- EXPORT_SYMBOL_GPL (rc_core_debug );
1999- module_param_named (debug , rc_core_debug , int , 0644 );
2000-
20012000MODULE_AUTHOR ("Mauro Carvalho Chehab" );
20022001MODULE_LICENSE ("GPL v2" );
0 commit comments