i2c: tegra: check the clk_prepare_enable() return value
commit 132c803f7b upstream.
NVIDIA's Tegra SoC allows read/write of controller register only
if controller clock is enabled. System hangs if read/write happens
to registers without enabling clock.
clk_prepare_enable() can be fail due to unknown reason and hence
adding check for return value of this function. If this function
success then only access register otherwise return to caller with
error.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
[bwh: Backported to 3.2:
- Adjust context
- Keep calling clk_enable() directly]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
cc4b50e025
commit
676bf08007
@ -341,7 +341,11 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
|
||||
u32 val;
|
||||
int err = 0;
|
||||
|
||||
clk_enable(i2c_dev->clk);
|
||||
err = clk_enable(i2c_dev->clk);
|
||||
if (err < 0) {
|
||||
dev_err(i2c_dev->dev, "Clock enable failed %d\n", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
tegra_periph_reset_assert(i2c_dev->clk);
|
||||
udelay(2);
|
||||
@ -543,7 +547,12 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
|
||||
if (i2c_dev->is_suspended)
|
||||
return -EBUSY;
|
||||
|
||||
clk_enable(i2c_dev->clk);
|
||||
ret = clk_enable(i2c_dev->clk);
|
||||
if (ret < 0) {
|
||||
dev_err(i2c_dev->dev, "Clock enable failed %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
int stop = (i == (num - 1)) ? 1 : 0;
|
||||
ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i], stop);
|
||||
|
||||
Reference in New Issue
Block a user