]> git.karo-electronics.de Git - linux-beck.git/commitdiff
V4L/DVB: em28xx-input: Don't generate one debug message for every get_key read
authorMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 27 Jun 2010 11:32:11 +0000 (08:32 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 2 Aug 2010 17:53:30 +0000 (14:53 -0300)
Instead of generating one printk for every IR read, prints it only when
count is different from the last count.

While here, as this code is called on every 100ms during the runtime
lifetime, do some performance optimization, assuming that, under normal
circumstances, it is unlikely that the driver would get a new key/key
repeat on every poll.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/em28xx/em28xx-input.c

index dd6d528998b13935a25bd3a14aac157838c603d4..6759cd5570dd2c720f9a13126e4aab2cf3353003 100644 (file)
@@ -292,18 +292,15 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir)
 
        /* read the registers containing the IR status */
        result = ir->get_key(ir, &poll_result);
-       if (result < 0) {
+       if (unlikely(result < 0)) {
                dprintk("ir->get_key() failed %d\n", result);
                return;
        }
 
-       dprintk("ir->get_key result tb=%02x rc=%02x lr=%02x data=%02x%02x\n",
-               poll_result.toggle_bit, poll_result.read_count,
-               ir->last_readcount, poll_result.rc_address,
-               poll_result.rc_data[0]);
-
-       if (poll_result.read_count > 0 &&
-           poll_result.read_count != ir->last_readcount) {
+       if (unlikely(poll_result.read_count != ir->last_readcount)) {
+               dprintk("%s: toggle: %d, count: %d, key 0x%02x%02x\n", __func__,
+                       poll_result.toggle_bit, poll_result.read_count,
+                       poll_result.rc_address, poll_result.rc_data[0]);
                if (ir->full_code)
                        ir_keydown(ir->input,
                                   poll_result.rc_address << 8 |
@@ -313,17 +310,17 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir)
                        ir_keydown(ir->input,
                                   poll_result.rc_data[0],
                                   poll_result.toggle_bit);
-       }
 
-       if (ir->dev->chip_id == CHIP_ID_EM2874)
-               /* The em2874 clears the readcount field every time the
-                  register is read.  The em2860/2880 datasheet says that it
-                  is supposed to clear the readcount, but it doesn't.  So with
-                  the em2874, we are looking for a non-zero read count as
-                  opposed to a readcount that is incrementing */
-               ir->last_readcount = 0;
-       else
-               ir->last_readcount = poll_result.read_count;
+               if (ir->dev->chip_id == CHIP_ID_EM2874)
+                       /* The em2874 clears the readcount field every time the
+                          register is read.  The em2860/2880 datasheet says that it
+                          is supposed to clear the readcount, but it doesn't.  So with
+                          the em2874, we are looking for a non-zero read count as
+                          opposed to a readcount that is incrementing */
+                       ir->last_readcount = 0;
+               else
+                       ir->last_readcount = poll_result.read_count;
+       }
 }
 
 static void em28xx_ir_work(struct work_struct *work)