diff options
author | Antonino A. Daplas <adaplas@gmail.com> | 2006-01-09 23:53:40 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-10 11:01:51 -0500 |
commit | 918799ab6f278805d4811770e9b18ae36408c17f (patch) | |
tree | f1700579a541c5d99467b965099e3238691ce4d5 | |
parent | ade9185a39aa2bc51f95b4899836e59df671d844 (diff) |
[PATCH] nvidiafb: Reduce stack usage
Reduce stack usage of NVCommonSetup()
Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/video/nvidia/nv_proto.h | 2 | ||||
-rw-r--r-- | drivers/video/nvidia/nv_setup.c | 34 | ||||
-rw-r--r-- | drivers/video/nvidia/nvidia.c | 3 |
3 files changed, 26 insertions, 13 deletions
diff --git a/drivers/video/nvidia/nv_proto.h b/drivers/video/nvidia/nv_proto.h index 3353103e8b0b..b149a690ee0f 100644 --- a/drivers/video/nvidia/nv_proto.h +++ b/drivers/video/nvidia/nv_proto.h | |||
@@ -4,7 +4,7 @@ | |||
4 | #define __NV_PROTO_H__ | 4 | #define __NV_PROTO_H__ |
5 | 5 | ||
6 | /* in nv_setup.c */ | 6 | /* in nv_setup.c */ |
7 | void NVCommonSetup(struct fb_info *info); | 7 | int NVCommonSetup(struct fb_info *info); |
8 | void NVWriteCrtc(struct nvidia_par *par, u8 index, u8 value); | 8 | void NVWriteCrtc(struct nvidia_par *par, u8 index, u8 value); |
9 | u8 NVReadCrtc(struct nvidia_par *par, u8 index); | 9 | u8 NVReadCrtc(struct nvidia_par *par, u8 index); |
10 | void NVWriteGr(struct nvidia_par *par, u8 index, u8 value); | 10 | void NVWriteGr(struct nvidia_par *par, u8 index, u8 value); |
diff --git a/drivers/video/nvidia/nv_setup.c b/drivers/video/nvidia/nv_setup.c index 2c024523c622..a18a9aebf05f 100644 --- a/drivers/video/nvidia/nv_setup.c +++ b/drivers/video/nvidia/nv_setup.c | |||
@@ -290,22 +290,29 @@ static void nv10GetConfig(struct nvidia_par *par) | |||
290 | par->MaxVClockFreqKHz = par->twoStagePLL ? 400000 : 350000; | 290 | par->MaxVClockFreqKHz = par->twoStagePLL ? 400000 : 350000; |
291 | } | 291 | } |
292 | 292 | ||
293 | void NVCommonSetup(struct fb_info *info) | 293 | int NVCommonSetup(struct fb_info *info) |
294 | { | 294 | { |
295 | struct nvidia_par *par = info->par; | 295 | struct nvidia_par *par = info->par; |
296 | struct fb_var_screeninfo var; | 296 | struct fb_var_screeninfo *var; |
297 | u16 implementation = par->Chipset & 0x0ff0; | 297 | u16 implementation = par->Chipset & 0x0ff0; |
298 | u8 *edidA = NULL, *edidB = NULL; | 298 | u8 *edidA = NULL, *edidB = NULL; |
299 | struct fb_monspecs monitorA, monitorB; | 299 | struct fb_monspecs *monitorA, *monitorB; |
300 | struct fb_monspecs *monA = NULL, *monB = NULL; | 300 | struct fb_monspecs *monA = NULL, *monB = NULL; |
301 | int mobile = 0; | 301 | int mobile = 0; |
302 | int tvA = 0; | 302 | int tvA = 0; |
303 | int tvB = 0; | 303 | int tvB = 0; |
304 | int FlatPanel = -1; /* really means the CRTC is slaved */ | 304 | int FlatPanel = -1; /* really means the CRTC is slaved */ |
305 | int Television = 0; | 305 | int Television = 0; |
306 | int err = 0; | ||
306 | 307 | ||
307 | memset(&monitorA, 0, sizeof(struct fb_monspecs)); | 308 | var = kzalloc(sizeof(struct fb_var_screeninfo), GFP_KERNEL); |
308 | memset(&monitorB, 0, sizeof(struct fb_monspecs)); | 309 | monitorA = kzalloc(sizeof(struct fb_monspecs), GFP_KERNEL); |
310 | monitorB = kzalloc(sizeof(struct fb_monspecs), GFP_KERNEL); | ||
311 | |||
312 | if (!var || !monitorA || !monitorB) { | ||
313 | err = -ENOMEM; | ||
314 | goto done; | ||
315 | } | ||
309 | 316 | ||
310 | par->PRAMIN = par->REGS + (0x00710000 / 4); | 317 | par->PRAMIN = par->REGS + (0x00710000 / 4); |
311 | par->PCRTC0 = par->REGS + (0x00600000 / 4); | 318 | par->PCRTC0 = par->REGS + (0x00600000 / 4); |
@@ -407,9 +414,9 @@ void NVCommonSetup(struct fb_info *info) | |||
407 | par->CRTCnumber = 0; | 414 | par->CRTCnumber = 0; |
408 | if (nvidia_probe_i2c_connector(info, 1, &edidA)) | 415 | if (nvidia_probe_i2c_connector(info, 1, &edidA)) |
409 | nvidia_probe_of_connector(info, 1, &edidA); | 416 | nvidia_probe_of_connector(info, 1, &edidA); |
410 | if (edidA && !fb_parse_edid(edidA, &var)) { | 417 | if (edidA && !fb_parse_edid(edidA, var)) { |
411 | printk("nvidiafb: EDID found from BUS1\n"); | 418 | printk("nvidiafb: EDID found from BUS1\n"); |
412 | monA = &monitorA; | 419 | monA = monitorA; |
413 | fb_edid_to_monspecs(edidA, monA); | 420 | fb_edid_to_monspecs(edidA, monA); |
414 | FlatPanel = (monA->input & FB_DISP_DDI) ? 1 : 0; | 421 | FlatPanel = (monA->input & FB_DISP_DDI) ? 1 : 0; |
415 | 422 | ||
@@ -495,17 +502,17 @@ void NVCommonSetup(struct fb_info *info) | |||
495 | 502 | ||
496 | if (nvidia_probe_i2c_connector(info, 1, &edidA)) | 503 | if (nvidia_probe_i2c_connector(info, 1, &edidA)) |
497 | nvidia_probe_of_connector(info, 1, &edidA); | 504 | nvidia_probe_of_connector(info, 1, &edidA); |
498 | if (edidA && !fb_parse_edid(edidA, &var)) { | 505 | if (edidA && !fb_parse_edid(edidA, var)) { |
499 | printk("nvidiafb: EDID found from BUS1\n"); | 506 | printk("nvidiafb: EDID found from BUS1\n"); |
500 | monA = &monitorA; | 507 | monA = monitorA; |
501 | fb_edid_to_monspecs(edidA, monA); | 508 | fb_edid_to_monspecs(edidA, monA); |
502 | } | 509 | } |
503 | 510 | ||
504 | if (nvidia_probe_i2c_connector(info, 2, &edidB)) | 511 | if (nvidia_probe_i2c_connector(info, 2, &edidB)) |
505 | nvidia_probe_of_connector(info, 2, &edidB); | 512 | nvidia_probe_of_connector(info, 2, &edidB); |
506 | if (edidB && !fb_parse_edid(edidB, &var)) { | 513 | if (edidB && !fb_parse_edid(edidB, var)) { |
507 | printk("nvidiafb: EDID found from BUS2\n"); | 514 | printk("nvidiafb: EDID found from BUS2\n"); |
508 | monB = &monitorB; | 515 | monB = monitorB; |
509 | fb_edid_to_monspecs(edidB, monB); | 516 | fb_edid_to_monspecs(edidB, monB); |
510 | } | 517 | } |
511 | 518 | ||
@@ -640,4 +647,9 @@ void NVCommonSetup(struct fb_info *info) | |||
640 | 647 | ||
641 | kfree(edidA); | 648 | kfree(edidA); |
642 | kfree(edidB); | 649 | kfree(edidB); |
650 | done: | ||
651 | kfree(var); | ||
652 | kfree(monitorA); | ||
653 | kfree(monitorB); | ||
654 | return err; | ||
643 | } | 655 | } |
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c index ae6f2ff70abf..dbcb8962e57d 100644 --- a/drivers/video/nvidia/nvidia.c +++ b/drivers/video/nvidia/nvidia.c | |||
@@ -1617,7 +1617,8 @@ static int __devinit nvidiafb_probe(struct pci_dev *pd, | |||
1617 | 1617 | ||
1618 | sprintf(nvidiafb_fix.id, "NV%x", (pd->device & 0x0ff0) >> 4); | 1618 | sprintf(nvidiafb_fix.id, "NV%x", (pd->device & 0x0ff0) >> 4); |
1619 | 1619 | ||
1620 | NVCommonSetup(info); | 1620 | if (NVCommonSetup(info)) |
1621 | goto err_out_arch; | ||
1621 | 1622 | ||
1622 | par->FbAddress = nvidiafb_fix.smem_start; | 1623 | par->FbAddress = nvidiafb_fix.smem_start; |
1623 | par->FbMapSize = par->RamAmountKBytes * 1024; | 1624 | par->FbMapSize = par->RamAmountKBytes * 1024; |