Commit 9fc7db7e authored by Tomasz Wlostowski's avatar Tomasz Wlostowski Committed by Juan David González Cobas

temperature readout: fixed concurrent reads between calibration timer and ZIO call

Signed-off-by: Juan David González Cobas's avatarJuan David Gonzalez Cobas <dcobas@cern.ch>
parent 35d47d05
......@@ -20,7 +20,7 @@
#include "hw/fd_main_regs.h"
#include "hw/acam_gpx.h"
int fd_calib_period_s = 30;
int fd_calib_period_s = 5;
module_param_named(calib_s, fd_calib_period_s, int, 0444);
/*
......@@ -385,6 +385,8 @@ int fd_acam_init(struct fd_dev *fd)
fd_writel(fd, ACAM_GMODE_ASOR, FD_REG_ASOR);
fd_writel(fd, ACAM_GMODE_ATMCR, FD_REG_ATMCR);
fd->temp_ready = 0;
/* Prepare the timely recalibration */
setup_timer(&fd->temp_timer, fd_update_calibration, (unsigned long)fd);
if (fd_calib_period_s)
......
......@@ -210,10 +210,13 @@ static int fd_zio_info_get(struct device *dev, struct zio_attribute *zattr,
fd = zdev->priv_d;
if (zattr->id == FD_ATTR_DEV_TEMP) {
attr[FD_ATTR_DEV_TEMP].value = fd_read_temp(fd, 0);
return 0;
if (fd->temp_ready)
{
attr[FD_ATTR_DEV_TEMP].value = fd->temp;
return 0;
} else
return -EAGAIN;
}
/* following is whole-dev */
if (zattr->id != FD_ATTR_DEV_UTC_H)
return 0;
......
......@@ -197,6 +197,7 @@ struct fd_dev {
uint8_t ds18_id[8];
unsigned long next_t;
int temp; /* temperature: scaled by 4 bits */
int temp_ready; /* temperature: measurement ready flag */
int verbose;
uint32_t tdc_attrs[FD_ATTR_TDC__LAST - FD_ATTR_DEV__LAST];
uint16_t mcp_iodir, mcp_olat;
......
......@@ -211,7 +211,10 @@ int fd_read_temp(struct fd_dev *fd, int verbose)
temp = ((int)data[1] << 8) | ((int)data[0]);
if(temp & 0x1000)
temp = -0x10000 + temp;
fd->temp = temp;
fd->temp_ready = 1;
if (verbose) {
dev_info(dev, "%s: Temperature 0x%x (%i bits: %i.%03i)\n", __func__,
temp, 9 + (data[4] >> 5),
......
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