Commit 684dcd056178a04374c71459dbd2b18c6d958ef7

Authored by Paul Mundt
1 parent e33afddca1

video: hitfb: Convert to framebuffer_alloc().

Follows the sh_mobile_lcdcfb change.

Also fixes up a memory leak with cmap allocation.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>

Showing 1 changed file with 35 additions and 14 deletions Side-by-side Diff

drivers/video/hitfb.c
... ... @@ -44,9 +44,6 @@
44 44 .accel = FB_ACCEL_NONE,
45 45 };
46 46  
47   -static u32 pseudo_palette[16];
48   -static struct fb_info fb_info;
49   -
50 47 static inline void hitfb_accel_wait(void)
51 48 {
52 49 while (fb_readw(HD64461_GRCFGR) & HD64461_GRCFGR_ACCSTATUS) ;
... ... @@ -331,6 +328,8 @@
331 328 static int __init hitfb_probe(struct platform_device *dev)
332 329 {
333 330 unsigned short lcdclor, ldr3, ldvndr;
  331 + struct fb_info *info;
  332 + int ret;
334 333  
335 334 if (fb_get_options("hitfb", NULL))
336 335 return -ENODEV;
337 336  
338 337  
339 338  
340 339  
341 340  
342 341  
343 342  
... ... @@ -384,28 +383,50 @@
384 383 break;
385 384 }
386 385  
387   - fb_info.fbops = &hitfb_ops;
388   - fb_info.var = hitfb_var;
389   - fb_info.fix = hitfb_fix;
390   - fb_info.pseudo_palette = pseudo_palette;
391   - fb_info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
  386 + info = framebuffer_alloc(sizeof(u32) * 16, &dev->dev);
  387 + if (unlikely(!info))
  388 + return -ENOMEM;
  389 +
  390 + info->fbops = &hitfb_ops;
  391 + info->var = hitfb_var;
  392 + info->fix = hitfb_fix;
  393 + info->pseudo_palette = info->par;
  394 + info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
392 395 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
393 396  
394   - fb_info.screen_base = (void *)hitfb_fix.smem_start;
  397 + info->screen_base = (void *)hitfb_fix.smem_start;
395 398  
396   - fb_alloc_cmap(&fb_info.cmap, 256, 0);
  399 + ret = fb_alloc_cmap(&info->cmap, 256, 0);
  400 + if (unlikely(ret < 0))
  401 + goto err_fb;
397 402  
398   - if (register_framebuffer(&fb_info) < 0)
399   - return -EINVAL;
  403 + ret = register_framebuffer(info);
  404 + if (unlikely(ret < 0))
  405 + goto err;
400 406  
  407 + platform_set_drvdata(dev, info);
  408 +
401 409 printk(KERN_INFO "fb%d: %s frame buffer device\n",
402   - fb_info.node, fb_info.fix.id);
  410 + info->node, info->fix.id);
  411 +
403 412 return 0;
  413 +
  414 +err:
  415 + fb_dealloc_cmap(&info->cmap);
  416 +err_fb:
  417 + framebuffer_release(info);
  418 + return ret;
404 419 }
405 420  
406 421 static int __exit hitfb_remove(struct platform_device *dev)
407 422 {
408   - return unregister_framebuffer(&fb_info);
  423 + struct fb_info *info = platform_get_drvdata(dev);
  424 +
  425 + unregister_framebuffer(info);
  426 + fb_dealloc_cmap(&info->cmap);
  427 + framebuffer_release(info);
  428 +
  429 + return 0;
409 430 }
410 431  
411 432 #ifdef CONFIG_PM