[U-Boot] [PATCH 08/15] wdt: dw: Add driver-model support

Andy Shevchenko andy.shevchenko at gmail.com
Mon Jul 29 09:09:32 UTC 2019


On Mon, Jul 29, 2019 at 10:56 AM Jagan Teki <jagan at amarulasolutions.com> wrote:
>
> Add driver-model code for designware watchdog.

> +/*
> + * Set the watchdog time interval.
> + * Counter is 32 bit.
> + */
> +static int dw_wdt_set_timeout(struct dw_wdt *dw, unsigned int timeout)
> +{
> +       signed int i;
> +
> +       /* calculate the timeout range value */
> +       i = (log_2_n_round_up(timeout * dw->clk_rate)) - 16;

Redundant parenthesis.

> +       if (i > 15)
> +               i = 15;
> +       if (i < 0)
> +               i = 0;

Use clamp_t().

> +
> +       writel((i | (i << 4)), dw->regs + DW_WDT_TORR);
> +
> +       return 0;
> +}


> +       ret = clk_get_by_index(dev, 0, &clk);
> +       if (!ret)
> +               dw->clk_rate = clk_get_rate(&clk);
> +       else
> +               return -EINVAL;

Why not to use traditional pattern, i.e.

  if (ret)
    return -ERRNO;

-- 
With Best Regards,
Andy Shevchenko


More information about the U-Boot mailing list