Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] drxk: Improve the scu_command error message

Now, it outputs:

[10927.639641] drxk: SCU_RESULT_INVPAR while sending cmd 0x0203 with params:
[10927.646283] drxk: 02 00 00 00 10 00 07 00 03 02 ..........

Better than ERROR -3. This happens with Terratec H5 firmware.

It adds 2 new error conditions, and something useful to track
what the heck is that.

I suspect that the scu_command is dependent on the firmware
revision.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

+27 -18
+25 -18
drivers/media/dvb/frontends/drxk_hard.c
··· 1521 1521 unsigned long end; 1522 1522 u8 buffer[34]; 1523 1523 int cnt = 0, ii; 1524 + const char *p; 1525 + char errname[30]; 1524 1526 1525 1527 dprintk(1, "\n"); 1526 1528 ··· 1569 1567 1570 1568 /* Check if an error was reported by SCU */ 1571 1569 err = (s16)result[0]; 1570 + if (err >= 0) 1571 + goto error; 1572 1572 1573 - /* check a few fixed error codes */ 1574 - if (err == SCU_RESULT_UNKSTD) { 1575 - printk(KERN_ERR "drxk: SCU_RESULT_UNKSTD\n"); 1576 - status = -EINVAL; 1577 - goto error2; 1578 - } else if (err == SCU_RESULT_UNKCMD) { 1579 - printk(KERN_ERR "drxk: SCU_RESULT_UNKCMD\n"); 1580 - status = -EINVAL; 1581 - goto error2; 1582 - } else if (err < 0) { 1583 - /* 1584 - * here it is assumed that a nagative result means 1585 - * error, and positive no error 1586 - */ 1587 - printk(KERN_ERR "drxk: %s ERROR: %d\n", __func__, err); 1588 - status = -EINVAL; 1589 - goto error2; 1573 + /* check for the known error codes */ 1574 + switch (err) { 1575 + case SCU_RESULT_UNKCMD: 1576 + p = "SCU_RESULT_UNKCMD"; 1577 + break; 1578 + case SCU_RESULT_UNKSTD: 1579 + p = "SCU_RESULT_UNKSTD"; 1580 + break; 1581 + case SCU_RESULT_SIZE: 1582 + p = "SCU_RESULT_SIZE"; 1583 + break; 1584 + case SCU_RESULT_INVPAR: 1585 + p = "SCU_RESULT_INVPAR"; 1586 + break; 1587 + default: /* Other negative values are errors */ 1588 + sprintf(errname, "ERROR: %d\n", err); 1589 + p = errname; 1590 1590 } 1591 + printk(KERN_ERR "drxk: %s while sending cmd 0x%04x with params:", p, cmd); 1592 + print_hex_dump_bytes("drxk: ", DUMP_PREFIX_NONE, buffer, cnt); 1593 + status = -EINVAL; 1594 + goto error2; 1591 1595 } 1592 1596 1593 1597 error: 1594 1598 if (status < 0) 1595 1599 printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); 1596 - 1597 1600 error2: 1598 1601 mutex_unlock(&state->mutex); 1599 1602 return status;
+2
drivers/media/dvb/frontends/drxk_hard.h
··· 20 20 #define DRX_SCU_READY 0 21 21 #define DRXK_MAX_WAITTIME (200) 22 22 #define SCU_RESULT_OK 0 23 + #define SCU_RESULT_SIZE -4 24 + #define SCU_RESULT_INVPAR -3 23 25 #define SCU_RESULT_UNKSTD -2 24 26 #define SCU_RESULT_UNKCMD -1 25 27