On Mon, 30 Jul 2012 10:33:27 +0200, Bjørn Mork <bjorn@xxxxxxx> wrote:
Lan Tianyu <tianyu.lan@xxxxxxxxx> writes: Not directly related to this patch, but a question I started wondering about recently: Is there some generic guideline wrt parsing boolean flags in sysfs? If not, shouldn't there be? I see a lot of different approaches implementing this basic function. Personally I would prefer if they all did something like the set_usb2_hardware_lpm in drivers/usb/core/sysfs.c:
[...]
ret = strtobool(buf, &value);
[...]
Using strtobool() to allow "Y", "yes", "1" etc makes a nice user interface IMHO. Unless of course the variable is a true integer which only happens to currently allow 0 and 1, but may be extended with more values later.
I'd say that if someone is handling sysfs directly, he has burn in his brain that 0 is false and 1 is true. ;) (Shell complicates things a little, but still I feel that for sysfs users the connection is obvious.) Because of that, I stick to kstrtouint(). Also, I don't like how strtobool() treats "01" as a false value. -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +----<email/xmpp: mpn@xxxxxxxxxx>--------------ooO--(_)--Ooo-- -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html