+               struct clk clk;
+               if(!clk_get_by_name(dev, "ipg", &clk))
+                       rate = clk_get_rate(&clk);
+       }
+
+       /* as fallback we try to get the clk rate that way */
+       if (rate == 0)

!rate || IS_ERR_VALUE(rate)

This looked so weird I had to actually look at clk_get_rate()
in u-boot.

/**
 * clk_get_rate() - Get current clock rate.
 * @clk:        A clock struct that was previously successfully requested by
 *              clk_request/get_by_*().
 *
* Return: clock rate in Hz on success, 0 for invalid clock, or -ve error code
 *         for other errors.
 */
ulong clk_get_rate(struct clk *clk);

How can an ulong return a negative error value? What if the clock speed
happens to be the same as -errno?

-michael

Reply via email to