use dev_* logging calls overall

This is far more informative about what specific mezzanine
originates an error, e.g., low-level traces like

gpio_writel_with_retry: succeded after 66 retries
gpio_writel_with_retry: succeded after 65 retries
gpio_writel_with_retry: succeded after 97 retries
...

coming from nameless devices require identification of the originator.
parent 289428fe
...@@ -64,6 +64,7 @@ static uint64_t output_delay_ps(struct fd_dev *fd, int ch, int fine, int n, ...@@ -64,6 +64,7 @@ static uint64_t output_delay_ps(struct fd_dev *fd, int ch, int fine, int n,
uint64_t *results; uint64_t *results;
uint64_t res, acc = 0; uint64_t res, acc = 0;
int rem; int rem;
struct device *dev = &fd->fmc->dev;
results = kmalloc(n * sizeof(*results), GFP_KERNEL); results = kmalloc(n * sizeof(*results), GFP_KERNEL);
if (!results) if (!results)
...@@ -106,9 +107,9 @@ static uint64_t output_delay_ps(struct fd_dev *fd, int ch, int fine, int n, ...@@ -106,9 +107,9 @@ static uint64_t output_delay_ps(struct fd_dev *fd, int ch, int fine, int n,
res = fr * fd->bin; res = fr * fd->bin;
if (fd->verbose > 3) if (fd->verbose > 3)
pr_info("%s: ch %i, fine %i, bin %x got %08x, " dev_info(dev, "%s: ch %i, fine %i, bin %x got %08x, "
"res 0x%016llx\n", __func__, ch, fine, "res 0x%016llx\n", __func__, ch, fine,
fd->bin, fr, res); fd->bin, fr, res);
results[i] = res; results[i] = res;
acc += res; acc += res;
} }
...@@ -125,9 +126,9 @@ static uint64_t output_delay_ps(struct fd_dev *fd, int ch, int fine, int n, ...@@ -125,9 +126,9 @@ static uint64_t output_delay_ps(struct fd_dev *fd, int ch, int fine, int n,
if (results[i] < stats->min) stats->min = results[i]; if (results[i] < stats->min) stats->min = results[i];
} }
if (fd->verbose > 2) if (fd->verbose > 2)
pr_info("%s: ch %i, taps %i, count %i, result %llx " dev_info(dev, "%s: ch %i, taps %i, count %i, result %llx "
"(max-min %llx)\n", __func__, ch, fine, n, "(max-min %llx)\n", __func__, ch, fine, n,
stats->avg, stats->max - stats->min); stats->avg, stats->max - stats->min);
} }
kfree(results); kfree(results);
...@@ -145,6 +146,7 @@ static int fd_find_8ns_tap(struct fd_dev *fd, int ch) ...@@ -145,6 +146,7 @@ static int fd_find_8ns_tap(struct fd_dev *fd, int ch)
int l = 0, mid, r = FD_NUM_TAPS - 1; int l = 0, mid, r = FD_NUM_TAPS - 1;
uint64_t bias, dly; uint64_t bias, dly;
struct delay_stats stats; struct delay_stats stats;
struct device *dev = &fd->fmc->dev;
/* /*
* Measure the delay at zero setting, so it can be further * Measure the delay at zero setting, so it can be further
...@@ -156,7 +158,7 @@ static int fd_find_8ns_tap(struct fd_dev *fd, int ch) ...@@ -156,7 +158,7 @@ static int fd_find_8ns_tap(struct fd_dev *fd, int ch)
mid = ( l + r) / 2; mid = ( l + r) / 2;
dly = output_delay_ps(fd, ch, mid, FD_CAL_STEPS, &stats) - bias; dly = output_delay_ps(fd, ch, mid, FD_CAL_STEPS, &stats) - bias;
if (fd->verbose > 1) { if (fd->verbose > 1) {
printk("%s: ch%i @ %-5i: ", __func__, ch, mid); dev_info(dev, "%s: ch%i @ %-5i: ", __func__, ch, mid);
__pr_fixed("bias ", bias, ", "); __pr_fixed("bias ", bias, ", ");
__pr_fixed("min ", stats.min - bias, ", "); __pr_fixed("min ", stats.min - bias, ", ");
__pr_fixed("avg ", stats.avg - bias, ", "); __pr_fixed("avg ", stats.avg - bias, ", ");
...@@ -194,10 +196,11 @@ int fd_calibrate_outputs(struct fd_dev *fd) ...@@ -194,10 +196,11 @@ int fd_calibrate_outputs(struct fd_dev *fd)
fd_ch_writel(fd, ch, new, FD_REG_FRR); fd_ch_writel(fd, ch, new, FD_REG_FRR);
fd->ch[ch].frr_cur = new; fd->ch[ch].frr_cur = new;
if (1) { if (1) {
pr_info("%s: ch%i: 8ns @%i (f %i, off %i, t %i.%02i)\n", dev_info(&fd->fmc->dev,
__func__, FD_CH_EXT(ch), "%s: ch%i: 8ns @%i (f %i, off %i, t %i.%02i)\n",
new, fitted, fd->ch[ch].frr_offset, __func__, FD_CH_EXT(ch),
fd->temp / 16, (fd->temp & 0xf) * 100 / 16); new, fitted, fd->ch[ch].frr_offset,
fd->temp / 16, (fd->temp & 0xf) * 100 / 16);
} }
} }
return 0; return 0;
...@@ -217,10 +220,11 @@ void fd_update_calibration(unsigned long arg) ...@@ -217,10 +220,11 @@ void fd_update_calibration(unsigned long arg)
fd_ch_writel(fd, ch, new, FD_REG_FRR); fd_ch_writel(fd, ch, new, FD_REG_FRR);
fd->ch[ch].frr_cur = new; fd->ch[ch].frr_cur = new;
if (0) { if (0) {
pr_info("%s: ch%i: 8ns @%i (f %i, off %i, t %i.%02i)\n", dev_info(&fd->fmc->dev,
__func__, FD_CH_EXT(ch), "%s: ch%i: 8ns @%i (f %i, off %i, t %i.%02i)\n",
new, fitted, fd->ch[ch].frr_offset, __func__, FD_CH_EXT(ch),
fd->temp / 16, (fd->temp & 0xf) * 100 / 16); new, fitted, fd->ch[ch].frr_offset,
fd->temp / 16, (fd->temp & 0xf) * 100 / 16);
} }
} }
......
...@@ -111,7 +111,7 @@ static int fd_read_calibration_eeprom(struct fmc_device *fmc, ...@@ -111,7 +111,7 @@ static int fd_read_calibration_eeprom(struct fmc_device *fmc,
int fd_handle_eeprom_calibration(struct fd_dev *fd) int fd_handle_eeprom_calibration(struct fd_dev *fd)
{ {
struct fd_calibration *calib; struct fd_calibration *calib;
struct device *d = fd->fmc->hwdev; struct device *d = &fd->fmc->dev;
int i; int i;
u32 hash, horig; u32 hash, horig;
......
...@@ -91,7 +91,8 @@ int fd_reset_again(struct fd_dev *fd) ...@@ -91,7 +91,8 @@ int fd_reset_again(struct fd_dev *fd)
msleep(10); msleep(10);
} }
if (time_after_eq(jiffies, j)) { if (time_after_eq(jiffies, j)) {
pr_err("%s: timeout waiting for GCR lock bit\n", __func__); dev_err(&fd->fmc->dev,
"%s: timeout waiting for GCR lock bit\n", __func__);
return -EIO; return -EIO;
} }
...@@ -126,7 +127,7 @@ int fd_probe(struct fmc_device *fmc) ...@@ -126,7 +127,7 @@ int fd_probe(struct fmc_device *fmc)
{ {
struct fd_modlist *m; struct fd_modlist *m;
struct fd_dev *fd; struct fd_dev *fd;
struct device *dev = fmc->hwdev; struct device *dev = &fmc->dev;
char *fwname; char *fwname;
int i, index, ret; int i, index, ret;
...@@ -228,12 +229,12 @@ int fd_probe(struct fmc_device *fmc) ...@@ -228,12 +229,12 @@ int fd_probe(struct fmc_device *fmc)
/* init all subsystems */ /* init all subsystems */
for (i = 0, m = mods; i < ARRAY_SIZE(mods); i++, m++) { for (i = 0, m = mods; i < ARRAY_SIZE(mods); i++, m++) {
pr_debug("%s: Calling init for \"%s\"\n", __func__, dev_dbg(dev, "%s: Calling init for \"%s\"\n", __func__,
m->name); m->name);
ret = m->init(fd); ret = m->init(fd);
if (ret < 0) { if (ret < 0) {
pr_err("%s: error initializing %s\n", __func__, dev_err(dev, "%s: error initializing %s\n", __func__,
m->name); m->name);
goto err; goto err;
} }
} }
......
...@@ -290,8 +290,9 @@ int fd_irq_init(struct fd_dev *fd) ...@@ -290,8 +290,9 @@ int fd_irq_init(struct fd_dev *fd)
/* Check that the sw fifo size is a power of two */ /* Check that the sw fifo size is a power of two */
if (fd_sw_fifo_len & (fd_sw_fifo_len - 1)) { if (fd_sw_fifo_len & (fd_sw_fifo_len - 1)) {
pr_err("%s: fifo len must be a power of 2 (not %d = 0x%x)\n", dev_err(&fd->fmc->dev,
KBUILD_MODNAME, fd_sw_fifo_len, fd_sw_fifo_len); "fifo len must be a power of 2 (not %d = 0x%x)\n",
fd_sw_fifo_len, fd_sw_fifo_len);
return -EINVAL; return -EINVAL;
} }
...@@ -309,7 +310,7 @@ int fd_irq_init(struct fd_dev *fd) ...@@ -309,7 +310,7 @@ int fd_irq_init(struct fd_dev *fd)
tasklet_init(&fd->tlet, fd_tlet, (unsigned long)fd); tasklet_init(&fd->tlet, fd_tlet, (unsigned long)fd);
if (fd_timer_period_ms) { if (fd_timer_period_ms) {
dev_info(fd->fmc->hwdev,"Using a timer for input (%i ms)\n", dev_info(&fd->fmc->dev,"Using a timer for input (%i ms)\n",
jiffies_to_msecs(fd_timer_period_jiffies)); jiffies_to_msecs(fd_timer_period_jiffies));
mod_timer(&fd->fifo_timer, jiffies + fd_timer_period_jiffies); mod_timer(&fd->fifo_timer, jiffies + fd_timer_period_jiffies);
} else { } else {
......
...@@ -556,7 +556,8 @@ static int fd_zio_output(struct zio_cset *cset) ...@@ -556,7 +556,8 @@ static int fd_zio_output(struct zio_cset *cset)
ctrl = zio_get_ctrl(cset->chan->active_block); ctrl = zio_get_ctrl(cset->chan->active_block);
if (fd->verbose > 1) { if (fd->verbose > 1) {
pr_info("%s: attrs for cset %i: ", __func__, cset->index); dev_info(&fd->fmc->dev,
"%s: attrs for cset %i: ", __func__, cset->index);
for (i = FD_ATTR_DEV__LAST; i < FD_ATTR_OUT__LAST; i++) for (i = FD_ATTR_DEV__LAST; i < FD_ATTR_OUT__LAST; i++)
printk("%08x%c", ctrl->attr_channel.ext_val[i], printk("%08x%c", ctrl->attr_channel.ext_val[i],
i == FD_ATTR_OUT__LAST -1 ? '\n' : ' '); i == FD_ATTR_OUT__LAST -1 ? '\n' : ' ');
......
...@@ -47,7 +47,8 @@ static int gpio_writel_with_retry(struct fd_dev *fd, int val, int reg) ...@@ -47,7 +47,8 @@ static int gpio_writel_with_retry(struct fd_dev *fd, int val, int reg)
if(rv >= 0 && (rv == val)) if(rv >= 0 && (rv == val))
{ {
if(SPI_RETRIES-1-retries > 0) if(SPI_RETRIES-1-retries > 0)
pr_info("%s: succeded after %d retries\n", dev_info(&fd->fmc->dev,
"%s: succeded after %d retries\n",
__func__, SPI_RETRIES - 1 - retries); __func__, SPI_RETRIES - 1 - retries);
return 0; return 0;
} }
...@@ -86,6 +87,7 @@ void fd_gpio_set_clr(struct fd_dev *fd, int mask, int set) ...@@ -86,6 +87,7 @@ void fd_gpio_set_clr(struct fd_dev *fd, int mask, int set)
int fd_gpio_init(struct fd_dev *fd) int fd_gpio_init(struct fd_dev *fd)
{ {
int i, val; int i, val;
struct device *dev = &fd->fmc->dev;
fd->mcp_iodir = 0xffff; fd->mcp_iodir = 0xffff;
fd->mcp_olat = 0; fd->mcp_olat = 0;
...@@ -101,16 +103,16 @@ int fd_gpio_init(struct fd_dev *fd) ...@@ -101,16 +103,16 @@ int fd_gpio_init(struct fd_dev *fd)
if (i < 0) if (i < 0)
goto out; goto out;
if (i != val) { if (i != val) {
pr_err("%s: Error in GPIO communication\n", dev_err(dev, "%s: Error in GPIO communication\n",
KBUILD_MODNAME); KBUILD_MODNAME);
pr_err(" (got 0x%x, expected 0x%x)\n", i, val); dev_err(dev, " (got 0x%x, expected 0x%x)\n", i, val);
return -EIO; return -EIO;
} }
} }
/* last time we wrote 0, ok */ /* last time we wrote 0, ok */
return 0; return 0;
out: out:
pr_err("%s: Error in SPI communication\n", KBUILD_MODNAME); dev_err(dev, "%s: Error in SPI communication\n", KBUILD_MODNAME);
return -EIO; return -EIO;
} }
......
...@@ -118,8 +118,9 @@ void mi2c_scan(struct fd_dev *fd) ...@@ -118,8 +118,9 @@ void mi2c_scan(struct fd_dev *fd)
for(i = 0; i < 256; i += 2) { for(i = 0; i < 256; i += 2) {
mi2c_start(fd); mi2c_start(fd);
if(!mi2c_put_byte(fd, i)) if(!mi2c_put_byte(fd, i))
pr_info("%s: Found i2c device at 0x%x\n", dev_info(&fd->fmc->dev,
KBUILD_MODNAME, i >> 1); "%s: Found i2c device at 0x%x\n",
KBUILD_MODNAME, i >> 1);
mi2c_stop(fd); mi2c_stop(fd);
} }
} }
......
...@@ -141,8 +141,7 @@ static int ow_read_block(struct fd_dev *fd, int port, uint8_t *block, int len) ...@@ -141,8 +141,7 @@ static int ow_read_block(struct fd_dev *fd, int port, uint8_t *block, int len)
static int ds18x_read_serial(struct fd_dev *fd) static int ds18x_read_serial(struct fd_dev *fd)
{ {
if(!ow_reset(fd, 0)) { if(!ow_reset(fd, 0)) {
pr_err("%s: Failure in resetting one-wire channel\n", dev_err(&fd->fmc->dev, "Failure in resetting one-wire channel\n");
KBUILD_MODNAME);
return -EIO; return -EIO;
} }
...@@ -165,7 +164,7 @@ static int ds18x_access(struct fd_dev *fd) ...@@ -165,7 +164,7 @@ static int ds18x_access(struct fd_dev *fd)
return ow_write_byte(fd, FD_OW_PORT, CMD_ROM_SKIP); return ow_write_byte(fd, FD_OW_PORT, CMD_ROM_SKIP);
} }
out: out:
pr_err("%s: Failure in one-wire communication\n", KBUILD_MODNAME); dev_err(&fd->fmc->dev, "Failure in one-wire communication\n");
return -EIO; return -EIO;
} }
...@@ -185,6 +184,7 @@ int fd_read_temp(struct fd_dev *fd, int verbose) ...@@ -185,6 +184,7 @@ int fd_read_temp(struct fd_dev *fd, int verbose)
int i, temp; int i, temp;
unsigned long j; unsigned long j;
uint8_t data[9]; uint8_t data[9];
struct device *dev = &fd->fmc->dev;
/* If first conversion, ask for it first */ /* If first conversion, ask for it first */
if (fd->next_t == 0) if (fd->next_t == 0)
...@@ -204,7 +204,7 @@ int fd_read_temp(struct fd_dev *fd, int verbose) ...@@ -204,7 +204,7 @@ int fd_read_temp(struct fd_dev *fd, int verbose)
ow_read_block(fd, FD_OW_PORT, data, 9); ow_read_block(fd, FD_OW_PORT, data, 9);
if (verbose > 1) { if (verbose > 1) {
pr_info("%s: Scratchpad: ", __func__); dev_info(dev, "%s: Scratchpad: ", __func__);
for (i = 0; i < 9; i++) for (i = 0; i < 9; i++)
printk("%02x%c", data[i], i == 8 ? '\n' : ':'); printk("%02x%c", data[i], i == 8 ? '\n' : ':');
} }
...@@ -213,7 +213,7 @@ int fd_read_temp(struct fd_dev *fd, int verbose) ...@@ -213,7 +213,7 @@ int fd_read_temp(struct fd_dev *fd, int verbose)
temp = -0x10000 + temp; temp = -0x10000 + temp;
fd->temp = temp; fd->temp = temp;
if (verbose) { if (verbose) {
pr_info("%s: Temperature 0x%x (%i bits: %i.%03i)\n", __func__, dev_info(dev, "%s: Temperature 0x%x (%i bits: %i.%03i)\n", __func__,
temp, 9 + (data[4] >> 5), temp, 9 + (data[4] >> 5),
temp / 16, (temp & 0xf) * 1000 / 16); temp / 16, (temp & 0xf) * 1000 / 16);
} }
...@@ -234,7 +234,7 @@ int fd_onewire_init(struct fd_dev *fd) ...@@ -234,7 +234,7 @@ int fd_onewire_init(struct fd_dev *fd)
return -EIO; return -EIO;
if (fd->verbose) { if (fd->verbose) {
pr_info("%s: Found DS18xx sensor: ", __func__); dev_info(&fd->fmc->dev, "%s: Found DS18xx sensor: ", __func__);
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
printk("%02x%c", fd->ds18_id[i], i == 7 ? '\n' : ':'); printk("%02x%c", fd->ds18_id[i], i == 7 ? '\n' : ':');
} }
......
...@@ -39,6 +39,7 @@ int fd_pll_init(struct fd_dev *fd) ...@@ -39,6 +39,7 @@ int fd_pll_init(struct fd_dev *fd)
int i; int i;
unsigned long j; unsigned long j;
const struct ad9516_reg *r; const struct ad9516_reg *r;
struct device *dev = &fd->fmc->dev;
if (pll_writel(fd, 0x99, 0x000) < 0) if (pll_writel(fd, 0x99, 0x000) < 0)
goto out; goto out;
...@@ -48,16 +49,15 @@ int fd_pll_init(struct fd_dev *fd) ...@@ -48,16 +49,15 @@ int fd_pll_init(struct fd_dev *fd)
if (i < 0) if (i < 0)
goto out; goto out;
if (i != 0xc3) { if (i != 0xc3) {
pr_err("%s: Error in PLL communication\n", KBUILD_MODNAME); dev_err(dev, "Error in PLL communication\n");
pr_err(" (got 0x%x, expected 0xc3)\n", i); dev_err(dev, " (got 0x%x, expected 0xc3)\n", i);
return -EIO; return -EIO;
} }
/* Write the magic config */ /* Write the magic config */
for (i = 0, r = __9516_regs; i < ARRAY_SIZE(__9516_regs); i++, r++) { for (i = 0, r = __9516_regs; i < ARRAY_SIZE(__9516_regs); i++, r++) {
if (pll_writel(fd, r->val, r->reg) < 0) { if (pll_writel(fd, r->val, r->reg) < 0) {
pr_err("%s: Error in configuring PLL (step %i)\n", dev_err(dev, "Error in configuring PLL (step %i)\n", i);
KBUILD_MODNAME, i);
return -EIO; return -EIO;
} }
} }
...@@ -95,7 +95,7 @@ int fd_pll_init(struct fd_dev *fd) ...@@ -95,7 +95,7 @@ int fd_pll_init(struct fd_dev *fd)
return 0; return 0;
out: out:
pr_err("%s: Error in SPI communication\n", KBUILD_MODNAME); dev_err(dev, "Error in SPI communication\n");
return -EIO; return -EIO;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment