Commit b1e7223f authored by Antonino A. Daplas's avatar Antonino A. Daplas Committed by Linus Torvalds

fbdev: clean up exit patch of fb_set_var

Clean up exit patch of fb_set_var():

- consolidate all return values into a single local variable
- ensure that return values are valid error codes
- fix fb_set_var() returning success when fb_check_caps() failed
Signed-off-by: default avatarAntonino Daplas <adaplas@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0959f0ca
...@@ -799,11 +799,11 @@ static int fb_check_caps(struct fb_info *info, struct fb_var_screeninfo *var, ...@@ -799,11 +799,11 @@ static int fb_check_caps(struct fb_info *info, struct fb_var_screeninfo *var,
int int
fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
{ {
int err, flags = info->flags; int flags = info->flags;
int ret = 0;
if (var->activate & FB_ACTIVATE_INV_MODE) { if (var->activate & FB_ACTIVATE_INV_MODE) {
struct fb_videomode mode1, mode2; struct fb_videomode mode1, mode2;
int ret = 0;
fb_var_to_videomode(&mode1, var); fb_var_to_videomode(&mode1, var);
fb_var_to_videomode(&mode2, &info->var); fb_var_to_videomode(&mode2, &info->var);
...@@ -821,7 +821,9 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) ...@@ -821,7 +821,9 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
if (!ret) if (!ret)
fb_delete_videomode(&mode1, &info->modelist); fb_delete_videomode(&mode1, &info->modelist);
return ret;
ret = (ret) ? -EINVAL : 0;
goto done;
} }
if ((var->activate & FB_ACTIVATE_FORCE) || if ((var->activate & FB_ACTIVATE_FORCE) ||
...@@ -830,20 +832,21 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) ...@@ -830,20 +832,21 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
if (!info->fbops->fb_check_var) { if (!info->fbops->fb_check_var) {
*var = info->var; *var = info->var;
return 0; goto done;
} }
if ((err = info->fbops->fb_check_var(var, info))) ret = info->fbops->fb_check_var(var, info);
return err;
if (ret)
goto done;
if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) { if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
struct fb_videomode mode; struct fb_videomode mode;
int err = 0;
if (info->fbops->fb_get_caps) { if (info->fbops->fb_get_caps) {
err = fb_check_caps(info, var, activate); ret = fb_check_caps(info, var, activate);
if (err) if (ret)
goto done; goto done;
} }
...@@ -853,16 +856,14 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) ...@@ -853,16 +856,14 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
info->fbops->fb_set_par(info); info->fbops->fb_set_par(info);
fb_pan_display(info, &info->var); fb_pan_display(info, &info->var);
fb_set_cmap(&info->cmap, info); fb_set_cmap(&info->cmap, info);
fb_var_to_videomode(&mode, &info->var); fb_var_to_videomode(&mode, &info->var);
if (info->modelist.prev && info->modelist.next && if (info->modelist.prev && info->modelist.next &&
!list_empty(&info->modelist)) !list_empty(&info->modelist))
err = fb_add_videomode(&mode, &info->modelist); ret = fb_add_videomode(&mode, &info->modelist);
if (!err && (flags & FBINFO_MISC_USEREVENT)) { if (!ret && (flags & FBINFO_MISC_USEREVENT)) {
struct fb_event event; struct fb_event event;
int evnt = (activate & FB_ACTIVATE_ALL) ? int evnt = (activate & FB_ACTIVATE_ALL) ?
FB_EVENT_MODE_CHANGE_ALL : FB_EVENT_MODE_CHANGE_ALL :
...@@ -876,7 +877,7 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) ...@@ -876,7 +877,7 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
} }
done: done:
return 0; return ret;
} }
int int
......
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