Lan Tianyu <tianyu.lan@xxxxxxxxx> writes: > - if (sscanf(buf, "%d", &config) != 1 || config < 0 || config > 1) > + if (sscanf(buf, "%d", &val) != 1 || val < 0 || val > 1) > return -EINVAL; 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: static ssize_t set_usb2_hardware_lpm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct usb_device *udev = to_usb_device(dev); bool value; int ret; usb_lock_device(udev); ret = strtobool(buf, &value); if (!ret) ret = usb_set_usb2_hardware_lpm(udev, value); usb_unlock_device(udev); if (!ret) return count; return ret; } 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. Bjørn -- 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