From: Shreyansh Jain <shreyansh.jain@nxp.com>
To: "dev@dpdk.org" <dev@dpdk.org>
Cc: "ferruh.yigit@intel.com" <ferruh.yigit@intel.com>,
Shreyansh Jain <shreyansh.jain@nxp.com>,
"stable@dpdk.org" <stable@dpdk.org>
Subject: [dpdk-stable] [PATCH v2 06/20] bus/fslmc: fix parse method for bus devices
Date: Fri, 11 Jan 2019 11:58:09 +0000 [thread overview]
Message-ID: <20190111115712.6482-7-shreyansh.jain@nxp.com> (raw)
In-Reply-To: <20190111115712.6482-1-shreyansh.jain@nxp.com>
Current code expects that bus->parse() would get a string containing
the name of the bus. That is incorrect. bus->parse() is expected
to have strings like:
dpni.1,key=val
dpio.2,key=val
when user passed:
-b fslmc:dpni.1,key=val
This commit fixes this behavior.
Fixes: 50245be05d1a ("bus/fslmc: support device blacklisting")
Cc: stable@dpdk.org
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
drivers/bus/fslmc/fslmc_bus.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 89af9385a..565e0148f 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
- * Copyright 2016 NXP
+ * Copyright 2016,2018 NXP
*
*/
@@ -227,20 +227,16 @@ static int
rte_fslmc_parse(const char *name, void *addr)
{
uint16_t dev_id;
- char *t_ptr;
- char *sep = strchr(name, ':');
+ char *t_ptr = NULL, *dname = NULL;
- if (strncmp(name, RTE_STR(FSLMC_BUS_NAME),
- strlen(RTE_STR(FSLMC_BUS_NAME)))) {
- return -EINVAL;
- }
+ /* 'name' is expected to contain name of device, for example, dpio.1,
+ * dpni.2, etc.
+ */
- if (!sep) {
- DPAA2_BUS_ERR("Incorrect device name observed");
+ dname = strdup(name);
+ if (!dname)
return -EINVAL;
- }
-
- t_ptr = (char *)(sep + 1);
+ t_ptr = dname;
if (strncmp("dpni", t_ptr, 4) &&
strncmp("dpseci", t_ptr, 6) &&
@@ -251,24 +247,29 @@ rte_fslmc_parse(const char *name, void *addr)
strncmp("dpmcp", t_ptr, 5) &&
strncmp("dpdmai", t_ptr, 6)) {
DPAA2_BUS_ERR("Unknown or unsupported device");
- return -EINVAL;
+ goto err_out;
}
t_ptr = strchr(name, '.');
if (!t_ptr) {
DPAA2_BUS_ERR("Incorrect device string observed (%s)", t_ptr);
- return -EINVAL;
+ goto err_out;
}
t_ptr = (char *)(t_ptr + 1);
if (sscanf(t_ptr, "%hu", &dev_id) <= 0) {
DPAA2_BUS_ERR("Incorrect device string observed (%s)", t_ptr);
- return -EINVAL;
+ goto err_out;
}
+ free(dname);
if (addr)
- strcpy(addr, (char *)(sep + 1));
+ strcpy(addr, name);
+
return 0;
+err_out:
+ free(dname);
+ return -EINVAL;
}
static int
--
2.17.1
next prev parent reply other threads:[~2019-01-11 11:58 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20181227062233.30781-1-hemant.agrawal@nxp.com>
2018-12-27 6:22 ` [dpdk-stable] [PATCH 01/20] bus/fslmc: fix to reset portal memory before use Hemant Agrawal
2018-12-27 6:22 ` [dpdk-stable] [PATCH 02/20] bus/fslmc: fix the ring mode to use correct cache settings Hemant Agrawal
2018-12-27 6:22 ` [dpdk-stable] [PATCH 03/20] bus/fslmc: fix to use correct physical core for logical core Hemant Agrawal
2018-12-27 6:22 ` [dpdk-stable] [PATCH 04/20] net/dpaa2: fix bad check for not-null Hemant Agrawal
2018-12-27 6:22 ` [dpdk-stable] [PATCH 05/20] bus/fslmc: fix to convert error msg to warning Hemant Agrawal
2018-12-27 6:23 ` [dpdk-stable] [PATCH 06/20] bus/fslmc: fix parse method for bus devices Hemant Agrawal
2018-12-27 6:23 ` [dpdk-stable] [PATCH 07/20] net/dpaa2: fix device init for secondary process Hemant Agrawal
[not found] ` <20190111115712.6482-1-shreyansh.jain@nxp.com>
2019-01-11 11:57 ` [dpdk-stable] [PATCH v2 01/20] bus/fslmc: fix to reset portal memory before use Shreyansh Jain
2019-01-11 11:57 ` [dpdk-stable] [PATCH v2 02/20] bus/fslmc: fix the ring mode to use correct cache settings Shreyansh Jain
2019-01-11 11:57 ` [dpdk-stable] [PATCH v2 03/20] bus/fslmc: fix to use correct physical core for logical core Shreyansh Jain
2019-01-11 11:58 ` [dpdk-stable] [PATCH v2 04/20] net/dpaa2: fix bad check for not-null Shreyansh Jain
2019-01-11 11:58 ` [dpdk-stable] [PATCH v2 05/20] bus/fslmc: fix to convert error msg to warning Shreyansh Jain
2019-01-11 11:58 ` Shreyansh Jain [this message]
2019-01-11 11:58 ` [dpdk-stable] [PATCH v2 07/20] net/dpaa2: fix device init for secondary process Shreyansh Jain
[not found] ` <20190111122305.7133-1-shreyansh.jain@nxp.com>
2019-01-11 12:24 ` [dpdk-stable] [PATCH v3 01/19] bus/fslmc: fix to reset portal memory before use Shreyansh Jain
2019-01-11 12:24 ` [dpdk-stable] [PATCH v3 02/19] bus/fslmc: fix the ring mode to use correct cache settings Shreyansh Jain
2019-01-11 12:24 ` [dpdk-stable] [PATCH v3 03/19] bus/fslmc: fix to use correct physical core for logical core Shreyansh Jain
2019-01-11 12:24 ` [dpdk-stable] [PATCH v3 04/19] net/dpaa2: fix bad check for not-null Shreyansh Jain
2019-01-11 12:24 ` [dpdk-stable] [PATCH v3 05/19] bus/fslmc: fix to convert error msg to warning Shreyansh Jain
2019-01-11 12:24 ` [dpdk-stable] [PATCH v3 06/19] bus/fslmc: fix parse method for bus devices Shreyansh Jain
2019-01-11 12:24 ` [dpdk-stable] [PATCH v3 07/19] net/dpaa2: fix device init for secondary process Shreyansh Jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190111115712.6482-7-shreyansh.jain@nxp.com \
--to=shreyansh.jain@nxp.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).