[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <457e3754-c783-0ec4-068c-8b5f5ff8de0a@gmail.com>
Date: Thu, 18 Jun 2020 03:35:20 +0300
From: Dmitry Osipenko <digetx@...il.com>
To: Sowjanya Komatineni <skomatineni@...dia.com>,
thierry.reding@...il.com, jonathanh@...dia.com, frankc@...dia.com,
hverkuil@...all.nl, sakari.ailus@....fi, robh+dt@...nel.org,
helen.koike@...labora.com
Cc: sboyd@...nel.org, gregkh@...uxfoundation.org,
linux-media@...r.kernel.org, devicetree@...r.kernel.org,
linux-tegra@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-i2c@...r.kernel.org
Subject: Re: [RFC PATCH v2 14/18] gpu: host1x: mipi: Split
tegra_mipi_calibrate and tegra_mipi_wait
17.06.2020 04:41, Sowjanya Komatineni пишет:
...
> -static int tegra_mipi_wait(struct tegra_mipi *mipi)
> +int tegra_mipi_wait(struct tegra_mipi_device *device)
> {
> + struct tegra_mipi *mipi = device->mipi;
> unsigned long timeout = jiffies + msecs_to_jiffies(250);
> u32 value;
> + int err;
> +
> + err = clk_enable(device->mipi->clk);
> + if (err < 0)
> + return err;
> +
> + mutex_lock(&device->mipi->lock);
The timeout variable should be assigned *after* taking the lock.
It will be better if you could use the read_poll_timeout() or
readl_relaxed_poll_timeout() here.
> while (time_before(jiffies, timeout)) {
> value = tegra_mipi_readl(mipi, MIPI_CAL_STATUS);
> if ((value & MIPI_CAL_STATUS_ACTIVE) == 0 &&
> (value & MIPI_CAL_STATUS_DONE) != 0)
> - return 0;
> + goto done;
>
> usleep_range(10, 50);
> }
>
> - return -ETIMEDOUT;
> + err = -ETIMEDOUT;
> +done:
> + mutex_unlock(&device->mipi->lock);
> + clk_disable(device->mipi->clk);
> + return err;
> }
> +EXPORT_SYMBOL(tegra_mipi_wait);
Powered by blists - more mailing lists