Commit 465b8229 authored by Tuomas Tynkkynen's avatar Tuomas Tynkkynen Committed by Mauro Carvalho Chehab

[media] staging: lirc: Fix sparse warnings

Fix sparse warnings by adding __user and __iomem annotations where
necessary and removing certain unnecessary casts. While at it,
also use u32 in place of __u32.
Signed-off-by: default avatarTuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 0cacb46a
...@@ -64,7 +64,7 @@ static bool debug; ...@@ -64,7 +64,7 @@ static bool debug;
static int atir_minor; static int atir_minor;
static phys_addr_t pci_addr_phys; static phys_addr_t pci_addr_phys;
static unsigned char *pci_addr_lin; static unsigned char __iomem *pci_addr_lin;
static struct lirc_driver atir_driver; static struct lirc_driver atir_driver;
...@@ -382,7 +382,7 @@ static unsigned char do_get_bits(void) ...@@ -382,7 +382,7 @@ static unsigned char do_get_bits(void)
static unsigned int read_index(unsigned char index) static unsigned int read_index(unsigned char index)
{ {
unsigned char *addr; unsigned char __iomem *addr;
unsigned int value; unsigned int value;
/* addr = pci_addr_lin + DATA_PCI_OFF + ((index & 0xFF) << 2); */ /* addr = pci_addr_lin + DATA_PCI_OFF + ((index & 0xFF) << 2); */
addr = pci_addr_lin + ((index & 0xFF) << 2); addr = pci_addr_lin + ((index & 0xFF) << 2);
...@@ -392,7 +392,7 @@ static unsigned int read_index(unsigned char index) ...@@ -392,7 +392,7 @@ static unsigned int read_index(unsigned char index)
static void write_index(unsigned char index, unsigned int reg_val) static void write_index(unsigned char index, unsigned int reg_val)
{ {
unsigned char *addr; unsigned char __iomem *addr;
addr = pci_addr_lin + ((index & 0xFF) << 2); addr = pci_addr_lin + ((index & 0xFF) << 2);
writel(reg_val, addr); writel(reg_val, addr);
} }
......
...@@ -324,7 +324,8 @@ static loff_t lirc_lseek(struct file *filep, loff_t offset, int orig) ...@@ -324,7 +324,8 @@ static loff_t lirc_lseek(struct file *filep, loff_t offset, int orig)
return -ESPIPE; return -ESPIPE;
} }
static ssize_t lirc_read(struct file *filep, char *buf, size_t n, loff_t *ppos) static ssize_t lirc_read(struct file *filep, char __user *buf, size_t n,
loff_t *ppos)
{ {
int result = 0; int result = 0;
int count = 0; int count = 0;
...@@ -362,7 +363,7 @@ static ssize_t lirc_read(struct file *filep, char *buf, size_t n, loff_t *ppos) ...@@ -362,7 +363,7 @@ static ssize_t lirc_read(struct file *filep, char *buf, size_t n, loff_t *ppos)
return count ? count : result; return count ? count : result;
} }
static ssize_t lirc_write(struct file *filep, const char *buf, size_t n, static ssize_t lirc_write(struct file *filep, const char __user *buf, size_t n,
loff_t *ppos) loff_t *ppos)
{ {
int count; int count;
...@@ -463,43 +464,44 @@ static unsigned int lirc_poll(struct file *file, poll_table *wait) ...@@ -463,43 +464,44 @@ static unsigned int lirc_poll(struct file *file, poll_table *wait)
static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{ {
int result; int result;
__u32 features = LIRC_CAN_SET_TRANSMITTER_MASK | u32 __user *uptr = (u32 __user *)arg;
u32 features = LIRC_CAN_SET_TRANSMITTER_MASK |
LIRC_CAN_SEND_PULSE | LIRC_CAN_REC_MODE2; LIRC_CAN_SEND_PULSE | LIRC_CAN_REC_MODE2;
__u32 mode; u32 mode;
__u32 value; u32 value;
switch (cmd) { switch (cmd) {
case LIRC_GET_FEATURES: case LIRC_GET_FEATURES:
result = put_user(features, (__u32 *) arg); result = put_user(features, uptr);
if (result) if (result)
return result; return result;
break; break;
case LIRC_GET_SEND_MODE: case LIRC_GET_SEND_MODE:
result = put_user(LIRC_MODE_PULSE, (__u32 *) arg); result = put_user(LIRC_MODE_PULSE, uptr);
if (result) if (result)
return result; return result;
break; break;
case LIRC_GET_REC_MODE: case LIRC_GET_REC_MODE:
result = put_user(LIRC_MODE_MODE2, (__u32 *) arg); result = put_user(LIRC_MODE_MODE2, uptr);
if (result) if (result)
return result; return result;
break; break;
case LIRC_SET_SEND_MODE: case LIRC_SET_SEND_MODE:
result = get_user(mode, (__u32 *) arg); result = get_user(mode, uptr);
if (result) if (result)
return result; return result;
if (mode != LIRC_MODE_PULSE) if (mode != LIRC_MODE_PULSE)
return -EINVAL; return -EINVAL;
break; break;
case LIRC_SET_REC_MODE: case LIRC_SET_REC_MODE:
result = get_user(mode, (__u32 *) arg); result = get_user(mode, uptr);
if (result) if (result)
return result; return result;
if (mode != LIRC_MODE_MODE2) if (mode != LIRC_MODE_MODE2)
return -ENOSYS; return -ENOSYS;
break; break;
case LIRC_SET_TRANSMITTER_MASK: case LIRC_SET_TRANSMITTER_MASK:
result = get_user(value, (__u32 *) arg); result = get_user(value, uptr);
if (result) if (result)
return result; return result;
if ((value & LIRC_PARALLEL_TRANSMITTER_MASK) != value) if ((value & LIRC_PARALLEL_TRANSMITTER_MASK) != value)
......
...@@ -1011,7 +1011,8 @@ static ssize_t lirc_write(struct file *file, const char __user *buf, ...@@ -1011,7 +1011,8 @@ static ssize_t lirc_write(struct file *file, const char __user *buf,
static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{ {
int result; int result;
__u32 value; u32 __user *uptr = (u32 __user *)arg;
u32 value;
switch (cmd) { switch (cmd) {
case LIRC_GET_SEND_MODE: case LIRC_GET_SEND_MODE:
...@@ -1020,7 +1021,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) ...@@ -1020,7 +1021,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
result = put_user(LIRC_SEND2MODE result = put_user(LIRC_SEND2MODE
(hardware[type].features&LIRC_CAN_SEND_MASK), (hardware[type].features&LIRC_CAN_SEND_MASK),
(__u32 *) arg); uptr);
if (result) if (result)
return result; return result;
break; break;
...@@ -1029,7 +1030,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) ...@@ -1029,7 +1030,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
if (!(hardware[type].features&LIRC_CAN_SEND_MASK)) if (!(hardware[type].features&LIRC_CAN_SEND_MASK))
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
result = get_user(value, (__u32 *) arg); result = get_user(value, uptr);
if (result) if (result)
return result; return result;
/* only LIRC_MODE_PULSE supported */ /* only LIRC_MODE_PULSE supported */
...@@ -1046,7 +1047,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) ...@@ -1046,7 +1047,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
if (!(hardware[type].features&LIRC_CAN_SET_SEND_DUTY_CYCLE)) if (!(hardware[type].features&LIRC_CAN_SET_SEND_DUTY_CYCLE))
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
result = get_user(value, (__u32 *) arg); result = get_user(value, uptr);
if (result) if (result)
return result; return result;
if (value <= 0 || value > 100) if (value <= 0 || value > 100)
...@@ -1059,7 +1060,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) ...@@ -1059,7 +1060,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
if (!(hardware[type].features&LIRC_CAN_SET_SEND_CARRIER)) if (!(hardware[type].features&LIRC_CAN_SET_SEND_CARRIER))
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
result = get_user(value, (__u32 *) arg); result = get_user(value, uptr);
if (result) if (result)
return result; return result;
if (value > 500000 || value < 20000) if (value > 500000 || value < 20000)
......
...@@ -187,9 +187,9 @@ static bool debug; ...@@ -187,9 +187,9 @@ static bool debug;
/* Communication with user-space */ /* Communication with user-space */
static unsigned int lirc_poll(struct file *file, poll_table *wait); static unsigned int lirc_poll(struct file *file, poll_table *wait);
static ssize_t lirc_read(struct file *file, char *buf, size_t count, static ssize_t lirc_read(struct file *file, char __user *buf, size_t count,
loff_t *ppos); loff_t *ppos);
static ssize_t lirc_write(struct file *file, const char *buf, size_t n, static ssize_t lirc_write(struct file *file, const char __user *buf, size_t n,
loff_t *pos); loff_t *pos);
static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg); static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
static void add_read_queue(int flag, unsigned long val); static void add_read_queue(int flag, unsigned long val);
...@@ -252,7 +252,7 @@ static unsigned int lirc_poll(struct file *file, poll_table *wait) ...@@ -252,7 +252,7 @@ static unsigned int lirc_poll(struct file *file, poll_table *wait)
return 0; return 0;
} }
static ssize_t lirc_read(struct file *file, char *buf, size_t count, static ssize_t lirc_read(struct file *file, char __user *buf, size_t count,
loff_t *ppos) loff_t *ppos)
{ {
int n = 0; int n = 0;
...@@ -266,8 +266,8 @@ static ssize_t lirc_read(struct file *file, char *buf, size_t count, ...@@ -266,8 +266,8 @@ static ssize_t lirc_read(struct file *file, char *buf, size_t count,
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
while (n < count) { while (n < count) {
if (rx_head != rx_tail) { if (rx_head != rx_tail) {
if (copy_to_user((void *) buf + n, if (copy_to_user(buf + n,
(void *) (rx_buf + rx_head), rx_buf + rx_head,
sizeof(int))) { sizeof(int))) {
retval = -EFAULT; retval = -EFAULT;
break; break;
...@@ -291,7 +291,7 @@ static ssize_t lirc_read(struct file *file, char *buf, size_t count, ...@@ -291,7 +291,7 @@ static ssize_t lirc_read(struct file *file, char *buf, size_t count,
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
return n ? n : retval; return n ? n : retval;
} }
static ssize_t lirc_write(struct file *file, const char *buf, size_t n, static ssize_t lirc_write(struct file *file, const char __user *buf, size_t n,
loff_t *pos) loff_t *pos)
{ {
unsigned long flags; unsigned long flags;
...@@ -338,8 +338,9 @@ static ssize_t lirc_write(struct file *file, const char *buf, size_t n, ...@@ -338,8 +338,9 @@ static ssize_t lirc_write(struct file *file, const char *buf, size_t n,
static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{ {
u32 __user *uptr = (u32 __user *)arg;
int retval = 0; int retval = 0;
__u32 value = 0; u32 value = 0;
#ifdef LIRC_ON_SA1100 #ifdef LIRC_ON_SA1100
if (cmd == LIRC_GET_FEATURES) if (cmd == LIRC_GET_FEATURES)
...@@ -364,16 +365,16 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) ...@@ -364,16 +365,16 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
case LIRC_GET_FEATURES: case LIRC_GET_FEATURES:
case LIRC_GET_SEND_MODE: case LIRC_GET_SEND_MODE:
case LIRC_GET_REC_MODE: case LIRC_GET_REC_MODE:
retval = put_user(value, (__u32 *) arg); retval = put_user(value, uptr);
break; break;
case LIRC_SET_SEND_MODE: case LIRC_SET_SEND_MODE:
case LIRC_SET_REC_MODE: case LIRC_SET_REC_MODE:
retval = get_user(value, (__u32 *) arg); retval = get_user(value, uptr);
break; break;
#ifdef LIRC_ON_SA1100 #ifdef LIRC_ON_SA1100
case LIRC_SET_SEND_DUTY_CYCLE: case LIRC_SET_SEND_DUTY_CYCLE:
retval = get_user(value, (__u32 *) arg); retval = get_user(value, uptr);
if (retval) if (retval)
return retval; return retval;
if (value <= 0 || value > 100) if (value <= 0 || value > 100)
...@@ -388,7 +389,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg) ...@@ -388,7 +389,7 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
space_width -= LIRC_ON_SA1100_TRANSMITTER_LATENCY; space_width -= LIRC_ON_SA1100_TRANSMITTER_LATENCY;
break; break;
case LIRC_SET_SEND_CARRIER: case LIRC_SET_SEND_CARRIER:
retval = get_user(value, (__u32 *) arg); retval = get_user(value, uptr);
if (retval) if (retval)
return retval; return retval;
if (value > 500000 || value < 20000) if (value > 500000 || value < 20000)
......
...@@ -892,7 +892,8 @@ static int fw_load(struct IR_tx *tx) ...@@ -892,7 +892,8 @@ static int fw_load(struct IR_tx *tx)
} }
/* copied from lirc_dev */ /* copied from lirc_dev */
static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos) static ssize_t read(struct file *filep, char __user *outbuf, size_t n,
loff_t *ppos)
{ {
struct IR *ir = filep->private_data; struct IR *ir = filep->private_data;
struct IR_rx *rx; struct IR_rx *rx;
...@@ -954,7 +955,7 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos) ...@@ -954,7 +955,7 @@ static ssize_t read(struct file *filep, char *outbuf, size_t n, loff_t *ppos)
} }
m = lirc_buffer_read(rbuf, buf); m = lirc_buffer_read(rbuf, buf);
if (m == rbuf->chunk_size) { if (m == rbuf->chunk_size) {
ret = copy_to_user((void *)outbuf+written, buf, ret = copy_to_user(outbuf + written, buf,
rbuf->chunk_size); rbuf->chunk_size);
written += rbuf->chunk_size; written += rbuf->chunk_size;
} else { } else {
...@@ -1094,7 +1095,7 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key) ...@@ -1094,7 +1095,7 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key)
* sent to the device. We have a spin lock as per i2c documentation to prevent * sent to the device. We have a spin lock as per i2c documentation to prevent
* multiple concurrent sends which would probably cause the device to explode. * multiple concurrent sends which would probably cause the device to explode.
*/ */
static ssize_t write(struct file *filep, const char *buf, size_t n, static ssize_t write(struct file *filep, const char __user *buf, size_t n,
loff_t *ppos) loff_t *ppos)
{ {
struct IR *ir = filep->private_data; struct IR *ir = filep->private_data;
...@@ -1237,6 +1238,7 @@ static unsigned int poll(struct file *filep, poll_table *wait) ...@@ -1237,6 +1238,7 @@ static unsigned int poll(struct file *filep, poll_table *wait)
static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg) static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{ {
struct IR *ir = filep->private_data; struct IR *ir = filep->private_data;
unsigned long __user *uptr = (unsigned long __user *)arg;
int result; int result;
unsigned long mode, features; unsigned long mode, features;
...@@ -1244,11 +1246,10 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg) ...@@ -1244,11 +1246,10 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
switch (cmd) { switch (cmd) {
case LIRC_GET_LENGTH: case LIRC_GET_LENGTH:
result = put_user((unsigned long)13, result = put_user(13UL, uptr);
(unsigned long *)arg);
break; break;
case LIRC_GET_FEATURES: case LIRC_GET_FEATURES:
result = put_user(features, (unsigned long *) arg); result = put_user(features, uptr);
break; break;
case LIRC_GET_REC_MODE: case LIRC_GET_REC_MODE:
if (!(features&LIRC_CAN_REC_MASK)) if (!(features&LIRC_CAN_REC_MASK))
...@@ -1256,13 +1257,13 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg) ...@@ -1256,13 +1257,13 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
result = put_user(LIRC_REC2MODE result = put_user(LIRC_REC2MODE
(features&LIRC_CAN_REC_MASK), (features&LIRC_CAN_REC_MASK),
(unsigned long *)arg); uptr);
break; break;
case LIRC_SET_REC_MODE: case LIRC_SET_REC_MODE:
if (!(features&LIRC_CAN_REC_MASK)) if (!(features&LIRC_CAN_REC_MASK))
return -ENOSYS; return -ENOSYS;
result = get_user(mode, (unsigned long *)arg); result = get_user(mode, uptr);
if (!result && !(LIRC_MODE2REC(mode) & features)) if (!result && !(LIRC_MODE2REC(mode) & features))
result = -EINVAL; result = -EINVAL;
break; break;
...@@ -1270,13 +1271,13 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg) ...@@ -1270,13 +1271,13 @@ static long ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
if (!(features&LIRC_CAN_SEND_MASK)) if (!(features&LIRC_CAN_SEND_MASK))
return -ENOSYS; return -ENOSYS;
result = put_user(LIRC_MODE_PULSE, (unsigned long *) arg); result = put_user(LIRC_MODE_PULSE, uptr);
break; break;
case LIRC_SET_SEND_MODE: case LIRC_SET_SEND_MODE:
if (!(features&LIRC_CAN_SEND_MASK)) if (!(features&LIRC_CAN_SEND_MASK))
return -ENOSYS; return -ENOSYS;
result = get_user(mode, (unsigned long *) arg); result = get_user(mode, uptr);
if (!result && mode != LIRC_MODE_PULSE) if (!result && mode != LIRC_MODE_PULSE)
return -EINVAL; return -EINVAL;
break; break;
......
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