* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 2.
*/
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/kernel.h>
#include <linux/i2c.h>
#include <linux/mutex.h>
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
-#define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiB9000: "); printk(args); printk("\n"); } } while (0)
+#define dprintk(fmt, arg...) do { \
+ if (debug) \
+ printk(KERN_DEBUG pr_fmt("%s: " fmt), \
+ __func__, ##arg); \
+} while (0)
+
#define MAX_NUMBER_OF_FRONTENDS 6
struct i2c_device {
state->msg[1].buf = b;
ret = i2c_transfer(state->i2c.i2c_adap, state->msg, 2) != 2 ? -EREMOTEIO : 0;
if (ret != 0) {
- dprintk("i2c read error on %d", reg);
+ dprintk("i2c read error on %d\n", reg);
return -EREMOTEIO;
}
i2c->i2c_write_buffer[1] = reg & 0xff;
if (i2c_transfer(i2c->i2c_adap, msg, 2) != 2) {
- dprintk("read register %x error", reg);
+ dprintk("read register %x error\n", reg);
return 0;
}
return -EIO;
if (mutex_lock_interruptible(&state->platform.risc.mem_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return -EINTR;
}
dib9000_risc_mem_setup(state, cmd | 0x80);
return -EIO;
if (mutex_lock_interruptible(&state->platform.risc.mem_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return -EINTR;
}
dib9000_risc_mem_setup(state, cmd);
dib9000_write_word(state, 1025 + offs, 0);
dib9000_write_word(state, 1031 + offs, key);
- dprintk("going to download %dB of microcode", len);
+ dprintk("going to download %dB of microcode\n", len);
if (dib9000_write16_noinc(state, 1026 + offs, (u8 *) code, (u16) len) != 0) {
- dprintk("error while downloading microcode for RISC %c", 'A' + risc_id);
+ dprintk("error while downloading microcode for RISC %c\n", 'A' + risc_id);
return -EIO;
}
- dprintk("Microcode for RISC %c loaded", 'A' + risc_id);
+ dprintk("Microcode for RISC %c loaded\n", 'A' + risc_id);
return 0;
}
} while ((reset_reg & 0x8000) && --tries);
if (reset_reg & 0x8000) {
- dprintk("MBX: init ERROR, no response from RISC %c", 'A' + risc_id);
+ dprintk("MBX: init ERROR, no response from RISC %c\n", 'A' + risc_id);
return -EIO;
}
- dprintk("MBX: initialized");
+ dprintk("MBX: initialized\n");
return 0;
}
return -EINVAL;
if (mutex_lock_interruptible(&state->platform.risc.mbx_if_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return -EINTR;
}
tmp = MAX_MAILBOX_TRY;
do {
size = dib9000_read_word_attr(state, 1043, attr) & 0xff;
if ((size + len + 1) > MBX_MAX_WORDS && --tmp) {
- dprintk("MBX: RISC mbx full, retrying");
+ dprintk("MBX: RISC mbx full, retrying\n");
msleep(100);
} else
break;
} while (1);
- /*dprintk( "MBX: size: %d", size); */
+ /*dprintk( "MBX: size: %d\n", size); */
if (tmp == 0) {
ret = -EINVAL;
goto out;
}
#ifdef DUMP_MSG
- dprintk("--> %02x %d ", id, len + 1);
- for (i = 0; i < len; i++)
- dprintk("%04x ", data[i]);
- dprintk("\n");
+ dprintk("--> %02x %d %*ph\n", id, len + 1, len, data);
#endif
/* byte-order conversion - works on big (where it is not necessary) or little endian */
return 0;
if (mutex_lock_interruptible(&state->platform.risc.mbx_if_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return 0;
}
if (risc_id == 1)
}
#ifdef DUMP_MSG
- dprintk("<-- ");
+ dprintk("<--\n");
for (i = 0; i < size + 1; i++)
- dprintk("%04x ", d[i]);
+ dprintk("%04x\n", d[i]);
dprintk("\n");
#endif
} else {
- dprintk("MBX: message is too big for message cache (%d), flushing message", size);
+ dprintk("MBX: message is too big for message cache (%d), flushing message\n", size);
size--; /* Initial word already read */
while (size--)
dib9000_read16_noinc_attr(state, 1029 + mc_base, (u8 *) data, 2, attr);
b[2 * (size - 2) - 1] = '\0'; /* Bullet proof the buffer */
if (*b == '~') {
b++;
- dprintk("%s", b);
+ dprintk("%s\n", b);
} else
- dprintk("RISC%d: %d.%04d %s", state->fe_id, ts / 10000, ts % 10000, *b ? b : "<empty>");
+ dprintk("RISC%d: %d.%04d %s\n",
+ state->fe_id,
+ ts / 10000, ts % 10000, *b ? b : "<empty>");
return 1;
}
if (*block == 0) {
size = dib9000_mbx_read(state, block, 1, attr);
-/* dprintk( "MBX: fetched %04x message to cache", *block); */
+/* dprintk( "MBX: fetched %04x message to cache\n", *block); */
switch (*block >> 8) {
case IN_MSG_DEBUG_BUF:
return 1;
}
}
- dprintk("MBX: no free cache-slot found for new message...");
+ dprintk("MBX: no free cache-slot found for new message...\n");
return -1;
}
return -1;
if (mutex_lock_interruptible(&state->platform.risc.mbx_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return -1;
}
dib9000_read_word_attr(state, 1229, attr); /* Clear the IRQ */
/* if (tmp) */
-/* dprintk( "cleared IRQ: %x", tmp); */
+/* dprintk( "cleared IRQ: %x\n", tmp); */
mutex_unlock(&state->platform.risc.mbx_lock);
return ret;
} while (--timeout);
if (timeout == 0) {
- dprintk("waiting for message %d timed out", id);
+ dprintk("waiting for message %d timed out\n", id);
return -1;
}
return -EIO;
fw_version = (r[0] << 8) | r[1];
- dprintk("RISC: ver: %d.%02d (IC: %d)", fw_version >> 10, fw_version & 0x3ff, (r[2] << 8) | r[3]);
+ dprintk("RISC: ver: %d.%02d (IC: %d)\n", fw_version >> 10, fw_version & 0x3ff, (r[2] << 8) | r[3]);
if ((fw_version >> 10) != 7)
return -EINVAL;
value = dib9000_i2c_read16(client, 896);
if (value != 0x01b3) {
- dprintk("wrong Vendor ID (0x%x)", value);
+ dprintk("wrong Vendor ID (0x%x)\n", value);
return 0;
}
value = dib9000_i2c_read16(client, 897);
if (value != 0x4000 && value != 0x4001 && value != 0x4002 && value != 0x4003 && value != 0x4004 && value != 0x4005) {
- dprintk("wrong Device ID (0x%x)", value);
+ dprintk("wrong Device ID (0x%x)\n", value);
return 0;
}
/* protect this driver to be used with 7000PC */
if (value == 0x4000 && dib9000_i2c_read16(client, 769) == 0x4000) {
- dprintk("this driver does not work with DiB7000PC");
+ dprintk("this driver does not work with DiB7000PC\n");
return 0;
}
switch (value) {
case 0x4000:
- dprintk("found DiB7000MA/PA/MB/PB");
+ dprintk("found DiB7000MA/PA/MB/PB\n");
break;
case 0x4001:
- dprintk("found DiB7000HC");
+ dprintk("found DiB7000HC\n");
break;
case 0x4002:
- dprintk("found DiB7000MC");
+ dprintk("found DiB7000MC\n");
break;
case 0x4003:
- dprintk("found DiB9000A");
+ dprintk("found DiB9000A\n");
break;
case 0x4004:
- dprintk("found DiB9000H");
+ dprintk("found DiB9000H\n");
break;
case 0x4005:
- dprintk("found DiB9000M");
+ dprintk("found DiB9000M\n");
break;
}
if (address >= 1024 || !state->platform.risc.fw_is_running)
return -EINVAL;
- /* dprintk( "APB access thru rd fw %d %x", address, attribute); */
+ /* dprintk( "APB access thru rd fw %d %x\n", address, attribute); */
mb[0] = (u16) address;
mb[1] = len / 2;
if (len > 18)
return -EINVAL;
- /* dprintk( "APB access thru wr fw %d %x", address, attribute); */
+ /* dprintk( "APB access thru wr fw %d %x\n", address, attribute); */
mb[0] = (u16)address;
for (i = 0; i + 1 < len; i += 2)
int ret = 0;
if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return -EINTR;
}
if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) {
struct dib9000_state *state = fe->demodulator_priv;
u16 outreg, smo_mode;
- dprintk("setting output mode for demod %p to %d", fe, mode);
+ dprintk("setting output mode for demod %p to %d\n", fe, mode);
switch (mode) {
case OUTMODE_MPEG2_PAR_GATED_CLK:
outreg = 0;
break;
default:
- dprintk("Unhandled output_mode passed to be set for demod %p", &state->fe[0]);
+ dprintk("Unhandled output_mode passed to be set for demod %p\n", &state->fe[0]);
return -EINVAL;
}
len = 16;
if (dib9000_read_word(state, 790) != 0)
- dprintk("TunerITF: read busy");
+ dprintk("TunerITF: read busy\n");
dib9000_write_word(state, 784, (u16) (msg[index_msg].addr));
dib9000_write_word(state, 787, (len / 2) - 1);
i--;
if (i == 0)
- dprintk("TunerITF: read failed");
+ dprintk("TunerITF: read failed\n");
for (i = 0; i < len; i += 2) {
t = dib9000_read_word(state, 785);
msg[index_msg].buf[i + 1] = (t) & 0xff;
}
if (dib9000_read_word(state, 790) != 0)
- dprintk("TunerITF: read more data than expected");
+ dprintk("TunerITF: read more data than expected\n");
} else {
i = 1000;
while (dib9000_read_word(state, 789) && i)
i--;
if (i == 0)
- dprintk("TunerITF: write busy");
+ dprintk("TunerITF: write busy\n");
len = msg[index_msg].len;
if (len > 16)
while (dib9000_read_word(state, 791) > 0 && i)
i--;
if (i == 0)
- dprintk("TunerITF: write failed");
+ dprintk("TunerITF: write failed\n");
}
}
return num;
}
if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return 0;
}
st->gpio_val |= (val & 0x01) << num; /* set the new value */
dib9000_write_word(st, 774, st->gpio_val);
- dprintk("gpio dir: %04x: gpio val: %04x", st->gpio_dir, st->gpio_val);
+ dprintk("gpio dir: %04x: gpio val: %04x\n", st->gpio_dir, st->gpio_val);
return 0;
}
if ((state->pid_ctrl_index != -2) && (state->pid_ctrl_index < 9)) {
/* postpone the pid filtering cmd */
- dprintk("pid filter cmd postpone");
+ dprintk("pid filter cmd postpone\n");
state->pid_ctrl_index++;
state->pid_ctrl[state->pid_ctrl_index].cmd = DIB9000_PID_FILTER_CTRL;
state->pid_ctrl[state->pid_ctrl_index].onoff = onoff;
}
if (mutex_lock_interruptible(&state->demod_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return -EINTR;
}
val = dib9000_read_word(state, 294 + 1) & 0xffef;
val |= (onoff & 0x1) << 4;
- dprintk("PID filter enabled %d", onoff);
+ dprintk("PID filter enabled %d\n", onoff);
ret = dib9000_write_word(state, 294 + 1, val);
mutex_unlock(&state->demod_lock);
return ret;
if (state->pid_ctrl_index != -2) {
/* postpone the pid filtering cmd */
- dprintk("pid filter postpone");
+ dprintk("pid filter postpone\n");
if (state->pid_ctrl_index < 9) {
state->pid_ctrl_index++;
state->pid_ctrl[state->pid_ctrl_index].cmd = DIB9000_PID_FILTER;
state->pid_ctrl[state->pid_ctrl_index].pid = pid;
state->pid_ctrl[state->pid_ctrl_index].onoff = onoff;
} else
- dprintk("can not add any more pid ctrl cmd");
+ dprintk("can not add any more pid ctrl cmd\n");
return 0;
}
if (mutex_lock_interruptible(&state->demod_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return -EINTR;
}
- dprintk("Index %x, PID %d, OnOff %d", id, pid, onoff);
+ dprintk("Index %x, PID %d, OnOff %d\n", id, pid, onoff);
ret = dib9000_write_word(state, 300 + 1 + id,
onoff ? (1 << 13) | pid : 0);
mutex_unlock(&state->demod_lock);
int ret = 0;
if (mutex_lock_interruptible(&state->demod_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return -EINTR;
}
for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
if (state->get_frontend_internal == 0) {
if (mutex_lock_interruptible(&state->demod_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return -EINTR;
}
}
for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
state->fe[index_frontend]->ops.read_status(state->fe[index_frontend], &stat);
if (stat & FE_HAS_SYNC) {
- dprintk("TPS lock on the slave%i", index_frontend);
+ dprintk("TPS lock on the slave%i\n", index_frontend);
/* synchronize the cache with the other frontends */
state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend], c);
/* check that the correct parameters are set */
if (state->fe[0]->dtv_property_cache.frequency == 0) {
- dprintk("dib9000: must specify frequency ");
+ dprintk("dib9000: must specify frequency\n");
return 0;
}
if (state->fe[0]->dtv_property_cache.bandwidth_hz == 0) {
- dprintk("dib9000: must specify bandwidth ");
+ dprintk("dib9000: must specify bandwidth\n");
return 0;
}
state->pid_ctrl_index = -1; /* postpone the pid filtering cmd */
if (mutex_lock_interruptible(&state->demod_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return 0;
}
/* check the tune result */
if (exit_condition == 1) { /* tune failed */
- dprintk("tune failed");
+ dprintk("tune failed\n");
mutex_unlock(&state->demod_lock);
/* tune failed; put all the pid filtering cmd to junk */
state->pid_ctrl_index = -1;
return 0;
}
- dprintk("tune success on frontend%i", index_frontend_success);
+ dprintk("tune success on frontend%i\n", index_frontend_success);
/* synchronize all the channel cache */
state->get_frontend_internal = 1;
u16 lock = 0, lock_slave = 0;
if (mutex_lock_interruptible(&state->demod_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return -EINTR;
}
for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++)
int ret = 0;
if (mutex_lock_interruptible(&state->demod_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return -EINTR;
}
if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
ret = -EINTR;
goto error;
}
int ret = 0;
if (mutex_lock_interruptible(&state->demod_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return -EINTR;
}
*strength = 0;
}
if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
ret = -EINTR;
goto error;
}
u16 val;
if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return 0;
}
if (dib9000_fw_memmbx_sync(state, FE_SYNC_CHANNEL) < 0) {
u32 snr_master;
if (mutex_lock_interruptible(&state->demod_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return -EINTR;
}
snr_master = dib9000_get_snr(fe);
int ret = 0;
if (mutex_lock_interruptible(&state->demod_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
return -EINTR;
}
if (mutex_lock_interruptible(&state->platform.risc.mem_mbx_lock) < 0) {
- dprintk("could not get the lock");
+ dprintk("could not get the lock\n");
ret = -EINTR;
goto error;
}
client.i2c_write_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL);
if (!client.i2c_write_buffer) {
- dprintk("%s: not enough memory", __func__);
+ dprintk("%s: not enough memory\n", __func__);
return -ENOMEM;
}
client.i2c_read_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL);
if (!client.i2c_read_buffer) {
- dprintk("%s: not enough memory", __func__);
+ dprintk("%s: not enough memory\n", __func__);
ret = -ENOMEM;
goto error_memory;
}
if (dib9000_identify(&client) == 0) {
client.i2c_addr = default_addr;
if (dib9000_identify(&client) == 0) {
- dprintk("DiB9000 #%d: not identified", k);
+ dprintk("DiB9000 #%d: not identified\n", k);
ret = -EIO;
goto error;
}
dib9000_i2c_write16(&client, 1795, (1 << 10) | (4 << 6));
dib9000_i2c_write16(&client, 1794, (new_addr << 2) | 2);
- dprintk("IC %d initialized (to i2c_address 0x%x)", k, new_addr);
+ dprintk("IC %d initialized (to i2c_address 0x%x)\n", k, new_addr);
}
for (k = 0; k < no_of_demods; k++) {
while ((index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL))
index_frontend++;
if (index_frontend < MAX_NUMBER_OF_FRONTENDS) {
- dprintk("set slave fe %p to index %i", fe_slave, index_frontend);
+ dprintk("set slave fe %p to index %i\n", fe_slave, index_frontend);
state->fe[index_frontend] = fe_slave;
return 0;
}
- dprintk("too many slave frontend");
+ dprintk("too many slave frontend\n");
return -ENOMEM;
}
EXPORT_SYMBOL(dib9000_set_slave_frontend);
while ((index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL))
index_frontend++;
if (index_frontend != 1) {
- dprintk("remove slave fe %p (index %i)", state->fe[index_frontend - 1], index_frontend - 1);
+ dprintk("remove slave fe %p (index %i)\n", state->fe[index_frontend - 1], index_frontend - 1);
state->fe[index_frontend] = NULL;
return 0;
}
- dprintk("no frontend to be removed");
+ dprintk("no frontend to be removed\n");
return -ENODEV;
}
EXPORT_SYMBOL(dib9000_remove_slave_frontend);