On Wed, 14 Dec 2016, Todd Brandt wrote:
> add debugfs support for experimenting with USB timing delay
> values on the fly. Values are read/written from debugfs at
> /sys/kernel/debug/usb/timing.
>
> Signed-off-by: Todd Brandt <[email protected]>
> ---
> v2 changes:
> - moved the debug code from hub.c to usb.c
> - use debugfs instead of /sys/kernel/usb
...
> +static int usb_timing_show(struct seq_file *s, void *unused)
> +{
> + seq_printf(s, "tdrsmdn=%d\n", usb_timing.tdrsmdn);
> + seq_printf(s, "trsmrcy=%d\n", usb_timing.trsmrcy);
> + seq_printf(s, "trstrcy=%d\n", usb_timing.trstrcy);
> + return 0;
> +}
> +
> +static int usb_timing_open(struct inode *inode, struct file *file)
> +{
> + return single_open(file, usb_timing_show, inode->i_private);
> +}
> +
> +static ssize_t usb_timing_write(struct file *file,
> + const char __user *ubuf, size_t count, loff_t *ppos)
> +{
> + int val;
> + char buf[32];
> +
> + if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
> + return -EFAULT;
> +
> + if (sscanf(buf, "tdrsmdn=%u", &val) == 1)
> + usb_timing.tdrsmdn = max(val, USB_TIMING_TDRSMDN_MIN);
> + else if (sscanf(buf, "trsmrcy=%u", &val) == 1)
> + usb_timing.trsmrcy = max(val, USB_TIMING_TRSMRCY_MIN);
> + else if (sscanf(buf, "trstrcy=%u", &val) == 1)
> + usb_timing.trstrcy = max(val, USB_TIMING_TRSTRCY_MIN);
Nit: Since the values in usb_timing are signed integers, and since val
is a signed integer, why do the sscanf calls use %u rather than %d?
Alan Stern
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html