Commit 1c1620be authored by Federico Vaga's avatar Federico Vaga

drv: bugfix offset computation overflow

this patch indroduces an overflow bug:

bb859ef7 drv bugfix according to ZIO offset is uV

hwval is 32bit, but since user values are now bigger (uV) the
multiplication can overflow. We use 64bit to avoid it.
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
Signed-off-by: Milosz Malczak's avatarMilosz Malczak <milosz.malczak@cern.ch>
parent 9e2809f2
......@@ -113,9 +113,10 @@ static int zfad_offset_to_dac(struct zio_channel *chan,
enum fa100m14b4c_input_range range)
{
struct fa_dev *fa = get_zfadc(&chan->cset->zdev->head.dev);
int offset, gain, hwval;
int offset, gain;
int64_t hwval;
hwval = uval * 0x8000 / 5000000;
hwval = uval * 0x8000LL / 5000000;
if (hwval == 0x8000)
hwval = 0x7fff; /* -32768 .. 32767 */
......
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