aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/tgafb.c
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@linux-mips.org>2007-02-12 03:54:52 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-12 12:48:41 -0500
commitee9a25e5df81f4392439055c28989dfd4b18d894 (patch)
tree324dc90db08ead77c9ed064e01094c2e0ea9d00e /drivers/video/tgafb.c
parente019630e78e3482c2386d18cbdc7a4c54f7a809c (diff)
[PATCH] tgafb: switch to framebuffer_alloc()
This is a set of changes to update the driver to the framebuffer_alloc() API. Included, there is also a fix to a memory leak due to the colour map allocation not being freed upon driver's removal. Aside from the fix there are no functional changes. Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org> Cc: James Simmons <jsimmons@infradead.org> Cc: "Antonino A. Daplas" <adaplas@pol.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/tgafb.c')
-rw-r--r--drivers/video/tgafb.c61
1 files changed, 28 insertions, 33 deletions
diff --git a/drivers/video/tgafb.c b/drivers/video/tgafb.c
index 4b88fab83b74..0a00a6cc7c2b 100644
--- a/drivers/video/tgafb.c
+++ b/drivers/video/tgafb.c
@@ -1342,14 +1342,10 @@ tgafb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
1342 TGA_24PLUSZ_FB_OFFSET 1342 TGA_24PLUSZ_FB_OFFSET
1343 }; 1343 };
1344 1344
1345 struct all_info {
1346 struct fb_info info;
1347 struct tga_par par;
1348 u32 pseudo_palette[16];
1349 } *all;
1350
1351 void __iomem *mem_base; 1345 void __iomem *mem_base;
1352 unsigned long bar0_start, bar0_len; 1346 unsigned long bar0_start, bar0_len;
1347 struct fb_info *info;
1348 struct tga_par *par;
1353 u8 tga_type; 1349 u8 tga_type;
1354 int ret; 1350 int ret;
1355 1351
@@ -1360,13 +1356,14 @@ tgafb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
1360 } 1356 }
1361 1357
1362 /* Allocate the fb and par structures. */ 1358 /* Allocate the fb and par structures. */
1363 all = kmalloc(sizeof(*all), GFP_KERNEL); 1359 info = framebuffer_alloc(sizeof(struct tga_par), &pdev->dev);
1364 if (!all) { 1360 if (!info) {
1365 printk(KERN_ERR "tgafb: Cannot allocate memory\n"); 1361 printk(KERN_ERR "tgafb: Cannot allocate memory\n");
1366 return -ENOMEM; 1362 return -ENOMEM;
1367 } 1363 }
1368 memset(all, 0, sizeof(*all)); 1364
1369 pci_set_drvdata(pdev, all); 1365 par = info->par;
1366 pci_set_drvdata(pdev, info);
1370 1367
1371 /* Request the mem regions. */ 1368 /* Request the mem regions. */
1372 bar0_start = pci_resource_start(pdev, 0); 1369 bar0_start = pci_resource_start(pdev, 0);
@@ -1386,25 +1383,23 @@ tgafb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
1386 1383
1387 /* Grab info about the card. */ 1384 /* Grab info about the card. */
1388 tga_type = (readl(mem_base) >> 12) & 0x0f; 1385 tga_type = (readl(mem_base) >> 12) & 0x0f;
1389 all->par.pdev = pdev; 1386 par->pdev = pdev;
1390 all->par.tga_mem_base = mem_base; 1387 par->tga_mem_base = mem_base;
1391 all->par.tga_fb_base = mem_base + fb_offset_presets[tga_type]; 1388 par->tga_fb_base = mem_base + fb_offset_presets[tga_type];
1392 all->par.tga_regs_base = mem_base + TGA_REGS_OFFSET; 1389 par->tga_regs_base = mem_base + TGA_REGS_OFFSET;
1393 all->par.tga_type = tga_type; 1390 par->tga_type = tga_type;
1394 pci_read_config_byte(pdev, PCI_REVISION_ID, &all->par.tga_chip_rev); 1391 pci_read_config_byte(pdev, PCI_REVISION_ID, &par->tga_chip_rev);
1395 1392
1396 /* Setup framebuffer. */ 1393 /* Setup framebuffer. */
1397 all->info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA | 1394 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA |
1398 FBINFO_HWACCEL_IMAGEBLIT | FBINFO_HWACCEL_FILLRECT; 1395 FBINFO_HWACCEL_IMAGEBLIT | FBINFO_HWACCEL_FILLRECT;
1399 all->info.fbops = &tgafb_ops; 1396 info->fbops = &tgafb_ops;
1400 all->info.screen_base = all->par.tga_fb_base; 1397 info->screen_base = par->tga_fb_base;
1401 all->info.par = &all->par; 1398 info->pseudo_palette = (void *)(par + 1);
1402 all->info.pseudo_palette = all->pseudo_palette;
1403 1399
1404 /* This should give a reasonable default video mode. */ 1400 /* This should give a reasonable default video mode. */
1405 1401
1406 ret = fb_find_mode(&all->info.var, &all->info, mode_option, 1402 ret = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL,
1407 NULL, 0, NULL,
1408 tga_type == TGA_TYPE_8PLANE ? 8 : 32); 1403 tga_type == TGA_TYPE_8PLANE ? 8 : 32);
1409 if (ret == 0 || ret == 4) { 1404 if (ret == 0 || ret == 4) {
1410 printk(KERN_ERR "tgafb: Could not find valid video mode\n"); 1405 printk(KERN_ERR "tgafb: Could not find valid video mode\n");
@@ -1412,29 +1407,28 @@ tgafb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
1412 goto err1; 1407 goto err1;
1413 } 1408 }
1414 1409
1415 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { 1410 if (fb_alloc_cmap(&info->cmap, 256, 0)) {
1416 printk(KERN_ERR "tgafb: Could not allocate color map\n"); 1411 printk(KERN_ERR "tgafb: Could not allocate color map\n");
1417 ret = -ENOMEM; 1412 ret = -ENOMEM;
1418 goto err1; 1413 goto err1;
1419 } 1414 }
1420 1415
1421 tgafb_set_par(&all->info); 1416 tgafb_set_par(info);
1422 tgafb_init_fix(&all->info); 1417 tgafb_init_fix(info);
1423 1418
1424 all->info.device = &pdev->dev; 1419 if (register_framebuffer(info) < 0) {
1425 if (register_framebuffer(&all->info) < 0) {
1426 printk(KERN_ERR "tgafb: Could not register framebuffer\n"); 1420 printk(KERN_ERR "tgafb: Could not register framebuffer\n");
1427 ret = -EINVAL; 1421 ret = -EINVAL;
1428 goto err1; 1422 goto err1;
1429 } 1423 }
1430 1424
1431 printk(KERN_INFO "tgafb: DC21030 [TGA] detected, rev=0x%02x\n", 1425 printk(KERN_INFO "tgafb: DC21030 [TGA] detected, rev=0x%02x\n",
1432 all->par.tga_chip_rev); 1426 par->tga_chip_rev);
1433 printk(KERN_INFO "tgafb: at PCI bus %d, device %d, function %d\n", 1427 printk(KERN_INFO "tgafb: at PCI bus %d, device %d, function %d\n",
1434 pdev->bus->number, PCI_SLOT(pdev->devfn), 1428 pdev->bus->number, PCI_SLOT(pdev->devfn),
1435 PCI_FUNC(pdev->devfn)); 1429 PCI_FUNC(pdev->devfn));
1436 printk(KERN_INFO "fb%d: %s frame buffer device at 0x%lx\n", 1430 printk(KERN_INFO "fb%d: %s frame buffer device at 0x%lx\n",
1437 all->info.node, all->info.fix.id, bar0_start); 1431 info->node, info->fix.id, bar0_start);
1438 1432
1439 return 0; 1433 return 0;
1440 1434
@@ -1443,7 +1437,7 @@ tgafb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
1443 iounmap(mem_base); 1437 iounmap(mem_base);
1444 release_mem_region(bar0_start, bar0_len); 1438 release_mem_region(bar0_start, bar0_len);
1445 err0: 1439 err0:
1446 kfree(all); 1440 framebuffer_release(info);
1447 return ret; 1441 return ret;
1448} 1442}
1449 1443
@@ -1456,10 +1450,11 @@ tgafb_pci_unregister(struct pci_dev *pdev)
1456 if (!info) 1450 if (!info)
1457 return; 1451 return;
1458 unregister_framebuffer(info); 1452 unregister_framebuffer(info);
1453 fb_dealloc_cmap(&info->cmap);
1459 iounmap(par->tga_mem_base); 1454 iounmap(par->tga_mem_base);
1460 release_mem_region(pci_resource_start(pdev, 0), 1455 release_mem_region(pci_resource_start(pdev, 0),
1461 pci_resource_len(pdev, 0)); 1456 pci_resource_len(pdev, 0));
1462 kfree(info); 1457 framebuffer_release(info);
1463} 1458}
1464 1459
1465#ifdef MODULE 1460#ifdef MODULE