> From: Clark Wang <xiaoning.wang@xxxxxxx> > Sent: Wednesday, March 17, 2021 2:54 PM > > Manage irq resource request/release in runtime pm to save irq domain's > power. > > Signed-off-by: Frank Li <Frank.Li@xxxxxxx> > Signed-off-by: Fugang Duan <fugang.duan@xxxxxxx> > Reviewed-by: Frank Li <Frank.Li@xxxxxxx> > --- > drivers/i2c/busses/i2c-imx-lpi2c.c | 26 ++++++++++++++------------ > 1 file changed, 14 insertions(+), 12 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c > b/drivers/i2c/busses/i2c-imx-lpi2c.c > index 664fcc0dba51..e718bb6b2387 100644 > --- a/drivers/i2c/busses/i2c-imx-lpi2c.c > +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c > @@ -94,6 +94,7 @@ enum lpi2c_imx_pincfg { > > struct lpi2c_imx_struct { > struct i2c_adapter adapter; > + int irq; > struct clk *clk_per; > struct clk *clk_ipg; > void __iomem *base; > @@ -543,7 +544,7 @@ static int lpi2c_imx_probe(struct platform_device > *pdev) { > struct lpi2c_imx_struct *lpi2c_imx; > unsigned int temp; > - int irq, ret; > + int ret; > > lpi2c_imx = devm_kzalloc(&pdev->dev, sizeof(*lpi2c_imx), GFP_KERNEL); > if (!lpi2c_imx) > @@ -553,9 +554,9 @@ static int lpi2c_imx_probe(struct platform_device > *pdev) > if (IS_ERR(lpi2c_imx->base)) > return PTR_ERR(lpi2c_imx->base); > > - irq = platform_get_irq(pdev, 0); > - if (irq < 0) > - return irq; > + lpi2c_imx->irq = platform_get_irq(pdev, 0); > + if (lpi2c_imx->irq < 0) > + return lpi2c_imx->irq; > > lpi2c_imx->adapter.owner = THIS_MODULE; > lpi2c_imx->adapter.algo = &lpi2c_imx_algo; > @@ -581,14 +582,6 @@ static int lpi2c_imx_probe(struct platform_device > *pdev) > if (ret) > lpi2c_imx->bitrate = I2C_MAX_STANDARD_MODE_FREQ; > > - ret = devm_request_irq(&pdev->dev, irq, lpi2c_imx_isr, > - IRQF_NO_SUSPEND, > - pdev->name, lpi2c_imx); > - if (ret) { > - dev_err(&pdev->dev, "can't claim irq %d\n", irq); > - return ret; > - } > - > i2c_set_adapdata(&lpi2c_imx->adapter, lpi2c_imx); > platform_set_drvdata(pdev, lpi2c_imx); > > @@ -640,6 +633,7 @@ static int __maybe_unused > lpi2c_runtime_suspend(struct device *dev) { > struct lpi2c_imx_struct *lpi2c_imx = dev_get_drvdata(dev); > > + devm_free_irq(dev, lpi2c_imx->irq, lpi2c_imx); > clk_disable_unprepare(lpi2c_imx->clk_ipg); > clk_disable_unprepare(lpi2c_imx->clk_per); > pinctrl_pm_select_idle_state(dev); > @@ -665,6 +659,14 @@ static int __maybe_unused > lpi2c_runtime_resume(struct device *dev) > dev_err(dev, "can't enable I2C ipg clock, ret=%d\n", ret); > } > > + ret = devm_request_irq(dev, lpi2c_imx->irq, lpi2c_imx_isr, I guess unnecessary to use devm in rpm > + IRQF_NO_SUSPEND, > + dev_name(dev), lpi2c_imx); > + if (ret) { > + dev_err(dev, "can't claim irq %d\n", lpi2c_imx->irq); > + return ret; > + } > + > return ret; > } > > -- > 2.25.1