• Mauro Carvalho Chehab's avatar
    [media] drx-j: replace the ugly CHK_ERROR() macro · 068e94ea
    Mauro Carvalho Chehab authored
    Using return and goto inside macros is ugly and makes harder to
    understand the code and the labels. Remove those macros, and add
    a proper error debug message, when something bad happens.
    
    This was generated using the following coccinelle script:
    
    @@
    @@
    -DUMMY_READ();
    +do {
    +	u16 dummy;
    +	RR16(demod->my_i2c_dev_addr, SCU_RAM_VERSION_HI__A, &dummy);
    +} while (0);
    
    @@
    expression dev, addr, val;
    @@
    -WR16(dev, addr, val)
    +CHK_ERROR(DRXJ_DAP.write_reg16func(dev, addr, val, 0))
    
    @@
    expression dev, addr, val;
    @@
    -RR16(dev, addr, val)
    +CHK_ERROR(DRXJ_DAP.read_reg16func(dev, addr, val, 0))
    
    @@
    expression dev, addr, val;
    @@
    -WR32(dev, addr, val)
    +CHK_ERROR(DRXJ_DAP.write_reg32func(dev, addr, val, 0))
    
    @@
    expression dev, addr, val;
    @@
    -RR32(dev, addr, val)
    +CHK_ERROR(DRXJ_DAP.read_reg32func(dev, addr, val, 0))
    
    @@
    expression dev, addr, val, block;
    @@
    -WRB(dev, addr, val, block)
    +CHK_ERROR(DRXJ_DAP.write_block_func(dev, addr, val, block, 0))
    
    @@
    expression dev, addr, val, block;
    @@
    -RRB(dev, addr, val, block)
    +CHK_ERROR(DRXJ_DAP.read_block_func(dev, addr, val, block, 0))
    
    @@
    expression dev, addr, val;
    @@
    -BCWR16(dev, addr, val)
    +CHK_ERROR(DRXJ_DAP.write_reg16func(dev, addr, val, DRXDAP_FASI_BROADCAST))
    
    @@
    expression dev, addr, val;
    @@
    -ARR32(dev, addr, val)
    +CHK_ERROR(drxj_dap_atomic_read_reg32(dev, addr, val, 0))
    
    @@
    expression dev, addr, val;
    @@
    -SARR16(dev, addr, val)
    +CHK_ERROR(drxj_dap_scu_atomic_read_reg16(dev, addr, val, 0))
    
    @@
    expression x;
    @@
    -CHK_ERROR(x);
    +rc = x;
    +if (rc != DRX_STS_OK) {
    +	pr_err("error %d\n", rc);
    +	goto rw_error;
    +}
    Acked-by: default avatarDevin Heitmueller <dheitmueller@kernellabs.com>
    Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
    068e94ea
drxj.c 595 KB