Re: [RFC PATCH 2/2] usb: Example for how to use device node at usb device driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Friday 08 January 2016 13:44:24 Peter Chen wrote:
> +	  u32 duration_us = 0;

> +       of_property_read_u32(hdev->dev.of_node, "delay-duration-us", &duration_us);
> +       if (duration_us > 0) {
> +               usleep_range(duration_us, duration_us + 10);
> +               dev_info(&hdev->dev, "The delay is %d us\n", duration_us);
> +       }
> +

I think especially for an example, it would be better to use error checking and
not initialize the variable:

	u32 duration_us;
	int ret;
...
	ret = of_property_read_u32(hdev->dev.of_node, "delay-duration-us", &duration_us);
	if (!ret && duration_us > 0) {
		...
	}

The effect is the same as the other one.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux