Commit 0a6fd02c authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: use unsigned samples for comedi_buf_put()/get()

Sample values in comedi are generally represented as unsigned values.
`comedi_buf_put()` and `comedi_buf_get()` use a `short` to hold the
16-bit data value being transferred to or from the comedi buffer.
Change them to use `unsigned short` for consistency.
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3ba0938c
...@@ -344,7 +344,7 @@ unsigned int comedi_buf_read_free(struct comedi_async *async, ...@@ -344,7 +344,7 @@ unsigned int comedi_buf_read_free(struct comedi_async *async,
} }
EXPORT_SYMBOL_GPL(comedi_buf_read_free); EXPORT_SYMBOL_GPL(comedi_buf_read_free);
int comedi_buf_put(struct comedi_async *async, short x) int comedi_buf_put(struct comedi_async *async, unsigned short x)
{ {
unsigned int n = __comedi_buf_write_alloc(async, sizeof(short), 1); unsigned int n = __comedi_buf_write_alloc(async, sizeof(short), 1);
...@@ -352,20 +352,20 @@ int comedi_buf_put(struct comedi_async *async, short x) ...@@ -352,20 +352,20 @@ int comedi_buf_put(struct comedi_async *async, short x)
async->events |= COMEDI_CB_ERROR; async->events |= COMEDI_CB_ERROR;
return 0; return 0;
} }
*(short *)(async->prealloc_buf + async->buf_write_ptr) = x; *(unsigned short *)(async->prealloc_buf + async->buf_write_ptr) = x;
comedi_buf_write_free(async, sizeof(short)); comedi_buf_write_free(async, sizeof(short));
return 1; return 1;
} }
EXPORT_SYMBOL_GPL(comedi_buf_put); EXPORT_SYMBOL_GPL(comedi_buf_put);
int comedi_buf_get(struct comedi_async *async, short *x) int comedi_buf_get(struct comedi_async *async, unsigned short *x)
{ {
unsigned int n = comedi_buf_read_n_available(async); unsigned int n = comedi_buf_read_n_available(async);
if (n < sizeof(short)) if (n < sizeof(short))
return 0; return 0;
comedi_buf_read_alloc(async, sizeof(short)); comedi_buf_read_alloc(async, sizeof(short));
*x = *(short *)(async->prealloc_buf + async->buf_read_ptr); *x = *(unsigned short *)(async->prealloc_buf + async->buf_read_ptr);
comedi_buf_read_free(async, sizeof(short)); comedi_buf_read_free(async, sizeof(short));
return 1; return 1;
} }
......
...@@ -346,8 +346,8 @@ unsigned int comedi_buf_read_n_available(struct comedi_async *); ...@@ -346,8 +346,8 @@ unsigned int comedi_buf_read_n_available(struct comedi_async *);
unsigned int comedi_buf_read_alloc(struct comedi_async *, unsigned int); unsigned int comedi_buf_read_alloc(struct comedi_async *, unsigned int);
unsigned int comedi_buf_read_free(struct comedi_async *, unsigned int); unsigned int comedi_buf_read_free(struct comedi_async *, unsigned int);
int comedi_buf_put(struct comedi_async *, short); int comedi_buf_put(struct comedi_async *, unsigned short);
int comedi_buf_get(struct comedi_async *, short *); int comedi_buf_get(struct comedi_async *, unsigned short *);
void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset, void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
const void *source, unsigned int num_bytes); const void *source, unsigned int num_bytes);
......
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