Message ID | 20200527120111.5781-11-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 03:01:10PM +0300, Serge Semin wrote: > This is a preparation patch before adding a quirk with custom registers > map creation required for the Baikal-T1 System I2C support. Looks good. Though one nit below. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > 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. > > Changelog v4: > - Use PTR_ERR_OR_ZERO() helper in the bt1_i2c_request_regs() method. > - Discard devm_platform_get_and_ioremap_resource() utilization. > --- > drivers/i2c/busses/i2c-designware-platdrv.c | 18 +++++++++++++----- > 1 file changed, 13 insertions(+), 5 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c > index ad292de2d260..061c8d506c7c 100644 > --- a/drivers/i2c/busses/i2c-designware-platdrv.c > +++ b/drivers/i2c/busses/i2c-designware-platdrv.c > @@ -108,6 +108,15 @@ static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev) > pm_runtime_put_noidle(dev->dev); > } > > +static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev) > +{ > + struct platform_device *pdev = to_platform_device(dev->dev); > + > + dev->base = devm_platform_ioremap_resource(pdev, 0); > + > + return PTR_ERR_OR_ZERO(dev->base); > +} > + > static int dw_i2c_plat_probe(struct platform_device *pdev) > { > struct dw_i2c_platform_data *pdata = dev_get_platdata(&pdev->dev); > @@ -125,15 +134,14 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) > return -ENOMEM; > > dev->flags |= (uintptr_t)device_get_match_data(&pdev->dev); It's related to previous patch, but I just realized that '|' is not needed here. Care to amend in the previous patch? > - > - dev->base = devm_platform_ioremap_resource(pdev, 0); > - 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); > -- > 2.26.2 >
On Wed, May 27, 2020 at 04:58:01PM +0300, Andy Shevchenko wrote: > On Wed, May 27, 2020 at 03:01:10PM +0300, Serge Semin wrote: > > This is a preparation patch before adding a quirk with custom registers > > map creation required for the Baikal-T1 System I2C support. > > Looks good. Though one nit below. > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > > 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. > > > > Changelog v4: > > - Use PTR_ERR_OR_ZERO() helper in the bt1_i2c_request_regs() method. > > - Discard devm_platform_get_and_ioremap_resource() utilization. > > --- > > drivers/i2c/busses/i2c-designware-platdrv.c | 18 +++++++++++++----- > > 1 file changed, 13 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c > > index ad292de2d260..061c8d506c7c 100644 > > --- a/drivers/i2c/busses/i2c-designware-platdrv.c > > +++ b/drivers/i2c/busses/i2c-designware-platdrv.c > > @@ -108,6 +108,15 @@ static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev) > > pm_runtime_put_noidle(dev->dev); > > } > > > > +static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev) > > +{ > > + struct platform_device *pdev = to_platform_device(dev->dev); > > + > > + dev->base = devm_platform_ioremap_resource(pdev, 0); > > + > > + return PTR_ERR_OR_ZERO(dev->base); > > +} > > + > > static int dw_i2c_plat_probe(struct platform_device *pdev) > > { > > struct dw_i2c_platform_data *pdata = dev_get_platdata(&pdev->dev); > > @@ -125,15 +134,14 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) > > return -ENOMEM; > > > > > dev->flags |= (uintptr_t)device_get_match_data(&pdev->dev); > > It's related to previous patch, but I just realized that '|' is not needed > here. Care to amend in the previous patch? Agreed. Thanks. -Sergey > > > - > > - dev->base = devm_platform_ioremap_resource(pdev, 0); > > - 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); > > -- > > 2.26.2 > > > > -- > With Best Regards, > Andy Shevchenko > >
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index ad292de2d260..061c8d506c7c 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -108,6 +108,15 @@ static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev) pm_runtime_put_noidle(dev->dev); } +static int dw_i2c_plat_request_regs(struct dw_i2c_dev *dev) +{ + struct platform_device *pdev = to_platform_device(dev->dev); + + dev->base = devm_platform_ioremap_resource(pdev, 0); + + return PTR_ERR_OR_ZERO(dev->base); +} + static int dw_i2c_plat_probe(struct platform_device *pdev) { struct dw_i2c_platform_data *pdata = dev_get_platdata(&pdev->dev); @@ -125,15 +134,14 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) return -ENOMEM; dev->flags |= (uintptr_t)device_get_match_data(&pdev->dev); - - dev->base = devm_platform_ioremap_resource(pdev, 0); - 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. 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. Changelog v4: - Use PTR_ERR_OR_ZERO() helper in the bt1_i2c_request_regs() method. - Discard devm_platform_get_and_ioremap_resource() utilization. --- drivers/i2c/busses/i2c-designware-platdrv.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)