Commit bfb46984 authored by Federico Vaga's avatar Federico Vaga

style: checkpatch fixes

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent aceac379
......@@ -12,7 +12,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <asm/io.h>
#include <linux/io.h>
#include "fmc-tdc.h"
......@@ -50,6 +50,7 @@ static struct {
static inline int acam_is_pll_locked(struct fmctdc_dev *ft)
{
uint32_t status;
ft_writel(ft, TDC_CTRL_READ_ACAM_CFG, TDC_REG_CTRL);
udelay(100);
......
......@@ -50,7 +50,7 @@ static int ft_read_calibration_eeprom(struct fmc_device *fmc, void *buf,
return ret;
ret = sdbfs_fread(&fs, 0, buf, length);
sdbfs_dev_destroy(&fs);
return ret;
}
......@@ -68,25 +68,26 @@ int ft_handle_eeprom_calibration(struct fmctdc_dev *ft)
memcpy(calib, &default_calibration, sizeof(struct ft_calibration));
i = ft_read_calibration_eeprom(ft->fmc, raw_calib, sizeof(raw_calib));
if(i < 0)
{
dev_err(d, "Failed to read the calibration EEPROM. Using default calibration parameters.\n");
for (i =0; i < FT_NUM_CHANNELS; i++)
if (i < 0) {
dev_err(d,
"Failed to read calibration EEPROM. Using default.\n");
for (i = 0; i < FT_NUM_CHANNELS; i++)
calib->zero_offset[i] = 0;
calib->vcxo_default_tune = 32000;
} else {
calib->zero_offset[0] = 0;
for (i = FT_CH_1 + 1; i < FT_NUM_CHANNELS; i++)
calib->zero_offset[i] =
le32_to_cpu(raw_calib[i - 1]) / 100 - calib->zero_offset[0];
le32_to_cpu(raw_calib[i - 1]) / 100
- calib->zero_offset[0];
calib->vcxo_default_tune = le32_to_cpu(raw_calib[4]);
}
calib->calibration_temp = le32_to_cpu(raw_calib[5]);
calib->wr_offset = le32_to_cpu(raw_calib[6]) / 100;
for (i = 0; i < ARRAY_SIZE(calib->zero_offset); i++)
dev_info(d, "calib: zero_offset[%i] = %i ps\n", i,
calib->zero_offset[i]);
......
......@@ -30,7 +30,7 @@
#include "hw/tdc_regs.h"
/* Module parameters */
static int ft_verbose = 0;
static int ft_verbose;
module_param_named(verbose, ft_verbose, int, 0444);
MODULE_PARM_DESC(verbose, "Print a lot of debugging messages.");
......@@ -138,8 +138,9 @@ void ft_enable_acquisition(struct fmctdc_dev *ft, int enable)
ft->acquisition_on = enable;
if (!enable) {
/* when disabling acquisition, clear the FIFOs, reset width validation state
machine and sequence IDs */
/* when disabling acquisition, clear the FIFOs,
reset width validation state machine and
sequence IDs */
for (i = FT_CH_1; i <= FT_NUM_CHANNELS; i++)
ft_reset_channel(ft, i);
......@@ -157,6 +158,7 @@ void ft_enable_acquisition(struct fmctdc_dev *ft, int enable)
static int ft_channels_init(struct fmctdc_dev *ft)
{
int i, ret;
for (i = FT_CH_1; i <= FT_NUM_CHANNELS; i++) {
ret = ft_init_channel(ft, i);
if (ret < 0)
......@@ -170,14 +172,16 @@ static int ft_channels_init(struct fmctdc_dev *ft)
static void ft_channels_exit(struct fmctdc_dev *ft)
{
int i;
for (i = FT_CH_1; i <= FT_NUM_CHANNELS; i++)
kfree(ft->channels[i - 1].fifo.t);
}
struct ft_modlist {
char *name;
int (*init) (struct fmctdc_dev *);
void (*exit) (struct fmctdc_dev *);
int (*init)(struct fmctdc_dev *);
void (*exit)(struct fmctdc_dev *);
};
static struct ft_modlist init_subsystems[] = {
......@@ -205,8 +209,8 @@ int ft_probe(struct fmc_device *fmc)
index = fmc->op->validate(fmc, &ft_drv);
if (index < 0) {
dev_info(dev, "not using \"%s\" according to "
"modparam\n", KBUILD_MODNAME);
dev_info(dev, "not using \"%s\" according to modparam\n",
KBUILD_MODNAME);
return -ENODEV;
}
......@@ -229,10 +233,11 @@ int ft_probe(struct fmc_device *fmc)
else
fwname = ft->carrier_specific->gateware_name;
/* reprogram the card, but do not try to read the SDB.
/* reprogram the card, but do not try to read the SDB.
Everything (including the SDB descriptor/bus logic) is clocked
from the FMC oscillator which needs to be bootstrapped by the gateware with
no possibility for the driver to check if something went wrong... */
from the FMC oscillator which needs to be bootstrapped by
the gateware with no possibility for the driver to check if
something went wrong... */
ret = fmc_reprogram(fmc, &ft_drv, fwname, -1);
if (ret < 0) {
......@@ -244,7 +249,7 @@ int ft_probe(struct fmc_device *fmc)
return ret; /* other error: pass over */
}
dev_info(dev, "Gateware successfully loaded \n");
dev_info(dev, "Gateware successfully loaded\n");
ret = ft->carrier_specific->reset_core(ft);
if (ret < 0)
......@@ -318,7 +323,7 @@ int ft_probe(struct fmc_device *fmc)
ft->initialized = 1;
return 0;
err:
err:
while (--m, --i >= 0)
if (m->exit)
m->exit(ft);
......
......@@ -30,15 +30,18 @@
static void ft_readout_tasklet(unsigned long arg);
static void copy_timestamps(struct fmctdc_dev *ft, int base_addr, int size, void *dst)
static void copy_timestamps(struct fmctdc_dev *ft, int base_addr,
int size, void *dst)
{
int i;
uint32_t addr;
uint32_t *dptr;
BUG_ON(size & 3 || base_addr & 3); /* no unaligned reads, please. */
/* no unaligned reads, please. */
BUG_ON(size & 3 || base_addr & 3);
/* FIXME: use SDB to determine buffer base address (after fixing the HDL) */
/* FIXME: use SDB to determine buffer base address
(after fixing the HDL) */
addr = ft->ft_buffer_base + base_addr;
for (i = 0, dptr = (uint32_t *) dst; i < size / 4; i++, dptr++)
......@@ -116,9 +119,9 @@ static inline void enqueue_timestamp(struct fmctdc_dev *ft, int channel,
fifo->head = (fifo->head + 1) % fifo->size;
if (fifo->count < fifo->size)
fifo->count++;
else {
else
fifo->tail = (fifo->tail + 1) % fifo->size;
}
spin_unlock_irqrestore(&ft->lock, flags);
}
......@@ -137,16 +140,18 @@ static inline void process_timestamp(struct fmctdc_dev *ft,
st = &ft->channels[channel - 1];
/* first, convert the timestamp from the HDL units (81 ps bins)
to the WR format (where fractional part is 8 ns rescaled to 4096 units) */
to the WR format (where fractional part is 8 ns rescaled to
4096 units) */
ts.channel = channel;
ts.seconds = hwts->utc;
frac = hwts->bins * 81 * 64 / 125; /* 64/125 = 4096/8000: reduce fraction to avoid 64-bit division */
/* 64/125 = 4096/8000: reduce fraction to avoid 64-bit division */
frac = hwts->bins * 81 * 64 / 125;
ts.coarse = hwts->coarse + frac / 4096;
ts.frac = frac % 4096;
/* the addition above may result with the coarse counter goint out of range: */
/* the addition above may result with the coarse counter going
out of range: */
if (unlikely(ts.coarse >= 125000000)) {
ts.coarse -= 125000000;
ts.seconds++;
......@@ -155,21 +160,26 @@ static inline void process_timestamp(struct fmctdc_dev *ft,
/* A trivial state machine to remove glitches, react on rising edge only
and drop pulses that are narrower than 100 ns.
We are waiting for a falling edge, but a rising one occurs - ignore it.
We are waiting for a falling edge,
but a rising one occurs - ignore it.
*/
if (unlikely(edge != st->expected_edge))
st->expected_edge = 1; /* wait unconditionally for next rising edge */
else {
if (unlikely(edge != st->expected_edge)) {
/* wait unconditionally for next rising edge */
st->expected_edge = 1;
} else {
if (st->expected_edge == 0) { /* got a falling edge after a rising one */
if (st->expected_edge == 0) {
/* got a falling edge after a rising one */
struct ft_wr_timestamp diff = ts;
ft_ts_sub(&diff, &st->prev_ts);
/* Check timestamp width. Must be at least 100 ns (coarse = 12, frac = 2048) */
/* Check timestamp width. Must be at least 100 ns
(coarse = 12, frac = 2048) */
if (likely
(diff.seconds || diff.coarse > 12
|| (diff.coarse == 12 && diff.frac >= 2048))) {
ts = st->prev_ts;
ts = st->prev_ts;
ft_ts_apply_offset(&ts,
ft->calib.
zero_offset[channel - 1]);
......@@ -180,7 +190,8 @@ static inline void process_timestamp(struct fmctdc_dev *ft,
ft_ts_apply_offset(&ts,
st->user_offset);
/* Got a dacapo flag? make a gap in the sequence ID to indicate
/* Got a dacapo flag? make a gap in
the sequence ID to indicate
an unknown loss of timestamps */
ts.seq_id = st->cur_seq_id++;
......@@ -210,7 +221,8 @@ static irqreturn_t ft_irq_handler(int irq, void *dev_id)
if (likely(irq_stat & (TDC_IRQ_TDC_TSTAMP | TDC_IRQ_TDC_TIME))) {
/* clear the IRQ */
fmc_writel(ft->fmc, irq_stat, ft->ft_irq_base + TDC_REG_EIC_ISR);
fmc_writel(ft->fmc, irq_stat,
ft->ft_irq_base + TDC_REG_EIC_ISR);
tasklet_schedule(&ft->readout_tasklet);
return IRQ_HANDLED;
......@@ -271,14 +283,17 @@ static void ft_readout_tasklet(unsigned long arg)
/* Start reading from the oldest event */
if (count == FT_BUFFER_EVENTS)
rd_ptr = (ft->cur_wr_ptr >> 4) & 0x000ff; /* The oldest is curr_wr_ptr */
/* The oldest is curr_wr_ptr */
rd_ptr = (ft->cur_wr_ptr >> 4) & 0x000ff;
else
rd_ptr = (ft->prev_wr_ptr >> 4) & 0x000ff; /* The oldest is prev_wr_ptr */
/* The oldest is prev_wr_ptr */
rd_ptr = (ft->prev_wr_ptr >> 4) & 0x000ff;
for (; count > 0; count--) {
struct ft_hw_timestamp hwts;
copy_timestamps( ft, rd_ptr * sizeof(struct ft_hw_timestamp),
sizeof(struct ft_hw_timestamp), &hwts );
copy_timestamps(ft, rd_ptr * sizeof(struct ft_hw_timestamp),
sizeof(struct ft_hw_timestamp), &hwts);
process_timestamp(ft, &hwts, dacapo);
rd_ptr = (rd_ptr + 1) % FT_BUFFER_EVENTS;
}
......@@ -291,7 +306,8 @@ static void ft_readout_tasklet(unsigned long arg)
/* FIXME: race condition */
if (test_bit(FT_FLAG_CH_INPUT_READY, &st->flags)) {
struct zio_cset *cset = &zdev->cset[i - 1];
/* there is an active block, try reading an accumulated sample */
/* there is an active block, try reading an
accumulated sample */
if (ft_read_sw_fifo(ft, i, cset->chan) == 0) {
clear_bit(FT_FLAG_CH_INPUT_READY, &st->flags);
zio_trigger_data_done(cset);
......@@ -299,7 +315,7 @@ static void ft_readout_tasklet(unsigned long arg)
}
}
out:
out:
/* ack the irq */
fmc_writel(ft->fmc, TDC_IRQ_TDC_TSTAMP,
ft->ft_irq_base + TDC_REG_EIC_ISR);
......@@ -322,7 +338,8 @@ int ft_irq_init(struct fmctdc_dev *ft)
ft->ft_irq_base + TDC_REG_EIC_IER);
/* pass the core's base addr as the VIC IRQ vector. */
/* fixme: vector table points to the bridge instead of the core's base address */
/* fixme: vector table points to the bridge instead of
the core's base address */
ft->fmc->irq = ft->ft_irq_base;
ret = ft->fmc->op->irq_request(ft->fmc, ft_irq_handler, "fmc-tdc", 0);
......
......@@ -28,9 +28,10 @@ static int ft_spec_reset(struct fmctdc_dev *ft)
/* set local bus clock to 160 MHz. The FPGA can't handle more. */
gennum_writel(spec, 0xE001F04C, 0x808);
msleep(3000); /* it takes a while for the PLL to bootstrap.... or not!
We have no possibility to check, as the PLL status register is driven
by the clock from this PLL :( */
/* it takes a while for the PLL to bootstrap.... or not!
We have no possibility to check, as the PLL status register is driven
by the clock from this PLL :( */
msleep(3000);
return 0;
}
......
......@@ -24,9 +24,10 @@ static int ft_svec_reset(struct fmctdc_dev *ft)
{
unsigned long tmo;
/* FIXME: An UGLY hack: ft_svec_reset() executed on slot 0 (first mezzanine to
be initialized) resets BOTH cards. The reason is that we need both mezzanines PLLs
running to read the entire SDB tree (parts of the system interconnect are clocked from
/* FIXME: An UGLY hack: ft_svec_reset() executed on slot 0
(first mezzanine to be initialized) resets BOTH cards. The reason is
that we need both mezzanines PLLs running to read the entire
SDB tree (parts of the system interconnect are clocked from
FMC clock lines. */
if (ft->fmc->slot_id != 0)
......@@ -40,9 +41,9 @@ static int ft_svec_reset(struct fmctdc_dev *ft)
tmo = jiffies + 2 * HZ;
while (time_before(jiffies, tmo)) {
uint32_t stat;
stat =
fmc_readl(ft->fmc,
TDC_SVEC_CARRIER_BASE + TDC_REG_CARRIER_CTL0);
stat = fmc_readl(ft->fmc,
TDC_SVEC_CARRIER_BASE + TDC_REG_CARRIER_CTL0);
if ((stat & TDC_CARRIER_CTL0_PLL_STAT_FMC0) &&
(stat & TDC_CARRIER_CTL0_PLL_STAT_FMC1))
......@@ -62,10 +63,12 @@ static int ft_svec_copy_timestamps(struct fmctdc_dev *ft, int base_addr,
uint32_t addr;
uint32_t *dptr;
if (unlikely(size & 3 || base_addr & 3)) /* no unaligned reads, please. */
/* no unaligned reads, please. */
if (unlikely(size & 3 || base_addr & 3))
return -EIO;
/* FIXME: use SDB to determine buffer base address (after fixing the HDL) */
/* FIXME: use SDB to determine buffer base address
(after fixing the HDL) */
addr = ft->ft_buffer_base + base_addr;
for (i = 0, dptr = (uint32_t *) dst; i < size / 4; i++, dptr++)
......
......@@ -12,7 +12,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <asm/io.h>
#include <linux/io.h>
#include "fmc-tdc.h"
......@@ -102,8 +102,8 @@ int ft_set_tai_time(struct fmctdc_dev *ft, uint64_t seconds, uint32_t coarse)
return 0;
}
int ft_get_tai_time(struct fmctdc_dev *ft, uint64_t * seconds,
uint32_t * coarse)
int ft_get_tai_time(struct fmctdc_dev *ft, uint64_t *seconds,
uint32_t *coarse)
{
*seconds = ft_readl(ft, TDC_REG_CURRENT_UTC);
*coarse = 0;
......@@ -124,7 +124,7 @@ int ft_set_host_time(struct fmctdc_dev *ft)
return 0;
}
void ft_set_vcxo_tune (struct fmctdc_dev *ft, int value)
void ft_set_vcxo_tune(struct fmctdc_dev *ft, int value)
{
ft_writel(ft, value, TDC_REG_DAC_TUNE);
ft_writel(ft, TDC_CTRL_CONFIG_DAC, TDC_REG_CTRL);
......@@ -143,13 +143,13 @@ int ft_wr_mode(struct fmctdc_dev *ft, int on)
} else {
ft_writel(ft, 0, TDC_REG_WR_CTRL);
ft->wr_mode = 0;
ft_set_vcxo_tune (ft, ft->calib.vcxo_default_tune & 0xffff);
ft_set_vcxo_tune(ft, ft->calib.vcxo_default_tune & 0xffff);
}
spin_unlock_irqrestore(&ft->lock, flags);
wr_stat = ft_readl(ft, TDC_REG_WR_STAT);
if( ! (wr_stat & TDC_WR_STAT_LINK))
if (!(wr_stat & TDC_WR_STAT_LINK))
return -ENOLINK;
return 0;
}
......@@ -157,11 +157,12 @@ int ft_wr_mode(struct fmctdc_dev *ft, int on)
int ft_wr_query(struct fmctdc_dev *ft)
{
uint32_t wr_stat;
wr_stat = ft_readl(ft, TDC_REG_WR_STAT);
if (!ft->wr_mode)
return -ENODEV;
if (! (wr_stat & TDC_WR_STAT_LINK))
if (!(wr_stat & TDC_WR_STAT_LINK))
return -ENOLINK;
if (wr_stat & TDC_WR_STAT_AUX_LOCKED)
return 0;
......
......@@ -28,7 +28,7 @@
#include "fmc-tdc.h"
#define _RW_ (S_IRUGO | S_IWUGO) /* I want 80-col lines so this lazy thing */
#define _RW_ (S_IRUGO | S_IWUGO) /* I want 80-col lines so this lazy thing */
/* The sample size. Mandatory, device-wide */
ZIO_ATTR_DEFINE_STD(ZIO_DEV, ft_zattr_dev_std) = {
......@@ -78,7 +78,7 @@ void ft_zio_kill_buffer(struct fmctdc_dev *ft, int channel)
/* TDC input attributes: only the user offset is special */
static int ft_zio_info_channel(struct device *dev, struct zio_attribute *zattr,
uint32_t * usr_val)
uint32_t *usr_val)
{
struct zio_cset *cset;
struct fmctdc_dev *ft;
......@@ -107,7 +107,7 @@ static int ft_zio_info_channel(struct device *dev, struct zio_attribute *zattr,
/* Overall and device-wide attributes: only get_time is special */
static int ft_zio_info_get(struct device *dev, struct zio_attribute *zattr,
uint32_t * usr_val)
uint32_t *usr_val)
{
struct zio_device *zdev;
struct fmctdc_dev *ft;
......@@ -209,9 +209,8 @@ static int ft_zio_input(struct zio_cset *cset)
st = &ft->channels[cset->index];
/* Ready for input. If there's already something, return it now */
if (ft_read_sw_fifo(ft, cset->index + 1, cset->chan) == 0) {
if (ft_read_sw_fifo(ft, cset->index + 1, cset->chan) == 0)
return 0; /* don't call data_done, let the caller do it */
}
/* Mark the active block is valid, and return EAGAIN */
......@@ -293,7 +292,7 @@ static const struct zio_sysfs_operations ft_zio_sysfs_ops = {
#define DECLARE_CHANNEL(ch_name) \
{\
ZIO_SET_OBJ_NAME( ch_name ),\
ZIO_SET_OBJ_NAME(ch_name),\
.raw_io = ft_zio_input,\
.n_chan = 1,\
.ssize = 4, /* FIXME: 0? */\
......
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