Received: by 10.223.185.116 with SMTP id b49csp2314995wrg; Sat, 17 Feb 2018 18:18:28 -0800 (PST) X-Google-Smtp-Source: AH8x2276aDUSx+ZUMTVvFJ4K3rKIo/Opsd4RaVIFFOfsr6DR36m582sgZvSUAARoK3CVeLvkzts/ X-Received: by 10.98.200.80 with SMTP id z77mr1522172pff.85.1518920308827; Sat, 17 Feb 2018 18:18:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518920308; cv=none; d=google.com; s=arc-20160816; b=EWfKunmA8LKtp4n7uBfpcpMfZgLMfrIuehTDougbxLVG3Qmy77Fym4c8TNHCQYi3cf Bsx4bOT4Si82qcfUyEhQv2EwgfIc4VBkJfwmQuaEv/8tW67qniyuhNuW8va6YPX4J/VX fIuuaheo2AyxKaHr5toOrIgAYbzriGLHr4sNld51bxfANcFM/zwV0rwTVFan0UkikAva YuPF8Q9UZmww3KQi7cpN8Psc+i2I+j9pH8CAVEvcGJv3mzgJ8NLvxe4Q//YXp9F/O87s l0MGRc6mK6HMHxZtQmADweZwPIAIbiNbAIdUaR/w1fwvmRAHYbmDcs5QVwd3nBDlOZ6k FZdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:arc-authentication-results; bh=cLU2J8dn4FcjYkBc+GL6tQuDBxNDIuFL62JSPZoMge8=; b=jVu1l1CsBFzWd2TRDKM2MfKJ/16RLEo6tedeEyvtQvgzqaFrBNP3nVFM9jP3sK0aFk 4Q7aH7aqhBqMA/f63A1R+RqGJqYWbGWL8INiykptoXdJaT3j63y91X5FYh/dLvEBf5fE ZICk/AxEmkZTJ/LXblWv4S17t9yoipzEXcU8LM4bQUl5Yc/JQ74AlFr6rETsp83xG+XN 8TAW6OFdrunuifk9We28115Ino7N02c3rXMRrN2wbez6C3Lw39OfvDLZ7ofwowDp+z1P AZwbjQ8+71B17c4sdVpuMuwVSQe7mq8mq130+CWF36wxcvGmPwPlMp32Nk/mTblPTxS1 LaOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f17si1547852pge.270.2018.02.17.18.17.31; Sat, 17 Feb 2018 18:18:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751349AbeBRCP1 convert rfc822-to-8bit (ORCPT + 99 others); Sat, 17 Feb 2018 21:15:27 -0500 Received: from mga03.intel.com ([134.134.136.65]:9643 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751258AbeBRCPZ (ORCPT ); Sat, 17 Feb 2018 21:15:25 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Feb 2018 18:15:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,527,1511856000"; d="scan'208";a="201959724" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga005.jf.intel.com with ESMTP; 17 Feb 2018 18:15:22 -0800 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 17 Feb 2018 18:15:22 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 17 Feb 2018 18:15:21 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.125]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.116]) with mapi id 14.03.0319.002; Sun, 18 Feb 2018 10:15:19 +0800 From: "Wu, Hao" To: Moritz Fischer CC: Alan Tull , "linux-fpga@vger.kernel.org" , linux-kernel , "linux-api@vger.kernel.org" , "Kang, Luwei" , "Zhang, Yi Z" , Xiao Guangrong , "Whisonant, Tim" , "Luebbers, Enno" , "Rao, Shiva" , "Rauer, Christopher" Subject: RE: [PATCH v4 07/24] fpga: dfl: add feature device infrastructure Thread-Topic: [PATCH v4 07/24] fpga: dfl: add feature device infrastructure Thread-Index: AQHTpK4DVba3ru3Qfk6Vgd/PbQo+oqOj3wKAgAAC9QCAAVknQIAAIXaAgAQVgCA= Date: Sun, 18 Feb 2018 02:15:18 +0000 Message-ID: References: <1518513893-4719-1-git-send-email-hao.wu@intel.com> <1518513893-4719-8-git-send-email-hao.wu@intel.com> <20180214210319.GC25618@tyrael.ni.corp.natinst.com> <20180215194901.GA4382@tyrael.ni.corp.natinst.com> In-Reply-To: <20180215194901.GA4382@tyrael.ni.corp.natinst.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTYxMTk1OTgtZjBlNi00MTE3LTljN2YtMjg5YTRmNTc0MDJjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJ5Q0ZRZm5POGlxYXp5clZFaDFsZmVKeklyYXUyVUVkTWdxaXo4QXpxYytqQ3FiVGUyRlE3dVBKUnlHR1NcL2Q3aCJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Thu, Feb 15, 2018 at 10:05:20AM +0000, Wu, Hao wrote: > > > On Wed, Feb 14, 2018 at 3:03 PM, Moritz Fischer wrote: > > > > > > Hi Moritz, > > > > > > > HI Hao, > > > > > > > > Hi Alan and Moritz > > > > Thanks a lot for the code review and comments. > > > > > > On Tue, Feb 13, 2018 at 05:24:36PM +0800, Wu Hao wrote: > > > >> From: Xiao Guangrong > > > >> > > > >> This patch abstracts the common operations of the sub features, and > defines > > > >> the feature_ops data structure, including init, uinit and ioctl function > > > >> pointers. And this patch adds some common helper functions for FME and > > > AFU > > > >> drivers, e.g feature_dev_use_begin/end which are used to ensure > exclusive > > > >> usage of the feature device file. > > > >> > > > >> Signed-off-by: Tim Whisonant > > > >> Signed-off-by: Enno Luebbers > > > >> Signed-off-by: Shiva Rao > > > >> Signed-off-by: Christopher Rauer > > > >> Signed-off-by: Kang Luwei > > > >> Signed-off-by: Zhang Yi > > > >> Signed-off-by: Xiao Guangrong > > > >> Signed-off-by: Wu Hao > > > >> --- > > > >> v2: rebased > > > >> v3: use const for feature_ops. > > > >> replace pci related function. > > > >> v4: rebase and add more comments in code. > > > >> --- > > > >> drivers/fpga/dfl.c | 59 +++++++++++++++++++++++++++++++++++++ > > > >> drivers/fpga/dfl.h | 85 > > > +++++++++++++++++++++++++++++++++++++++++++++++++++++- > > > >> 2 files changed, 143 insertions(+), 1 deletion(-) > > > >> > > > >> diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c > > > >> index 38dc819..c0aad87 100644 > > > >> --- a/drivers/fpga/dfl.c > > > >> +++ b/drivers/fpga/dfl.c > > > >> @@ -74,6 +74,65 @@ static enum fpga_id_type > feature_dev_id_type(struct > > > platform_device *pdev) > > > >> return FPGA_ID_MAX; > > > >> } > > > >> > > > >> +void fpga_dev_feature_uinit(struct platform_device *pdev) > > > >> +{ > > > >> + struct feature *feature; > > > >> + struct feature_platform_data *pdata = dev_get_platdata(&pdev- > >dev); > > > > See comment below w.r.t ordering declarations. Not a must for sure. > > > >> + > > > >> + fpga_dev_for_each_feature(pdata, feature) > > > >> + if (feature->ops) { > > > >> + feature->ops->uinit(pdev, feature); > > > >> + feature->ops = NULL; > > > >> + } > > > >> +} > > > >> +EXPORT_SYMBOL_GPL(fpga_dev_feature_uinit); > > > >> + > > > >> +static int > > > >> +feature_instance_init(struct platform_device *pdev, > > > >> + struct feature_platform_data *pdata, > > > >> + struct feature *feature, struct feature_driver *drv) > > > >> +{ > > > >> + int ret; > > > >> + > > > >> + WARN_ON(!feature->ioaddr); > > > > > > > > Not sure I understand correctly, is the !feature->ioaddr a use-case that > > > > happens? If not just return early. > > > > Actually this should never happen (init a feature without mapped mmio > > resource address). If this warning is seen, that means there should be > > critical issues somewhere in driver enumeration code. But sure, I can just > > use if () return instead. : ) > > > > > >> + > > > >> + ret = drv->ops->init(pdev, feature); > > > >> + if (ret) > > > >> + return ret; > > > >> + > > > >> + feature->ops = drv->ops; > > > >> + > > > >> + return ret; > > > >> +} > > > >> + > > > >> +int fpga_dev_feature_init(struct platform_device *pdev, > > > >> + struct feature_driver *feature_drvs) > > > >> +{ > > > >> + struct feature *feature; > > > >> + struct feature_driver *drv = feature_drvs; > > > >> + struct feature_platform_data *pdata = dev_get_platdata(&pdev- > >dev); > > > >> + int ret; > > > > We don't have clear guidelines here, but some subsystems want reverse > > > > X-Mas tree declarations. > > > > > > Sounds good! I agree. > > > > Do you mean we should reverse fpga_xxx definitions? If yes, then I can update > > the code to use fpga_dfl_xxx or dfl_xxx instead. : ) > > More a stylistic thing, in the sense that you'd have the longest line > first: > > + struct feature_platform_data *pdata = dev_get_platdata(&pdev->dev); > + struct feature_driver *drv = feature_drvs; > + struct feature *feature; > + int ret; > > Instead of: > > + struct feature *feature; > + struct feature_driver *drv = feature_drvs; > + struct feature_platform_data *pdata = dev_get_platdata(&pdev->dev); > + int ret; > > as I said not a big deal, some subsystems want you to do this, I don't > think we made that a strict rule so far, but it makes it visually more > pleasing ;-) Oh.. I see. Thanks for the suggestion, I will update the patch for this. Hao > > Moritz