parse_az6007.pl: Move the I2C read decode hack to the proper place
authorMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 24 Jul 2011 11:05:12 +0000 (08:05 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 24 Jul 2011 11:05:12 +0000 (08:05 -0300)
The removal of the extra bytes should be done only at the payload.
Also, moving it to the logic that handles the I2C subaddress
makes the code more readable.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
contrib/az6007/parse_az6007.pl

index 29939f6..5970605 100755 (executable)
@@ -2250,6 +2250,12 @@ sub i2c_decode($$$$$)
 
        $write = 1 if (!($reqtype & 0x80));
 
+       if ($n >= 6 && !$write) {
+               # This is how az6007 returns reads
+               $n -= 6;
+               $data = substr($data, 3 * 5, $n * 3);
+       }
+
        $addr = $wvalue & 0xff;
 
        if ($wvalue > 255) {
@@ -2284,12 +2290,6 @@ while (<>) {
                if ($req == 0xb9 || $req == 0xbd) {
                        my ($addr, $data, $write, $n) = i2c_decode($reqtype, $wvalue, $windex, $wlen, $payload);
 
-                       if ($n > 6 && !$write) {
-                               # This is how az6007 returns reads
-                               $n -= 6;
-                               $data = substr($data, 3 * 5, $n * 3);
-                       }
-
                        if ($addr == 0x52) {
                                parse_drxk_addr($timestamp, $addr, $n, $data, $write) if ($show_drxk);
                        } elsif ($addr == 0xc0) {