Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752767AbbHGKnl (ORCPT ); Fri, 7 Aug 2015 06:43:41 -0400 Received: from mail-bn1on0088.outbound.protection.outlook.com ([157.56.110.88]:62120 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751375AbbHGKnj (ORCPT ); Fri, 7 Aug 2015 06:43:39 -0400 X-Greylist: delayed 63527 seconds by postgrey-1.27 at vger.kernel.org; Fri, 07 Aug 2015 06:43:38 EDT Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Robert.Richter@caviumnetworks.com; Date: Fri, 7 Aug 2015 12:43:20 +0200 From: Robert Richter To: Tomasz Nowicki CC: David Daney , , , "David S. Miller" , , Sunil Goutham , , , David Daney Subject: Re: [PATCH 2/2] net, thunder, bgx: Add support for ACPI binding. Message-ID: <20150807104320.GQ1820@rric.localhost> References: <1438907590-29649-1-git-send-email-ddaney.cavm@gmail.com> <1438907590-29649-3-git-send-email-ddaney.cavm@gmail.com> <55C467A0.4020601@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <55C467A0.4020601@linaro.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Originating-IP: [92.224.195.216] X-ClientProxiedBy: AMSPR04CA0026.eurprd04.prod.outlook.com (10.242.87.144) To CY1PR0701MB1613.namprd07.prod.outlook.com (25.163.20.150) X-Microsoft-Exchange-Diagnostics: 1;CY1PR0701MB1613;2:Fd/yOVmqT2YTIHVWcNu8l5l1qXS0r7q8GZHmb4ZVIa8JKVjPCOgKlHXyp7+43Tp1D20TsMnNO4Zfwrh49b9GX+X6gutvoggPHO9O0qoORq5AYV3HsHDT9u+Jb+bB66sDL/NHC1nhQrfJKe8IPk2ZSPXqP3gbsKV5av1Lrh6PNco=;3:2NpVX0VGn6Vau4MVGKmvDqWmeBUMwCU3qHD0BXPZH8JFx+IeD2+qER1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6YPCJeoNCbh4=;4:Tv202D5jGVfQ1v/OVKP6jSQ/QSJV4E+LFnubp0yvXfzw/oa5MnLRQ0of+AVnbQRUanmYUkm09nthMg++FRkB9ZxfO3N7hKx6+Imzk+meCaJVXTlTrOI0ZmYWFgqEXs97JEFCtg70ZREDValaw/xl4z6hxvDsJ8qUKlQ4ibKZLnn/xl6p0ifSuGt1mvXsrTkxYDn3EVdXBoS9rVl9RaQC9xXq78TON7647IVRtnlR+J99ezgZkKBG5wO0MoIDfEylFcQaDk33z5P30Vf7skmmCnOpIw4rc1xmrGVF6Jl13nI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:CY1PR0701MB1613;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0701MB1613; X-Forefront-PRVS: 066153096A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(6009001)(199003)(24454002)(189002)(64706001)(5001860100001)(50466002)(66066001)(47776003)(23726002)(42186005)(76506005)(122386002)(40100003)(46102003)(46406003)(33656002)(81156007)(4001540100001)(5001960100002)(4001350100001)(77156002)(86362001)(110136002)(87976001)(62966003)(92566002)(97756001)(101416001)(83506001)(189998001)(77096005)(106356001)(105586002)(97736004)(54356999)(76176999)(50986999)(2950100001)(68736005)(5001830100001)(5001920100001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR0701MB1613;H:rric.localhost;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR0701MB1613;23:vEd7MvXIVqx97URNRJNw8mFG9FGds5dLuvWaI15?= =?us-ascii?Q?neZasFZE34h/OTsLA8PWBzmyXPLsdGw8GHabaPnT6KGzb15FDXLYaUQPYHKG?= =?us-ascii?Q?szz8kUK4ie21wr7tABbkIlM+SHu+/G96rMgOAkBEZVYcu9x+dvb6O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MsXOWHmNNTnlxX9KZh05lJVDUiRI2mc1/+gzLmoMl7?= =?us-ascii?Q?U35IJhX3bZqzaZgakaEAmhXf313/r4eegniylZJy3YFcFSyOsK51/l8GehYP?= =?us-ascii?Q?KsW1GyR31QnxyEwZd0iLjCCJVGAFQoH87?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR0701MB1613;5:TT6tDFd7flcBTHjLHvQWEC+gie/P1d0HnWL5B5ixWn2Xa+/BPuphPs2eq/K9pBq0RiuCZd7qJ8Dzof8qLhPkTiijDOgAFXU1GvHTmUTJzCvx1QFpIMVjMXfz2DNzOPUCdPpwx01itn7cjxoM+N8/KQ==;24:ZGMZ2sCYSpH5zeCYEd/iLg4GnKLxmAeMcihKN3B9FwuofTpgEQBdRT/riB1HS5w2M4qoBLimM8lnZU8OVqslKS7hBSHDPgFQ0FsIzk4nmmQ=;20:gtityx0+choz0Ew0pN9l3trh862vrRxRXrrmisIcKeV4dI4q8B5DQiOtsR/mF2n5n+mRVcacKLCL66aeumztZA== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2015 10:43:34.8535 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0701MB1613 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1897 Lines: 70 On 07.08.15 10:09:04, Tomasz Nowicki wrote: > On 07.08.2015 02:33, David Daney wrote: ... > >+#else > >+ > >+static int bgx_init_acpi_phy(struct bgx *bgx) > >+{ > >+ return -ENODEV; > >+} > >+ > >+#endif /* CONFIG_ACPI */ > >+ > > #if IS_ENABLED(CONFIG_OF_MDIO) > > > > static int bgx_init_of_phy(struct bgx *bgx) > >@@ -882,7 +1010,12 @@ static int bgx_init_of_phy(struct bgx *bgx) > > > > static int bgx_init_phy(struct bgx *bgx) > > { > >- return bgx_init_of_phy(bgx); > >+ int err = bgx_init_of_phy(bgx); > >+ > >+ if (err != -ENODEV) > >+ return err; > >+ > >+ return bgx_init_acpi_phy(bgx); > > } > > > > If kernel can work with DT and ACPI (both compiled in), it should take only > one path instead of probing DT and ACPI sequentially. How about: > > @@ -902,10 +925,9 @@ static int bgx_probe(struct pci_dev *pdev, const struct > pci_device_id *ent) > bgx_vnic[bgx->bgx_id] = bgx; > bgx_get_qlm_mode(bgx); > > - snprintf(bgx_sel, 5, "bgx%d", bgx->bgx_id); > - np = of_find_node_by_name(NULL, bgx_sel); > - if (np) > - bgx_init_of(bgx, np); > + err = acpi_disabled ? bgx_init_of_phy(bgx) : bgx_init_acpi_phy(bgx); > + if (err) > + goto err_enable; > > bgx_init_hw(bgx); I would not pollute bgx_probe() with acpi and dt specifics, and instead keep bgx_init_phy(). The typical design pattern for this is: static int bgx_init_phy(struct bgx *bgx) { #ifdef CONFIG_ACPI if (!acpi_disabled) return bgx_init_acpi_phy(bgx); #endif return bgx_init_of_phy(bgx); } This adds acpi runtime detection (acpi=no), does not call dt code in case of acpi, and saves the #else for bgx_init_acpi_phy(). -Robert -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/