linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Sylvain Munaut <tnt@246tNt.com>
To: Adrian Cox <adrian@humboldt.co.uk>
Cc: Sylvain Munaut <tnt@246tNt.com>,
	Asier Llano Palacios <a.llano@usyscom.com>,
	ML linuxppc-embedded <linuxppc-embedded@ozlabs.org>
Subject: [PATCH] i2c: Race fix for i2c-mpc.c
Date: Mon, 16 May 2005 08:24:29 +0200 (CEST)	[thread overview]
Message-ID: <0.20050516_092837.tnt@patchsend.246tNt.com> (raw)

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

             reply	other threads:[~2005-05-16  7:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-16  6:24 Sylvain Munaut [this message]
2005-05-16 15:30 ` [PATCH] i2c: Race fix for i2c-mpc.c Kumar Gala
2005-05-16 16:06   ` Sylvain Munaut
2005-05-17 16:12     ` Kumar Gala

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0.20050516_092837.tnt@patchsend.246tNt.com \
    --to=tnt@246tnt.com \
    --cc=a.llano@usyscom.com \
    --cc=adrian@humboldt.co.uk \
    --cc=linuxppc-embedded@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).