Received: by 10.223.185.116 with SMTP id b49csp888142wrg; Wed, 14 Feb 2018 08:27:16 -0800 (PST) X-Google-Smtp-Source: AH8x226ND7W/CnJw1wPYqy+CjYy59uwcPWFeZizMfqxRV2tbgJCoOJBbqKs1i44/+L62JDWaDIBC X-Received: by 2002:a17:902:8544:: with SMTP id d4-v6mr5026284plo.312.1518625636661; Wed, 14 Feb 2018 08:27:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518625636; cv=none; d=google.com; s=arc-20160816; b=nC+/l9kSU5ZrU8QniB1e7qQzJ9ZPTqiSr77wbDoe+S27cIJu5m3lcd9qLhsbSsJISe QXD42TICqE0qxzGnIgrjwnOGY3UhxadHdSxMuKN1zvNeark54zp+LzyvM8Xi3+FSsBC9 OHiniVNZ5NZNeV25okCAaz55k4ho+ZhUNdcxwWGUCnODN0ivUfiAuM4t/tB4v4tYmpXo zTetiBsB+7w8P7qNp/yYvBlN42h2yXdqutxJGhr4OyRZ+2pyYm6oyjmE5rLD2yIPUVrp GzWL5mZnwfOvzxnH8cEkg9XME1F/f2naLkCAi6grXP5HFMye890MWY/sRHPQxv5qvylw kzQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dmarc-filter :arc-authentication-results; bh=NsjEwAo5MuM8yqBSHqeRpFv0mB9RVdEEAwb1B7bnXK8=; b=Wj4IxzIgX4F/YLhZjOMmt+CuuRwnF0GV1EUMbT7aFEmljFY5rJGgzOk+E7DkwkbEUi Df+CF//1v/08/7VZzgwRi83dK1tspC3OXXaqwfBlweC9HOsCPBYgYAOZVQGrdnDzX69N f/RnE4A2Gh96kW0PfvYbYKK9/qhVSMcKXge6gxMd8SyA23oGG2JSM+J1v508jidOhcyy jzcnoxvApMWDprU2VEeg4/sGGBbfwYUD8j8K7txiJ4uqCgiTn4W4F7c+PdsvNZgquyTn pQqDgLEKu7CnxSioheukeKeQnEUBTk/IB/UR3Rg6zWS4LjHDJythlszaACXUjvChEZW4 Sb8w== 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 m66si1373410pfi.23.2018.02.14.08.27.01; Wed, 14 Feb 2018 08:27:16 -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 S1032501AbeBNQZb (ORCPT + 99 others); Wed, 14 Feb 2018 11:25:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:41210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032204AbeBNQZ3 (ORCPT ); Wed, 14 Feb 2018 11:25:29 -0500 Received: from mail-ua0-f180.google.com (mail-ua0-f180.google.com [209.85.217.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1983D217BB; Wed, 14 Feb 2018 16:25:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1983D217BB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=atull@kernel.org Received: by mail-ua0-f180.google.com with SMTP id e25so14006101uan.5; Wed, 14 Feb 2018 08:25:29 -0800 (PST) X-Gm-Message-State: APf1xPA17rAhTm6LwF7o17TM4ctXRoNXudGZs+yqkbp102L9aLeqZGOD YueaBUMhlmq+hobbdwHhNU6Eq3zEzOQv3X+x/ng= X-Received: by 10.176.95.45 with SMTP id p45mr1303212uah.43.1518625528137; Wed, 14 Feb 2018 08:25:28 -0800 (PST) MIME-Version: 1.0 Received: by 10.159.60.79 with HTTP; Wed, 14 Feb 2018 08:24:47 -0800 (PST) In-Reply-To: <1518513893-4719-7-git-send-email-hao.wu@intel.com> References: <1518513893-4719-1-git-send-email-hao.wu@intel.com> <1518513893-4719-7-git-send-email-hao.wu@intel.com> From: Alan Tull Date: Wed, 14 Feb 2018 10:24:47 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 06/24] fpga: dfl: adds fpga_cdev_find_port To: Wu Hao Cc: Moritz Fischer , linux-fpga@vger.kernel.org, linux-kernel , linux-api@vger.kernel.org, "Kang, Luwei" , "Zhang, Yi Z" , Tim Whisonant , Enno Luebbers , Shiva Rao , Christopher Rauer , Xiao Guangrong Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 13, 2018 at 3:24 AM, Wu Hao wrote: Hi Hao, > 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. OK, that is very clear now, thanks! Ack with the minor doc changes below. > > 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: Alan Tull > --- > 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(+) > > 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); > > +/** > + * __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 device 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 if it > + * does. Good but this would be more brief and more specific and more in line with recommended format in Documentation/kernel-doc-nano-HOWTO.txt: * Return: pointer to port's platform device if successful, NULL otherwise. > If this function returns non-zero and a reference to the platform > + * device of port can be obtained. This if..then type sentence is not complete (missing the 'then' part). I see where you might have gotten inspiration for it from core.c. Probably you could just delete the sentence and all would be clear. > + * > + * NOTE: you will need to drop the device reference with put_device() after use. > + */ Good Thanks, Alan > +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 = 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 = 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 *info); > void fpga_remove_feature_devs(struct fpga_cdev *cdev); > > +/* > + * need to drop the device reference with put_device() after use port platform > + * device returned by __fpga_cdev_find_port and fpga_cdev_find_port functions. > + */ > +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 = __fpga_cdev_find_port(cdev, data, match); > + mutex_unlock(&cdev->lock); > + > + return pdev; > +} > #endif /* __FPGA_DFL_H */ > -- > 2.7.4 >