Skip to content

Commit 692acbd

Browse files
author
Ben Dooks
committed
i2c-s3c2410: Allow more than one i2c-s3c2410 adapter
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@fluff.org>
1 parent 6a039ca commit 692acbd

1 file changed

Lines changed: 19 additions & 14 deletions

File tree

‎drivers/i2c/busses/i2c-s3c2410.c‎

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -559,19 +559,6 @@ static const struct i2c_algorithm s3c24xx_i2c_algorithm = {
559559
.functionality = s3c24xx_i2c_func,
560560
};
561561

562-
static struct s3c24xx_i2c s3c24xx_i2c = {
563-
.lock = __SPIN_LOCK_UNLOCKED(s3c24xx_i2c.lock),
564-
.wait = __WAIT_QUEUE_HEAD_INITIALIZER(s3c24xx_i2c.wait),
565-
.tx_setup = 50,
566-
.adap = {
567-
.name = "s3c2410-i2c",
568-
.owner = THIS_MODULE,
569-
.algo = &s3c24xx_i2c_algorithm,
570-
.retries = 2,
571-
.class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
572-
},
573-
};
574-
575562
/* s3c24xx_i2c_calcdivisor
576563
*
577564
* return the divisor settings for a given frequency
@@ -797,7 +784,7 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
797784

798785
static int s3c24xx_i2c_probe(struct platform_device *pdev)
799786
{
800-
struct s3c24xx_i2c *i2c = &s3c24xx_i2c;
787+
struct s3c24xx_i2c *i2c;
801788
struct s3c2410_platform_i2c *pdata;
802789
struct resource *res;
803790
int ret;
@@ -808,6 +795,22 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
808795
return -EINVAL;
809796
}
810797

798+
i2c = kzalloc(sizeof(struct s3c24xx_i2c), GFP_KERNEL);
799+
if (!i2c) {
800+
dev_err(&pdev->dev, "no memory for state\n");
801+
return -ENOMEM;
802+
}
803+
804+
strlcpy(i2c->adap.name, "s3c2410-i2c", sizeof(i2c->adap.name));
805+
i2c->adap.owner = THIS_MODULE;
806+
i2c->adap.algo = &s3c24xx_i2c_algorithm;
807+
i2c->adap.retries = 2;
808+
i2c->adap.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
809+
i2c->tx_setup = 50;
810+
811+
spin_lock_init(&i2c->lock);
812+
init_waitqueue_head(&i2c->wait);
813+
811814
/* find the clock and enable it */
812815

813816
i2c->dev = &pdev->dev;
@@ -929,6 +932,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
929932
clk_put(i2c->clk);
930933

931934
err_noclk:
935+
kfree(i2c);
932936
return ret;
933937
}
934938

@@ -953,6 +957,7 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
953957

954958
release_resource(i2c->ioarea);
955959
kfree(i2c->ioarea);
960+
kfree(i2c);
956961

957962
return 0;
958963
}

0 commit comments

Comments
 (0)