Commit 4e79a24c authored by Alessandro Rubini's avatar Alessandro Rubini

kernel: major message review

Messaging with cset->dev or fa->fmc->hwdev resulted in poor context:
"cset0" in the former case and the carrier name+id in the latter case.
This commit uses fa->fmc->dev, which has more context (more than hwdev
if the carrier is multi-mezzanine).

This also downgrades some dev_err to dev_info (all errors related with
invalid values written to attributes).
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 8d09350c
......@@ -44,7 +44,7 @@ int fa_probe(struct fmc_device *fmc)
/* Validate the new FMC device */
i = fmc->op->validate(fmc, &fa_dev_drv);
if (i < 0) {
dev_info(fmc->hwdev, "not using \"%s\" according to "
dev_info(&fmc->dev, "not using \"%s\" according to "
"modparam\n", KBUILD_MODNAME);
return -ENODEV;
}
......@@ -67,10 +67,10 @@ int fa_probe(struct fmc_device *fmc)
/* init all subsystems */
for (i = 0, m = mods; i < ARRAY_SIZE(mods); i++, m++) {
dev_dbg(fmc->hwdev, "Calling init for \"%s\"\n", m->name);
dev_dbg(&fmc->dev, "Calling init for \"%s\"\n", m->name);
err = m->init(fa);
if (err) {
dev_err(fmc->hwdev, "error initializing %s\n", m->name);
dev_err(&fmc->dev, "error initializing %s\n", m->name);
goto out;
}
......
......@@ -129,6 +129,7 @@ int zfad_map_dma(struct zio_cset *cset, struct zfad_block *zfad_block,
unsigned int n_blocks)
{
struct fa_dev *fa = cset->zdev->priv_d;
struct device *dev = &fa->fmc->dev;
struct scatterlist *sg;
struct fa_dma_item *items;
uint32_t dev_mem_off = 0;
......@@ -138,17 +139,17 @@ int zfad_map_dma(struct zio_cset *cset, struct zfad_block *zfad_block,
pages = zfat_calculate_nents(zfad_block, n_blocks);
if (!pages) {
dev_err(&cset->head.dev, "No pages to transfer %i\n",
dev_info(dev, "No pages to transfer %i\n",
n_blocks);
return -EINVAL;
}
dev_dbg(&cset->head.dev, "using %d pages to transfer %i blocks\n",
dev_dbg(dev, "using %d pages to transfer %i blocks\n",
pages, n_blocks);
/* Create sglists for the transfers */
err = sg_alloc_table(&fa->sgt, pages, GFP_ATOMIC);
if (err) {
dev_err(&cset->head.dev, "cannot allocate sg table\n");
dev_err(dev, "cannot allocate sg table (%i pages)\n", pages);
goto out;
}
......@@ -171,7 +172,7 @@ int zfad_map_dma(struct zio_cset *cset, struct zfad_block *zfad_block,
sglen = dma_map_sg(fa->fmc->hwdev, fa->sgt.sgl,
fa->sgt.nents, DMA_FROM_DEVICE);
if (!sglen) {
dev_err(fa->fmc->hwdev, "cannot map dma memory\n");
dev_err(dev, "cannot map dma memory\n");
goto out_map;
}
......@@ -187,14 +188,13 @@ int zfad_map_dma(struct zio_cset *cset, struct zfad_block *zfad_block,
i_blk++; /* index the next block */
if (unlikely(i_blk > n_blocks)) {
dev_err(&fa->zdev->head.dev,
"DMA map out of block\n");
dev_err(dev, "DMA map out of block\n");
BUG();
}
}
dev_dbg(&cset->head.dev, "configure DMA item %d"
pr_debug("configure DMA item %d "
"(addr: 0x%llx len: %d)(dev off: 0x%x)\n",
i, (long long)sg_dma_address(sg),
sg_dma_len(sg), dev_mem_off);
......
......@@ -169,10 +169,11 @@ static inline int zfad_get_chx_index(unsigned long addr,
*/
int zfad_fsm_command(struct fa_dev *fa, uint32_t command)
{
struct device *dev = &fa->fmc->dev;
uint32_t val;
if (command != ZFA_START && command != ZFA_STOP) {
dev_err(fa->fmc->hwdev, "Invalid command\n");
dev_info(dev, "Invalid command %i\n", command);
return -EINVAL;
}
......@@ -202,15 +203,15 @@ int zfad_fsm_command(struct fa_dev *fa, uint32_t command)
/* Verify that SerDes PLL is lockes */
zfa_hardware_read(fa, ZFA_STA_SERDES_PLL, &val);
if (!val) {
dev_err(fa->fmc->hwdev,
"Cannot start acquisition: SerDes PLL not locked\n");
dev_info(dev, "Cannot start acquisition: "
"SerDes PLL not locked\n");
return -EBUSY;
}
/* Verify that SerDes is synched */
zfa_hardware_read(fa, ZFA_STA_SERDES_SYNCED, &val);
if (!val) {
dev_err(fa->fmc->hwdev,
"Cannot start acquisition: SerDes not synchronized\n");
dev_info(dev, "Cannot start acquisition: "
"SerDes not synchronized\n");
return -EBUSY;
}
......@@ -224,15 +225,15 @@ int zfad_fsm_command(struct fa_dev *fa, uint32_t command)
* from zfat_arm_trigger() or zfad_input_cset()
*/
if (!(fa->zdev->cset->ti->flags & ZIO_TI_ARMED)) {
dev_err(fa->fmc->hwdev,
"Trigger not armed, cannot start acquisition\n");
return -EPERM;
dev_info(dev, "Cannot start acquisition: "
"Trigger refuses to arm\n");
return -EIO;
}
dev_dbg(fa->fmc->hwdev, "FSM START Command, Enable interrupts\n");
dev_dbg(dev, "FSM START Command, Enable interrupts\n");
zfa_hardware_write(fa, ZFA_IRQ_MASK, ZFAT_ALL);
} else {
dev_dbg(fa->fmc->hwdev, "FSM STOP Command, Disable interrupts\n");
dev_dbg(dev, "FSM STOP Command, Disable interrupts\n");
zfa_hardware_write(fa, ZFA_IRQ_MASK, ZFAT_NONE);
}
......@@ -431,10 +432,8 @@ static int zfad_conf_set(struct device *dev, struct zio_attribute *zattr,
zfad_reset_offset(fa);
return 0;
case ZFAT_SR_DECI:
if (usr_val == 0) {
dev_err(dev, "max-sample-rate minimum value is 1\n");
return -EINVAL;
}
if (usr_val == 0)
usr_val++;
break;
/* FIXME temporary until TLV control */
case ZFA_CH1_CTL_TERM:
......@@ -442,11 +441,8 @@ static int zfad_conf_set(struct device *dev, struct zio_attribute *zattr,
case ZFA_CH3_CTL_TERM:
case ZFA_CH4_CTL_TERM:
case ZFA_CHx_CTL_TERM:
if (usr_val != 0 && usr_val != 1) {
dev_err(dev, "50 Ohm termination can be activated (1) "
"or deactivated (0)\n");
return -EINVAL;
}
if (usr_val > 1)
usr_val = 1;
break;
/* FIXME temporary until TLV control */
......@@ -595,13 +591,13 @@ static int zfad_input_cset(struct zio_cset *cset)
{
struct fa_dev *fa = cset->zdev->priv_d;
dev_dbg(fa->fmc->hwdev, "Ready to acquire\n");
dev_dbg(&fa->fmc->dev, "Ready to acquire\n");
/* ZIO should configure only the interleaved channel */
if (!cset->interleave)
return -EINVAL;
/* nsamples can't be 0 */
if (!cset->interleave->current_ctrl->nsamples) {
dev_err(&cset->head.dev, "no post/pre-sample configured\n");
dev_info(&fa->fmc->dev, "pre + post = 0: can't acquire\n");
return -EINVAL;
}
......@@ -654,7 +650,7 @@ static void zfat_get_irq_status(struct fa_dev *fa,
/* Get current interrupts status */
zfa_hardware_read(fa, ZFA_IRQ_SRC, irq_status);
zfa_hardware_read(fa, ZFA_IRQ_MULTI, irq_multi);
dev_dbg(fa->fmc->hwdev, "irq status = 0x%x multi = 0x%x\n",
dev_dbg(&fa->fmc->dev, "irq status = 0x%x multi = 0x%x\n",
*irq_status, *irq_multi);
/* Clear current interrupts status */
......@@ -683,7 +679,7 @@ static void zfad_dma_start(struct zio_cset *cset)
/* Start DMA transefer */
zfa_hardware_write(fa, ZFA_DMA_CTL_START, 1);
dev_dbg(fa->fmc->hwdev, "Start DMA transfer\n");
dev_dbg(&fa->fmc->dev, "Start DMA transfer\n");
}
/**
......@@ -709,7 +705,7 @@ static void zfad_dma_done(struct zio_cset *cset)
* it can store blocks into the buffer
*/
zio_trigger_data_done(cset);
dev_dbg(fa->fmc->hwdev, "%i blocks transfered\n", fa->n_shots);
dev_dbg(&fa->fmc->dev, "%i blocks transfered\n", fa->n_shots);
/*
* we can safely re-enable triggers.
......@@ -725,13 +721,13 @@ static void zfad_dma_done(struct zio_cset *cset)
zfa_hardware_write(fa, ZFAT_CFG_SW_EN,
ti->zattr_set.ext_zattr[5].value);
} else {
dev_dbg(&cset->head.dev, "Software acquisition over");
dev_dbg(&fa->fmc->dev, "Software acquisition over");
zfa_hardware_write(fa, ZFAT_CFG_SW_EN, 1);
}
/* Automatic start next acquisition */
if (enable_auto_start) {
dev_dbg(fa->fmc->hwdev, "Automatic start\n");
dev_dbg(&fa->fmc->dev, "Automatic start\n");
zfad_fsm_command(fa, ZFA_START);
}
}
......@@ -752,7 +748,7 @@ static void zfad_dma_error(struct zio_cset *cset)
zfad_unmap_dma(cset, zfad_block);
zfa_hardware_read(fa, ZFA_DMA_STA, &val);
dev_err(fa->fmc->hwdev,
dev_err(&fa->fmc->dev,
"DMA error (status 0x%x). All acquisition lost\n", val);
zfad_fsm_command(fa, ZFA_STOP);
fa->n_dma_err++;
......@@ -794,7 +790,7 @@ static void zfat_irq_trg_fire(struct zio_cset *cset)
struct zio_control *ctrl;
uint32_t dev_mem_off, trg_pos, pre_samp;
dev_dbg(fa->fmc->hwdev, "Trigger fire %i/%i\n",
dev_dbg(&fa->fmc->dev, "Trigger fire %i/%i\n",
fa->n_fires + 1, fa->n_shots);
if (fa->n_fires >= fa->n_shots) {
WARN(1, "Invalid Fire, STOP acquisition");
......@@ -813,7 +809,7 @@ static void zfat_irq_trg_fire(struct zio_cset *cset)
zfa_hardware_read(fa, ZFAT_POS, &trg_pos);
/* translate from sample count to memory offset */
dev_mem_off = (trg_pos - pre_samp) * cset->ssize * nchan;
dev_dbg(fa->fmc->hwdev,
dev_dbg(&fa->fmc->dev,
"Trigger @ 0x%08x, pre %i, offset 0x%08x\n",
trg_pos, pre_samp, dev_mem_off);
......@@ -848,9 +844,9 @@ static void zfat_irq_acq_end(struct zio_cset *cset)
uint32_t val = 0;
int try = 5;
dev_dbg(fa->fmc->hwdev, "Acquisition done\n");
dev_dbg(&fa->fmc->dev, "Acquisition done\n");
if (fa->n_fires != fa->n_shots) {
dev_err(fa->fmc->hwdev,
dev_err(&fa->fmc->dev,
"Expected %i trigger fires, but %i occurs\n",
fa->n_shots, fa->n_fires);
}
......@@ -866,7 +862,7 @@ static void zfat_irq_acq_end(struct zio_cset *cset)
if (val != ZFA_STATE_IDLE) {
/* we can't DMA if the state machine is not idle */
dev_warn(fa->fmc->hwdev,
dev_warn(&fa->fmc->dev,
"Can't start DMA on the last acquisition, "
"State Machine is not IDLE (status:%d)\n", val);
zfad_fsm_command(fa, ZFA_STOP);
......@@ -912,7 +908,7 @@ static irqreturn_t zfad_irq(int irq, void *ptr)
return IRQ_NONE;
irq_handler:
dev_dbg(fa->fmc->hwdev, "Handle ADC interrupts\n");
dev_dbg(&fa->fmc->dev, "Handle ADC interrupts\n");
if (unlikely((status & (ZFAT_DMA_DONE | ZFAT_DMA_ERR)) &&
(status & (ZFAT_TRG_FIRE | ZFAT_ACQ_END)))) {
WARN(1, "Cannot handle trigger interrupt and DMA interrupt at "
......@@ -1004,7 +1000,7 @@ static int zfad_zio_probe(struct zio_device *zdev)
err = fa->fmc->op->irq_request(fa->fmc, zfad_irq, "fmc-adc-100m14b",
IRQF_SHARED);
if (err)
dev_err(fa->fmc->hwdev, "can't request irq %i (err %i)\n",
dev_err(&fa->fmc->dev, "can't request irq %i (error %i)\n",
fa->fmc->irq, err);
/* Force stop FSM to prevent early trigger fire */
......@@ -1155,15 +1151,15 @@ void fa_zio_unregister(void)
int fa_zio_init(struct fa_dev *fa)
{
struct device *hwdev = fa->fmc->hwdev;
struct device *msgdev = &fa->fmc->dev;
uint32_t val;
int err;
/* Check if hardware supports 64-bit DMA */
if(dma_set_mask(hwdev, DMA_BIT_MASK(64))) {
dev_err(hwdev, "64-bit DMA addressing not available, try 32\n");
/* Check if hardware supports 32-bit DMA */
if(dma_set_mask(hwdev, DMA_BIT_MASK(32))) {
dev_err(hwdev, "32-bit DMA addressing not available\n");
dev_err(msgdev, "32-bit DMA addressing not available\n");
return -EINVAL;
}
}
......@@ -1172,26 +1168,26 @@ int fa_zio_init(struct fa_dev *fa)
/* Verify that the FMC is plugged (0 is plugged) */
zfa_hardware_read(fa, ZFA_CAR_FMC_PRES, &val);
if (val) {
dev_err(hwdev, "No FCM ADC plugged\n");
dev_err(msgdev, "No FCM ADC plugged\n");
return -ENODEV;
}
/* Verify that system PLL is locked (1 is calibrated) */
zfa_hardware_read(fa, ZFA_CAR_SYS_PLL, &val);
if (!val) {
dev_err(hwdev, "System PLL not locked\n");
dev_err(msgdev, "System PLL not locked\n");
return -ENODEV;
}
/* Verify that DDR3 calibration is done (1 is calibrated) */
zfa_hardware_read(fa, ZFA_CAR_DDR_CAL, &val);
if (!val) {
dev_err(hwdev, "DDR3 Calibration not done\n");
dev_err(msgdev, "DDR3 Calibration not done\n");
return -ENODEV;
}
/* Allocate the hardware zio_device for registration */
fa->hwzdev = zio_allocate_device();
if (IS_ERR(fa->hwzdev)) {
dev_err(hwdev, "Cannot allocate ZIO device\n");
dev_err(msgdev, "Cannot allocate ZIO device\n");
err = PTR_ERR(fa->hwzdev);
goto out_allocate;
}
......@@ -1204,7 +1200,7 @@ int fa_zio_init(struct fa_dev *fa)
err = zio_register_device(fa->hwzdev, "adc-100m14b",
fa->fmc->device_id);
if (err) {
dev_err(hwdev, "Cannot register ZIO device fmc-adc-100m14b\n");
dev_err(msgdev, "Cannot register ZIO device fmc-adc-100m14b\n");
goto out_dev;
}
return 0;
......
......@@ -109,12 +109,12 @@ static int zfat_conf_set(struct device *zdev, struct zio_attribute *zattr,
case ZFAT_SW:
/* Fire if software trigger is enabled (index 5) */
if (!ti->zattr_set.ext_zattr[5].value) {
dev_err(dev, "sw trigger must be enable");
dev_info(dev, "sw trigger is not enabled\n");
return -EPERM;
}
/* Fire if nsamples!=0 */
if (!ti->nsamples) {
dev_err(dev, "there aren't samples to acquire");
dev_info(dev, "pre + post = 0: cannot acquire\n");
return -EINVAL;
}
/*
......@@ -157,7 +157,8 @@ static struct zio_ti *zfat_create(struct zio_trigger_type *trig,
struct zfat_instance *zfat;
if (!fa) {
dev_err(&cset->head.dev, "no spec device defined\n");
/* This only happens if we have a bug in the init sequence */
dev_err(&cset->head.dev, "No FMC device associated\n");
return ERR_PTR(-ENODEV);
}
......@@ -225,7 +226,7 @@ static void zfat_data_done(struct zio_cset *cset)
struct fa_dev *fa = cset->zdev->priv_d;
unsigned int i;
dev_dbg(&cset->head.dev, "Data done\n");
dev_dbg(&fa->fmc->dev, "Data done\n");
/* Nothing to store */
if (!zfad_block)
......@@ -234,11 +235,11 @@ static void zfat_data_done(struct zio_cset *cset)
/* Store blocks */
for(i = 0; i < fa->n_shots; ++i)
if (likely(i < fa->n_fires)) {/* Store filled blocks */
dev_dbg(&cset->head.dev, "Store Block %i/%i\n",
dev_dbg(&fa->fmc->dev, "Store Block %i/%i\n",
i + 1, fa->n_shots);
bi->b_op->store_block(bi, zfad_block[i].block);
} else { /* Free un-filled blocks */
dev_dbg(&cset->head.dev, "Free un-acquired block %d/%d "
dev_dbg(&fa->fmc->dev, "Free un-acquired block %d/%d "
"(received %d shots)\n",
i + 1, fa->n_shots, fa->n_fires);
bi->b_op->free_block(bi, zfad_block[i].block);
......@@ -264,22 +265,23 @@ static int zfat_arm_trigger(struct zio_ti *ti)
struct zio_channel *interleave = ti->cset->interleave;
struct zio_buffer_type *zbuf = ti->cset->zbuf;
struct fa_dev *fa = ti->cset->zdev->priv_d;
struct device *msgdev = &fa->fmc->dev;
struct zio_block *block;
struct zfad_block *zfad_block;
unsigned int size;
uint32_t dev_mem_off;
int i, err = 0;
dev_dbg(&ti->head.dev, "Arming trigger\n");
dev_dbg(msgdev, "Arming trigger\n");
/* Update the current control: sequence, nsamples and tstamp */
interleave->current_ctrl->nsamples = ti->nsamples;
/* Allocate the necessary blocks for multi-shot acquisition */
fa->n_shots = ti->zattr_set.std_zattr[ZIO_ATTR_TRIG_N_SHOTS].value;
dev_dbg(&ti->head.dev, "programmed shot %i\n", fa->n_shots);
dev_dbg(msgdev, "programmed shot %i\n", fa->n_shots);
if (!fa->n_shots) {
dev_err(&ti->head.dev, "Cannot arm. No programmed shots\n");
dev_info(msgdev, "Cannot arm. No programmed shots\n");
return -EINVAL;
}
......@@ -301,11 +303,11 @@ static int zfat_arm_trigger(struct zio_ti *ti)
dev_mem_off = 0;
/* Allocate ZIO blocks */
for (i = 0; i < fa->n_shots; ++i) {
dev_dbg(&ti->cset->head.dev, "Allocating block %d ...\n", i);
dev_dbg(msgdev, "Allocating block %d ...\n", i);
block = zbuf->b_op->alloc_block(interleave->bi, size,
GFP_KERNEL);
if (!block) {
dev_err(&ti->cset->head.dev,
dev_err(msgdev,
"arm trigger fail, cannot allocate block\n");
err = -ENOMEM;
goto out_allocate;
......@@ -317,7 +319,7 @@ static int zfat_arm_trigger(struct zio_ti *ti)
zfad_block[i].block = block;
zfad_block[i].dev_mem_off = dev_mem_off;
dev_mem_off += size;
dev_dbg(&ti->cset->head.dev, "next dev_mem_off 0x%x (+%d)",
dev_dbg(msgdev, "next dev_mem_off 0x%x (+%d)",
dev_mem_off, size);
}
......@@ -350,7 +352,7 @@ static void zfat_abort(struct zio_ti *ti)
struct zfad_block *zfad_block = cset->interleave->priv_d;
unsigned int i;
dev_dbg(&ti->head.dev, "Aborting trigger");
dev_dbg(&fa->fmc->dev, "Aborting trigger");
/* Free all blocks */
for(i = 0; i < fa->n_shots; ++i)
bi->b_op->free_block(bi, zfad_block[i].block);
......@@ -364,8 +366,6 @@ static int zfat_push(struct zio_ti *ti, struct zio_channel *chan,
{
dev_err(&ti->head.dev, "trigger \"%s\" does not support output",
ti->head.name);
BUG();
return -EIO;
}
......
......@@ -355,7 +355,7 @@ static inline int zfa_hardware_write(struct fa_dev *fa,
uint32_t cur, val;
if ((usr_val & (~zfad_regs[index].mask))) {
dev_err(fa->fmc->hwdev, "value 0x%x must fit mask 0x%x\n",
dev_info(&fa->fmc->dev, "value 0x%x must fit mask 0x%x\n",
usr_val, zfad_regs[index].mask);
return -EINVAL;
}
......
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