public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
Subject: [patch 7/9] i2c-s3c2410: Allow more than one i2c-s3c2410 adapter
Date: Fri, 31 Oct 2008 16:04:27 +0000	[thread overview]
Message-ID: <20081031160438.015437012@fluff.org.uk> (raw)
In-Reply-To: 20081031160420.164160051@fluff.org.uk

[-- Attachment #1: simtec/s3c64xx/i2c-allow-multiple-instances.patch --]
[-- Type: text/plain, Size: 2340 bytes --]

Newer SoCs such as the S3C6410 have 2 instances of this i2c
controller block in and thus require the ability to create
two seperate busses from this. 

Signed-off-by: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>

Index: linux.git/drivers/i2c/busses/i2c-s3c2410.c
===================================================================
--- linux.git.orig/drivers/i2c/busses/i2c-s3c2410.c	2008-10-31 11:56:08.000000000 +0000
+++ linux.git/drivers/i2c/busses/i2c-s3c2410.c	2008-10-31 11:56:12.000000000 +0000
@@ -560,19 +560,6 @@ static const struct i2c_algorithm s3c24x
 	.functionality		= s3c24xx_i2c_func,
 };
 
-static struct s3c24xx_i2c s3c24xx_i2c = {
-	.lock		= __SPIN_LOCK_UNLOCKED(s3c24xx_i2c.lock),
-	.wait		= __WAIT_QUEUE_HEAD_INITIALIZER(s3c24xx_i2c.wait),
-	.tx_setup	= 50,
-	.adap		= {
-		.name			= "s3c2410-i2c",
-		.owner			= THIS_MODULE,
-		.algo			= &s3c24xx_i2c_algorithm,
-		.retries		= 2,
-		.class			= I2C_CLASS_HWMON | I2C_CLASS_SPD,
-	},
-};
-
 /* s3c24xx_i2c_calcdivisor
  *
  * return the divisor settings for a given frequency
@@ -798,7 +785,7 @@ static int s3c24xx_i2c_init(struct s3c24
 
 static int s3c24xx_i2c_probe(struct platform_device *pdev)
 {
-	struct s3c24xx_i2c *i2c = &s3c24xx_i2c;
+	struct s3c24xx_i2c *i2c;
 	struct s3c2410_platform_i2c *pdata;
 	struct resource *res;
 	int ret;
@@ -809,6 +796,22 @@ static int s3c24xx_i2c_probe(struct plat
 		return -EINVAL;
 	}
 
+	i2c = kzalloc(sizeof(struct s3c24xx_i2c), GFP_KERNEL);
+	if (!i2c) {
+		dev_err(&pdev->dev, "no memory for state\n");
+		return -ENOMEM;
+	}
+
+	strlcpy(i2c->adap.name, "s3c2410-i2c", sizeof(i2c->adap.name));
+	i2c->adap.owner   = THIS_MODULE;
+	i2c->adap.algo    = &s3c24xx_i2c_algorithm;
+	i2c->adap.retries = 2;
+	i2c->adap.class   = I2C_CLASS_HWMON | I2C_CLASS_SPD;
+	i2c->tx_setup     = 50;
+
+	spin_lock_init(&i2c->lock);
+	init_waitqueue_head(&i2c->wait);
+
 	/* find the clock and enable it */
 
 	i2c->dev = &pdev->dev;
@@ -930,6 +933,7 @@ static int s3c24xx_i2c_probe(struct plat
 	clk_put(i2c->clk);
 
  err_noclk:
+	kfree(i2c);
 	return ret;
 }
 
@@ -954,6 +958,7 @@ static int s3c24xx_i2c_remove(struct pla
 
 	release_resource(i2c->ioarea);
 	kfree(i2c->ioarea);
+	kfree(i2c);
 
 	return 0;
 }

-- 
Ben (ben-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org, http://www.fluff.org/)

  'a smiley only costs 4 bytes'

  parent reply	other threads:[~2008-10-31 16:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-31 16:04 [patch 0/9] I2C patches for S3C24XX Ben Dooks
2008-10-31 16:04 ` [patch 1/9] i2c-s3c2410: fix check for being in suspend Ben Dooks
2008-10-31 16:04 ` [patch 2/9] i2c-s3c2410: Use <linux/io.h> over <asm/io.h> Ben Dooks
2008-10-31 16:04 ` [patch 3/9] i2c-s3c2410: fixup style problems from checkpatch.pl Ben Dooks
2008-10-31 16:04 ` [patch 4/9] i2c-s3c2410: use platform data for gpio configuration Ben Dooks
2008-10-31 16:04 ` [patch 5/9] i2c-s3c2410: Add ARCH_S3C64XX to allowed archs Ben Dooks
2008-10-31 16:04 ` [patch 6/9] i2c-s3c2410: remove default platform data Ben Dooks
2008-10-31 16:04 ` Ben Dooks [this message]
2008-10-31 16:04 ` [patch 8/9] S3C: Add i2c1 device definition Ben Dooks
2008-10-31 16:04 ` [patch 9/9] i2c-s3c2410: change IRQ to be plain integer Ben Dooks

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=20081031160438.015437012@fluff.org.uk \
    --to=ben-linux-elnmno+kys3ytjvyw6ydsg@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.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