Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

Ben Dooks 692acbd3 6a039cab

+19 -14
+19 -14
drivers/i2c/busses/i2c-s3c2410.c
··· 559 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 562 /* s3c24xx_i2c_calcdivisor 576 563 * 577 564 * return the divisor settings for a given frequency ··· 784 797 785 798 static int s3c24xx_i2c_probe(struct platform_device *pdev) 786 799 { 787 - struct s3c24xx_i2c *i2c = &s3c24xx_i2c; 800 + struct s3c24xx_i2c *i2c; 788 801 struct s3c2410_platform_i2c *pdata; 789 802 struct resource *res; 790 803 int ret; ··· 794 807 dev_err(&pdev->dev, "no platform data\n"); 795 808 return -EINVAL; 796 809 } 810 + 811 + i2c = kzalloc(sizeof(struct s3c24xx_i2c), GFP_KERNEL); 812 + if (!i2c) { 813 + dev_err(&pdev->dev, "no memory for state\n"); 814 + return -ENOMEM; 815 + } 816 + 817 + strlcpy(i2c->adap.name, "s3c2410-i2c", sizeof(i2c->adap.name)); 818 + i2c->adap.owner = THIS_MODULE; 819 + i2c->adap.algo = &s3c24xx_i2c_algorithm; 820 + i2c->adap.retries = 2; 821 + i2c->adap.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 822 + i2c->tx_setup = 50; 823 + 824 + spin_lock_init(&i2c->lock); 825 + init_waitqueue_head(&i2c->wait); 797 826 798 827 /* find the clock and enable it */ 799 828 ··· 932 929 clk_put(i2c->clk); 933 930 934 931 err_noclk: 932 + kfree(i2c); 935 933 return ret; 936 934 } 937 935 ··· 957 953 958 954 release_resource(i2c->ioarea); 959 955 kfree(i2c->ioarea); 956 + kfree(i2c); 960 957 961 958 return 0; 962 959 }