Commit d7352716 authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

kernel, lib: reindented code according to kernel style

parent f813f1e7
......@@ -209,7 +209,7 @@ void ft_ts_sub(struct ft_wr_timestamp *a, struct ft_wr_timestamp *b);
int ft_set_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);
int ft_set_host_time (struct fmctdc_dev *ft);
int ft_set_host_time(struct fmctdc_dev *ft);
int ft_enable_wr_mode(struct fmctdc_dev *ft, int enable);
int ft_check_wr_mode(struct fmctdc_dev *ft);
......
......@@ -70,7 +70,7 @@ static int ft_init_channel(struct fmctdc_dev *ft, int channel)
return 0;
}
static void ft_reset_channel (struct fmctdc_dev *ft, int channel)
static void ft_reset_channel(struct fmctdc_dev *ft, int channel)
{
struct ft_channel_state *st = &ft->channels[channel - FT_CH_1];
......@@ -81,7 +81,7 @@ static void ft_reset_channel (struct fmctdc_dev *ft, int channel)
st->cur_seq_id = 0;
st->expected_edge = 1;
clear_bit(FT_FLAG_CH_INPUT_READY, &st->flags);
ft_zio_kill_buffer( ft, channel );
ft_zio_kill_buffer(ft, channel);
}
int ft_enable_termination(struct fmctdc_dev *ft, int channel, int enable)
......@@ -116,7 +116,7 @@ void ft_enable_acquisition(struct fmctdc_dev *ft, int enable)
uint32_t ien, cmd;
int i;
if (ft->acquisition_on == ( enable ? 1: 0 ))
if (ft->acquisition_on == (enable ? 1 : 0))
return;
ien = ft_readl(ft, TDC_REG_INPUT_ENABLE);
......@@ -129,7 +129,7 @@ void ft_enable_acquisition(struct fmctdc_dev *ft, int enable)
cmd = TDC_CTRL_DIS_ACQ;
}
spin_lock (&ft->lock);
spin_lock(&ft->lock);
ft_writel(ft, ien, TDC_REG_INPUT_ENABLE);
ft_writel(ft, TDC_CTRL_CLEAR_DACAPO_FLAG, TDC_REG_CTRL);
......@@ -137,21 +137,21 @@ void ft_enable_acquisition(struct fmctdc_dev *ft, int enable)
ft->acquisition_on = enable;
if(!enable)
{
if (!enable) {
/* 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);
ft_reset_channel(ft, i);
ft->prev_wr_ptr = ft->cur_wr_ptr = 0;
}
spin_unlock (&ft->lock);
spin_unlock(&ft->lock);
if(ft->verbose)
dev_info(&ft->fmc->dev, "acquisition is %s\n", enable ? "on" : "off");
if (ft->verbose)
dev_info(&ft->fmc->dev, "acquisition is %s\n",
enable ? "on" : "off");
}
static int ft_channels_init(struct fmctdc_dev *ft)
......@@ -335,7 +335,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);
......
......@@ -153,8 +153,9 @@ static inline void process_timestamp(struct fmctdc_dev *ft,
(diff.seconds || diff.coarse > 12
|| (diff.coarse == 12 && diff.frac >= 2048))) {
ft_ts_apply_offset(&ts,
ft->calib.
zero_offset[channel - 1]);
ft->
calib.zero_offset[channel -
1]);
if (st->user_offset)
ft_ts_apply_offset(&ts,
......@@ -282,7 +283,7 @@ static void ft_readout_tasklet(unsigned long arg)
}
}
out:
out:
/* ack the irq */
fmc_writel(ft->fmc, TDC_IRQ_TDC_TSTAMP << ft->irq_shift,
ft->ft_irq_base + TDC_REG_IRQ_STATUS);
......
......@@ -92,8 +92,10 @@ int ft_set_tai_time(struct fmctdc_dev *ft, uint64_t seconds, uint32_t coarse)
dev_info(&ft->fmc->dev, "Setting TAI time to %lld:%d\n",
seconds, coarse);
if(coarse != 0)
dev_warn(&ft->fmc->dev, "Warning: ignoring sub-second part (%d) when setting time.\n", coarse);
if (coarse != 0)
dev_warn(&ft->fmc->dev,
"Warning: ignoring sub-second part (%d) when setting time.\n",
coarse);
ft_writel(ft, seconds & 0xffffffff, TDC_REG_START_UTC);
ft_writel(ft, TDC_CTRL_LOAD_UTC, TDC_REG_CTRL);
......@@ -108,7 +110,7 @@ int ft_get_tai_time(struct fmctdc_dev *ft, uint64_t * seconds,
return 0;
}
int ft_set_host_time (struct fmctdc_dev *ft)
int ft_set_host_time(struct fmctdc_dev *ft)
{
struct timespec local_ts;
......
......@@ -73,7 +73,7 @@ static enum ft_devtype __ft_get_type(struct device *dev)
void ft_zio_kill_buffer(struct fmctdc_dev *ft, int channel)
{
zio_trigger_abort_disable( &ft->zdev->cset [ channel - FT_CH_1 ], 0);
zio_trigger_abort_disable(&ft->zdev->cset[channel - FT_CH_1], 0);
}
/* TDC input attributes: only the user offset is special */
......@@ -145,7 +145,9 @@ static int ft_zio_info_get(struct device *dev, struct zio_attribute *zattr,
attr[FT_ATTR_DEV_COARSE].value = coarse;
attr[FT_ATTR_DEV_SECONDS].value = (uint32_t) seconds;
*usr_val = (zattr->id == FT_ATTR_DEV_COARSE ? coarse : (uint32_t) seconds);
*usr_val =
(zattr->id ==
FT_ATTR_DEV_COARSE ? coarse : (uint32_t) seconds);
return 0;
}
case FT_ATTR_DEV_ENABLE_INPUTS:
......@@ -176,7 +178,8 @@ static int ft_zio_conf_channel(struct device *dev, struct zio_attribute *zattr,
case FT_ATTR_TDC_USER_OFFSET:
user_offs = usr_val;
if(user_offs < -FT_USER_OFFSET_RANGE || user_offs > FT_USER_OFFSET_RANGE)
if (user_offs < -FT_USER_OFFSET_RANGE
|| user_offs > FT_USER_OFFSET_RANGE)
return -EINVAL;
spin_lock(&ft->lock);
st->user_offset = usr_val;
......@@ -235,10 +238,9 @@ static int ft_zio_conf_set(struct device *dev, struct zio_attribute *zattr,
if (zattr->id == FT_ATTR_DEV_SECONDS) {
attr[FT_ATTR_DEV_SECONDS].value = usr_val;
return ft_set_tai_time( ft,
return ft_set_tai_time(ft,
attr[FT_ATTR_DEV_SECONDS].value,
attr[FT_ATTR_DEV_COARSE].value
);
attr[FT_ATTR_DEV_COARSE].value);
return -ENOTSUPP;
} else if (zattr->id == FT_ATTR_DEV_ENABLE_INPUTS) {
attr[FT_ATTR_DEV_ENABLE_INPUTS].value = usr_val ? 1 : 0;
......
......@@ -71,8 +71,8 @@ static int ow_reset(struct fmctdc_dev *ft, int port)
data = ((port << CSR_SEL_OFS) & CSR_SEL_MSK)
| CSR_CYC_MSK | CSR_RST_MSK;
ow_writel(ft, data, R_CSR);
while(ow_readl(ft, R_CSR) & CSR_CYC_MSK)
/* FIXME: timeout */;
while (ow_readl(ft, R_CSR) & CSR_CYC_MSK)
/* FIXME: timeout */ ;
reg = ow_readl(ft, R_CSR);
return ~reg & CSR_DAT_MSK;
}
......@@ -81,11 +81,11 @@ static int slot(struct fmctdc_dev *ft, int port, int bit)
{
uint32_t reg, data;
data = ((port<<CSR_SEL_OFS) & CSR_SEL_MSK)
data = ((port << CSR_SEL_OFS) & CSR_SEL_MSK)
| CSR_CYC_MSK | (bit & CSR_DAT_MSK);
ow_writel(ft, data, R_CSR);
while(ow_readl(ft, R_CSR) & CSR_CYC_MSK)
/* FIXME: timeout */;
while (ow_readl(ft, R_CSR) & CSR_CYC_MSK)
/* FIXME: timeout */ ;
reg = ow_readl(ft, R_CSR);
return reg & CSR_DAT_MSK;
}
......@@ -104,7 +104,7 @@ static int ow_read_byte(struct fmctdc_dev *ft, int port)
{
int byte = 0, i;
for(i = 0; i < 8; i++)
for (i = 0; i < 8; i++)
byte |= (read_bit(ft, port) << i);
return byte;
}
......@@ -114,34 +114,37 @@ static int ow_write_byte(struct fmctdc_dev *ft, int port, int byte)
int data = 0;
int i;
for (i = 0; i < 8; i++){
for (i = 0; i < 8; i++) {
data |= write_bit(ft, port, (byte & 0x1)) << i;
byte >>= 1;
}
return 0; /* success */
}
static int ow_write_block(struct fmctdc_dev *ft, int port, uint8_t *block, int len)
static int ow_write_block(struct fmctdc_dev *ft, int port, uint8_t * block,
int len)
{
int i;
for(i = 0; i < len; i++)
for (i = 0; i < len; i++)
ow_write_byte(ft, port, block[i]);
return 0;
}
static int ow_read_block(struct fmctdc_dev *ft, int port, uint8_t *block, int len)
static int ow_read_block(struct fmctdc_dev *ft, int port, uint8_t * block,
int len)
{
int i;
for(i = 0; i < len; i++)
for (i = 0; i < len; i++)
block[i] = ow_read_byte(ft, port);
return 0;
}
static int ds18x_read_serial(struct fmctdc_dev *ft)
{
if(!ow_reset(ft, 0)) {
dev_err(&ft->fmc->dev, "Failure in resetting one-wire channel\n");
if (!ow_reset(ft, 0)) {
dev_err(&ft->fmc->dev,
"Failure in resetting one-wire channel\n");
return -EIO;
}
......@@ -151,7 +154,7 @@ static int ds18x_read_serial(struct fmctdc_dev *ft)
static int ds18x_access(struct fmctdc_dev *ft)
{
if(!ow_reset(ft, 0))
if (!ow_reset(ft, 0))
goto out;
if (0) {
......@@ -175,7 +178,7 @@ static void __temp_command_and_next_t(struct fmctdc_dev *ft, int cfg_reg)
ds18x_access(ft);
ow_write_byte(ft, FT_OW_PORT, CMD_CONVERT_TEMP);
/* The conversion takes some time, so mark when will it be ready */
ms = 94 * ( 1 << (cfg_reg >> 5));
ms = 94 * (1 << (cfg_reg >> 5));
ft->next_t = jiffies + msecs_to_jiffies(ms);
}
......@@ -188,7 +191,7 @@ int ft_read_temp(struct fmctdc_dev *ft, int verbose)
/* If first conversion, ask for it first */
if (ft->next_t == 0)
__temp_command_and_next_t(ft, 0x7f /* we ignore: max time */);
__temp_command_and_next_t(ft, 0x7f /* we ignore: max time */ );
/* Wait for it to be ready: (FIXME: we need a time policy here) */
j = jiffies;
......@@ -209,16 +212,16 @@ int ft_read_temp(struct fmctdc_dev *ft, int verbose)
printk("%02x%c", data[i], i == 8 ? '\n' : ':');
}
temp = ((int)data[1] << 8) | ((int)data[0]);
if(temp & 0x1000)
if (temp & 0x1000)
temp = -0x10000 + temp;
ft->temp = temp;
ft->temp_ready = 1;
if (verbose) {
dev_info(dev, "%s: Temperature 0x%x (%i bits: %i.%03i)\n", __func__,
temp, 9 + (data[4] >> 5),
temp / 16, (temp & 0xf) * 1000 / 16);
dev_info(dev, "%s: Temperature 0x%x (%i bits: %i.%03i)\n",
__func__, temp, 9 + (data[4] >> 5), temp / 16,
(temp & 0xf) * 1000 / 16);
}
__temp_command_and_next_t(ft, data[4]); /* start next conversion */
......@@ -230,10 +233,9 @@ int ft_onewire_init(struct fmctdc_dev *ft)
int i;
ow_writel(ft, ((CLK_DIV_NOR & CDR_NOR_MSK)
| (( CLK_DIV_OVD << CDR_OVD_OFS) & CDR_OVD_MSK)),
R_CDR);
| ((CLK_DIV_OVD << CDR_OVD_OFS) & CDR_OVD_MSK)), R_CDR);
if(ds18x_read_serial(ft) < 0)
if (ds18x_read_serial(ft) < 0)
return -EIO;
if (ft->verbose) {
......
......@@ -39,7 +39,7 @@ static inline int fmctdc_is_verbose(void)
#define __define_board(b, ub) struct __fmctdc_board *b = (void *)(ub)
/* These two from ../tools/fdelay-raw.h, used internally */
static inline int __fmctdc_sysfs_get(char *path, uint32_t *resp)
static inline int __fmctdc_sysfs_get(char *path, uint32_t * resp)
{
FILE *f = fopen(path, "r");
......@@ -56,7 +56,7 @@ static inline int __fmctdc_sysfs_get(char *path, uint32_t *resp)
return 0;
}
static inline int __fmctdc_sysfs_set(char *path, uint32_t *value)
static inline int __fmctdc_sysfs_set(char *path, uint32_t * value)
{
char s[16];
int fd, ret, len;
......@@ -77,7 +77,7 @@ static inline int __fmctdc_sysfs_set(char *path, uint32_t *value)
/* And these two for the board structure */
static inline int fmctdc_sysfs_get(struct __fmctdc_board *b, char *name,
uint32_t *resp)
uint32_t * resp)
{
char pathname[128];
......@@ -86,7 +86,7 @@ static inline int fmctdc_sysfs_get(struct __fmctdc_board *b, char *name,
}
static inline int fmctdc_sysfs_set(struct __fmctdc_board *b, char *name,
uint32_t *value)
uint32_t * value)
{
char pathname[128];
......
......@@ -50,7 +50,7 @@ int fmctdc_init(void)
/* And look in /sys as well */
glob("/sys/bus/zio/devices/ft-*", 0, NULL, &glob_sys);
glob("/sys/bus/zio/devices/zio-ft-*", GLOB_APPEND , NULL, &glob_sys);
glob("/sys/bus/zio/devices/zio-ft-*", GLOB_APPEND, NULL, &glob_sys);
assert(glob_dev.gl_pathc == glob_sys.gl_pathc);
/* Allocate as needed */
......@@ -126,7 +126,7 @@ void fmctdc_exit(void)
free(b->sysbase);
free(b->devbase);
}
if(ft_nboards)
if (ft_nboards)
free(ft_boards);
}
......@@ -224,7 +224,7 @@ int fmctdc_set_termination(struct fmctdc_board *userb, int channel, int on)
uint32_t val;
char attr[32];
if(channel < FMCTDC_CH_1 || channel > FMCTDC_NUM_CHANNELS)
if (channel < FMCTDC_CH_1 || channel > FMCTDC_NUM_CHANNELS)
return -EINVAL;
snprintf(attr, sizeof(attr), "ft-ch%d/termination", channel);
......@@ -240,13 +240,13 @@ int fmctdc_get_termination(struct fmctdc_board *userb, int channel)
char attr[32];
int ret;
if(channel < FMCTDC_CH_1 || channel > FMCTDC_NUM_CHANNELS)
if (channel < FMCTDC_CH_1 || channel > FMCTDC_NUM_CHANNELS)
return -EINVAL;
snprintf(attr, sizeof(attr), "ft-ch%d/termination", channel);
ret = fmctdc_sysfs_get(b, attr, &val);
if(ret)
if (ret)
return ret;
return val;
}
......@@ -258,7 +258,7 @@ int fmctdc_get_acquisition(struct fmctdc_board *userb)
int ret;
ret = fmctdc_sysfs_get(b, "enable_inputs", &val);
if(ret)
if (ret)
return ret;
return val;
}
......@@ -272,12 +272,12 @@ int fmctdc_set_acquisition(struct fmctdc_board *userb, int on)
return fmctdc_sysfs_set(b, "enable_inputs", &val);
}
static int __fmctdc_open_channel(struct __fmctdc_board *b, int channel)
{
char fname[128];
if (b->fdc[channel - 1] <= 0) {
snprintf(fname, sizeof(fname), "%s-%d-0-ctrl", b->devbase, channel - 1);
snprintf(fname, sizeof(fname), "%s-%d-0-ctrl", b->devbase,
channel - 1);
b->fdc[channel - 1] = open(fname, O_RDONLY | O_NONBLOCK);
}
return b->fdc[channel - 1];
......@@ -290,8 +290,8 @@ int fmctdc_fileno_channel(struct fmctdc_board *userb, int channel)
}
/* "read" behaves like the system call and obeys O_NONBLOCK */
int fmctdc_read(struct fmctdc_board *userb, int channel, struct fmctdc_time *t, int n,
int flags)
int fmctdc_read(struct fmctdc_board *userb, int channel, struct fmctdc_time *t,
int n, int flags)
{
__define_board(b, userb);
struct zio_control ctrl;
......@@ -299,7 +299,7 @@ int fmctdc_read(struct fmctdc_board *userb, int channel, struct fmctdc_time *t,
int i, j, fd;
fd_set set;
if(channel < FMCTDC_CH_1 || channel > FMCTDC_NUM_CHANNELS)
if (channel < FMCTDC_CH_1 || channel > FMCTDC_NUM_CHANNELS)
return -EINVAL;
fd = __fmctdc_open_channel(b, channel);
......@@ -334,7 +334,7 @@ int fmctdc_read(struct fmctdc_board *userb, int channel, struct fmctdc_time *t,
/* So, first sample and blocking read. Wait.. */
FD_ZERO(&set);
FD_SET(fd, &set);
if (select(fd+1, &set, NULL, NULL, NULL) < 0)
if (select(fd + 1, &set, NULL, NULL, NULL) < 0)
return -1;
continue;
}
......@@ -342,11 +342,12 @@ int fmctdc_read(struct fmctdc_board *userb, int channel, struct fmctdc_time *t,
}
/* "fread" behaves like stdio: it reads all the samples */
int fmctdc_fread(struct fmctdc_board *userb, int channel, struct fmctdc_time *t, int n)
int fmctdc_fread(struct fmctdc_board *userb, int channel, struct fmctdc_time *t,
int n)
{
int i, loop;
for (i = 0; i < n; ) {
for (i = 0; i < n;) {
loop = fmctdc_read(userb, channel, t + i, n - i, 0);
if (loop < 0)
return -1;
......@@ -366,10 +367,9 @@ int fmctdc_set_time(struct fmctdc_board *userb, struct fmctdc_time *t)
attrs[0] = t->seconds & 0xffffffff;
attrs[1] = t->coarse;
for (i = ARRAY_SIZE(names) - 1; i >= 0; i--)
{
for (i = ARRAY_SIZE(names) - 1; i >= 0; i--) {
ret = fmctdc_sysfs_set(b, names[i], attrs + i);
if(ret < 0)
if (ret < 0)
return ret;
}
return 0;
......@@ -381,10 +381,9 @@ int fmctdc_get_time(struct fmctdc_board *userb, struct fmctdc_time *t)
uint32_t attrs[ARRAY_SIZE(names)];
int i, ret;
for (i = 0; i < ARRAY_SIZE(names); i++)
{
for (i = 0; i < ARRAY_SIZE(names); i++) {
ret = fmctdc_sysfs_get(b, names[i], attrs + i);
if(ret < 0)
if (ret < 0)
return ret;
}
......@@ -416,8 +415,7 @@ extern int fmctdc_check_wr_mode(struct fmctdc_board *userb)
__define_board(b, userb);
ret = __fmctdc_command(b, FT_CMD_WR_QUERY);
switch(ret)
{
switch (ret) {
case 0:
return 1; /* no error: locked to WR */
case -EAGAIN:
......
......@@ -49,13 +49,15 @@ extern int fmctdc_set_host_time(struct fmctdc_board *b);
extern int fmctdc_set_acquisition(struct fmctdc_board *b, int enable);
extern int fmctdc_get_acquisition(struct fmctdc_board *b);
extern int fmctdc_set_termination(struct fmctdc_board *b, int channel, int enable);
extern int fmctdc_set_termination(struct fmctdc_board *b, int channel,
int enable);
extern int fmctdc_get_termination(struct fmctdc_board *b, int channel);
extern int fmctdc_fread(struct fmctdc_board *b, int channel, struct fmctdc_time *t, int n);
extern int fmctdc_fread(struct fmctdc_board *b, int channel,
struct fmctdc_time *t, int n);
extern int fmctdc_fileno_channel(struct fmctdc_board *b, int channel);
extern int fmctdc_read(struct fmctdc_board *b, int channel, struct fmctdc_time *t, int n,
int flags);
extern int fmctdc_read(struct fmctdc_board *b, int channel,
struct fmctdc_time *t, int n, int flags);
extern float fmctdc_read_temperature(struct fmctdc_board *b);
......
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