Commit e5367711 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

fb: push down the BKL in the ioctl handler

Framebuffer is heavily BKL dependant at the moment so just wrap the ioctl
handler in the driver as we push down.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 978ccaa8
...@@ -1002,101 +1002,132 @@ fb_blank(struct fb_info *info, int blank) ...@@ -1002,101 +1002,132 @@ fb_blank(struct fb_info *info, int blank)
return ret; return ret;
} }
static int static long
fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, fb_ioctl(struct file *file, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
struct inode *inode = file->f_path.dentry->d_inode;
int fbidx = iminor(inode); int fbidx = iminor(inode);
struct fb_info *info = registered_fb[fbidx]; struct fb_info *info;
struct fb_ops *fb = info->fbops; struct fb_ops *fb;
struct fb_var_screeninfo var; struct fb_var_screeninfo var;
struct fb_fix_screeninfo fix; struct fb_fix_screeninfo fix;
struct fb_con2fbmap con2fb; struct fb_con2fbmap con2fb;
struct fb_cmap_user cmap; struct fb_cmap_user cmap;
struct fb_event event; struct fb_event event;
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
int i; long ret = 0;
if (!fb) lock_kernel();
info = registered_fb[fbidx];
fb = info->fbops;
if (!fb) {
unlock_kernel();
return -ENODEV; return -ENODEV;
}
switch (cmd) { switch (cmd) {
case FBIOGET_VSCREENINFO: case FBIOGET_VSCREENINFO:
return copy_to_user(argp, &info->var, ret = copy_to_user(argp, &info->var,
sizeof(var)) ? -EFAULT : 0; sizeof(var)) ? -EFAULT : 0;
break;
case FBIOPUT_VSCREENINFO: case FBIOPUT_VSCREENINFO:
if (copy_from_user(&var, argp, sizeof(var))) if (copy_from_user(&var, argp, sizeof(var))) {
return -EFAULT; ret = -EFAULT;
break;
}
acquire_console_sem(); acquire_console_sem();
info->flags |= FBINFO_MISC_USEREVENT; info->flags |= FBINFO_MISC_USEREVENT;
i = fb_set_var(info, &var); ret = fb_set_var(info, &var);
info->flags &= ~FBINFO_MISC_USEREVENT; info->flags &= ~FBINFO_MISC_USEREVENT;
release_console_sem(); release_console_sem();
if (i) return i; if (ret == 0 && copy_to_user(argp, &var, sizeof(var)))
if (copy_to_user(argp, &var, sizeof(var))) ret = -EFAULT;
return -EFAULT; break;
return 0;
case FBIOGET_FSCREENINFO: case FBIOGET_FSCREENINFO:
return copy_to_user(argp, &info->fix, ret = copy_to_user(argp, &info->fix,
sizeof(fix)) ? -EFAULT : 0; sizeof(fix)) ? -EFAULT : 0;
break;
case FBIOPUTCMAP: case FBIOPUTCMAP:
if (copy_from_user(&cmap, argp, sizeof(cmap))) if (copy_from_user(&cmap, argp, sizeof(cmap)))
return -EFAULT; ret = -EFAULT;
return (fb_set_user_cmap(&cmap, info)); else
ret = fb_set_user_cmap(&cmap, info);
break;
case FBIOGETCMAP: case FBIOGETCMAP:
if (copy_from_user(&cmap, argp, sizeof(cmap))) if (copy_from_user(&cmap, argp, sizeof(cmap)))
return -EFAULT; ret = -EFAULT;
return fb_cmap_to_user(&info->cmap, &cmap); else
ret = fb_cmap_to_user(&info->cmap, &cmap);
break;
case FBIOPAN_DISPLAY: case FBIOPAN_DISPLAY:
if (copy_from_user(&var, argp, sizeof(var))) if (copy_from_user(&var, argp, sizeof(var))) {
return -EFAULT; ret = -EFAULT;
break;
}
acquire_console_sem(); acquire_console_sem();
i = fb_pan_display(info, &var); ret = fb_pan_display(info, &var);
release_console_sem(); release_console_sem();
if (i) if (ret == 0 && copy_to_user(argp, &var, sizeof(var)))
return i; ret = -EFAULT;
if (copy_to_user(argp, &var, sizeof(var))) break;
return -EFAULT;
return 0;
case FBIO_CURSOR: case FBIO_CURSOR:
return -EINVAL; ret = -EINVAL;
break;
case FBIOGET_CON2FBMAP: case FBIOGET_CON2FBMAP:
if (copy_from_user(&con2fb, argp, sizeof(con2fb))) if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
return -EFAULT; ret = -EFAULT;
if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES) else if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
return -EINVAL; ret = -EINVAL;
else {
con2fb.framebuffer = -1; con2fb.framebuffer = -1;
event.info = info; event.info = info;
event.data = &con2fb; event.data = &con2fb;
fb_notifier_call_chain(FB_EVENT_GET_CONSOLE_MAP, &event); fb_notifier_call_chain(FB_EVENT_GET_CONSOLE_MAP,
return copy_to_user(argp, &con2fb, &event);
ret = copy_to_user(argp, &con2fb,
sizeof(con2fb)) ? -EFAULT : 0; sizeof(con2fb)) ? -EFAULT : 0;
}
break;
case FBIOPUT_CON2FBMAP: case FBIOPUT_CON2FBMAP:
if (copy_from_user(&con2fb, argp, sizeof(con2fb))) if (copy_from_user(&con2fb, argp, sizeof(con2fb))) {
return - EFAULT; ret = -EFAULT;
if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES) break;
return -EINVAL; }
if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX) if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES) {
return -EINVAL; ret = -EINVAL;
break;
}
if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX) {
ret = -EINVAL;
break;
}
if (!registered_fb[con2fb.framebuffer]) if (!registered_fb[con2fb.framebuffer])
request_module("fb%d", con2fb.framebuffer); request_module("fb%d", con2fb.framebuffer);
if (!registered_fb[con2fb.framebuffer]) if (!registered_fb[con2fb.framebuffer]) {
return -EINVAL; ret = -EINVAL;
break;
}
event.info = info; event.info = info;
event.data = &con2fb; event.data = &con2fb;
return fb_notifier_call_chain(FB_EVENT_SET_CONSOLE_MAP, ret = fb_notifier_call_chain(FB_EVENT_SET_CONSOLE_MAP,
&event); &event);
break;
case FBIOBLANK: case FBIOBLANK:
acquire_console_sem(); acquire_console_sem();
info->flags |= FBINFO_MISC_USEREVENT; info->flags |= FBINFO_MISC_USEREVENT;
i = fb_blank(info, arg); ret = fb_blank(info, arg);
info->flags &= ~FBINFO_MISC_USEREVENT; info->flags &= ~FBINFO_MISC_USEREVENT;
release_console_sem(); release_console_sem();
return i; break;;
default: default:
if (fb->fb_ioctl == NULL) if (fb->fb_ioctl == NULL)
return -EINVAL; ret = -ENOTTY;
return fb->fb_ioctl(info, cmd, arg); else
ret = fb->fb_ioctl(info, cmd, arg);
} }
unlock_kernel();
return ret;
} }
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
...@@ -1150,7 +1181,7 @@ static int fb_getput_cmap(struct inode *inode, struct file *file, ...@@ -1150,7 +1181,7 @@ static int fb_getput_cmap(struct inode *inode, struct file *file,
put_user(compat_ptr(data), &cmap->transp)) put_user(compat_ptr(data), &cmap->transp))
return -EFAULT; return -EFAULT;
err = fb_ioctl(inode, file, cmd, (unsigned long) cmap); err = fb_ioctl(file, cmd, (unsigned long) cmap);
if (!err) { if (!err) {
if (copy_in_user(&cmap32->start, if (copy_in_user(&cmap32->start,
...@@ -1204,7 +1235,7 @@ static int fb_get_fscreeninfo(struct inode *inode, struct file *file, ...@@ -1204,7 +1235,7 @@ static int fb_get_fscreeninfo(struct inode *inode, struct file *file,
old_fs = get_fs(); old_fs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
err = fb_ioctl(inode, file, cmd, (unsigned long) &fix); err = fb_ioctl(file, cmd, (unsigned long) &fix);
set_fs(old_fs); set_fs(old_fs);
if (!err) if (!err)
...@@ -1231,7 +1262,7 @@ fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1231,7 +1262,7 @@ fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case FBIOPUT_CON2FBMAP: case FBIOPUT_CON2FBMAP:
arg = (unsigned long) compat_ptr(arg); arg = (unsigned long) compat_ptr(arg);
case FBIOBLANK: case FBIOBLANK:
ret = fb_ioctl(inode, file, cmd, arg); ret = fb_ioctl(file, cmd, arg);
break; break;
case FBIOGET_FSCREENINFO: case FBIOGET_FSCREENINFO:
...@@ -1358,7 +1389,7 @@ static const struct file_operations fb_fops = { ...@@ -1358,7 +1389,7 @@ static const struct file_operations fb_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.read = fb_read, .read = fb_read,
.write = fb_write, .write = fb_write,
.ioctl = fb_ioctl, .unlocked_ioctl = fb_ioctl,
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
.compat_ioctl = fb_compat_ioctl, .compat_ioctl = fb_compat_ioctl,
#endif #endif
......
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