Description: 1. use request_firmware() instead of system calls 2. remove direct access to registered_fb[] in load_56rle_image() 3. check load_565rle_image() return value in msm_fb.c 4. move load_565rle_image() extern to msm_fb.h change INIT_IMAGE_FILE and add one-line comment Signed-off-by: Xiaochen Wang <wangxiaochen0@xxxxxxxxx> --- drivers/staging/msm/logo.c | 43 +++++++++++------------------------------ drivers/staging/msm/msm_fb.c | 9 +++---- drivers/staging/msm/msm_fb.h | 5 ++++ 3 files changed, 21 insertions(+), 36 deletions(-) diff --git a/drivers/staging/msm/logo.c b/drivers/staging/msm/logo.c index 7272765..90eb150 100644 --- a/drivers/staging/msm/logo.c +++ b/drivers/staging/msm/logo.c @@ -19,10 +19,11 @@ #include <linux/fb.h> #include <linux/vt_kern.h> #include <linux/unistd.h> -#include <linux/syscalls.h> #include <linux/irq.h> #include <asm/system.h> +#include <linux/firmware.h> +#include "msm_fb.h" #define fb_width(fb) ((fb)->var.xres) #define fb_height(fb) ((fb)->var.yres) @@ -37,46 +38,29 @@ static void memset16(void *_ptr, unsigned short val, unsigned count) } /* 565RLE image format: [count(2 bytes), rle(2 bytes)] */ -int load_565rle_image(char *filename) +int load_565rle_image(char *filename, struct msm_fb_data_type *mfd) { + const struct firmware *fw; struct fb_info *info; - int fd, err = 0; unsigned count, max; - unsigned short *data, *bits, *ptr; + unsigned short *bits, *ptr; - info = registered_fb[0]; + info = mfd->fbi; if (!info) { printk(KERN_WARNING "%s: Can not access framebuffer\n", __func__); return -ENODEV; } - fd = sys_open(filename, O_RDONLY, 0); - if (fd < 0) { - printk(KERN_WARNING "%s: Can not open %s\n", + if (request_firmware(&fw, filename, &mfd->pdev->dev)) { + printk(KERN_WARNING "%s: Can not load file %s\n", __func__, filename); return -ENOENT; } - count = (unsigned)sys_lseek(fd, (off_t)0, 2); - if (count == 0) { - sys_close(fd); - err = -EIO; - goto err_logo_close_file; - } - sys_lseek(fd, (off_t)0, 0); - data = kmalloc(count, GFP_KERNEL); - if (!data) { - printk(KERN_WARNING "%s: Can not alloc data\n", __func__); - err = -ENOMEM; - goto err_logo_close_file; - } - if ((unsigned)sys_read(fd, (char *)data, count) != count) { - err = -EIO; - goto err_logo_free_data; - } + count = fw->size; + ptr = (unsigned short *)(fw->data); max = fb_width(info) * fb_height(info); - ptr = data; bits = (unsigned short *)(info->screen_base); while (count > 3) { unsigned n = ptr[0]; @@ -89,10 +73,7 @@ int load_565rle_image(char *filename) count -= 4; } -err_logo_free_data: - kfree(data); -err_logo_close_file: - sys_close(fd); - return err; + release_firmware(fw); + return 0; } EXPORT_SYMBOL(load_565rle_image); diff --git a/drivers/staging/msm/msm_fb.c b/drivers/staging/msm/msm_fb.c index a2f29d4..b6d8039 100644 --- a/drivers/staging/msm/msm_fb.c +++ b/drivers/staging/msm/msm_fb.c @@ -48,10 +48,6 @@ #include "mdp.h" #include "mdp4.h" -#ifdef CONFIG_FB_MSM_LOGO -#define INIT_IMAGE_FILE "/logo.rle" -extern int load_565rle_image(char *filename); -#endif #define pgprot_noncached(prot) \ @@ -975,7 +971,10 @@ static int msm_fb_register(struct msm_fb_data_type *mfd) mfd->index, fbi->var.xres, fbi->var.yres, fbi->fix.smem_len); #ifdef CONFIG_FB_MSM_LOGO - if (!load_565rle_image(INIT_IMAGE_FILE)) ; /* Flip buffer */ + /* Flip buffer */ + ret = load_565rle_image(INIT_IMAGE_FILE, mfd); + if (ret < 0) + printk(KERN_ERR "%s: failed to load image\n", __func__); #endif ret = 0; diff --git a/drivers/staging/msm/msm_fb.h b/drivers/staging/msm/msm_fb.h index 4bca6d2..b83588f 100644 --- a/drivers/staging/msm/msm_fb.h +++ b/drivers/staging/msm/msm_fb.h @@ -155,4 +155,9 @@ int msm_fb_detect_client(const char *name); void msm_fb_config_backlight(struct msm_fb_data_type *mfd); #endif +#ifdef CONFIG_FB_MSM_LOGO +#define INIT_IMAGE_FILE "logo.rle" /* Image file is used as firmware. */ +extern int load_565rle_image(char *filename, struct msm_fb_data_type *mfd); +#endif + #endif /* MSM_FB_H */ -- 1.7.2.3 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/devel