All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: Race fix for i2c-mpc.c
@ 2005-05-16  6:24 Sylvain Munaut
  2005-05-16 15:30 ` Kumar Gala
  0 siblings, 1 reply; 5+ messages in thread
From: Sylvain Munaut @ 2005-05-16  6:24 UTC (permalink / raw)
  To: Adrian Cox; +Cc: Sylvain Munaut, Asier Llano Palacios, ML linuxppc-embedded

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>
---
--- linux-2.6/drivers/i2c/busses/i2c-mpc.c	2005-05-16 09:08:02.000000000 +0200
+++ linux-2.6/drivers/i2c/busses/i2c-mpc.c	2005-05-16 09:09:51.000000000 +0200
@@ -333,6 +333,9 @@
 	} else
 		i2c->irq = 0;
 
+	mpc_i2c_setclock(i2c);
+	ocp_set_drvdata(ocp, i2c);
+
 	i2c->adap = mpc_ops;
 	i2c_set_adapdata(&i2c->adap, i2c);
 
@@ -341,8 +344,6 @@
 		goto fail_add;
 	}
 
-	mpc_i2c_setclock(i2c);
-	ocp_set_drvdata(ocp, i2c);
 	return result;
 
       fail_add:
@@ -358,8 +359,8 @@
 static void __devexit mpc_i2c_remove(struct ocp_device *ocp)
 {
 	struct mpc_i2c *i2c = ocp_get_drvdata(ocp);
-	ocp_set_drvdata(ocp, NULL);
 	i2c_del_adapter(&i2c->adap);
+	ocp_set_drvdata(ocp, NULL);
 
 	if (ocp->def->irq != OCP_IRQ_NA)
 		free_irq(i2c->irq, i2c);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] i2c: Race fix for i2c-mpc.c
  2005-05-16  6:24 [PATCH] i2c: Race fix for i2c-mpc.c Sylvain Munaut
@ 2005-05-16 15:30 ` Kumar Gala
  2005-05-16 16:06   ` Sylvain Munaut
  0 siblings, 1 reply; 5+ messages in thread
From: Kumar Gala @ 2005-05-16 15:30 UTC (permalink / raw)
  To: Sylvain Munaut; +Cc: Asier Llano Palacios, ML linuxppc-embedded

Sylvain,

Are you really still using the OCP side of the driver?  Do we need a=20
similar fix for the platform driver side?

- kumar

On May 16, 2005, at 1:24 AM, Sylvain Munaut wrote:

> 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>
> ---
>  --- linux-2.6/drivers/i2c/busses/i2c-mpc.c=A0=A0=A0=A0=A0 2005-05-16=20=

> 09:08:02.000000000 +0200
>  +++ linux-2.6/drivers/i2c/busses/i2c-mpc.c=A0=A0=A0=A0=A0 2005-05-16=20=

> 09:09:51.000000000 +0200
>  @@ -333,6 +333,9 @@
>  =A0=A0=A0=A0=A0=A0=A0 } else
>  =A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0 i2c->irq =3D 0;
>  =A0
>  +=A0=A0=A0=A0=A0=A0 mpc_i2c_setclock(i2c);
> +=A0=A0=A0=A0=A0=A0 ocp_set_drvdata(ocp, i2c);
>  +
>  =A0=A0=A0=A0=A0=A0=A0 i2c->adap =3D mpc_ops;
>  =A0=A0=A0=A0=A0=A0=A0 i2c_set_adapdata(&i2c->adap, i2c);
>  =A0
>  @@ -341,8 +344,6 @@
>  =A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0 goto fail_add;
>  =A0=A0=A0=A0=A0=A0=A0 }
>  =A0
>  -=A0=A0=A0=A0=A0=A0 mpc_i2c_setclock(i2c);
> -=A0=A0=A0=A0=A0=A0 ocp_set_drvdata(ocp, i2c);
>  =A0=A0=A0=A0=A0=A0=A0 return result;
>  =A0
>  =A0=A0=A0=A0=A0=A0 fail_add:
>  @@ -358,8 +359,8 @@
>  =A0static void __devexit mpc_i2c_remove(struct ocp_device *ocp)
>  =A0{
>  =A0=A0=A0=A0=A0=A0=A0 struct mpc_i2c *i2c =3D ocp_get_drvdata(ocp);
> -=A0=A0=A0=A0=A0=A0 ocp_set_drvdata(ocp, NULL);
>  =A0=A0=A0=A0=A0=A0=A0 i2c_del_adapter(&i2c->adap);
>  +=A0=A0=A0=A0=A0=A0 ocp_set_drvdata(ocp, NULL);
>  =A0
>  =A0=A0=A0=A0=A0=A0=A0 if (ocp->def->irq !=3D OCP_IRQ_NA)
> =A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0 free_irq(i2c->irq, i2c);
>  _______________________________________________
> Linuxppc-embedded mailing list
>  Linuxppc-embedded@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-embedded

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] i2c: Race fix for i2c-mpc.c
  2005-05-16 15:30 ` Kumar Gala
@ 2005-05-16 16:06   ` Sylvain Munaut
  2005-05-17 16:12     ` Kumar Gala
  0 siblings, 1 reply; 5+ messages in thread
From: Sylvain Munaut @ 2005-05-16 16:06 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Asier Llano Palacios, ML linuxppc-embedded

[-- Attachment #1: Type: text/plain, Size: 1141 bytes --]

Kumar Gala wrote:
> Sylvain,
> 
> Are you really still using the OCP side of the driver?  Do we need a 
> similar fix for the platform driver side?

/me hits himself with a hammer

Damn I included the wrong diff ... Sorry about that, the good one is
in attachment.


No I don't use the OCP side but I changed both to stay coherent. I don't 
experience the problem myself, it's Asier who reported it and it 
apparently mostly shows up on the second i2c bus (where I have nothing 
on my hardware and anyway my bootloader init I2C beforehand ...).

But the patch looks correct, when a bus is added, it should be ready to 
be used.


	Sylvain


---
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>
---

[-- Attachment #2: i2c-mpc-racefix.diff --]
[-- Type: text/x-patch, Size: 1314 bytes --]

--- linux-2.6/drivers/i2c/busses/i2c-mpc.c	2005-05-16 09:47:10.000000000 +0200
+++ linux-2.6-mpc52xx/drivers/i2c/busses/i2c-mpc.c	2005-05-16 17:50:18.000000000 +0200
@@ -333,6 +333,9 @@
 	} else
 		i2c->irq = 0;
 
+	mpc_i2c_setclock(i2c);
+	ocp_set_drvdata(ocp, i2c);
+
 	i2c->adap = mpc_ops;
 	i2c_set_adapdata(&i2c->adap, i2c);
 
@@ -341,8 +344,6 @@
 		goto fail_add;
 	}
 
-	mpc_i2c_setclock(i2c);
-	ocp_set_drvdata(ocp, i2c);
 	return result;
 
       fail_add:
@@ -358,8 +359,8 @@
 static void __devexit mpc_i2c_remove(struct ocp_device *ocp)
 {
 	struct mpc_i2c *i2c = ocp_get_drvdata(ocp);
-	ocp_set_drvdata(ocp, NULL);
 	i2c_del_adapter(&i2c->adap);
+	ocp_set_drvdata(ocp, NULL);
 
 	if (ocp->def->irq != OCP_IRQ_NA)
 		free_irq(i2c->irq, i2c);
@@ -430,6 +431,9 @@
 			goto fail_irq;
 		}
 
+	mpc_i2c_setclock(i2c);
+	dev_set_drvdata(device, i2c);
+
 	i2c->adap = mpc_ops;
 	i2c_set_adapdata(&i2c->adap, i2c);
 	i2c->adap.dev.parent = &pdev->dev;
@@ -438,8 +442,6 @@
 		goto fail_add;
 	}
 
-	mpc_i2c_setclock(i2c);
-	dev_set_drvdata(device, i2c);
 	return result;
 
       fail_add:
@@ -456,8 +458,8 @@
 {
 	struct mpc_i2c *i2c = dev_get_drvdata(device);
 
-	dev_set_drvdata(device, NULL);
 	i2c_del_adapter(&i2c->adap);
+	dev_set_drvdata(device, NULL);
 
 	if (i2c->irq != 0)
 		free_irq(i2c->irq, i2c);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] i2c: Race fix for i2c-mpc.c
  2005-05-16 16:06   ` Sylvain Munaut
@ 2005-05-17 16:12     ` Kumar Gala
  0 siblings, 0 replies; 5+ messages in thread
From: Kumar Gala @ 2005-05-17 16:12 UTC (permalink / raw)
  To: Sylvain Munaut; +Cc: Asier Llano Palacios, ML linuxppc-embedded

Sylvain,

Looks reasonable to me.  Add a Signed-off-by: Kumar Gala=20
<kumar.gala@freescale.com> line and sent to GregKH, lm-sensors guys. =20
CC me if you would.

- kumar

On May 16, 2005, at 11:06 AM, Sylvain Munaut wrote:

> Kumar Gala wrote:
>  > Sylvain,
>  >
> > Are you really still using the OCP side of the driver?=A0 Do we need =
a
> > similar fix for the platform driver side?
>
> /me hits himself with a hammer
>
> Damn I included the wrong diff ... Sorry about that, the good one is
>  in attachment.
>
>
>
> No I don't use the OCP side but I changed both to stay coherent. I=20
> don't
> experience the problem myself, it's Asier who reported it and it
> apparently mostly shows up on the second i2c bus (where I have nothing
> on my hardware and anyway my bootloader init I2C beforehand ...).
>
> But the patch looks correct, when a bus is added, it should be ready =
to
> be used.
>
>
>
> =A0=A0=A0=A0=A0=A0=A0 Sylvain
>
>
>
> ---
>  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>
> ---
> <i2c-mpc-racefix.diff>=

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] i2c: Race fix for i2c-mpc.c
  2005-06-22  5:17 [PATCH] I2C: add i2c driver for TPS6501x Greg KH
@ 2005-06-22  5:17 ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2005-06-22  5:17 UTC (permalink / raw)
  To: linux-kernel, sensors; +Cc: tnt

[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>

---
commit 7f02d56e54f2a8afaa01974df650ace9dc15d0cd
tree dd39ab530763bfb2f34e84c83d469199e53fc8b0
parent d68a861d857c11a017a8f755fa250afaf8b1bcdb
author Sylvain Munaut <tnt@246tNt.com> Wed, 18 May 2005 19:39:57 +0200
committer Greg Kroah-Hartman <gregkh@suse.de> Tue, 21 Jun 2005 21:52:01 -0700

 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
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -333,6 +333,9 @@ static int __devinit mpc_i2c_probe(struc
 	} else
 		i2c->irq = 0;
 
+	mpc_i2c_setclock(i2c);
+	ocp_set_drvdata(ocp, i2c);
+
 	i2c->adap = mpc_ops;
 	i2c_set_adapdata(&i2c->adap, i2c);
 
@@ -341,8 +344,6 @@ static int __devinit mpc_i2c_probe(struc
 		goto fail_add;
 	}
 
-	mpc_i2c_setclock(i2c);
-	ocp_set_drvdata(ocp, i2c);
 	return result;
 
       fail_add:
@@ -358,8 +359,8 @@ static int __devinit mpc_i2c_probe(struc
 static void __devexit mpc_i2c_remove(struct ocp_device *ocp)
 {
 	struct mpc_i2c *i2c = ocp_get_drvdata(ocp);
-	ocp_set_drvdata(ocp, NULL);
 	i2c_del_adapter(&i2c->adap);
+	ocp_set_drvdata(ocp, NULL);
 
 	if (ocp->def->irq != OCP_IRQ_NA)
 		free_irq(i2c->irq, i2c);
@@ -430,6 +431,9 @@ static int fsl_i2c_probe(struct device *
 			goto fail_irq;
 		}
 
+	mpc_i2c_setclock(i2c);
+	dev_set_drvdata(device, i2c);
+
 	i2c->adap = mpc_ops;
 	i2c_set_adapdata(&i2c->adap, i2c);
 	i2c->adap.dev.parent = &pdev->dev;
@@ -438,8 +442,6 @@ static int fsl_i2c_probe(struct device *
 		goto fail_add;
 	}
 
-	mpc_i2c_setclock(i2c);
-	dev_set_drvdata(device, i2c);
 	return result;
 
       fail_add:
@@ -456,8 +458,8 @@ static int fsl_i2c_remove(struct device 
 {
 	struct mpc_i2c *i2c = dev_get_drvdata(device);
 
-	dev_set_drvdata(device, NULL);
 	i2c_del_adapter(&i2c->adap);
+	dev_set_drvdata(device, NULL);
 
 	if (i2c->irq != 0)
 		free_irq(i2c->irq, i2c);


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-06-22  6:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-16  6:24 [PATCH] i2c: Race fix for i2c-mpc.c Sylvain Munaut
2005-05-16 15:30 ` Kumar Gala
2005-05-16 16:06   ` Sylvain Munaut
2005-05-17 16:12     ` Kumar Gala
  -- strict thread matches above, loose matches on Subject: below --
2005-06-22  5:17 [PATCH] I2C: add i2c driver for TPS6501x Greg KH
2005-06-22  5:17 ` [PATCH] i2c: Race fix for i2c-mpc.c Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.