Re: [PATCH 3/3] viafb: use read-only mode parsing

From: Florian Tobias Schandinat
Date: Sun Sep 13 2009 - 15:05:34 EST


Andrew Morton schrieb:
On Mon, 7 Sep 2009 02:24:44 +0000
Florian Tobias Schandinat <FlorianSchandinat@xxxxxx> wrote:

+static void parse_mode(const char *str, u32 *xres, u32 *yres)
+{
+ char *ptr;
+
+ *xres = simple_strtoul(str, &ptr, 10);
+ if (ptr[0] != 'x')
+ goto out_default;
+
+ *yres = simple_strtoul(&ptr[1], &ptr, 10);
+ if (ptr[0])
+ goto out_default;
+
+ return;
+
+out_default:
+ printk(KERN_WARNING "viafb received invalid mode string: %s\n", str);
+ *xres = 640;
+ *yres = 480;
+}

One wonders if we could use sscanf here?

You're right.
But I am planning to add the optional arguments -<bpp> and @<refresh> to make it easier to select a mode and slowly move towards generic modedb format. I think that can be done easier with pointer handling than sscanf usage but I don't have a strong opinion about it so feel free to request me to change it.

Example: (new format)
viafb_mode=800x480-16@60
instead (old format)
viafb_mode=800x480 viafb_bpp=16 viafb_refresh=60

The second simple_strtoul() could use strict_strtoul(), but that's not
obviously superior IMO.

True.


Thanks,

Florian Tobias Schandinat
--
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/