@@ -33,14 +33,12 @@ static int drm_fbdev_fb_open(struct fb_info *info, int user)
return 0;
}
-static int drm_fbdev_fb_release(struct fb_info *info, int user)
+static void drm_fbdev_fb_release(struct fb_info *info, int user)
{
struct drm_fb_helper *fb_helper = info->par;
if (user)
module_put(fb_helper->dev->driver->fops->owner);
-
- return 0;
}
static void drm_fbdev_cleanup(struct drm_fb_helper *fb_helper)
@@ -197,13 +197,12 @@ nouveau_fbcon_open(struct fb_info *info, int user)
return 0;
}
-static int
+static void
nouveau_fbcon_release(struct fb_info *info, int user)
{
struct nouveau_fbdev *fbcon = info->par;
struct nouveau_drm *drm = nouveau_drm(fbcon->helper.dev);
pm_runtime_put(drm->dev->dev);
- return 0;
}
static const struct fb_ops nouveau_fbcon_ops = {
@@ -64,7 +64,7 @@ radeonfb_open(struct fb_info *info, int user)
return 0;
}
-static int
+static void
radeonfb_release(struct fb_info *info, int user)
{
struct radeon_fbdev *rfbdev = info->par;
@@ -72,7 +72,6 @@ radeonfb_release(struct fb_info *info, int user)
pm_runtime_mark_last_busy(rdev->ddev->dev);
pm_runtime_put_autosuspend(rdev->ddev->dev);
- return 0;
}
static const struct fb_ops radeonfb_ops = {
@@ -187,15 +187,14 @@ static int arcfb_open(struct fb_info *info, int user)
return 0;
}
-static int arcfb_release(struct fb_info *info, int user)
+static void arcfb_release(struct fb_info *info, int user)
{
struct arcfb_par *par = info->par;
int count = atomic_read(&par->ref_count);
- if (!count)
- return -EINVAL;
+ if (WARN_ON(!count))
+ return;
atomic_dec(&par->ref_count);
- return 0;
}
static int arcfb_pan_display(struct fb_var_screeninfo *var,
@@ -532,14 +532,14 @@ static int arkfb_open(struct fb_info *info, int user)
/* Close framebuffer */
-static int arkfb_release(struct fb_info *info, int user)
+static void arkfb_release(struct fb_info *info, int user)
{
struct arkfb_info *par = info->par;
mutex_lock(&(par->open_lock));
- if (par->ref_count == 0) {
+ if (WARN_ON(par->ref_count == 0)) {
mutex_unlock(&(par->open_lock));
- return -EINVAL;
+ return;
}
if (par->ref_count == 1) {
@@ -549,8 +549,6 @@ static int arkfb_release(struct fb_info *info, int user)
par->ref_count--;
mutex_unlock(&(par->open_lock));
-
- return 0;
}
/* Validate passed in var */
@@ -235,7 +235,7 @@ static const struct fb_fix_screeninfo atyfb_fix = {
*/
static int atyfb_open(struct fb_info *info, int user);
-static int atyfb_release(struct fb_info *info, int user);
+static void atyfb_release(struct fb_info *info, int user);
static int atyfb_check_var(struct fb_var_screeninfo *var,
struct fb_info *info);
static int atyfb_set_par(struct fb_info *info);
@@ -1677,7 +1677,7 @@ static int aty_disable_irq(struct atyfb_par *par)
return 0;
}
-static int atyfb_release(struct fb_info *info, int user)
+static void atyfb_release(struct fb_info *info, int user)
{
struct atyfb_par *par = (struct atyfb_par *) info->par;
#ifdef __sparc__
@@ -1685,14 +1685,14 @@ static int atyfb_release(struct fb_info *info, int user)
#endif
if (!user)
- return 0;
+ return;
par->open--;
mdelay(1);
wait_for_idle(par);
if (par->open)
- return 0;
+ return;
#ifdef __sparc__
was_mmaped = par->mmaped;
@@ -1724,8 +1724,6 @@ static int atyfb_release(struct fb_info *info, int user)
}
#endif
aty_disable_irq(par);
-
- return 0;
}
/*
@@ -434,11 +434,10 @@ static int cirrusfb_open(struct fb_info *info, int user)
}
/*--- Close /dev/fbx --------------------------------------------------------*/
-static int cirrusfb_release(struct fb_info *info, int user)
+static void cirrusfb_release(struct fb_info *info, int user)
{
if (--opencount == 0)
switch_monitor(info->par, 0);
- return 0;
}
/**** END Interface used by the World *************************************/
@@ -1422,7 +1422,7 @@ static int fsl_diu_open(struct fb_info *info, int user)
/* turn off fb if count == 0
*/
-static int fsl_diu_release(struct fb_info *info, int user)
+static void fsl_diu_release(struct fb_info *info, int user)
{
struct mfb_info *mfbi = info->par;
@@ -1446,7 +1446,6 @@ static int fsl_diu_release(struct fb_info *info, int user)
}
spin_unlock(&diu_lock);
- return 0;
}
static const struct fb_ops fsl_diu_ops = {
@@ -380,11 +380,10 @@ static int hgafb_open(struct fb_info *info, int init)
* @init: open by console system or userland.
*/
-static int hgafb_release(struct fb_info *info, int init)
+static void hgafb_release(struct fb_info *info, int init)
{
hga_txt_mode();
hga_clear_screen();
- return 0;
}
/**
@@ -190,7 +190,7 @@ static int i740fb_open(struct fb_info *info, int user)
return 0;
}
-static int i740fb_release(struct fb_info *info, int user)
+static void i740fb_release(struct fb_info *info, int user)
{
struct i740fb_par *par = info->par;
@@ -198,13 +198,11 @@ static int i740fb_release(struct fb_info *info, int user)
if (par->ref_count == 0) {
fb_err(info, "release called with zero refcount\n");
mutex_unlock(&(par->open_lock));
- return -EINVAL;
+ return;
}
par->ref_count--;
mutex_unlock(&(par->open_lock));
-
- return 0;
}
static u32 i740_calc_fifo(struct i740fb_par *par, u32 freq, int bpp)
@@ -1257,14 +1257,14 @@ static int i810fb_open(struct fb_info *info, int user)
return 0;
}
-static int i810fb_release(struct fb_info *info, int user)
+static void i810fb_release(struct fb_info *info, int user)
{
struct i810fb_par *par = info->par;
mutex_lock(&par->open_lock);
- if (par->use_count == 0) {
+ if (WARN_ON(par->use_count == 0)) {
mutex_unlock(&par->open_lock);
- return -EINVAL;
+ return;
}
if (par->use_count == 1) {
@@ -1274,8 +1274,6 @@ static int i810fb_release(struct fb_info *info, int user)
par->use_count--;
mutex_unlock(&par->open_lock);
-
- return 0;
}
@@ -133,7 +133,7 @@ static void get_initial_mode(struct intelfb_info *dinfo);
static void update_dinfo(struct intelfb_info *dinfo,
struct fb_var_screeninfo *var);
static int intelfb_open(struct fb_info *info, int user);
-static int intelfb_release(struct fb_info *info, int user);
+static void intelfb_release(struct fb_info *info, int user);
static int intelfb_check_var(struct fb_var_screeninfo *var,
struct fb_info *info);
static int intelfb_set_par(struct fb_info *info);
@@ -1187,7 +1187,7 @@ static int intelfb_open(struct fb_info *info, int user)
return 0;
}
-static int intelfb_release(struct fb_info *info, int user)
+static void intelfb_release(struct fb_info *info, int user)
{
struct intelfb_info *dinfo = GET_DINFO(info);
@@ -1197,8 +1197,6 @@ static int intelfb_release(struct fb_info *info, int user)
if (!dinfo->open)
intelfbhw_disable_irq(dinfo);
}
-
- return 0;
}
static int intelfb_check_var(struct fb_var_screeninfo *var,
@@ -400,7 +400,7 @@ static int matroxfb_open(struct fb_info *info, int user)
return(0);
}
-static int matroxfb_release(struct fb_info *info, int user)
+static void matroxfb_release(struct fb_info *info, int user)
{
struct matrox_fb_info *minfo = info2minfo(info);
@@ -414,7 +414,6 @@ static int matroxfb_release(struct fb_info *info, int user)
if (!(--minfo->usecount) && minfo->dead) {
matroxfb_remove(minfo, 0);
}
- return(0);
}
static int matroxfb_pan_display(struct fb_var_screeninfo *var,
@@ -279,15 +279,13 @@ static int matroxfb_dh_open(struct fb_info* info, int user) {
#undef m2info
}
-static int matroxfb_dh_release(struct fb_info* info, int user) {
+static void matroxfb_dh_release(struct fb_info *info, int user)
+{
#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
- int err = 0;
struct matrox_fb_info *minfo = m2info->primary_dev;
- if (minfo) {
- err = minfo->fbops.fb_release(&minfo->fbcon, user);
- }
- return err;
+ if (minfo)
+ minfo->fbops.fb_release(&minfo->fbcon, user);
#undef m2info
}
@@ -561,20 +561,18 @@ neofb_open(struct fb_info *info, int user)
return 0;
}
-static int
+static void
neofb_release(struct fb_info *info, int user)
{
struct neofb_par *par = info->par;
- if (!par->ref_count)
- return -EINVAL;
+ if (WARN_ON(!par->ref_count))
+ return;
if (par->ref_count == 1) {
restore_vga(&par->state);
}
par->ref_count--;
-
- return 0;
}
static int
@@ -1002,15 +1002,12 @@ static int nvidiafb_open(struct fb_info *info, int user)
return 0;
}
-static int nvidiafb_release(struct fb_info *info, int user)
+static void nvidiafb_release(struct fb_info *info, int user)
{
struct nvidia_par *par = info->par;
- int err = 0;
- if (!par->open_count) {
- err = -EINVAL;
- goto done;
- }
+ if (WARN_ON(!par->open_count))
+ return;
if (par->open_count == 1) {
nvidia_write_regs(par, &par->initial_state);
@@ -1018,8 +1015,6 @@ static int nvidiafb_release(struct fb_info *info, int user)
}
par->open_count--;
-done:
- return err;
}
static struct fb_ops nvidia_fb_ops = {
@@ -222,10 +222,9 @@ static void omapfb_sync(struct fb_info *info);
/* Called when the omapfb device is closed. We make sure that any pending
* gfx DMA operations are ended, before we return. */
-static int omapfb_release(struct fb_info *info, int user)
+static void omapfb_release(struct fb_info *info, int user)
{
omapfb_sync(info);
- return 0;
}
/* Store a single color palette entry into a pseudo palette or the hardware
@@ -752,9 +752,8 @@ static int omapfb_open(struct fb_info *fbi, int user)
return 0;
}
-static int omapfb_release(struct fb_info *fbi, int user)
+static void omapfb_release(struct fb_info *fbi, int user)
{
- return 0;
}
static unsigned calc_rotation_offset_dma(const struct fb_var_screeninfo *var,
@@ -508,7 +508,7 @@ static int ps3fb_open(struct fb_info *info, int user)
return 0;
}
-static int ps3fb_release(struct fb_info *info, int user)
+static void ps3fb_release(struct fb_info *info, int user)
{
if (atomic_dec_and_test(&ps3fb.f_count)) {
if (atomic_read(&ps3fb.ext_flip)) {
@@ -519,7 +519,6 @@ static int ps3fb_release(struct fb_info *info, int user)
}
}
}
- return 0;
}
/*
@@ -745,7 +745,7 @@ static int overlayfb_open(struct fb_info *info, int user)
return 0;
}
-static int overlayfb_release(struct fb_info *info, int user)
+static void overlayfb_release(struct fb_info *info, int user)
{
struct pxafb_layer *ofb = container_of(info, struct pxafb_layer, fb);
@@ -758,7 +758,6 @@ static int overlayfb_release(struct fb_info *info, int user)
ofb->usage--;
}
- return 0;
}
static int overlayfb_check_var(struct fb_var_screeninfo *var,
@@ -1052,15 +1052,15 @@ static int rivafb_open(struct fb_info *info, int user)
return 0;
}
-static int rivafb_release(struct fb_info *info, int user)
+static void rivafb_release(struct fb_info *info, int user)
{
struct riva_par *par = info->par;
NVTRACE_ENTER();
mutex_lock(&par->open_lock);
- if (!par->ref_count) {
+ if (WARN_ON(!par->ref_count)) {
mutex_unlock(&par->open_lock);
- return -EINVAL;
+ return;
}
if (par->ref_count == 1) {
par->riva.LockUnlock(&par->riva, 0);
@@ -1074,7 +1074,6 @@ static int rivafb_release(struct fb_info *info, int user)
par->ref_count--;
mutex_unlock(&par->open_lock);
NVTRACE_LEAVE();
- return 0;
}
static int rivafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
@@ -523,14 +523,14 @@ static int s3fb_open(struct fb_info *info, int user)
/* Close framebuffer */
-static int s3fb_release(struct fb_info *info, int user)
+static void s3fb_release(struct fb_info *info, int user)
{
struct s3fb_info *par = info->par;
mutex_lock(&(par->open_lock));
- if (par->ref_count == 0) {
+ if (WARN_ON(par->ref_count == 0)) {
mutex_unlock(&(par->open_lock));
- return -EINVAL;
+ return;
}
if (par->ref_count == 1)
@@ -538,8 +538,6 @@ static int s3fb_release(struct fb_info *info, int user)
par->ref_count--;
mutex_unlock(&(par->open_lock));
-
- return 0;
}
/* Validate passed in var */
@@ -1621,7 +1621,7 @@ static int savagefb_open(struct fb_info *info, int user)
return 0;
}
-static int savagefb_release(struct fb_info *info, int user)
+static void savagefb_release(struct fb_info *info, int user)
{
struct savagefb_par *par = info->par;
@@ -1634,7 +1634,6 @@ static int savagefb_release(struct fb_info *info, int user)
par->open_count--;
mutex_unlock(&par->open_lock);
- return 0;
}
static const struct fb_ops savagefb_ops = {
@@ -1781,7 +1781,7 @@ static void sh_mobile_fb_reconfig(struct fb_info *info)
* Locking: both .fb_release() and .fb_open() are called with info->lock held if
* user == 1, or with console sem held, if user == 0.
*/
-static int sh_mobile_lcdc_release(struct fb_info *info, int user)
+static void sh_mobile_lcdc_release(struct fb_info *info, int user)
{
struct sh_mobile_lcdc_chan *ch = info->par;
@@ -1798,8 +1798,6 @@ static int sh_mobile_lcdc_release(struct fb_info *info, int user)
}
mutex_unlock(&ch->open_lock);
-
- return 0;
}
static int sh_mobile_lcdc_open(struct fb_info *info, int user)
@@ -1396,10 +1396,9 @@ sisfb_open(struct fb_info *info, int user)
return 0;
}
-static int
+static void
sisfb_release(struct fb_info *info, int user)
{
- return 0;
}
static int
@@ -162,12 +162,9 @@ static int xxxfb_open(struct fb_info *info, int user)
* console system is released. Usually you don't need this function.
* The case where it is usually used is to go from a graphics state
* to a text mode state.
- *
- * Returns negative errno on error, or zero on success.
*/
-static int xxxfb_release(struct fb_info *info, int user)
+static void xxxfb_release(struct fb_info *info, int user)
{
- return 0;
}
/**
@@ -1163,7 +1163,7 @@ static void ufx_free_framebuffer(struct ufx_data *dev)
/*
* Assumes caller is holding info->lock mutex (for open and release at least)
*/
-static int ufx_ops_release(struct fb_info *info, int user)
+static void ufx_ops_release(struct fb_info *info, int user)
{
struct ufx_data *dev = info->par;
@@ -1187,8 +1187,6 @@ static int ufx_ops_release(struct fb_info *info, int user)
kref_put(&dev->kref, ufx_free);
mutex_unlock(&disconnect_mutex);
-
- return 0;
}
/* Check whether a video mode is supported by the chip
@@ -1029,7 +1029,7 @@ static void dlfb_ops_destroy(struct fb_info *info)
/*
* Assumes caller is holding info->lock mutex (for open and release at least)
*/
-static int dlfb_ops_release(struct fb_info *info, int user)
+static void dlfb_ops_release(struct fb_info *info, int user)
{
struct dlfb_data *dlfb = info->par;
@@ -1042,8 +1042,6 @@ static int dlfb_ops_release(struct fb_info *info, int user)
}
dev_dbg(info->dev, "release, user=%d count=%d\n", user, dlfb->fb_count);
-
- return 0;
}
/*
@@ -1182,14 +1182,14 @@ static int uvesafb_open(struct fb_info *info, int user)
return 0;
}
-static int uvesafb_release(struct fb_info *info, int user)
+static void uvesafb_release(struct fb_info *info, int user)
{
struct uvesafb_ktask *task = NULL;
struct uvesafb_par *par = info->par;
int cnt = atomic_read(&par->ref_count);
- if (!cnt)
- return -EINVAL;
+ if (WARN_ON(!cnt))
+ return;
if (cnt != 1)
goto out;
@@ -1210,7 +1210,6 @@ static int uvesafb_release(struct fb_info *info, int user)
out:
atomic_dec(&par->ref_count);
uvesafb_free(task);
- return 0;
}
static int uvesafb_set_par(struct fb_info *info)
@@ -554,13 +554,11 @@ static int vmlfb_open(struct fb_info *info, int user)
return 0;
}
-static int vmlfb_release(struct fb_info *info, int user)
+static void vmlfb_release(struct fb_info *info, int user)
{
/*
* Restore registers here.
*/
-
- return 0;
}
static int vml_nearest_clock(int clock)
@@ -311,18 +311,16 @@ static int vga16fb_open(struct fb_info *info, int user)
return 0;
}
-static int vga16fb_release(struct fb_info *info, int user)
+static void vga16fb_release(struct fb_info *info, int user)
{
struct vga16fb_par *par = info->par;
- if (!par->ref_count)
- return -EINVAL;
+ if (WARN_ON(!par->ref_count))
+ return;
if (par->ref_count == 1)
restore_vga(&par->state);
par->ref_count--;
-
- return 0;
}
static int vga16fb_check_var(struct fb_var_screeninfo *var,
@@ -165,10 +165,9 @@ static int viafb_open(struct fb_info *info, int user)
return 0;
}
-static int viafb_release(struct fb_info *info, int user)
+static void viafb_release(struct fb_info *info, int user)
{
DEBUG_MSG(KERN_INFO "viafb_release!\n");
- return 0;
}
static inline int get_var_refresh(struct fb_var_screeninfo *var)
@@ -299,14 +299,14 @@ static int vt8623fb_open(struct fb_info *info, int user)
return 0;
}
-static int vt8623fb_release(struct fb_info *info, int user)
+static void vt8623fb_release(struct fb_info *info, int user)
{
struct vt8623fb_info *par = info->par;
mutex_lock(&(par->open_lock));
- if (par->ref_count == 0) {
+ if (WARN_ON(par->ref_count == 0)) {
mutex_unlock(&(par->open_lock));
- return -EINVAL;
+ return;
}
if (par->ref_count == 1)
@@ -314,8 +314,6 @@ static int vt8623fb_release(struct fb_info *info, int user)
par->ref_count--;
mutex_unlock(&(par->open_lock));
-
- return 0;
}
static int vt8623fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
@@ -238,7 +238,7 @@ struct fb_ops {
/* open/release and usage marking */
struct module *owner;
int (*fb_open)(struct fb_info *info, int user);
- int (*fb_release)(struct fb_info *info, int user);
+ void (*fb_release)(struct fb_info *info, int user);
/* For framebuffers with strange non linear layouts or that do not
* work with normal memory mapped access
Change struct fb_ops.release and its implementations to not return a value. Returing an error is not necessary and callers of the function ignore it. It is also good practice to make clean-up code unable ot fail, as such failure cannot be handled. In several places drivers tested for the correctness of the internal reference counting and failed silently if the counter was incorrect. This would be an error in the implementation, which would require fixing. So change these tests to return no error, but print a warning. v2: * update omapfb2 (kernel test robot) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> --- drivers/gpu/drm/drm_fbdev_generic.c | 4 +--- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 3 +-- drivers/gpu/drm/radeon/radeon_fb.c | 3 +-- drivers/video/fbdev/arcfb.c | 7 +++---- drivers/video/fbdev/arkfb.c | 8 +++----- drivers/video/fbdev/aty/atyfb_base.c | 10 ++++------ drivers/video/fbdev/cirrusfb.c | 3 +-- drivers/video/fbdev/fsl-diu-fb.c | 3 +-- drivers/video/fbdev/hgafb.c | 3 +-- drivers/video/fbdev/i740fb.c | 6 ++---- drivers/video/fbdev/i810/i810_main.c | 8 +++----- drivers/video/fbdev/intelfb/intelfbdrv.c | 6 ++---- drivers/video/fbdev/matrox/matroxfb_base.c | 3 +-- drivers/video/fbdev/matrox/matroxfb_crtc2.c | 10 ++++------ drivers/video/fbdev/neofb.c | 8 +++----- drivers/video/fbdev/nvidia/nvidia.c | 11 +++-------- drivers/video/fbdev/omap/omapfb_main.c | 3 +-- drivers/video/fbdev/omap2/omapfb/omapfb-main.c | 3 +-- drivers/video/fbdev/ps3fb.c | 3 +-- drivers/video/fbdev/pxafb.c | 3 +-- drivers/video/fbdev/riva/fbdev.c | 7 +++---- drivers/video/fbdev/s3fb.c | 8 +++----- drivers/video/fbdev/savage/savagefb_driver.c | 3 +-- drivers/video/fbdev/sh_mobile_lcdcfb.c | 4 +--- drivers/video/fbdev/sis/sis_main.c | 3 +-- drivers/video/fbdev/skeletonfb.c | 5 +---- drivers/video/fbdev/smscufx.c | 4 +--- drivers/video/fbdev/udlfb.c | 4 +--- drivers/video/fbdev/uvesafb.c | 7 +++---- drivers/video/fbdev/vermilion/vermilion.c | 4 +--- drivers/video/fbdev/vga16fb.c | 8 +++----- drivers/video/fbdev/via/viafbdev.c | 3 +-- drivers/video/fbdev/vt8623fb.c | 8 +++----- include/linux/fb.h | 2 +- 34 files changed, 62 insertions(+), 116 deletions(-)