Re: [Linux-fbdev-devel] fb: modedb uses wrong default_mode

From: James Simmons
Date: Mon Nov 20 2006 - 11:48:32 EST



> James Simmons <jsimmons@xxxxxxxxxxxxx> wrote:
>
> > Who knows how many drivers get this wrong. BTW Jordan is right.
> > DEFAULT_MODEDB_INDEX is unless. Also we don't need dbsize anymore.
> > Jordan did point out a error in fb_find_mode. It should be
> >
> > if (!db)
> > db = modedb;
> > dbsize = ARRAY_SIZE(modedb);
> >
> > if (!default_mode)
> > default_mode = &db[DEFAULT_MODEDB_INDEX];
> > if (!default_bpp)
> > default_bpp = 8;
> >
> > db will always be set.
>
> I think we do need dbsize, and that the code which I have now:

I really don't trust dbsize. The driver writer can pass in the wrong
number. Whereas ARRAY_SIZE will always be correct. Lets take the position
that we use dbsize then we need to test if dbsize is greater than the
really size of the modedb. The dbsize parameter was for the days before we
had ARRAY_SIZE.

> int fb_find_mode(struct fb_var_screeninfo *var,
> struct fb_info *info, const char *mode_option,
> const struct fb_videomode *db, unsigned int dbsize,
> const struct fb_videomode *default_mode,
> unsigned int default_bpp)
> {
> int i;
>
> /* Set up defaults */
> if (!db) {
> db = modedb;
> dbsize = ARRAY_SIZE(modedb);
> }

if (dbsize > ARRAY_SIZE(db))
dbsize = ARRAY_SIZE(db);

> if (!default_mode)
> default_mode = &db[0];
>
> if (!default_bpp)
> default_bpp = 8;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/