i2c: busses: convert to devm_platform_ioremap_resource
authorDejin Zheng <zhengdejin5@gmail.com>
Thu, 9 Apr 2020 13:52:24 +0000 (21:52 +0800)
committerWolfram Sang <wsa@the-dreams.de>
Wed, 15 Apr 2020 10:09:09 +0000 (12:09 +0200)
use devm_platform_ioremap_resource() to simplify code, it
contains platform_get_resource and devm_ioremap_resource.

Reviewed-by: Barry Song <baohua@kernel.org>
Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Robert Richter <rrichter@marvell.com>
Acked-by: Thor Thayer <thor.thayer@linux.intel.com>
Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
24 files changed:
drivers/i2c/busses/i2c-altera.c
drivers/i2c/busses/i2c-axxia.c
drivers/i2c/busses/i2c-bcm-kona.c
drivers/i2c/busses/i2c-davinci.c
drivers/i2c/busses/i2c-digicolor.c
drivers/i2c/busses/i2c-emev2.c
drivers/i2c/busses/i2c-exynos5.c
drivers/i2c/busses/i2c-hix5hd2.c
drivers/i2c/busses/i2c-img-scb.c
drivers/i2c/busses/i2c-jz4780.c
drivers/i2c/busses/i2c-lpc2k.c
drivers/i2c/busses/i2c-meson.c
drivers/i2c/busses/i2c-mv64xxx.c
drivers/i2c/busses/i2c-octeon-platdrv.c
drivers/i2c/busses/i2c-owl.c
drivers/i2c/busses/i2c-qup.c
drivers/i2c/busses/i2c-rk3x.c
drivers/i2c/busses/i2c-sirf.c
drivers/i2c/busses/i2c-stu300.c
drivers/i2c/busses/i2c-sun6i-p2wi.c
drivers/i2c/busses/i2c-synquacer.c
drivers/i2c/busses/i2c-xlp9xx.c
drivers/i2c/busses/i2c-xlr.c
drivers/i2c/busses/i2c-zx2967.c

index 20ef638..083699d 100644 (file)
@@ -382,7 +382,6 @@ static const struct i2c_algorithm altr_i2c_algo = {
 static int altr_i2c_probe(struct platform_device *pdev)
 {
        struct altr_i2c_dev *idev = NULL;
-       struct resource *res;
        int irq, ret;
        u32 val;
 
@@ -390,8 +389,7 @@ static int altr_i2c_probe(struct platform_device *pdev)
        if (!idev)
                return -ENOMEM;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       idev->base = devm_ioremap_resource(&pdev->dev, res);
+       idev->base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(idev->base))
                return PTR_ERR(idev->base);
 
index be3681d..d45e229 100644 (file)
@@ -734,7 +734,6 @@ static int axxia_i2c_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
        struct axxia_i2c_dev *idev = NULL;
-       struct resource *res;
        void __iomem *base;
        int ret = 0;
 
@@ -742,8 +741,7 @@ static int axxia_i2c_probe(struct platform_device *pdev)
        if (!idev)
                return -ENOMEM;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       base = devm_ioremap_resource(&pdev->dev, res);
+       base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(base))
                return PTR_ERR(base);
 
index 572aebb..3e63f70 100644 (file)
@@ -750,7 +750,6 @@ static int bcm_kona_i2c_probe(struct platform_device *pdev)
        int rc = 0;
        struct bcm_kona_i2c_dev *dev;
        struct i2c_adapter *adap;
-       struct resource *iomem;
 
        /* Allocate memory for private data structure */
        dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
@@ -762,8 +761,7 @@ static int bcm_kona_i2c_probe(struct platform_device *pdev)
        init_completion(&dev->done);
 
        /* Map hardware registers */
-       iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       dev->base = devm_ioremap_resource(dev->device, iomem);
+       dev->base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(dev->base))
                return -ENOMEM;
 
index e3ceb25..232a767 100644 (file)
@@ -761,7 +761,6 @@ static int davinci_i2c_probe(struct platform_device *pdev)
 {
        struct davinci_i2c_dev *dev;
        struct i2c_adapter *adap;
-       struct resource *mem;
        struct i2c_bus_recovery_info *rinfo;
        int r, irq;
 
@@ -814,8 +813,7 @@ static int davinci_i2c_probe(struct platform_device *pdev)
        if (IS_ERR(dev->clk))
                return PTR_ERR(dev->clk);
 
-       mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       dev->base = devm_ioremap_resource(&pdev->dev, mem);
+       dev->base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(dev->base)) {
                return PTR_ERR(dev->base);
        }
index 056a5c4..332f004 100644 (file)
@@ -290,7 +290,6 @@ static int dc_i2c_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
        struct dc_i2c *i2c;
-       struct resource *r;
        int ret = 0, irq;
 
        i2c = devm_kzalloc(&pdev->dev, sizeof(struct dc_i2c), GFP_KERNEL);
@@ -311,8 +310,7 @@ static int dc_i2c_probe(struct platform_device *pdev)
        if (IS_ERR(i2c->clk))
                return PTR_ERR(i2c->clk);
 
-       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       i2c->regs = devm_ioremap_resource(&pdev->dev, r);
+       i2c->regs = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(i2c->regs))
                return PTR_ERR(i2c->regs);
 
index 959d491..1a31935 100644 (file)
@@ -361,15 +361,13 @@ static const struct i2c_algorithm em_i2c_algo = {
 static int em_i2c_probe(struct platform_device *pdev)
 {
        struct em_i2c_device *priv;
-       struct resource *r;
        int ret;
 
        priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
        if (!priv)
                return -ENOMEM;
 
-       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       priv->base = devm_ioremap_resource(&pdev->dev, r);
+       priv->base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(priv->base))
                return PTR_ERR(priv->base);
 
index 5270309..ba7033c 100644 (file)
@@ -736,7 +736,6 @@ static int exynos5_i2c_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
        struct exynos5_i2c *i2c;
-       struct resource *mem;
        int ret;
 
        i2c = devm_kzalloc(&pdev->dev, sizeof(struct exynos5_i2c), GFP_KERNEL);
@@ -762,8 +761,7 @@ static int exynos5_i2c_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       i2c->regs = devm_ioremap_resource(&pdev->dev, mem);
+       i2c->regs = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(i2c->regs)) {
                ret = PTR_ERR(i2c->regs);
                goto err_clk;
index 6610304..ab15b1e 100644 (file)
@@ -388,7 +388,6 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
        struct hix5hd2_i2c_priv *priv;
-       struct resource *mem;
        unsigned int freq;
        int irq, ret;
 
@@ -409,8 +408,7 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev)
                }
        }
 
-       mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       priv->regs = devm_ioremap_resource(&pdev->dev, mem);
+       priv->regs = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(priv->regs))
                return PTR_ERR(priv->regs);
 
index 422097a..c937ea7 100644 (file)
@@ -1330,7 +1330,6 @@ static int img_i2c_probe(struct platform_device *pdev)
 {
        struct device_node *node = pdev->dev.of_node;
        struct img_i2c *i2c;
-       struct resource *res;
        int irq, ret;
        u32 val;
 
@@ -1338,8 +1337,7 @@ static int img_i2c_probe(struct platform_device *pdev)
        if (!i2c)
                return -ENOMEM;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       i2c->base = devm_ioremap_resource(&pdev->dev, res);
+       i2c->base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(i2c->base))
                return PTR_ERR(i2c->base);
 
index b426fc9..ba831df 100644 (file)
@@ -763,7 +763,6 @@ static int jz4780_i2c_probe(struct platform_device *pdev)
        int ret = 0;
        unsigned int clk_freq = 0;
        unsigned short tmp;
-       struct resource *r;
        struct jz4780_i2c *i2c;
 
        i2c = devm_kzalloc(&pdev->dev, sizeof(struct jz4780_i2c), GFP_KERNEL);
@@ -787,8 +786,7 @@ static int jz4780_i2c_probe(struct platform_device *pdev)
        init_completion(&i2c->trans_waitq);
        spin_lock_init(&i2c->lock);
 
-       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       i2c->iomem = devm_ioremap_resource(&pdev->dev, r);
+       i2c->iomem = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(i2c->iomem))
                return PTR_ERR(i2c->iomem);
 
index 13b0c12..197cb64 100644 (file)
@@ -346,7 +346,6 @@ static const struct i2c_algorithm i2c_lpc2k_algorithm = {
 static int i2c_lpc2k_probe(struct platform_device *pdev)
 {
        struct lpc2k_i2c *i2c;
-       struct resource *res;
        u32 bus_clk_rate;
        u32 scl_high;
        u32 clkrate;
@@ -356,8 +355,7 @@ static int i2c_lpc2k_probe(struct platform_device *pdev)
        if (!i2c)
                return -ENOMEM;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       i2c->base = devm_ioremap_resource(&pdev->dev, res);
+       i2c->base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(i2c->base))
                return PTR_ERR(i2c->base);
 
index 06b3bed..b3bd869 100644 (file)
@@ -397,7 +397,6 @@ static int meson_i2c_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
        struct meson_i2c *i2c;
-       struct resource *mem;
        struct i2c_timings timings;
        int irq, ret = 0;
 
@@ -422,8 +421,7 @@ static int meson_i2c_probe(struct platform_device *pdev)
                return PTR_ERR(i2c->clk);
        }
 
-       mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       i2c->regs = devm_ioremap_resource(&pdev->dev, mem);
+       i2c->regs = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(i2c->regs))
                return PTR_ERR(i2c->regs);
 
index 9b8f1d8..829b8c9 100644 (file)
@@ -877,7 +877,6 @@ mv64xxx_i2c_probe(struct platform_device *pd)
 {
        struct mv64xxx_i2c_data         *drv_data;
        struct mv64xxx_i2c_pdata        *pdata = dev_get_platdata(&pd->dev);
-       struct resource *r;
        int     rc;
 
        if ((!pdata && !pd->dev.of_node))
@@ -888,8 +887,7 @@ mv64xxx_i2c_probe(struct platform_device *pd)
        if (!drv_data)
                return -ENOMEM;
 
-       r = platform_get_resource(pd, IORESOURCE_MEM, 0);
-       drv_data->reg_base = devm_ioremap_resource(&pd->dev, r);
+       drv_data->reg_base = devm_platform_ioremap_resource(pd, 0);
        if (IS_ERR(drv_data->reg_base))
                return PTR_ERR(drv_data->reg_base);
 
index 64bda83..0c22796 100644 (file)
@@ -136,7 +136,6 @@ static int octeon_i2c_probe(struct platform_device *pdev)
 {
        struct device_node *node = pdev->dev.of_node;
        int irq, result = 0, hlc_irq = 0;
-       struct resource *res_mem;
        struct octeon_i2c *i2c;
        bool cn78xx_style;
 
@@ -167,8 +166,7 @@ static int octeon_i2c_probe(struct platform_device *pdev)
        i2c->roff.twsi_int = 0x10;
        i2c->roff.sw_twsi_ext = 0x18;
 
-       res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       i2c->twsi_base = devm_ioremap_resource(&pdev->dev, res_mem);
+       i2c->twsi_base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(i2c->twsi_base)) {
                result = PTR_ERR(i2c->twsi_base);
                goto out;
index 3ab8be6..fba6efc 100644 (file)
@@ -396,15 +396,13 @@ static int owl_i2c_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct owl_i2c_dev *i2c_dev;
-       struct resource *res;
        int ret, irq;
 
        i2c_dev = devm_kzalloc(dev, sizeof(*i2c_dev), GFP_KERNEL);
        if (!i2c_dev)
                return -ENOMEM;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       i2c_dev->base = devm_ioremap_resource(dev, res);
+       i2c_dev->base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(i2c_dev->base))
                return PTR_ERR(i2c_dev->base);
 
index 748872a..155dcde 100644 (file)
@@ -1660,7 +1660,6 @@ static int qup_i2c_probe(struct platform_device *pdev)
        static const int blk_sizes[] = {4, 16, 32};
        struct qup_i2c_dev *qup;
        unsigned long one_bit_t;
-       struct resource *res;
        u32 io_mode, hw_ver, size;
        int ret, fs_div, hs_div;
        u32 src_clk_freq = DEFAULT_SRC_CLK;
@@ -1757,8 +1756,7 @@ nodma:
                return -EINVAL;
        }
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       qup->base = devm_ioremap_resource(qup->dev, res);
+       qup->base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(qup->base))
                return PTR_ERR(qup->base);
 
index 73272d4..fbe41c8 100644 (file)
@@ -1193,7 +1193,6 @@ static int rk3x_i2c_probe(struct platform_device *pdev)
        struct device_node *np = pdev->dev.of_node;
        const struct of_device_id *match;
        struct rk3x_i2c *i2c;
-       struct resource *mem;
        int ret = 0;
        int bus_nr;
        u32 value;
@@ -1223,8 +1222,7 @@ static int rk3x_i2c_probe(struct platform_device *pdev)
        spin_lock_init(&i2c->lock);
        init_waitqueue_head(&i2c->wait);
 
-       mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       i2c->regs = devm_ioremap_resource(&pdev->dev, mem);
+       i2c->regs = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(i2c->regs))
                return PTR_ERR(i2c->regs);
 
index a459e00..d7f72ec 100644 (file)
@@ -271,7 +271,6 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev)
 {
        struct sirfsoc_i2c *siic;
        struct i2c_adapter *adap;
-       struct resource *mem_res;
        struct clk *clk;
        int bitrate;
        int ctrl_speed;
@@ -309,8 +308,7 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev)
        adap = &siic->adapter;
        adap->class = I2C_CLASS_DEPRECATED;
 
-       mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       siic->base = devm_ioremap_resource(&pdev->dev, mem_res);
+       siic->base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(siic->base)) {
                err = PTR_ERR(siic->base);
                goto out;
index ba6b60c..64d739b 100644 (file)
@@ -860,7 +860,6 @@ static int stu300_probe(struct platform_device *pdev)
 {
        struct stu300_dev *dev;
        struct i2c_adapter *adap;
-       struct resource *res;
        int bus_nr;
        int ret = 0;
 
@@ -876,8 +875,7 @@ static int stu300_probe(struct platform_device *pdev)
        }
 
        dev->pdev = pdev;
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       dev->virtbase = devm_ioremap_resource(&pdev->dev, res);
+       dev->virtbase = devm_platform_ioremap_resource(pdev, 0);
        dev_dbg(&pdev->dev, "initialize bus device I2C%d on virtual "
                "base %p\n", bus_nr, dev->virtbase);
        if (IS_ERR(dev->virtbase))
index e5293f0..17c27f7 100644 (file)
@@ -187,7 +187,6 @@ static int p2wi_probe(struct platform_device *pdev)
        struct device_node *childnp;
        unsigned long parent_clk_freq;
        u32 clk_freq = I2C_MAX_STANDARD_MODE_FREQ;
-       struct resource *r;
        struct p2wi *p2wi;
        u32 slave_addr;
        int clk_div;
@@ -231,8 +230,7 @@ static int p2wi_probe(struct platform_device *pdev)
                p2wi->slave_addr = slave_addr;
        }
 
-       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       p2wi->regs = devm_ioremap_resource(dev, r);
+       p2wi->regs = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(p2wi->regs))
                return PTR_ERR(p2wi->regs);
 
index 9099d0a..8cc91a8 100644 (file)
@@ -536,7 +536,6 @@ static const struct i2c_adapter synquacer_i2c_ops = {
 static int synquacer_i2c_probe(struct platform_device *pdev)
 {
        struct synquacer_i2c *i2c;
-       struct resource *r;
        u32 bus_speed;
        int ret;
 
@@ -574,8 +573,7 @@ static int synquacer_i2c_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       i2c->base = devm_ioremap_resource(&pdev->dev, r);
+       i2c->base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(i2c->base))
                return PTR_ERR(i2c->base);
 
index 391c878..286faa9 100644 (file)
@@ -506,15 +506,13 @@ static int xlp9xx_i2c_smbus_setup(struct xlp9xx_i2c_dev *priv,
 static int xlp9xx_i2c_probe(struct platform_device *pdev)
 {
        struct xlp9xx_i2c_dev *priv;
-       struct resource *res;
        int err = 0;
 
        priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
        if (!priv)
                return -ENOMEM;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       priv->base = devm_ioremap_resource(&pdev->dev, res);
+       priv->base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(priv->base))
                return PTR_ERR(priv->base);
 
index 282f161..126d139 100644 (file)
@@ -362,7 +362,6 @@ static int xlr_i2c_probe(struct platform_device *pdev)
 {
        const struct of_device_id *match;
        struct xlr_i2c_private  *priv;
-       struct resource *res;
        struct clk *clk;
        unsigned long clk_rate;
        unsigned long clk_div;
@@ -380,8 +379,7 @@ static int xlr_i2c_probe(struct platform_device *pdev)
        else
                priv->cfg = &xlr_i2c_config_default;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       priv->iobase = devm_ioremap_resource(&pdev->dev, res);
+       priv->iobase = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(priv->iobase))
                return PTR_ERR(priv->iobase);
 
index 5f33185..8db9519 100644 (file)
@@ -502,7 +502,6 @@ static int zx2967_i2c_probe(struct platform_device *pdev)
 {
        struct zx2967_i2c *i2c;
        void __iomem *reg_base;
-       struct resource *res;
        struct clk *clk;
        int ret;
 
@@ -510,8 +509,7 @@ static int zx2967_i2c_probe(struct platform_device *pdev)
        if (!i2c)
                return -ENOMEM;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       reg_base = devm_ioremap_resource(&pdev->dev, res);
+       reg_base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(reg_base))
                return PTR_ERR(reg_base);