Commit 918799ab authored by Antonino A. Daplas's avatar Antonino A. Daplas Committed by Linus Torvalds

[PATCH] nvidiafb: Reduce stack usage

Reduce stack usage of NVCommonSetup()
Signed-off-by: default avatarAntonino Daplas <adaplas@pol.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ade9185a
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#define __NV_PROTO_H__ #define __NV_PROTO_H__
/* in nv_setup.c */ /* in nv_setup.c */
void NVCommonSetup(struct fb_info *info); int NVCommonSetup(struct fb_info *info);
void NVWriteCrtc(struct nvidia_par *par, u8 index, u8 value); void NVWriteCrtc(struct nvidia_par *par, u8 index, u8 value);
u8 NVReadCrtc(struct nvidia_par *par, u8 index); u8 NVReadCrtc(struct nvidia_par *par, u8 index);
void NVWriteGr(struct nvidia_par *par, u8 index, u8 value); void NVWriteGr(struct nvidia_par *par, u8 index, u8 value);
......
...@@ -290,22 +290,29 @@ static void nv10GetConfig(struct nvidia_par *par) ...@@ -290,22 +290,29 @@ static void nv10GetConfig(struct nvidia_par *par)
par->MaxVClockFreqKHz = par->twoStagePLL ? 400000 : 350000; par->MaxVClockFreqKHz = par->twoStagePLL ? 400000 : 350000;
} }
void NVCommonSetup(struct fb_info *info) int NVCommonSetup(struct fb_info *info)
{ {
struct nvidia_par *par = info->par; struct nvidia_par *par = info->par;
struct fb_var_screeninfo var; struct fb_var_screeninfo *var;
u16 implementation = par->Chipset & 0x0ff0; u16 implementation = par->Chipset & 0x0ff0;
u8 *edidA = NULL, *edidB = NULL; u8 *edidA = NULL, *edidB = NULL;
struct fb_monspecs monitorA, monitorB; struct fb_monspecs *monitorA, *monitorB;
struct fb_monspecs *monA = NULL, *monB = NULL; struct fb_monspecs *monA = NULL, *monB = NULL;
int mobile = 0; int mobile = 0;
int tvA = 0; int tvA = 0;
int tvB = 0; int tvB = 0;
int FlatPanel = -1; /* really means the CRTC is slaved */ int FlatPanel = -1; /* really means the CRTC is slaved */
int Television = 0; int Television = 0;
int err = 0;
memset(&monitorA, 0, sizeof(struct fb_monspecs)); var = kzalloc(sizeof(struct fb_var_screeninfo), GFP_KERNEL);
memset(&monitorB, 0, sizeof(struct fb_monspecs)); monitorA = kzalloc(sizeof(struct fb_monspecs), GFP_KERNEL);
monitorB = kzalloc(sizeof(struct fb_monspecs), GFP_KERNEL);
if (!var || !monitorA || !monitorB) {
err = -ENOMEM;
goto done;
}
par->PRAMIN = par->REGS + (0x00710000 / 4); par->PRAMIN = par->REGS + (0x00710000 / 4);
par->PCRTC0 = par->REGS + (0x00600000 / 4); par->PCRTC0 = par->REGS + (0x00600000 / 4);
...@@ -407,9 +414,9 @@ void NVCommonSetup(struct fb_info *info) ...@@ -407,9 +414,9 @@ void NVCommonSetup(struct fb_info *info)
par->CRTCnumber = 0; par->CRTCnumber = 0;
if (nvidia_probe_i2c_connector(info, 1, &edidA)) if (nvidia_probe_i2c_connector(info, 1, &edidA))
nvidia_probe_of_connector(info, 1, &edidA); nvidia_probe_of_connector(info, 1, &edidA);
if (edidA && !fb_parse_edid(edidA, &var)) { if (edidA && !fb_parse_edid(edidA, var)) {
printk("nvidiafb: EDID found from BUS1\n"); printk("nvidiafb: EDID found from BUS1\n");
monA = &monitorA; monA = monitorA;
fb_edid_to_monspecs(edidA, monA); fb_edid_to_monspecs(edidA, monA);
FlatPanel = (monA->input & FB_DISP_DDI) ? 1 : 0; FlatPanel = (monA->input & FB_DISP_DDI) ? 1 : 0;
...@@ -495,17 +502,17 @@ void NVCommonSetup(struct fb_info *info) ...@@ -495,17 +502,17 @@ void NVCommonSetup(struct fb_info *info)
if (nvidia_probe_i2c_connector(info, 1, &edidA)) if (nvidia_probe_i2c_connector(info, 1, &edidA))
nvidia_probe_of_connector(info, 1, &edidA); nvidia_probe_of_connector(info, 1, &edidA);
if (edidA && !fb_parse_edid(edidA, &var)) { if (edidA && !fb_parse_edid(edidA, var)) {
printk("nvidiafb: EDID found from BUS1\n"); printk("nvidiafb: EDID found from BUS1\n");
monA = &monitorA; monA = monitorA;
fb_edid_to_monspecs(edidA, monA); fb_edid_to_monspecs(edidA, monA);
} }
if (nvidia_probe_i2c_connector(info, 2, &edidB)) if (nvidia_probe_i2c_connector(info, 2, &edidB))
nvidia_probe_of_connector(info, 2, &edidB); nvidia_probe_of_connector(info, 2, &edidB);
if (edidB && !fb_parse_edid(edidB, &var)) { if (edidB && !fb_parse_edid(edidB, var)) {
printk("nvidiafb: EDID found from BUS2\n"); printk("nvidiafb: EDID found from BUS2\n");
monB = &monitorB; monB = monitorB;
fb_edid_to_monspecs(edidB, monB); fb_edid_to_monspecs(edidB, monB);
} }
...@@ -640,4 +647,9 @@ void NVCommonSetup(struct fb_info *info) ...@@ -640,4 +647,9 @@ void NVCommonSetup(struct fb_info *info)
kfree(edidA); kfree(edidA);
kfree(edidB); kfree(edidB);
done:
kfree(var);
kfree(monitorA);
kfree(monitorB);
return err;
} }
...@@ -1617,7 +1617,8 @@ static int __devinit nvidiafb_probe(struct pci_dev *pd, ...@@ -1617,7 +1617,8 @@ static int __devinit nvidiafb_probe(struct pci_dev *pd,
sprintf(nvidiafb_fix.id, "NV%x", (pd->device & 0x0ff0) >> 4); sprintf(nvidiafb_fix.id, "NV%x", (pd->device & 0x0ff0) >> 4);
NVCommonSetup(info); if (NVCommonSetup(info))
goto err_out_arch;
par->FbAddress = nvidiafb_fix.smem_start; par->FbAddress = nvidiafb_fix.smem_start;
par->FbMapSize = par->RamAmountKBytes * 1024; par->FbMapSize = par->RamAmountKBytes * 1024;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment