diff mbox series

[v6,1/1] PCI: kirin: Add MSI support

Message ID 20180711065724.128299-2-songxiaowei@hisilicon.com
State Superseded
Headers show
Series [v6,1/1] PCI: kirin: Add MSI support | expand

Commit Message

Songxiaowei (Kirin_DRV) July 11, 2018, 6:57 a.m. UTC
Add support for MSI

Signed-off-by: Xiaowei Song <songxiaowei@hisilicon.com>
Signed-off-by: Yao Chen <chenyao11@huawei.com>
---
 drivers/pci/dwc/pcie-kirin.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Comments

Andy Shevchenko July 11, 2018, 7:23 a.m. UTC | #1
On Wed, Jul 11, 2018 at 9:57 AM, Xiaowei Song <songxiaowei@hisilicon.com> wrote:
> Add support for MSI

> +static int kirin_pcie_add_msi(struct dw_pcie *pci,
> +                               struct platform_device *pdev)
> +{
> +       int ret = 0;
> +
> +       if (IS_ENABLED(CONFIG_PCI_MSI)) {
> +               ret = platform_get_irq(pdev, 0);
> +               if (ret < 0) {
> +                       dev_err(&pdev->dev,
> +                               "failed to get MSI IRQ (%d)\n", ret);
> +                       return ret;
> +               }
> +
> +               pci->pp.msi_irq = ret;
> +       }
> +
> +       return ret;
> +}

Like someone already noticed, is it really IRQ number you would like to return?

If you rewrite like

int irq;

if (IS_ENABLED(...)) {
 irq = ...
 if (irq < 0)
   return irq;

... = irq;

}

return 0;

It would be slightly more explicit what you do and what you return.
Songxiaowei (Kirin_DRV) July 11, 2018, 7:36 a.m. UTC | #2
> -----邮件原件-----
> 发件人: Andy Shevchenko [mailto:andy.shevchenko@gmail.com]
> 发送时间: 2018年7月11日 15:23
> 收件人: Songxiaowei (Kirin_DRV) <songxiaowei@hisilicon.com>
> 抄送: Wangbinghui <wangbinghui@hisilicon.com>; Bjorn Helgaas
> <bhelgaas@google.com>; Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>;
> Rob Herring <robh+dt@kernel.org>; linux-pci@vger.kernel.org; Linux Kernel
> Mailing List <linux-kernel@vger.kernel.org>; Suzhuangluan
> <suzhuangluan@hisilicon.com>; Kongfei <kongfei@hisilicon.com>; chenyao
> (F) <chenyao11@huawei.com>
> 主题: Re: [PATCH v6 1/1] PCI: kirin: Add MSI support
> 
> On Wed, Jul 11, 2018 at 9:57 AM, Xiaowei Song <songxiaowei@hisilicon.com>
> wrote:
> > Add support for MSI
> 
> > +static int kirin_pcie_add_msi(struct dw_pcie *pci,
> > +                               struct platform_device *pdev) {
> > +       int ret = 0;
> > +
> > +       if (IS_ENABLED(CONFIG_PCI_MSI)) {
> > +               ret = platform_get_irq(pdev, 0);
> > +               if (ret < 0) {
> > +                       dev_err(&pdev->dev,
> > +                               "failed to get MSI IRQ (%d)\n", ret);
> > +                       return ret;
> > +               }
> > +
> > +               pci->pp.msi_irq = ret;
> > +       }
> > +
> > +       return ret;
> > +}
> 
> Like someone already noticed, is it really IRQ number you would like to
> return?
> 
> If you rewrite like
> 
> int irq;
> 
> if (IS_ENABLED(...)) {
>  irq = ...
>  if (irq < 0)
>    return irq;
> 
> ... = irq;
> 
> }
> 
> return 0;
> 
> It would be slightly more explicit what you do and what you return.
>

Hi Andy
I think did not get Lorenzo's meaning before, thank you so much, and I'll modify the patch as soon as possible.
Best Regards,
Xiaowei Song.
> --
> With Best Regards,
> Andy Shevchenko
diff mbox series

Patch

diff --git a/drivers/pci/dwc/pcie-kirin.c b/drivers/pci/dwc/pcie-kirin.c
index d2970a009eb5..369bf87d2fff 100644
--- a/drivers/pci/dwc/pcie-kirin.c
+++ b/drivers/pci/dwc/pcie-kirin.c
@@ -430,6 +430,9 @@  static int kirin_pcie_host_init(struct pcie_port *pp)
 {
 	kirin_pcie_establish_link(pp);
 
+	if (IS_ENABLED(CONFIG_PCI_MSI))
+		dw_pcie_msi_init(pp);
+
 	return 0;
 }
 
@@ -445,9 +448,34 @@  static const struct dw_pcie_host_ops kirin_pcie_host_ops = {
 	.host_init = kirin_pcie_host_init,
 };
 
+static int kirin_pcie_add_msi(struct dw_pcie *pci,
+				struct platform_device *pdev)
+{
+	int ret = 0;
+
+	if (IS_ENABLED(CONFIG_PCI_MSI)) {
+		ret = platform_get_irq(pdev, 0);
+		if (ret < 0) {
+			dev_err(&pdev->dev,
+				"failed to get MSI IRQ (%d)\n", ret);
+			return ret;
+		}
+
+		pci->pp.msi_irq = ret;
+	}
+
+	return ret;
+}
+
 static int __init kirin_add_pcie_port(struct dw_pcie *pci,
 				      struct platform_device *pdev)
 {
+	int ret;
+
+	ret = kirin_pcie_add_msi(pci, pdev);
+	if (ret < 0)
+		return ret;
+
 	pci->pp.ops = &kirin_pcie_host_ops;
 
 	return dw_pcie_host_init(&pci->pp);