diff options
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-s3c2410.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index d6343e2c5889..f14007ff2531 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -559,19 +559,6 @@ static const struct i2c_algorithm s3c24xx_i2c_algorithm = { | |||
559 | .functionality = s3c24xx_i2c_func, | 559 | .functionality = s3c24xx_i2c_func, |
560 | }; | 560 | }; |
561 | 561 | ||
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 | |||
575 | /* s3c24xx_i2c_calcdivisor | 562 | /* s3c24xx_i2c_calcdivisor |
576 | * | 563 | * |
577 | * return the divisor settings for a given frequency | 564 | * return the divisor settings for a given frequency |
@@ -797,7 +784,7 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c) | |||
797 | 784 | ||
798 | static int s3c24xx_i2c_probe(struct platform_device *pdev) | 785 | static int s3c24xx_i2c_probe(struct platform_device *pdev) |
799 | { | 786 | { |
800 | struct s3c24xx_i2c *i2c = &s3c24xx_i2c; | 787 | struct s3c24xx_i2c *i2c; |
801 | struct s3c2410_platform_i2c *pdata; | 788 | struct s3c2410_platform_i2c *pdata; |
802 | struct resource *res; | 789 | struct resource *res; |
803 | int ret; | 790 | int ret; |
@@ -808,6 +795,22 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
808 | return -EINVAL; | 795 | return -EINVAL; |
809 | } | 796 | } |
810 | 797 | ||
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 | |||
811 | /* find the clock and enable it */ | 814 | /* find the clock and enable it */ |
812 | 815 | ||
813 | i2c->dev = &pdev->dev; | 816 | i2c->dev = &pdev->dev; |
@@ -929,6 +932,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
929 | clk_put(i2c->clk); | 932 | clk_put(i2c->clk); |
930 | 933 | ||
931 | err_noclk: | 934 | err_noclk: |
935 | kfree(i2c); | ||
932 | return ret; | 936 | return ret; |
933 | } | 937 | } |
934 | 938 | ||
@@ -953,6 +957,7 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev) | |||
953 | 957 | ||
954 | release_resource(i2c->ioarea); | 958 | release_resource(i2c->ioarea); |
955 | kfree(i2c->ioarea); | 959 | kfree(i2c->ioarea); |
960 | kfree(i2c); | ||
956 | 961 | ||
957 | return 0; | 962 | return 0; |
958 | } | 963 | } |