Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933521AbbLVSaE (ORCPT ); Tue, 22 Dec 2015 13:30:04 -0500 Received: from mail-by2on0086.outbound.protection.outlook.com ([207.46.100.86]:10336 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754500AbbLVS35 (ORCPT ); Tue, 22 Dec 2015 13:29:57 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=David.Daney@caviumnetworks.com; Message-ID: <5679968B.4090908@caviumnetworks.com> Date: Tue, 22 Dec 2015 10:29:31 -0800 From: David Daney User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Will Deacon CC: David Daney , , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , , , Marc Zyngier , Bjorn Helgaas , , Arnd Bergmann , David Daney Subject: Re: [PATCH 1/2] PCI: generic: Refactor code to enable reuse by other drivers. References: <1450749222-15966-1-git-send-email-ddaney.cavm@gmail.com> <1450749222-15966-2-git-send-email-ddaney.cavm@gmail.com> <20151222100732.GD32623@arm.com> In-Reply-To: <20151222100732.GD32623@arm.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [64.2.3.194] X-ClientProxiedBy: BY2PR07CA071.namprd07.prod.outlook.com (10.141.251.46) To DM3PR07MB2138.namprd07.prod.outlook.com (25.164.4.144) X-Microsoft-Exchange-Diagnostics: 1;DM3PR07MB2138;2:HhD2smIyJqvFn2V3+QUMv6q836cPj/5Emc9ry622VN/NlK2gKQanpXM91YT7XwF7Z2vzw7ffzYSq1zEgfeWkKYTfFiwzaxod6VxHDNA/v9116/QYBgOw9EDla2wBI09ny4hUmsA9Ug3/kDhiRg/UHQ==;3:4QlL7tvhmx4yp2o5Hk3kg6c1wJcvX7pq69WD0X+PgQuGAQzoUntmsUfpU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ispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001)(10201501046);SRVR:DM3PR07MB2138;BCL:0;PCL:0;RULEID:;SRVR:DM3PR07MB2138; X-Microsoft-Exchange-Diagnostics: 1;DM3PR07MB2138;4:8kmcBaHlNhLLJRnDJP9jvxnZgMWx8On8KkrQYKL3JCdDPRDvLWIEKcvY6smZzwUPAsqy3+SleGkwkI1x9Zifi/NGvF+7Lk5uJJB7oBOAupOIXKsf5rT8vIHer+pYlpwy7+Jde4zRZGQV5hhM2xWLUQN0vAxqD9E0Hr5WeKKe/B9yny3uQIMM1Xi7W0YTyH+Yz9QRGLlZC9ih11BOUJFymTvgY5ST96JRyzxzdA1/20StnUV5OIXHbiwQJF0X5tWrwqAdOqG3jmTiyFXTAcOrnLZkHLv0OVudLZ3TjZgIUQjWfPM0OIrlpCb7w6EG3PoFhfaOBxYfrvXHbArmKMq60DIE9NRCer7grDj+MMzm+miCMOWjHmMlc4V73NWmntxx X-Forefront-PRVS: 0798146F16 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(979002)(6009001)(24454002)(189002)(377454003)(199003)(479174004)(3846002)(50466002)(122386002)(105586002)(6116002)(1096002)(53416004)(92566002)(586003)(59896002)(65816999)(189998001)(5004730100002)(5008740100001)(69596002)(99136001)(42186005)(19580395003)(19580405001)(101416001)(80316001)(87976001)(2950100001)(87266999)(50986999)(33656002)(65806001)(47776003)(54356999)(76176999)(64126003)(40100003)(66066001)(65956001)(83506001)(5890100001)(36756003)(4001350100001)(110136002)(106356001)(81156007)(5001960100002)(77096005)(97736004)(230700001)(23756003)(41533002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM3PR07MB2138;H:dl.caveonetworks.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?iso-8859-1?Q?1;DM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q+ZEzZnQon9FRv6+vo= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2015 18:29:39.8451 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR07MB2138 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3312 Lines: 76 On 12/22/2015 02:07 AM, Will Deacon wrote: > On Mon, Dec 21, 2015 at 05:53:41PM -0800, David Daney wrote: >> From: David Daney >> >> No change in functionality. >> >> Move structure definitions into a separate header file. Split probe >> function in to two parts: >> >> - a small driver specific probe function (gen_pci_probe) >> >> - a common probe that can be used by other drivers >> (gen_pci_common_probe) >> >> Signed-off-by: David Daney >> --- >> drivers/pci/host/pci-host-generic.c | 53 ++++++++++++----------------------- >> drivers/pci/host/pci-host-generic.h | 56 +++++++++++++++++++++++++++++++++++++ >> 2 files changed, 74 insertions(+), 35 deletions(-) >> create mode 100644 drivers/pci/host/pci-host-generic.h >> >> diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c >> index 5434c90..e83cec7 100644 >> --- a/drivers/pci/host/pci-host-generic.c >> +++ b/drivers/pci/host/pci-host-generic.c [...] >> -static int gen_pci_probe(struct platform_device *pdev) >> +int gen_pci_common_probe(struct platform_device *pdev, >> + struct gen_pci *pci) > > Whilst I'm fine with this patch, I don't know how Bjorn will feel about > exposing this function outside of the generic host driver. We could avoid > it by turning things upside-down and having the generic driver probe > the other drivers by matching a compatible string with a probe function > pointer, but I'd be interested to see what others think. > Note: I know that pci-host-generic is not built as a loadable module, but... struct of_device_id, MODULE_DEVICE_TABLE, struct platform_driver and the registering of platform drivers is fairly well standardized in the kernel, and module loading userpace tools. The struct of_device_id, MODULE_DEVICE_TABLE must really reside in the same module as the driver for the device. We are creating a separate driver precisely because we don't want to mix all this ThunderX specific code into the pci-host-generic driver when it is used by arm-32bit and others. This means that, at a minimum, we would have to export the pci-host-generic probe function so that it could be referenced by struct platform_driver in other modules. This brings up the next problem. How to attach driver specific data to the generic driver structures? At first I tried augmenting struct gen_pci_cfg_bus_ops with a callback .init() function to be called by the generic driver, but this would also require adding an an element to struct gen_pci to point to a driver specific data object. It felt a little convoluted and complex. This led me to the current design where struct gen_pci is embedded in the driver specific structure, and the allocation of this is done in the driver specific probe function. No more callbacks, no additions to the pci-host-generic structures. I think it is a little cleaner this way. If there are suggestions as to how it can be made cleaner yet, I would be happy to implement and test them. David Daney > Will > -- 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/