diff options
author | Fancy Fang <chen.fang@nxp.com> | 2017-01-04 15:34:43 +0800 |
---|---|---|
committer | Anson Huang <Anson.Huang@nxp.com> | 2017-06-08 20:59:10 +0800 |
commit | 6692115b7c04d026214a6f0c613c3be25ec5ec88 (patch) | |
tree | 2922bc2cb178aed1106277a02e30f317f143719a /drivers/video | |
parent | 7c1f48f717819842790502b857f2c1069b5738ac (diff) |
MLK-13722-2 video: mxsfb: change 'usage' to atomic_t type
The 'usage' field of mxsfb_layer is used to record the
overlay fb user counts. So change its type to atomic_t
to avoid race problem.
Signed-off-by: Fancy Fang <chen.fang@nxp.com>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/fbdev/mxsfb.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c index 95d2b287f87a..84a2f15c895e 100644 --- a/drivers/video/fbdev/mxsfb.c +++ b/drivers/video/fbdev/mxsfb.c @@ -56,6 +56,7 @@ #include <linux/fb.h> #include <linux/mxcfb.h> #include <linux/regulator/consumer.h> +#include <linux/types.h> #include <linux/videodev2.h> #include <video/of_display_timing.h> #include <video/videomode.h> @@ -217,7 +218,7 @@ struct mxsfb_layer { struct fb_info *ol_fb; int id; int registered; - uint32_t usage; + atomic_t usage; int blank_state; uint32_t global_alpha; @@ -1663,7 +1664,7 @@ static int overlayfb_open(struct fb_info *info, int user) struct mxsfb_layer *ofb = (struct mxsfb_layer*)info->par; struct mxsfb_info *fbi = ofb->fbi; - if (ofb->usage++ == 0) { + if (atomic_inc_return(&ofb->usage) == 1) { memset((void*)&info->var, 0x0, sizeof(info->var)); ofb->ol_fb->var.xres = fbi->fb_info->var.xres; @@ -1682,9 +1683,9 @@ static int overlayfb_release(struct fb_info *info, int user) struct mxsfb_layer *ofb = (struct mxsfb_layer*)info->par; struct mxsfb_info *fbi = ofb->fbi; - BUG_ON(!ofb->usage); + BUG_ON(!atomic_read(&ofb->usage)); - if (--ofb->usage == 0) { + if (atomic_dec_return(&ofb->usage) == 0) { if (ofb->blank_state == FB_BLANK_UNBLANK) ofb->ops->disable(ofb); @@ -1907,7 +1908,7 @@ static void init_mxsfb_overlay(struct mxsfb_info *fbi, ofb->id = 0; ofb->ops = &ofb_ops; - ofb->usage = 0; + atomic_set(&ofb->usage, 0); ofb->blank_state = -1; ofb->global_alpha = 255; ofb->fbi = fbi; |