From cdf9221d00e641f1ca827e7c734f21fadf5746c8 Mon Sep 17 00:00:00 2001 From: zwl Date: Fri, 26 Sep 2014 15:27:21 +0800 Subject: [PATCH] rk fb:sys: modify to avoid sys node CTS Test Fail where error like div zero or null pointer --- drivers/video/rockchip/lcdc/rk3288_lcdc.c | 4 +++ drivers/video/rockchip/rkfb_sysfs.c | 34 ++++++++++++++++------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/drivers/video/rockchip/lcdc/rk3288_lcdc.c b/drivers/video/rockchip/lcdc/rk3288_lcdc.c index 3fd91108185f..3ef6f23829b2 100755 --- a/drivers/video/rockchip/lcdc/rk3288_lcdc.c +++ b/drivers/video/rockchip/lcdc/rk3288_lcdc.c @@ -2998,6 +2998,10 @@ static int rk3288_lcdc_fps_mgr(struct rk_lcdc_driver *dev_drv, int fps, u32 pixclock; u32 x_total, y_total; if (set) { + if (fps == 0) { + dev_info(dev_drv->dev, "unsupport set fps=0\n"); + return 0; + } ft = div_u64(1000000000000llu, fps); x_total = screen->mode.upper_margin + screen->mode.lower_margin + diff --git a/drivers/video/rockchip/rkfb_sysfs.c b/drivers/video/rockchip/rkfb_sysfs.c index 4584a1be7b07..0f8a4b47879e 100755 --- a/drivers/video/rockchip/rkfb_sysfs.c +++ b/drivers/video/rockchip/rkfb_sysfs.c @@ -39,14 +39,15 @@ static ssize_t show_screen_info(struct device *dev, struct fb_info *fbi = dev_get_drvdata(dev); struct rk_lcdc_driver *dev_drv = (struct rk_lcdc_driver *)fbi->par; struct rk_screen *screen = dev_drv->cur_screen; - int fps; + int fps = 0; u32 x = screen->mode.left_margin + screen->mode.right_margin + screen->mode.xres + screen->mode.hsync_len; u32 y = screen->mode.upper_margin + screen->mode.lower_margin + screen->mode.yres + screen->mode.vsync_len; u64 ft = (u64)x * y * (dev_drv->pixclock); - fps = div64_u64(1000000000000llu, ft); + if (ft > 0) + fps = div64_u64(1000000000000llu, ft); return snprintf(buf, PAGE_SIZE, "xres:%d\nyres:%d\nfps:%d\n", screen->mode.xres, screen->mode.yres, fps); } @@ -133,7 +134,9 @@ static ssize_t show_overlay(struct device *dev, struct rk_lcdc_driver *dev_drv = (struct rk_lcdc_driver *)fbi->par; int ovl; - ovl = dev_drv->ops->ovl_mgr(dev_drv, 0, 0); + + if (dev_drv->ops->ovl_mgr) + ovl = dev_drv->ops->ovl_mgr(dev_drv, 0, 0); if (ovl < 0) return ovl; @@ -155,8 +158,8 @@ static ssize_t set_overlay(struct device *dev, struct device_attribute *attr, ret = kstrtoint(buf, 0, &ovl); if (ret) return ret; - - ret = dev_drv->ops->ovl_mgr(dev_drv, ovl, 1); + if (dev_drv->ops->ovl_mgr) + ret = dev_drv->ops->ovl_mgr(dev_drv, ovl, 1); if (ret < 0) return ret; @@ -171,7 +174,8 @@ static ssize_t show_fps(struct device *dev, (struct rk_lcdc_driver *)fbi->par; int fps; - fps = dev_drv->ops->fps_mgr(dev_drv, 0, 0); + if (dev_drv->ops->fps_mgr) + fps = dev_drv->ops->fps_mgr(dev_drv, 0, 0); if (fps < 0) return fps; @@ -190,7 +194,14 @@ static ssize_t set_fps(struct device *dev, struct device_attribute *attr, ret = kstrtoint(buf, 0, &fps); if (ret) return ret; - ret = dev_drv->ops->fps_mgr(dev_drv, fps, 1); + + if (fps == 0) { + dev_info(dev, "unsupport set fps=0\n"); + return count; + } + + if (dev_drv->ops->fps_mgr) + ret = dev_drv->ops->fps_mgr(dev_drv, fps, 1); if (ret < 0) return ret; @@ -241,7 +252,8 @@ static ssize_t set_fb_win_map(struct device *dev, struct device_attribute *attr, "fb0-win2\n" "fb1-win1\n" "fb2-win0\n"); return count; } else { - dev_drv->ops->fb_win_remap(dev_drv, order); + if (dev_drv->ops->fb_win_remap) + dev_drv->ops->fb_win_remap(dev_drv, order); } return count; @@ -338,7 +350,8 @@ static ssize_t set_dsp_lut(struct device *dev, struct device_attribute *attr, printk("\n"); } #endif - dev_drv->ops->set_dsp_lut(dev_drv, dsp_lut); + if (dev_drv->ops->set_dsp_lut) + dev_drv->ops->set_dsp_lut(dev_drv, dsp_lut); return count; } @@ -367,7 +380,8 @@ static ssize_t set_dsp_cabc(struct device *dev, struct device_attribute *attr, if (ret) return ret; - ret = dev_drv->ops->set_dsp_cabc(dev_drv, mode); + if (dev_drv->ops->set_dsp_cabc) + ret = dev_drv->ops->set_dsp_cabc(dev_drv, mode); if (ret < 0) return ret; -- 2.34.1