staging: panel: fix sparse warnings in lcd_write
This patch fixes two sparse warnings related to lcd_write : warning: incorrect type in argument 1 (different address spaces) warning: incorrect type in initializer (incompatible argument 2 (different address spaces)) lcd_write can be used from kernel space (in panel_lcd_print) or from user space. So we introduce the lcd_write_char function that will write a char to the device. We modify lcd_write and panel_lcd_print to use it. Finally we add __user annotation missing in lcd_write. Signed-off-by: Bastien Armand <armand.bastien@laposte.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e112f89bcc
commit
70a8c3eb85
1 changed files with 110 additions and 97 deletions
|
@ -1217,24 +1217,8 @@ static inline int handle_lcd_special_code(void)
|
|||
return processed;
|
||||
}
|
||||
|
||||
static ssize_t lcd_write(struct file *file,
|
||||
const char *buf, size_t count, loff_t *ppos)
|
||||
static void lcd_write_char(char c)
|
||||
{
|
||||
const char *tmp = buf;
|
||||
char c;
|
||||
|
||||
for (; count-- > 0; (ppos ? (*ppos)++ : 0), ++tmp) {
|
||||
if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
|
||||
/* let's be a little nice with other processes
|
||||
that need some CPU */
|
||||
schedule();
|
||||
|
||||
if (ppos == NULL && file == NULL)
|
||||
/* let's not use get_user() from the kernel ! */
|
||||
c = *tmp;
|
||||
else if (get_user(c, tmp))
|
||||
return -EFAULT;
|
||||
|
||||
/* first, we'll test if we're in escape mode */
|
||||
if ((c != '\n') && lcd_escape_len >= 0) {
|
||||
/* yes, let's add this char to the buffer */
|
||||
|
@ -1324,6 +1308,24 @@ static ssize_t lcd_write(struct file *file,
|
|||
} /* escape codes */
|
||||
}
|
||||
|
||||
static ssize_t lcd_write(struct file *file,
|
||||
const char __user *buf, size_t count, loff_t *ppos)
|
||||
{
|
||||
const char __user *tmp = buf;
|
||||
char c;
|
||||
|
||||
for (; count-- > 0; (*ppos)++, tmp++) {
|
||||
if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
|
||||
/* let's be a little nice with other processes
|
||||
that need some CPU */
|
||||
schedule();
|
||||
|
||||
if (get_user(c, buf))
|
||||
return -EFAULT;
|
||||
|
||||
lcd_write_char(c);
|
||||
}
|
||||
|
||||
return tmp - buf;
|
||||
}
|
||||
|
||||
|
@ -1365,8 +1367,19 @@ static struct miscdevice lcd_dev = {
|
|||
/* public function usable from the kernel for any purpose */
|
||||
static void panel_lcd_print(const char *s)
|
||||
{
|
||||
if (lcd_enabled && lcd_initialized)
|
||||
lcd_write(NULL, s, strlen(s), NULL);
|
||||
const char *tmp = s;
|
||||
int count = strlen(s);
|
||||
|
||||
if (lcd_enabled && lcd_initialized) {
|
||||
for (; count-- > 0; tmp++) {
|
||||
if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
|
||||
/* let's be a little nice with other processes
|
||||
that need some CPU */
|
||||
schedule();
|
||||
|
||||
lcd_write_char(*tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize the LCD driver */
|
||||
|
|
Loading…
Add table
Reference in a new issue