diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2005-05-18 13:39:57 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-06-22 00:52:01 -0400 |
commit | 7f02d56e54f2a8afaa01974df650ace9dc15d0cd (patch) | |
tree | dd39ab530763bfb2f34e84c83d469199e53fc8b0 /drivers | |
parent | d68a861d857c11a017a8f755fa250afaf8b1bcdb (diff) |
[PATCH] i2c: Race fix for i2c-mpc.c
i2c: Race fix for i2c-mpc.c
The problem was that the clock speed and driver data is
initialized after the i2c adapter was added. This caused
the i2c bus to start working at a wrong speed. (Mostly
noticable on the second bus on mpc5200)
With this patch we've tried to keep the i2c adapter
working perfectly all the time it is included in the system.
Initialize before added, Remove garbage after deleleted.
Submitted-by: Asier Llano Palacios
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Signed-off-by: Kumar Gala <kumar.gala@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/i2c/busses/i2c-mpc.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index c8a8703dcbcb..d41ca31dbcb2 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -333,6 +333,9 @@ static int __devinit mpc_i2c_probe(struct ocp_device *ocp) | |||
333 | } else | 333 | } else |
334 | i2c->irq = 0; | 334 | i2c->irq = 0; |
335 | 335 | ||
336 | mpc_i2c_setclock(i2c); | ||
337 | ocp_set_drvdata(ocp, i2c); | ||
338 | |||
336 | i2c->adap = mpc_ops; | 339 | i2c->adap = mpc_ops; |
337 | i2c_set_adapdata(&i2c->adap, i2c); | 340 | i2c_set_adapdata(&i2c->adap, i2c); |
338 | 341 | ||
@@ -341,8 +344,6 @@ static int __devinit mpc_i2c_probe(struct ocp_device *ocp) | |||
341 | goto fail_add; | 344 | goto fail_add; |
342 | } | 345 | } |
343 | 346 | ||
344 | mpc_i2c_setclock(i2c); | ||
345 | ocp_set_drvdata(ocp, i2c); | ||
346 | return result; | 347 | return result; |
347 | 348 | ||
348 | fail_add: | 349 | fail_add: |
@@ -358,8 +359,8 @@ static int __devinit mpc_i2c_probe(struct ocp_device *ocp) | |||
358 | static void __devexit mpc_i2c_remove(struct ocp_device *ocp) | 359 | static void __devexit mpc_i2c_remove(struct ocp_device *ocp) |
359 | { | 360 | { |
360 | struct mpc_i2c *i2c = ocp_get_drvdata(ocp); | 361 | struct mpc_i2c *i2c = ocp_get_drvdata(ocp); |
361 | ocp_set_drvdata(ocp, NULL); | ||
362 | i2c_del_adapter(&i2c->adap); | 362 | i2c_del_adapter(&i2c->adap); |
363 | ocp_set_drvdata(ocp, NULL); | ||
363 | 364 | ||
364 | if (ocp->def->irq != OCP_IRQ_NA) | 365 | if (ocp->def->irq != OCP_IRQ_NA) |
365 | free_irq(i2c->irq, i2c); | 366 | free_irq(i2c->irq, i2c); |
@@ -430,6 +431,9 @@ static int fsl_i2c_probe(struct device *device) | |||
430 | goto fail_irq; | 431 | goto fail_irq; |
431 | } | 432 | } |
432 | 433 | ||
434 | mpc_i2c_setclock(i2c); | ||
435 | dev_set_drvdata(device, i2c); | ||
436 | |||
433 | i2c->adap = mpc_ops; | 437 | i2c->adap = mpc_ops; |
434 | i2c_set_adapdata(&i2c->adap, i2c); | 438 | i2c_set_adapdata(&i2c->adap, i2c); |
435 | i2c->adap.dev.parent = &pdev->dev; | 439 | i2c->adap.dev.parent = &pdev->dev; |
@@ -438,8 +442,6 @@ static int fsl_i2c_probe(struct device *device) | |||
438 | goto fail_add; | 442 | goto fail_add; |
439 | } | 443 | } |
440 | 444 | ||
441 | mpc_i2c_setclock(i2c); | ||
442 | dev_set_drvdata(device, i2c); | ||
443 | return result; | 445 | return result; |
444 | 446 | ||
445 | fail_add: | 447 | fail_add: |
@@ -456,8 +458,8 @@ static int fsl_i2c_remove(struct device *device) | |||
456 | { | 458 | { |
457 | struct mpc_i2c *i2c = dev_get_drvdata(device); | 459 | struct mpc_i2c *i2c = dev_get_drvdata(device); |
458 | 460 | ||
459 | dev_set_drvdata(device, NULL); | ||
460 | i2c_del_adapter(&i2c->adap); | 461 | i2c_del_adapter(&i2c->adap); |
462 | dev_set_drvdata(device, NULL); | ||
461 | 463 | ||
462 | if (i2c->irq != 0) | 464 | if (i2c->irq != 0) |
463 | free_irq(i2c->irq, i2c); | 465 | free_irq(i2c->irq, i2c); |