[patch 09/11] ps3fb: Round up video modes

Geert Uytterhoeven Geert.Uytterhoeven at sonycom.com
Sun Jan 27 20:53:24 EST 2008


On Sat, 26 Jan 2008, Andrew Morton wrote:
> > On Fri, 25 Jan 2008 16:06:32 +0100 Geert Uytterhoeven <Geert.Uytterhoeven at sonycom.com> wrote:
> >  static int ps3fb_cmp_mode(const struct fb_videomode *vmode,
> >  			  const struct fb_var_screeninfo *var)
> >  {
> > -	/* resolution + black border must match a native resolution */
> > -	if (vmode->left_margin + vmode->xres + vmode->right_margin !=
> > -	    var->left_margin + var->xres + var->right_margin ||
> > -	    vmode->upper_margin + vmode->yres + vmode->lower_margin !=
> > -	    var->upper_margin + var->yres + var->lower_margin)
> > +	long xres, yres, left_margin, right_margin, upper_margin, lower_margin;
> > +	long dx, dy;
> 
> I don't think these need to be longs?  And they probably don't need to be
> signed either.
> 
> If a switch to u32 improves the code any, it might be worth doing..
> 
> All the typecasting which this patch adds makes me wonder if the choice
> of types requires a general revisit...

The problems are:
  - Adding up the various fb_var_screeninfo.* timing fields (which are u32) may
    cause overflows. That's why I use `long' (which is 64-bit on ppc64).
    Perhaps I should change it to s64 for readability?
  - If I make xres, yres, left_margin, right_margin, upper_margin, lower_margin
    u32, I need more casts for calculating dx and dy. Probably u64 would be OK,
    though.
  - dx and dy are signed because they can be smaller than 0.

With kind regards,

Geert Uytterhoeven
Software Architect

Sony Network and Software Technology Center Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone:    +32 (0)2 700 8453
Fax:      +32 (0)2 700 8622
E-mail:   Geert.Uytterhoeven at sonycom.com
Internet: http://www.sony-europe.com/

Sony Network and Software Technology Center Europe
A division of Sony Service Centre (Europe) N.V.
Registered office: Technologielaan 7 · B-1840 Londerzeel · Belgium
VAT BE 0413.825.160 · RPR Brussels
Fortis Bank Zaventem · Swift GEBABEBB08A · IBAN BE39001382358619


More information about the Linuxppc-dev mailing list