[PATCH] staging: lirc: Fix sparse warnings

2014-05-08 Thread Tuomas Tynkkynen
Fix sparse warnings by adding __user and __iomem annotations where
necessary and removing certain unnecessary casts.

Signed-off-by: Tuomas Tynkkynen tuomas.tynkky...@iki.fi
---
Compile tested only.
 drivers/staging/media/lirc/lirc_bt829.c|6 +++---
 drivers/staging/media/lirc/lirc_parallel.c |   17 +
 drivers/staging/media/lirc/lirc_serial.c   |8 
 drivers/staging/media/lirc/lirc_sir.c  |   18 +-
 drivers/staging/media/lirc/lirc_zilog.c|   20 +++-
 5 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_bt829.c 
b/drivers/staging/media/lirc/lirc_bt829.c
index 30edc74..fe01054 100644
--- a/drivers/staging/media/lirc/lirc_bt829.c
+++ b/drivers/staging/media/lirc/lirc_bt829.c
@@ -64,7 +64,7 @@ static bool debug;
 
 static int atir_minor;
 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;
 
@@ -382,7 +382,7 @@ static unsigned char do_get_bits(void)
 
 static unsigned int read_index(unsigned char index)
 {
-   unsigned char *addr;
+   unsigned char __iomem *addr;
unsigned int value;
/*  addr = pci_addr_lin + DATA_PCI_OFF + ((index  0xFF)  2); */
addr = pci_addr_lin + ((index  0xFF)  2);
@@ -392,7 +392,7 @@ static unsigned int read_index(unsigned char index)
 
 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);
writel(reg_val, addr);
 }
diff --git a/drivers/staging/media/lirc/lirc_parallel.c 
b/drivers/staging/media/lirc/lirc_parallel.c
index 62f5137..ea11fbb 100644
--- a/drivers/staging/media/lirc/lirc_parallel.c
+++ b/drivers/staging/media/lirc/lirc_parallel.c
@@ -324,7 +324,8 @@ static loff_t lirc_lseek(struct file *filep, loff_t offset, 
int orig)
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 count = 0;
@@ -362,7 +363,7 @@ static ssize_t lirc_read(struct file *filep, char *buf, 
size_t n, loff_t *ppos)
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)
 {
int count;
@@ -470,36 +471,36 @@ static long lirc_ioctl(struct file *filep, unsigned int 
cmd, unsigned long arg)
 
switch (cmd) {
case LIRC_GET_FEATURES:
-   result = put_user(features, (__u32 *) arg);
+   result = put_user(features, (__u32 __user *) arg);
if (result)
return result;
break;
case LIRC_GET_SEND_MODE:
-   result = put_user(LIRC_MODE_PULSE, (__u32 *) arg);
+   result = put_user(LIRC_MODE_PULSE, (__u32 __user *) arg);
if (result)
return result;
break;
case LIRC_GET_REC_MODE:
-   result = put_user(LIRC_MODE_MODE2, (__u32 *) arg);
+   result = put_user(LIRC_MODE_MODE2, (__u32 __user *) arg);
if (result)
return result;
break;
case LIRC_SET_SEND_MODE:
-   result = get_user(mode, (__u32 *) arg);
+   result = get_user(mode, (__u32 __user *) arg);
if (result)
return result;
if (mode != LIRC_MODE_PULSE)
return -EINVAL;
break;
case LIRC_SET_REC_MODE:
-   result = get_user(mode, (__u32 *) arg);
+   result = get_user(mode, (__u32 __user *) arg);
if (result)
return result;
if (mode != LIRC_MODE_MODE2)
return -ENOSYS;
break;
case LIRC_SET_TRANSMITTER_MASK:
-   result = get_user(value, (__u32 *) arg);
+   result = get_user(value, (__u32 __user *) arg);
if (result)
return result;
if ((value  LIRC_PARALLEL_TRANSMITTER_MASK) != value)
diff --git a/drivers/staging/media/lirc/lirc_serial.c 
b/drivers/staging/media/lirc/lirc_serial.c
index 10c685d..5fced89 100644
--- a/drivers/staging/media/lirc/lirc_serial.c
+++ b/drivers/staging/media/lirc/lirc_serial.c
@@ -1020,7 +1020,7 @@ static long lirc_ioctl(struct file *filep, unsigned int 
cmd, unsigned long arg)
 
result = put_user(LIRC_SEND2MODE
  (hardware[type].featuresLIRC_CAN_SEND_MASK),
- (__u32 *) arg);
+   

Re: [PATCH] staging: lirc: Fix sparse warnings

2014-05-08 Thread Dan Carpenter
On Thu, May 08, 2014 at 01:11:48PM +0300, Tuomas Tynkkynen wrote:
 Fix sparse warnings by adding __user and __iomem annotations where
 necessary and removing certain unnecessary casts.
 
 Signed-off-by: Tuomas Tynkkynen tuomas.tynkky...@iki.fi

This patch adds spaces between the cast and the variable.  There
shouldn't be a cast.  That rule is so people remember that casting is a
high precedence operation.

Joe recently added a check for cast spacing to ./scripts/checkpatch.pl
--strict.  Run your patch through ./scripts/checkpatch.pl --strict and
fix the warnings.

 @@ -470,36 +471,36 @@ static long lirc_ioctl(struct file *filep, unsigned int 
 cmd, unsigned long arg)
  
   switch (cmd) {
   case LIRC_GET_FEATURES:
 - result = put_user(features, (__u32 *) arg);
 + result = put_user(features, (__u32 __user *) arg);

arg is alway a u32 __user pointer.  Do this at the start of the
function.

u32 __user *uptr = (u32 __user *)arg;

Then replace all the arg references with uptr.  Btw, the difference
between __u32 and u32 is that __u32 is for code which is shared with
user space and u32 is only allowed in kernel code.

regards,
dan carpenter

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] staging: lirc: Fix sparse warnings

2014-05-08 Thread Dan Carpenter
On Thu, May 08, 2014 at 01:30:28PM +0300, Dan Carpenter wrote:
 On Thu, May 08, 2014 at 01:11:48PM +0300, Tuomas Tynkkynen wrote:
  Fix sparse warnings by adding __user and __iomem annotations where
  necessary and removing certain unnecessary casts.
  
  Signed-off-by: Tuomas Tynkkynen tuomas.tynkky...@iki.fi
 
 This patch adds spaces between the cast and the variable.  There
 shouldn't be a cast.
 
I meant space.  There shouldn't be a space.

regards,
dan carpenter

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html