Received: by 10.223.185.116 with SMTP id b49csp762505wrg; Fri, 16 Feb 2018 06:51:32 -0800 (PST) X-Google-Smtp-Source: AH8x225ltomrsdTtS/yzDy5sQOR4zKZI4K4qd1UWgVrK5b1yvSUkkd1be1eEfuZIMBCQXejmumKD X-Received: by 10.98.41.194 with SMTP id p185mr6453119pfp.38.1518792692607; Fri, 16 Feb 2018 06:51:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518792692; cv=none; d=google.com; s=arc-20160816; b=IYsSPkAZoNz39+Lc6DX4u/Nzz/ljtxFc7Dl8inxc2mLP73k/dh8fG9UkUZyRZJ2ql5 1bIKhYyRDl+jAoaF98ihePXp+KfV3ejRdysmYD0AFKp+7IojMGuQdpg0aDFY1bKhHqCh O949TFSRSop5AKVQJQRVHm+BavQ71IhczaaH/0NHkh6AzHMXsHpQw4NHeTCeRHwtykTZ Tx46P6UlMbcovNcFR52WDxOZznew2qdSKLXcwoQ2oraUVB9s11USbYDRQNracT3UG9Uo fC1CvGkFQUCUSTyUb4S5l5QZyV0o61RctQ8vQTggeXigq0wHoNi9cjVEK3RSESy+oSwj GXww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=JNlQHxrIodxahp9feo7OIkrPOrDWVLs7SGVmZmySjwU=; b=Nr8qS6AyniaPa5ji3todOIn3lpKwPyOpNxZ56/foUeBb6ZUZg3ZWj5WkdoPaaHrIsO cL2oSrz3j5n+ut1yOKyidmKYlNE7Oz+WVKysRZEfPeDgVCe+h4Ulb4AxYdxvEvk8F5cK UbZQq17ZNKPC0zNynjoezIWRoz3ZzvIyI3+FXZ9Q1nGKIrmqBNS/SFtNjSc59QT6KXSm xQM4fifKknWeBl+lBI0XA6HfXHrwlrXP78Eb71uxnK9t3/20yo4foMeO8u8BWv0FH4K/ QtC21CFJuBLN1oShzA++3M5Yhe28c/ywaI7HV2uUdkJBUD0wH29AWZ6JSHZ/Y+uph+RY Cy1A== 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 m66si1208282pfi.23.2018.02.16.06.51.18; Fri, 16 Feb 2018 06:51:32 -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 S1161694AbeBOTyA (ORCPT + 99 others); Thu, 15 Feb 2018 14:54:00 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:39148 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033831AbeBOTx4 (ORCPT ); Thu, 15 Feb 2018 14:53:56 -0500 Received: by mail-pl0-f67.google.com with SMTP id s13so422677plq.6 for ; Thu, 15 Feb 2018 11:53:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=JNlQHxrIodxahp9feo7OIkrPOrDWVLs7SGVmZmySjwU=; b=NPS2aElo3Jt9BJjrPzCycgQHbj1WD2DNqUIqpoX7LYBF37ofpA+VMlmibDSObAGB+q xOQsRdJMOSYobK4Jzj6PvbkQrdA+prmIuGcznyN5hpsNpBve4UQPtrEQyinld9juVEPc aES/XQrQ7NDFr+T2yXo3AkXGRIMDEzY4aoakxBpT9dqmzGTaoe0OZOJDWUKjjQWvEWDC Y5f57vEI59brLa6W31pvBunH5tptop7ZE4On48WtBzzc5lYx+b9LBS/GPau6Q2LmYop7 XfT8DWE2PvVJFVoMkZHZPXqofAucWnIirWhGSRXlH3Wq+NhERGd9KgXpqmW/DZFUBAlW zpdg== X-Gm-Message-State: APf1xPC4b51xx9W3FD78wSrnD0DuxWI2O890kU3+d5clNippb6v8msQR 8sZWNLrAh2Qh6xSbf1xgLXaW+g== X-Received: by 2002:a17:902:595d:: with SMTP id e29-v6mr3560684plj.189.1518724435937; Thu, 15 Feb 2018 11:53:55 -0800 (PST) Received: from localhost (207-114-172-147.static.twtelecom.net. [207.114.172.147]) by smtp.gmail.com with ESMTPSA id l84sm46085456pfb.153.2018.02.15.11.53.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Feb 2018 11:53:55 -0800 (PST) Date: Thu, 15 Feb 2018 11:49:01 -0800 From: Moritz Fischer To: "Wu, Hao" Cc: Alan Tull , Moritz Fischer , "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 Message-ID: <20180215194901.GA4382@tyrael.ni.corp.natinst.com> 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> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="C7zPtVaVf+AK4Oqc" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --C7zPtVaVf+AK4Oqc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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: > >=20 > > Hi Moritz, > >=20 > > > HI Hao, > > > >=20 > Hi Alan and Moritz >=20 > Thanks a lot for the code review and comments. >=20 > > > 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 func= tion > > >> pointers. And this patch adds some common helper functions for FME a= nd > > AFU > > >> drivers, e.g feature_dev_use_begin/end which are used to ensure excl= usive > > >> 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(stru= ct > > platform_device *pdev) > > >> return FPGA_ID_MAX; > > >> } > > >> > > >> +void fpga_dev_feature_uinit(struct platform_device *pdev) > > >> +{ > > >> + struct feature *feature; > > >> + struct feature_platform_data *pdata =3D 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 =3D 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 t= hat > > > happens? If not just return early. >=20 > 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. : ) >=20 > > >> + > > >> + ret =3D drv->ops->init(pdev, feature); > > >> + if (ret) > > >> + return ret; > > >> + > > >> + feature->ops =3D 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 =3D feature_drvs; > > >> + struct feature_platform_data *pdata =3D dev_get_platdata(&pdev= ->dev); > > >> + int ret; > > > We don't have clear guidelines here, but some subsystems want reverse > > > X-Mas tree declarations. > >=20 > > Sounds good! I agree. >=20 > Do you mean we should reverse fpga_xxx definitions? If yes, then I can up= date > 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 =3D dev_get_platdata(&pdev->dev); + struct feature_driver *drv =3D feature_drvs; + struct feature *feature; + int ret; Instead of: + struct feature *feature; + struct feature_driver *drv =3D feature_drvs; + struct feature_platform_data *pdata =3D 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 ;-) Moritz --C7zPtVaVf+AK4Oqc Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEowQ4eJSlIZpNWnl2UVwKRFcJcNgFAlqF5CkACgkQUVwKRFcJ cNhqqwf+Ibu/z4f0N3WBO4bAxe34nIx6p14BO4VSmsMKVOXdtzqbBc+wHnXqOcVK JZwXBvn4+7dVHbCLHivj0pnYk78gCptUUFrZRvDNoDsF8wwx1jsKjOjrh100T4Dn Tq8yG4LIi8A/85lt8CEcUDkXeu5M+7IMDAba2I/9fH/px0tUSThIXl6B8ERX+ev/ xC4WONYsmshDoq0x3l48Lgxh7KSZf92YsAeC4kHCitRa/e4LmV9dcKLQxWg9sgjl I4z+W4V+56pOku7zqLb8LdU3lbHNSIc+pesw/lBInFWw+eyhCU7puTq9JEpmB8rK 0xBsFSh0B4wkWKTPIYnuUw2buQKvsA== =MGvV -----END PGP SIGNATURE----- --C7zPtVaVf+AK4Oqc--