Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932226AbdLTF7w (ORCPT ); Wed, 20 Dec 2017 00:59:52 -0500 Received: from fllnx209.ext.ti.com ([198.47.19.16]:43504 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932186AbdLTF7u (ORCPT ); Wed, 20 Dec 2017 00:59:50 -0500 Subject: Re: [PATCH v6 09/18] PCI: dwc: dra7xx: Help compiler to remove unused code To: Niklas Cassel , Lorenzo Pieralisi , Bjorn Helgaas References: <20171219232940.659-1-niklas.cassel@axis.com> <20171219232940.659-10-niklas.cassel@axis.com> CC: Niklas Cassel , , , From: Kishon Vijay Abraham I Message-ID: Date: Wed, 20 Dec 2017 11:28:55 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20171219232940.659-10-niklas.cassel@axis.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1648 Lines: 49 On Wednesday 20 December 2017 04:59 AM, Niklas Cassel wrote: > The dra7xx driver supports both host and ep mode. > When enabling support for only one of the modes, help the compiler > to remove code for the mode that we have not enabled in the driver. > > By adding if (!IS_ENABLED(CONFIG_PCI_DRA7XX_HOST)) return -ENODEV; > anything after that statement will get silently dropped by the compiler, > including static functions and structures that are referenced indirectly > from there. > > Suggested-by: Arnd Bergmann > Signed-off-by: Niklas Cassel Acked-by: Kishon Vijay Abraham I > --- > drivers/pci/dwc/pci-dra7xx.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c > index 07c74ae3614e..224ff8affdce 100644 > --- a/drivers/pci/dwc/pci-dra7xx.c > +++ b/drivers/pci/dwc/pci-dra7xx.c > @@ -694,6 +694,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) > > switch (mode) { > case DW_PCIE_RC_TYPE: > + if (!IS_ENABLED(CONFIG_PCI_DRA7XX_HOST)) { > + ret = -ENODEV; > + goto err_gpio; > + } > + > dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_DEVICE_TYPE, > DEVICE_TYPE_RC); > ret = dra7xx_add_pcie_port(dra7xx, pdev); > @@ -701,6 +706,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) > goto err_gpio; > break; > case DW_PCIE_EP_TYPE: > + if (!IS_ENABLED(CONFIG_PCI_DRA7XX_EP)) { > + ret = -ENODEV; > + goto err_gpio; > + } > + > dra7xx_pcie_writel(dra7xx, PCIECTRL_TI_CONF_DEVICE_TYPE, > DEVICE_TYPE_EP); > >