Message ID | 20200526215528.16417-12-Sergey.Semin@baikalelectronics.ru (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | i2c: designeware: Add Baikal-T1 System I2C support | expand |
On Wed, May 27, 2020 at 4:03 AM Serge Semin <Sergey.Semin@baikalelectronics.ru> wrote: > > This is a preparation patch before adding a quirk with custom registers > map creation required for the Baikal-T1 System I2C support. Since we've > touched this code anyway let's replace > platform_get_resource()-devm_ioremap_resource() tuple with ready-to-use > helper devm_platform_get_and_ioremap_resource(). ... > +static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev) > +{ > + struct platform_device *pdev = to_platform_device(dev->dev); > + int ret = 0; Redundant. > + dev->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); What's the point of this API if you don't use resource parameter? > + if (IS_ERR(dev->base)) > + ret = PTR_ERR(dev->base); > + > + return ret; return PTR_ERR_OR_ZERO(dev->base); > +} > - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); > - dev->base = devm_ioremap_resource(&pdev->dev, mem); > - if (IS_ERR(dev->base)) > - return PTR_ERR(dev->base); Wolfram, did my last series make your tree? I think there was a patch that touched this part...
On Wed, May 27, 2020 at 12:26:09PM +0300, Andy Shevchenko wrote: > On Wed, May 27, 2020 at 4:03 AM Serge Semin > <Sergey.Semin@baikalelectronics.ru> wrote: > > > > This is a preparation patch before adding a quirk with custom registers > > map creation required for the Baikal-T1 System I2C support. Since we've > > touched this code anyway let's replace > > platform_get_resource()-devm_ioremap_resource() tuple with ready-to-use > > helper devm_platform_get_and_ioremap_resource(). > > ... > > > +static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev) > > +{ > > + struct platform_device *pdev = to_platform_device(dev->dev); > > > + int ret = 0; > > Redundant. > > > + dev->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); > > What's the point of this API if you don't use resource parameter? > > > + if (IS_ERR(dev->base)) > > + ret = PTR_ERR(dev->base); > > + > > + return ret; > > return PTR_ERR_OR_ZERO(dev->base); > > > +} > > > - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); > > - dev->base = devm_ioremap_resource(&pdev->dev, mem); > > - if (IS_ERR(dev->base)) > > - return PTR_ERR(dev->base); > > Wolfram, did my last series make your tree? I think there was a patch > that touched this part... Right. It is there. I'll rebase the series on top of the i2c/for-next branch. -Serge > > -- > With Best Regards, > Andy Shevchenko
On Wed, May 27, 2020 at 12:50 PM Serge Semin <Sergey.Semin@baikalelectronics.ru> wrote: > On Wed, May 27, 2020 at 12:26:09PM +0300, Andy Shevchenko wrote: > > On Wed, May 27, 2020 at 4:03 AM Serge Semin > > <Sergey.Semin@baikalelectronics.ru> wrote: ... > > Wolfram, did my last series make your tree? I think there was a patch > > that touched this part... > > Right. It is there. I'll rebase the series on top of the i2c/for-next branch. Ah, my memory did a trick. Thank you!
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 5ef7ffcf7f85..93bdcfae57df 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -234,6 +234,18 @@ static const u32 supported_speeds[] = { I2C_MAX_STANDARD_MODE_FREQ, }; +static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev) +{ + struct platform_device *pdev = to_platform_device(dev->dev); + int ret = 0; + + dev->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); + if (IS_ERR(dev->base)) + ret = PTR_ERR(dev->base); + + return ret; +} + static int dw_i2c_plat_probe(struct platform_device *pdev) { struct dw_i2c_platform_data *pdata = dev_get_platdata(&pdev->dev); @@ -241,7 +253,6 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) struct dw_i2c_dev *dev; struct i2c_timings *t; u32 acpi_speed; - struct resource *mem; int i, irq, ret; irq = platform_get_irq(pdev, 0); @@ -253,16 +264,14 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) return -ENOMEM; dev->flags |= (uintptr_t)device_get_match_data(&pdev->dev); - - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - dev->base = devm_ioremap_resource(&pdev->dev, mem); - if (IS_ERR(dev->base)) - return PTR_ERR(dev->base); - dev->dev = &pdev->dev; dev->irq = irq; platform_set_drvdata(pdev, dev); + ret = dw_i2c_plat_request_regs(dev); + if (ret) + return ret; + dev->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); if (IS_ERR(dev->rst)) return PTR_ERR(dev->rst);
This is a preparation patch before adding a quirk with custom registers map creation required for the Baikal-T1 System I2C support. Since we've touched this code anyway let's replace platform_get_resource()-devm_ioremap_resource() tuple with ready-to-use helper devm_platform_get_and_ioremap_resource(). Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru> Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Rob Herring <robh+dt@kernel.org> Cc: linux-mips@vger.kernel.org Cc: devicetree@vger.kernel.org --- Changelog v3: - This is a new patch, which has been created due to declining the glue-layer approach. --- drivers/i2c/busses/i2c-designware-platdrv.c | 23 ++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)