Received: by 10.223.185.116 with SMTP id b49csp1185613wrg; Wed, 14 Feb 2018 13:01:14 -0800 (PST) X-Google-Smtp-Source: AH8x226a23Nj7WekNowLPrQiI6Ge+uSWmfayYTQQiunxybn5Bsl/tS9jjSZu9LTBRpFlrcZ0TU0J X-Received: by 2002:a17:902:523:: with SMTP id 32-v6mr281293plf.145.1518642074695; Wed, 14 Feb 2018 13:01:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518642074; cv=none; d=google.com; s=arc-20160816; b=GQ0zXz0EiO4xydMdEY+4S4zrwBO6N6awUtQ3lR703Rtlr5FAX6KDGV2cMZjMeNfZCg lZhpg2ae40/L6jWWz7/CXHoEJ/wH2HgWchb6mLzmq3TWcuYgjN/d6dmpGmz+76zZETLi ks6e2OtUQ8M3hyOKARpE4LI/MLDAg+rJrFwaUThCwkDcM1jncPgnvi5VFQjrr5vAIktS J8k0HXYecMVtm4ptPZYTsQS7rVv/KR2S32tb3Py01D8HC7nJwgFFrYDNZ69UBC8lINHR l9vJGrThv/X4F+zF4j/CIoBsBsn5IGheqLTQiGjHhTbaJz6NquYwu3iiE7SdT0Jerc6p RFvg== 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=bcLuD5Yo9ptLw6kxuHMWSTga4aicY3vc0u7vY7nIysw=; b=s9Mo8V1z1//eGdXKtPPDqrMoc7IEQMPqmKHAdhI70BhXV9UVTJDZnyp5S53AfcEL5H 9c6kR3fAW2SMP7ZLJrjdCMXAOUYqYhoBVpUP2k24kuyWzgENS1NDq+PZvqwinyB7kDc4 OT1JSqStJrX6kRjst+uYAUd9uYZo4WK0AEou8T9U/XqQNr7+iKLGxFVvqeoliiRPAhnd nMi20E7zsJ9e9ROfhhqvxxz4a8+7KC+To8rUDUWcLddz6y3cYrsV7z7WlEJFUeCXz7mG 8Ig8ELTN0nY0/EuUnsAeDbh1esLX6Rzrk2ajmm+nwMwJyP4qaZ6m9sGpHO4Yn+crGTXN 5AFw== 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 s204si2686855pgs.247.2018.02.14.13.00.59; Wed, 14 Feb 2018 13:01:14 -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 S1031149AbeBNVAG (ORCPT + 99 others); Wed, 14 Feb 2018 16:00:06 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:45405 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030902AbeBNVAD (ORCPT ); Wed, 14 Feb 2018 16:00:03 -0500 Received: by mail-pg0-f65.google.com with SMTP id e11so2506610pgq.12 for ; Wed, 14 Feb 2018 13:00:03 -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=bcLuD5Yo9ptLw6kxuHMWSTga4aicY3vc0u7vY7nIysw=; b=A3i11DOa2oWdUTqpNtOtoX7VF+k2pSYuPfW03Z4KGYbo2FTzHabB9v4CqN/JzsXR0l Q3wFo7GUEvDi3HjH2lFd7cIyRmUZ8cK7vC+r2clFgg2zLt1nJAETQQwkLQdmvyX9PplA +jh0avi5AT9iNAUJCISQdZgxuf+N6Qgt8twE3aWZfKZpqUk7SIMfXYCkuYdH6IpgcRGo rnZ37GXzJs5wBePoeVrG/QNriU6oG0KXso2vanj0RPO9RJRVzisjDc7DOLcdoM9hY5eE vVWqQjbmu73La0jhhEWCtPjGtfmZ4LkZzvXGIhvZtqKmfSPUfAuPfzgCmSQdVY44ZXdA XnCA== X-Gm-Message-State: APf1xPDyp0ROvvsww9vj7NrR9ulyf4osOUV53aX8uer1JjrZc/yEAFcp O9iJKQaBShOX8aijCg5xej+c/Q== X-Received: by 10.98.26.143 with SMTP id a137mr355655pfa.100.1518642003114; Wed, 14 Feb 2018 13:00:03 -0800 (PST) Received: from localhost (207-114-172-147.static.twtelecom.net. [207.114.172.147]) by smtp.gmail.com with ESMTPSA id i27sm11175601pfi.32.2018.02.14.13.00.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2018 13:00:02 -0800 (PST) Date: Wed, 14 Feb 2018 12:55:06 -0800 From: Moritz Fischer To: Wu Hao Cc: atull@kernel.org, mdf@kernel.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, luwei.kang@intel.com, yi.z.zhang@intel.com, Tim Whisonant , Enno Luebbers , Shiva Rao , Christopher Rauer , Xiao Guangrong Subject: Re: [PATCH v4 06/24] fpga: dfl: adds fpga_cdev_find_port Message-ID: <20180214205506.GA25618@tyrael.ni.corp.natinst.com> References: <1518513893-4719-1-git-send-email-hao.wu@intel.com> <1518513893-4719-7-git-send-email-hao.wu@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Q68bSM7Ycu6FN28Q" Content-Disposition: inline In-Reply-To: <1518513893-4719-7-git-send-email-hao.wu@intel.com> 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 --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Hao, On Tue, Feb 13, 2018 at 05:24:35PM +0800, Wu Hao wrote: > For feature devices, we need a method to find the port dedicated > to the device. This patch adds a function fpga_cdev_find_port > for this purpose. e.g FPGA Management Engine (FME) Partial > Reconfiguration sub feature, it uses this function to find > dedicated port on the device for PR function implementation. >=20 > Signed-off-by: Tim Whisonant > Signed-off-by: Enno Luebbers > Signed-off-by: Shiva Rao > Signed-off-by: Christopher Rauer > Signed-off-by: Xiao Guangrong > Signed-off-by: Wu Hao Acked-by: Moritz Fischer > --- > v3: s/fpga_for_each_port/fpga_cdev_find_port/ > move fpga_cdev_find_port to fpga-dfl module. > v4: improve description in commit message. > add comments to remind user to put_device after use this function. > --- > drivers/fpga/dfl.c | 34 ++++++++++++++++++++++++++++++++++ > drivers/fpga/dfl.h | 20 ++++++++++++++++++++ > 2 files changed, 54 insertions(+) >=20 > diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c > index dcfe5ab..38dc819 100644 > --- a/drivers/fpga/dfl.c > +++ b/drivers/fpga/dfl.c > @@ -783,6 +783,40 @@ void fpga_remove_feature_devs(struct fpga_cdev *cdev) > } > EXPORT_SYMBOL_GPL(fpga_remove_feature_devs); > =20 > +/** > + * __fpga_cdev_find_port - find a port under given container device > + * > + * @cdev: container device > + * @data: data passed to match function > + * @match: match function used to find specific port from the port devic= e list > + * > + * Find a port device under container device. This function needs to be > + * invoked with lock held. > + * > + * This function returns NULL if the device doesn't match and non-zero i= f it > + * does. If this function returns non-zero and a reference to the platfo= rm > + * device of port can be obtained. > + * > + * NOTE: you will need to drop the device reference with put_device() af= ter use. > + */ > +struct platform_device * > +__fpga_cdev_find_port(struct fpga_cdev *cdev, void *data, > + int (*match)(struct platform_device *, void *)) > +{ > + struct feature_platform_data *pdata; > + struct platform_device *port_dev; > + > + list_for_each_entry(pdata, &cdev->port_dev_list, node) { > + port_dev =3D pdata->dev; > + > + if (match(port_dev, data) && get_device(&port_dev->dev)) > + return port_dev; > + } > + > + return NULL; > +} > +EXPORT_SYMBOL_GPL(__fpga_cdev_find_port); > + > int fpga_port_id(struct platform_device *pdev) > { > void __iomem *base =3D get_feature_ioaddr_by_id(&pdev->dev, > diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h > index 9b19399..d6ecda1 100644 > --- a/drivers/fpga/dfl.h > +++ b/drivers/fpga/dfl.h > @@ -356,4 +356,24 @@ struct fpga_cdev { > struct fpga_cdev *fpga_enumerate_feature_devs(struct fpga_enum_info *inf= o); > void fpga_remove_feature_devs(struct fpga_cdev *cdev); > =20 > +/* > + * need to drop the device reference with put_device() after use port pl= atform > + * device returned by __fpga_cdev_find_port and fpga_cdev_find_port func= tions. > + */ > +struct platform_device * > +__fpga_cdev_find_port(struct fpga_cdev *cdev, void *data, > + int (*match)(struct platform_device *, void *)); > + > +static inline struct platform_device * > +fpga_cdev_find_port(struct fpga_cdev *cdev, void *data, > + int (*match)(struct platform_device *, void *)) > +{ > + struct platform_device *pdev; > + > + mutex_lock(&cdev->lock); > + pdev =3D __fpga_cdev_find_port(cdev, data, match); > + mutex_unlock(&cdev->lock); > + > + return pdev; > +} > #endif /* __FPGA_DFL_H */ > --=20 > 2.7.4 >=20 Thanks, Moritz --Q68bSM7Ycu6FN28Q Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEowQ4eJSlIZpNWnl2UVwKRFcJcNgFAlqEoicACgkQUVwKRFcJ cNi8lgf8DVZG8kd5D9+MQo+c1/Mgzgok7FgT261n9yUNqlxXBoaOv2pfrasDizK0 LirxHxRVQwNihPtxEy5qU0SNlMB1zg1ab1I+pFrNEexnNi6uNFlb98r9D62DfZjC RZOAU8JjrhFt/9pOFmEXbNtu5bWnrh8k0QpEOnrXoywksf6x3pptC7i/iBjsJYY/ JHrdPxhR0h5dU/fVAI97wwi7Fh47VkK5v0QETuuwLU3vsgIsepyACMzlBVJ272XW 75evaFyLufgeVcJQBFrpHI6lxcOBOmETv/gtxU6zdT4b05z5U52FtvCJ8dv9TavD Nmo58GqObWu7noL1Mpsg7g4KiHPDDg== =BgP7 -----END PGP SIGNATURE----- --Q68bSM7Ycu6FN28Q--