summaryrefslogtreecommitdiff
path: root/drivers/bus
diff options
context:
space:
mode:
authorShreyansh Jain <shreyansh.jain@nxp.com>2019-01-11 12:24:23 +0000
committerFerruh Yigit <ferruh.yigit@intel.com>2019-01-14 17:44:29 +0100
commit68f5637bcba7ecace57e12b85d82fdeadaa58843 (patch)
treeffd664d5d0d8e97fe3bbc1e4d85a54c3fa5e7136 /drivers/bus
parent7bf59396043c4f997196ff5f2a01b13531acf778 (diff)
downloaddpdk-next-eventdev-68f5637bcba7ecace57e12b85d82fdeadaa58843.zip
dpdk-next-eventdev-68f5637bcba7ecace57e12b85d82fdeadaa58843.tar.gz
dpdk-next-eventdev-68f5637bcba7ecace57e12b85d82fdeadaa58843.tar.xz
bus/fslmc: fix parse method for bus devices
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>
Diffstat (limited to 'drivers/bus')
-rw-r--r--drivers/bus/fslmc/fslmc_bus.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 89af938..565e014 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