diff options
author | Wolfram Sang <wsa+renesas@sang-engineering.com> | 2014-05-02 15:15:14 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2014-05-22 04:09:24 -0400 |
commit | 6ed7053c2255c34886297b995c6a18607b36d668 (patch) | |
tree | f60dd88b7667bdbb250937f190d25582c67148b4 | |
parent | ed4121e129ae46615ab570318b5b8f31494ced98 (diff) |
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: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r-- | drivers/i2c/busses/i2c-sh_mobile.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index 9a5b693454e1..9f02013eaeeb 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c | |||
@@ -228,7 +228,7 @@ static u32 sh_mobile_i2c_icch(unsigned long count_khz, u32 tHIGH, u32 tf) | |||
228 | return (((count_khz * (tHIGH + tf)) + 5000) / 10000); | 228 | return (((count_khz * (tHIGH + tf)) + 5000) / 10000); |
229 | } | 229 | } |
230 | 230 | ||
231 | static void sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd) | 231 | static int sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd) |
232 | { | 232 | { |
233 | unsigned long i2c_clk_khz; | 233 | unsigned long i2c_clk_khz; |
234 | u32 tHIGH, tLOW, tf; | 234 | u32 tHIGH, tLOW, tf; |
@@ -236,6 +236,7 @@ static void sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd) | |||
236 | /* Get clock rate after clock is enabled */ | 236 | /* Get clock rate after clock is enabled */ |
237 | clk_prepare_enable(pd->clk); | 237 | clk_prepare_enable(pd->clk); |
238 | i2c_clk_khz = clk_get_rate(pd->clk) / 1000; | 238 | i2c_clk_khz = clk_get_rate(pd->clk) / 1000; |
239 | clk_disable_unprepare(pd->clk); | ||
239 | i2c_clk_khz /= pd->clks_per_count; | 240 | i2c_clk_khz /= pd->clks_per_count; |
240 | 241 | ||
241 | if (pd->bus_speed == STANDARD_MODE) { | 242 | if (pd->bus_speed == STANDARD_MODE) { |
@@ -249,7 +250,7 @@ static void sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd) | |||
249 | } else { | 250 | } else { |
250 | dev_err(pd->dev, "unrecognized bus speed %lu Hz\n", | 251 | dev_err(pd->dev, "unrecognized bus speed %lu Hz\n", |
251 | pd->bus_speed); | 252 | pd->bus_speed); |
252 | goto out; | 253 | return -EINVAL; |
253 | } | 254 | } |
254 | 255 | ||
255 | pd->iccl = sh_mobile_i2c_iccl(i2c_clk_khz, tLOW, tf); | 256 | 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 | else | 267 | else |
267 | pd->icic &= ~ICIC_ICCHB8; | 268 | pd->icic &= ~ICIC_ICCHB8; |
268 | 269 | ||
269 | out: | 270 | return 0; |
270 | clk_disable_unprepare(pd->clk); | ||
271 | } | 271 | } |
272 | 272 | ||
273 | static void activate_ch(struct sh_mobile_i2c_data *pd) | 273 | 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 | if (resource_size(res) > 0x17) | 677 | if (resource_size(res) > 0x17) |
678 | pd->flags |= IIC_FLAG_HAS_ICIC67; | 678 | pd->flags |= IIC_FLAG_HAS_ICIC67; |
679 | 679 | ||
680 | sh_mobile_i2c_init(pd); | 680 | ret = sh_mobile_i2c_init(pd); |
681 | if (ret) | ||
682 | return ret; | ||
681 | 683 | ||
682 | /* Enable Runtime PM for this device. | 684 | /* Enable Runtime PM for this device. |
683 | * | 685 | * |