Commit 6ed7053c authored by Wolfram Sang's avatar Wolfram Sang Committed by Wolfram Sang

i2c: sh_mobile: bail out on errors when initializing

sh_mobile_i2c_init() could detect wrong settings, but didn't bail out,
so it would continue unconfigured. Fix this.
Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent ed4121e1
...@@ -228,7 +228,7 @@ static u32 sh_mobile_i2c_icch(unsigned long count_khz, u32 tHIGH, u32 tf) ...@@ -228,7 +228,7 @@ static u32 sh_mobile_i2c_icch(unsigned long count_khz, u32 tHIGH, u32 tf)
return (((count_khz * (tHIGH + tf)) + 5000) / 10000); return (((count_khz * (tHIGH + tf)) + 5000) / 10000);
} }
static void sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd) static int sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd)
{ {
unsigned long i2c_clk_khz; unsigned long i2c_clk_khz;
u32 tHIGH, tLOW, tf; u32 tHIGH, tLOW, tf;
...@@ -236,6 +236,7 @@ static void sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd) ...@@ -236,6 +236,7 @@ static void sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd)
/* Get clock rate after clock is enabled */ /* Get clock rate after clock is enabled */
clk_prepare_enable(pd->clk); clk_prepare_enable(pd->clk);
i2c_clk_khz = clk_get_rate(pd->clk) / 1000; i2c_clk_khz = clk_get_rate(pd->clk) / 1000;
clk_disable_unprepare(pd->clk);
i2c_clk_khz /= pd->clks_per_count; i2c_clk_khz /= pd->clks_per_count;
if (pd->bus_speed == STANDARD_MODE) { if (pd->bus_speed == STANDARD_MODE) {
...@@ -249,7 +250,7 @@ static void sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd) ...@@ -249,7 +250,7 @@ static void sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd)
} else { } else {
dev_err(pd->dev, "unrecognized bus speed %lu Hz\n", dev_err(pd->dev, "unrecognized bus speed %lu Hz\n",
pd->bus_speed); pd->bus_speed);
goto out; return -EINVAL;
} }
pd->iccl = sh_mobile_i2c_iccl(i2c_clk_khz, tLOW, tf); pd->iccl = sh_mobile_i2c_iccl(i2c_clk_khz, tLOW, tf);
...@@ -266,8 +267,7 @@ static void sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd) ...@@ -266,8 +267,7 @@ static void sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd)
else else
pd->icic &= ~ICIC_ICCHB8; pd->icic &= ~ICIC_ICCHB8;
out: return 0;
clk_disable_unprepare(pd->clk);
} }
static void activate_ch(struct sh_mobile_i2c_data *pd) static void activate_ch(struct sh_mobile_i2c_data *pd)
...@@ -677,7 +677,9 @@ static int sh_mobile_i2c_probe(struct platform_device *dev) ...@@ -677,7 +677,9 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
if (resource_size(res) > 0x17) if (resource_size(res) > 0x17)
pd->flags |= IIC_FLAG_HAS_ICIC67; pd->flags |= IIC_FLAG_HAS_ICIC67;
sh_mobile_i2c_init(pd); ret = sh_mobile_i2c_init(pd);
if (ret)
return ret;
/* Enable Runtime PM for this device. /* Enable Runtime PM for this device.
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment