Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1405732imm; Fri, 29 Jun 2018 18:11:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKSQOZR6EeF9sR6rXSvFRSGKjaAQQW69ij+uPPn7YiNj9rAPbh0j+FpWRt0SysBzoHcLePI X-Received: by 2002:a63:951e:: with SMTP id p30-v6mr14364540pgd.318.1530321103831; Fri, 29 Jun 2018 18:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530321103; cv=none; d=google.com; s=arc-20160816; b=y1tnlNiLsi70Kuig9/uipNkLTXsVHM2awzXP3AHA1t2Ui2SilfXEGdNZGcKpHjAe4g eNw4IIXNpCFbBdY6GciQS94d9jiMs6inyvWJTCf5B4D/qb3eOruf9GnIZjGgdzLV71nP NyUKbvhJA6a3/a5H5gmPnF6TYzWqgVG5CHw8PXY9YrRypIenLVDyX29UdSr1dxy1tkj5 gbMz+PIUzGErY8gRAcoBFLjtY8qzpfIJzW722JPs3MnVrVCKxJcqPwqqT3gJipIrBR7s T0569x7LaU9juY4QUpnCpeE04nxPng6RcKiikoTje37tiZa0UnzuQmcndALVEe5ieBNX GUaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=OFetacYqHzPJI3EDlcg1hPtakdhllZxu+hs67zR7HPE=; b=kSd2aczizRKLP5v5eqOsjDGJNmGrv7DnonERV1mbjgjKR/lEzHRSKbFHCLVpeBCvSh U0kpgv7Ll2jDpUf4QwK4X/lFwbEHbEVqc+wKVESfZTPf8jM0Uqy9zKz7ZKef1zTlwBwS X2ECZLf4JE+Ks1lCm9ZT7e992K6b2SgHfN/K28WEDKTwhUNmcfxnl53b3PR6BI2eMpKZ y2ApJSvwWHalSuA/CAxmTXlb9EN9FTkJlNJbE/tN3lxpXaAlLUJB3ydbOZwxHtZlCFZv pcfECihbkS0o2yfI8fR1nSyyjzCRLBKKIsGJcoZmvQ5+qrdctpfgW9INX8y6ZjKdsNGc yjiQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17-v6si5759192pgq.391.2018.06.29.18.11.29; Fri, 29 Jun 2018 18:11:43 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936104AbeF3BGX (ORCPT + 99 others); Fri, 29 Jun 2018 21:06:23 -0400 Received: from mga07.intel.com ([134.134.136.100]:23619 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935851AbeF3BGN (ORCPT ); Fri, 29 Jun 2018 21:06:13 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Jun 2018 18:06:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,288,1526367600"; d="scan'208";a="212317283" Received: from hao-dev.bj.intel.com ([10.238.157.61]) by orsmga004.jf.intel.com with ESMTP; 29 Jun 2018 18:06:11 -0700 From: Wu Hao To: atull@kernel.org, mdf@kernel.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-api@vger.kernel.org, luwei.kang@intel.com, yi.z.zhang@intel.com, hao.wu@intel.com Subject: [PATCH v7 11/29] fpga: dfl: add dfl_fpga_check_port_id function. Date: Sat, 30 Jun 2018 08:53:18 +0800 Message-Id: <1530320016-24712-12-git-send-email-hao.wu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530320016-24712-1-git-send-email-hao.wu@intel.com> References: <1530320016-24712-1-git-send-email-hao.wu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds one common function in DFL framework. It uses port_ops get_id callback to get port id and compare it with given value. This function could be used as match function of the dfl_fpga_cdev_find_port function. Signed-off-by: Wu Hao Acked-by: Alan Tull --- v6: reabse and add Acked-by from Alan. --- drivers/fpga/dfl.c | 22 ++++++++++++++++++++++ drivers/fpga/dfl.h | 1 + 2 files changed, 23 insertions(+) diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c index 421668a..a9b521b 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -216,6 +216,28 @@ void dfl_fpga_port_ops_del(struct dfl_fpga_port_ops *ops) EXPORT_SYMBOL_GPL(dfl_fpga_port_ops_del); /** + * dfl_fpga_check_port_id - check the port id + * @pdev: port platform device. + * @pport_id: port id to compare. + * + * Return: 1 if port device matches with given port id, otherwise 0. + */ +int dfl_fpga_check_port_id(struct platform_device *pdev, void *pport_id) +{ + struct dfl_fpga_port_ops *port_ops = dfl_fpga_port_ops_get(pdev); + int port_id; + + if (!port_ops || !port_ops->get_id) + return 0; + + port_id = port_ops->get_id(pdev); + dfl_fpga_port_ops_put(port_ops); + + return port_id == *(int *)pport_id; +} +EXPORT_SYMBOL_GPL(dfl_fpga_check_port_id); + +/** * dfl_fpga_dev_feature_uinit - uinit for sub features of dfl feature device * @pdev: feature device. */ diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h index 654e0f6..a8b869e 100644 --- a/drivers/fpga/dfl.h +++ b/drivers/fpga/dfl.h @@ -151,6 +151,7 @@ struct dfl_fpga_port_ops { void dfl_fpga_port_ops_del(struct dfl_fpga_port_ops *ops); struct dfl_fpga_port_ops *dfl_fpga_port_ops_get(struct platform_device *pdev); void dfl_fpga_port_ops_put(struct dfl_fpga_port_ops *ops); +int dfl_fpga_check_port_id(struct platform_device *pdev, void *pport_id); /** * struct dfl_feature_driver - sub feature's driver -- 1.8.3.1