Skip to contentSkip to conversation

fbdev: Reduce stack usage of intelfb

PATCH In review Antonino A. Daplas 1 participant 1 message Dec 21, 2004 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 9/9 fbdev: Reduce stack usage of intelfb

Reduce stack usage in intelfb_set_par() from 2404 bytes (on x86-32) to 12 bytes.

---

 intelfbdrv.c |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)
drivers/video/intelfb/intelfbdrv.c +16 -9
diff -Nru a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
@@ -1234,8 +1234,7 @@
 static int
 intelfb_set_par(struct fb_info *info)
 {
-	struct intelfb_hwstate hw;
-
+ 	struct intelfb_hwstate *hw;
         struct intelfb_info *dinfo = GET_DINFO(info);
 
 	if (FIXED_MODE(dinfo)) {
@@ -1243,6 +1242,10 @@
 		return -EINVAL;
 	}
 
+ 	hw = kmalloc(sizeof(*hw), GFP_ATOMIC);
+ 	if (!hw)
+ 		return -ENOMEM;
+
 	DBG_MSG("intelfb_set_par (%dx%d-%d)\n", info->var.xres,
 		info->var.yres, info->var.bits_per_pixel);
 
@@ -1251,15 +1254,15 @@
 	if (dinfo->accel)
 		intelfbhw_2d_stop(dinfo);
 
-	hw = dinfo->save_state;
-	if (intelfbhw_mode_to_hw(dinfo, &hw, &info->var))
-		return -EINVAL;
-	if (intelfbhw_program_mode(dinfo, &hw, 0))
-		return -EINVAL;
+ 	memcpy(hw, &dinfo->save_state, sizeof(*hw));
+ 	if (intelfbhw_mode_to_hw(dinfo, hw, &info->var))
+ 		goto invalid_mode;
+ 	if (intelfbhw_program_mode(dinfo, hw, 0))
+ 		goto invalid_mode;
 
 #if REGDUMP > 0
-	intelfbhw_read_hw_state(dinfo, &hw, 0);
-	intelfbhw_print_hw_state(dinfo, &hw);
+ 	intelfbhw_read_hw_state(dinfo, hw, 0);
+ 	intelfbhw_print_hw_state(dinfo, hw);
 #endif
 
 	update_dinfo(dinfo, &info->var);
@@ -1278,7 +1281,11 @@
 	} else {
 		info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
 	}
+	kfree(hw);
 	return 0;
+invalid_mode:
+	kfree(hw);
+	return -EINVAL;
 }
 
 static int

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/