Commit 21ec1bf7 authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: comedi_test: use unsigned int for waveform timing

Use `unsigned int` instead of `unsigned long` to hold the period of the
fake waveform generator and the current time within each waveform.  The
waveform period will be no more than `INT_MAX` and the current time
within the waveform (prior to the modulo operation to bring it actually
within the waveform period) will be no more than `INT_MAX + UINT_MAX /
1000`.
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Reviewed-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8fa8a260
...@@ -64,8 +64,8 @@ struct waveform_private { ...@@ -64,8 +64,8 @@ struct waveform_private {
struct timer_list timer; struct timer_list timer;
ktime_t last; /* time last timer interrupt occurred */ ktime_t last; /* time last timer interrupt occurred */
unsigned int uvolt_amplitude; /* waveform amplitude in microvolts */ unsigned int uvolt_amplitude; /* waveform amplitude in microvolts */
unsigned long usec_period; /* waveform period in microseconds */ unsigned int usec_period; /* waveform period in microseconds */
unsigned long usec_current; /* current time (mod waveform period) */ unsigned int usec_current; /* current time (mod waveform period) */
unsigned long usec_remainder; /* usec since last scan */ unsigned long usec_remainder; /* usec since last scan */
unsigned long state_bits; unsigned long state_bits;
unsigned int scan_period; /* scan period in usec */ unsigned int scan_period; /* scan period in usec */
...@@ -83,7 +83,7 @@ static const struct comedi_lrange waveform_ai_ranges = { ...@@ -83,7 +83,7 @@ static const struct comedi_lrange waveform_ai_ranges = {
static unsigned short fake_sawtooth(struct comedi_device *dev, static unsigned short fake_sawtooth(struct comedi_device *dev,
unsigned int range_index, unsigned int range_index,
unsigned long current_time) unsigned int current_time)
{ {
struct waveform_private *devpriv = dev->private; struct waveform_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev; struct comedi_subdevice *s = dev->read_subdev;
...@@ -115,7 +115,7 @@ static unsigned short fake_sawtooth(struct comedi_device *dev, ...@@ -115,7 +115,7 @@ static unsigned short fake_sawtooth(struct comedi_device *dev,
static unsigned short fake_squarewave(struct comedi_device *dev, static unsigned short fake_squarewave(struct comedi_device *dev,
unsigned int range_index, unsigned int range_index,
unsigned long current_time) unsigned int current_time)
{ {
struct waveform_private *devpriv = dev->private; struct waveform_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev; struct comedi_subdevice *s = dev->read_subdev;
...@@ -145,7 +145,7 @@ static unsigned short fake_squarewave(struct comedi_device *dev, ...@@ -145,7 +145,7 @@ static unsigned short fake_squarewave(struct comedi_device *dev,
static unsigned short fake_flatline(struct comedi_device *dev, static unsigned short fake_flatline(struct comedi_device *dev,
unsigned int range_index, unsigned int range_index,
unsigned long current_time) unsigned int current_time)
{ {
return dev->read_subdev->maxdata / 2; return dev->read_subdev->maxdata / 2;
} }
...@@ -153,7 +153,7 @@ static unsigned short fake_flatline(struct comedi_device *dev, ...@@ -153,7 +153,7 @@ static unsigned short fake_flatline(struct comedi_device *dev,
/* generates a different waveform depending on what channel is read */ /* generates a different waveform depending on what channel is read */
static unsigned short fake_waveform(struct comedi_device *dev, static unsigned short fake_waveform(struct comedi_device *dev,
unsigned int channel, unsigned int range, unsigned int channel, unsigned int range,
unsigned long current_time) unsigned int current_time)
{ {
enum { enum {
SAWTOOTH_CHAN, SAWTOOTH_CHAN,
...@@ -468,7 +468,7 @@ static int waveform_attach(struct comedi_device *dev, ...@@ -468,7 +468,7 @@ static int waveform_attach(struct comedi_device *dev,
(unsigned long)dev); (unsigned long)dev);
dev_info(dev->class_dev, dev_info(dev->class_dev,
"%s: %i microvolt, %li microsecond waveform attached\n", "%s: %u microvolt, %u microsecond waveform attached\n",
dev->board_name, dev->board_name,
devpriv->uvolt_amplitude, devpriv->usec_period); devpriv->uvolt_amplitude, devpriv->usec_period);
......
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