From patchwork Wed Feb 22 12:55:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 94317 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp925410obz; Wed, 22 Feb 2017 04:06:35 -0800 (PST) X-Received: by 10.157.22.193 with SMTP id s1mr17137034ots.17.1487765195324; Wed, 22 Feb 2017 04:06:35 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f13si1312710iod.99.2017.02.22.04.06.34; Wed, 22 Feb 2017 04:06:35 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id C569F60F22; Wed, 22 Feb 2017 12:06:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id CCDCE62D9F; Wed, 22 Feb 2017 11:58:47 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 718EA60D92; Wed, 22 Feb 2017 11:58:36 +0000 (UTC) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by lists.linaro.org (Postfix) with ESMTPS id 6F40660DFB for ; Wed, 22 Feb 2017 11:57:30 +0000 (UTC) Received: by mail-lf0-f49.google.com with SMTP id l12so178949lfe.0 for ; Wed, 22 Feb 2017 03:57:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cw46YJLijzTOeGkmlz2ZqsfY9k/IC6JETKZTgL8n/hs=; b=SPBj7KP1KwTeFxxQKb/ioKBz8WRPgg3so4MNvRp9PWI5cI8n1Cu6+Ii2RuQ4ZPbp9/ gOnmy68Ayb23Pll/eIKfEjESm7h3zQZ2SrX1NMZ7y8dRIfL7sYzlv/bHCjCA6HrBQBtz xdODs6qzpP0CGHZU3MH9A2uRiK/xiU95FEJ9OUilTezGdP01uwXppPinvcCKasQoHtXh IyIDSvtHV9U9jeyGgzSFuKL0d+VsYdYft4tNw9B73FsR85EhmcIg+32mj2bUsgVyQJts 1RiY7zx1EEJMqEHwqRdJo8ZqmrHHpiBT/V8lKGGD4AqHb1ZzSKZQKmROep+z3Lfivo/b asqg== X-Gm-Message-State: AMke39mkC3VdwWpeED6jJtCfmurN8IEkXM2P5z/ZuT5wMQkmsVi9OoaBJQrMmsYY6O/sfMYWy9c= X-Received: by 10.25.165.201 with SMTP id o192mr7212322lfe.84.1487764649057; Wed, 22 Feb 2017 03:57:29 -0800 (PST) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id v21sm7035187ljd.9.2017.02.22.03.57.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Feb 2017 03:57:28 -0800 (PST) From: Christophe Milard To: mike.holmes@linaro.org, yi.he@linaro.org, forrest.shi@linaro.org, sachin.saxena@linaro.com, bill.fischofer@linaro.org, lng-odp@lists.linaro.org Date: Wed, 22 Feb 2017 13:55:53 +0100 Message-Id: <1487768164-43184-11-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487768164-43184-1-git-send-email-christophe.milard@linaro.org> References: <1487768164-43184-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCH 10/21] linux-gen: drv: driver: adding device querry function X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Implementation of the device query function for the linux-gen ODP. Signed-off-by: Christophe Milard --- platform/linux-generic/drv_driver.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) -- 2.7.4 diff --git a/platform/linux-generic/drv_driver.c b/platform/linux-generic/drv_driver.c index 48a90a2..517a3c6 100644 --- a/platform/linux-generic/drv_driver.c +++ b/platform/linux-generic/drv_driver.c @@ -376,6 +376,43 @@ static void device_destroy_terminate(odpdrv_device_t drv_device) _odp_ishm_pool_free(list_elt_pool, device); } +odpdrv_device_t *odpdrv_device_query(odpdrv_enumr_t enumr, const char *address) +{ + _odpdrv_device_t *dev; + odpdrv_device_t *res; + int index = 0; + + int size = sizeof(odpdrv_device_t); /* for the ODPDRV_DEVICE_INVALID */ + + /* parse the list of device a first time to determine the size of + * the memory to be allocated: + */ + dev_list_read_lock(); + dev = device_lst.head; + while (dev) { + if ((dev->param.enumerator == enumr) && + ((address == NULL) || + (strcmp(dev->param.address, address) == 0))) + size += sizeof(odpdrv_device_t); + dev = dev->next; + } + + /* then fill the list: */ + res = (odpdrv_device_t *)malloc(size); + dev = device_lst.head; + while (dev) { + if ((dev->param.enumerator == enumr) && + ((address == NULL) || + (strcmp(dev->param.address, address) == 0))) + res[index++] = (odpdrv_device_t)dev; + dev = dev->next; + } + dev_list_read_unlock(); + res[index++] = ODPDRV_DEVICE_INVALID; + + return res; /* must be freed by caller! */ +} + odpdrv_devio_t odpdrv_devio_register(odpdrv_devio_param_t *param) { ODP_ERR("NOT Supported yet! Driver %s Registration!\n.",