DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/2] eal-pci: cleanups
@ 2015-04-13 22:11 Stephen Hemminger
  2015-04-13 22:11 ` [dpdk-dev] [PATCH 1/2] pci: cleanup whitespace Stephen Hemminger
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Stephen Hemminger @ 2015-04-13 22:11 UTC (permalink / raw)
  To: dev

Part of my patch-a-day seeries

Stephen Hemminger (2):
  pci: cleanup whitespace
  pci: rearrange logic from compare loop

 lib/librte_eal/linuxapp/eal/eal_pci.c | 41 +++++++++++++++++------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

-- 
2.1.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [dpdk-dev] [PATCH 1/2] pci: cleanup whitespace
  2015-04-13 22:11 [dpdk-dev] [PATCH 0/2] eal-pci: cleanups Stephen Hemminger
@ 2015-04-13 22:11 ` Stephen Hemminger
  2015-04-14  9:29   ` Qiu, Michael
  2015-04-13 22:11 ` [dpdk-dev] [PATCH 2/2] pci: rearrange logic from compare loop Stephen Hemminger
  2015-08-03 16:03 ` [dpdk-dev] [PATCH 0/2] eal-pci: cleanups Thomas Monjalon
  2 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2015-04-13 22:11 UTC (permalink / raw)
  To: dev

Fix whitespace errors reported by checkpatch, including
missing space around operators and places where tab should
be used instead of space.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
index 9cb0ffd..c98a778 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -68,22 +68,22 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev)
 
 	/* open /sys/bus/pci/devices/AAAA:BB:CC.D/driver */
 	snprintf(filename, sizeof(filename),
-	         SYSFS_PCI_DEVICES "/" PCI_PRI_FMT "/driver/unbind",
-	         loc->domain, loc->bus, loc->devid, loc->function);
+		 SYSFS_PCI_DEVICES "/" PCI_PRI_FMT "/driver/unbind",
+		 loc->domain, loc->bus, loc->devid, loc->function);
 
 	f = fopen(filename, "w");
 	if (f == NULL) /* device was not bound */
 		return 0;
 
 	n = snprintf(buf, sizeof(buf), PCI_PRI_FMT "\n",
-	             loc->domain, loc->bus, loc->devid, loc->function);
+		     loc->domain, loc->bus, loc->devid, loc->function);
 	if ((n < 0) || (n >= (int)sizeof(buf))) {
 		RTE_LOG(ERR, EAL, "%s(): snprintf failed\n", __func__);
 		goto error;
 	}
 	if (fwrite(buf, n, 1, f) == 0) {
 		RTE_LOG(ERR, EAL, "%s(): could not write to %s\n", __func__,
-				filename);
+			filename);
 		goto error;
 	}
 
@@ -205,8 +205,7 @@ pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev)
 		return -1;
 	}
 
-	for (i = 0; i<PCI_MAX_RESOURCE; i++) {
-
+	for (i = 0; i < PCI_MAX_RESOURCE; i++) {
 		if (fgets(buf, sizeof(buf), f) == NULL) {
 			RTE_LOG(ERR, EAL,
 				"%s(): cannot read resource\n", __func__);
@@ -402,8 +401,8 @@ parse_pci_addr_format(const char *buf, int bufsize, uint16_t *domain,
 		};
 		char *str[PCI_FMT_NVAL]; /* last element-separator is "." not ":" */
 	} splitaddr;
-
 	char *buf_copy = strndup(buf, bufsize);
+
 	if (buf_copy == NULL)
 		return -1;
 
@@ -411,7 +410,7 @@ parse_pci_addr_format(const char *buf, int bufsize, uint16_t *domain,
 			!= PCI_FMT_NVAL - 1)
 		goto error;
 	/* final split is on '.' between devid and function */
-	splitaddr.function = strchr(splitaddr.devid,'.');
+	splitaddr.function = strchr(splitaddr.devid, '.');
 	if (splitaddr.function == NULL)
 		goto error;
 	*splitaddr.function++ = '\0';
@@ -671,7 +670,7 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
 			if (ret != 0)
 				return ret;
 		} else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND &&
-		           rte_eal_process_type() == RTE_PROC_PRIMARY) {
+			   rte_eal_process_type() == RTE_PROC_PRIMARY) {
 			/* unbind current driver */
 			if (pci_unbind_kernel_driver(dev) < 0)
 				return -1;
-- 
2.1.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [dpdk-dev] [PATCH 2/2] pci: rearrange logic from compare loop
  2015-04-13 22:11 [dpdk-dev] [PATCH 0/2] eal-pci: cleanups Stephen Hemminger
  2015-04-13 22:11 ` [dpdk-dev] [PATCH 1/2] pci: cleanup whitespace Stephen Hemminger
@ 2015-04-13 22:11 ` Stephen Hemminger
  2015-04-14  9:30   ` Qiu, Michael
  2015-05-19 10:12   ` Bruce Richardson
  2015-08-03 16:03 ` [dpdk-dev] [PATCH 0/2] eal-pci: cleanups Thomas Monjalon
  2 siblings, 2 replies; 8+ messages in thread
From: Stephen Hemminger @ 2015-04-13 22:11 UTC (permalink / raw)
  To: dev

Do some cleanup of pci scan loop.
  * check errors first
  * don't initialize variables where not necessary
  * cuddle else (follow existing style)
  * chop off conditional after return

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

---
 lib/librte_eal/linuxapp/eal/eal_pci.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
index c98a778..d96b1c4 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -337,6 +337,12 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 	/* parse driver */
 	snprintf(filename, sizeof(filename), "%s/driver", dirname);
 	ret = pci_get_kernel_driver_by_path(filename, driver);
+	if (ret < 0) {
+		RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
+		free(dev);
+		return -1;
+	}
+
 	if (!ret) {
 		if (!strcmp(driver, "vfio-pci"))
 			dev->kdrv = RTE_KDRV_VFIO;
@@ -346,37 +352,31 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
 			dev->kdrv = RTE_KDRV_UIO_GENERIC;
 		else
 			dev->kdrv = RTE_KDRV_UNKNOWN;
-	} else if (ret < 0) {
-		RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
-		free(dev);
-		return -1;
 	} else
 		dev->kdrv = RTE_KDRV_UNKNOWN;
 
 	/* device is valid, add in list (sorted) */
 	if (TAILQ_EMPTY(&pci_device_list)) {
 		TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
-	}
-	else {
-		struct rte_pci_device *dev2 = NULL;
+	} else {
+		struct rte_pci_device *dev2;
 		int ret;
 
 		TAILQ_FOREACH(dev2, &pci_device_list, next) {
 			ret = rte_eal_compare_pci_addr(&dev->addr, &dev2->addr);
 			if (ret > 0)
 				continue;
-			else if (ret < 0) {
+
+			if (ret < 0) {
 				TAILQ_INSERT_BEFORE(dev2, dev, next);
-				return 0;
 			} else { /* already registered */
 				dev2->kdrv = dev->kdrv;
 				dev2->max_vfs = dev->max_vfs;
-				memmove(dev2->mem_resource,
-					dev->mem_resource,
+				memmove(dev2->mem_resource, dev->mem_resource,
 					sizeof(dev->mem_resource));
 				free(dev);
-				return 0;
 			}
+			return 0;
 		}
 		TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
 	}
-- 
2.1.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] pci: cleanup whitespace
  2015-04-13 22:11 ` [dpdk-dev] [PATCH 1/2] pci: cleanup whitespace Stephen Hemminger
@ 2015-04-14  9:29   ` Qiu, Michael
  0 siblings, 0 replies; 8+ messages in thread
From: Qiu, Michael @ 2015-04-14  9:29 UTC (permalink / raw)
  To: Stephen Hemminger, dev

On 4/14/2015 6:11 AM, Stephen Hemminger wrote:
> Fix whitespace errors reported by checkpatch, including
> missing space around operators and places where tab should
> be used instead of space.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Acked-by: Michael Qiu <michael.qiu@intel.com>

> ---
>  lib/librte_eal/linuxapp/eal/eal_pci.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
> index 9cb0ffd..c98a778 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
> @@ -68,22 +68,22 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev)
>  
>  	/* open /sys/bus/pci/devices/AAAA:BB:CC.D/driver */
>  	snprintf(filename, sizeof(filename),
> -	         SYSFS_PCI_DEVICES "/" PCI_PRI_FMT "/driver/unbind",
> -	         loc->domain, loc->bus, loc->devid, loc->function);
> +		 SYSFS_PCI_DEVICES "/" PCI_PRI_FMT "/driver/unbind",
> +		 loc->domain, loc->bus, loc->devid, loc->function);
>  
>  	f = fopen(filename, "w");
>  	if (f == NULL) /* device was not bound */
>  		return 0;
>  
>  	n = snprintf(buf, sizeof(buf), PCI_PRI_FMT "\n",
> -	             loc->domain, loc->bus, loc->devid, loc->function);
> +		     loc->domain, loc->bus, loc->devid, loc->function);
>  	if ((n < 0) || (n >= (int)sizeof(buf))) {
>  		RTE_LOG(ERR, EAL, "%s(): snprintf failed\n", __func__);
>  		goto error;
>  	}
>  	if (fwrite(buf, n, 1, f) == 0) {
>  		RTE_LOG(ERR, EAL, "%s(): could not write to %s\n", __func__,
> -				filename);
> +			filename);
>  		goto error;
>  	}
>  
> @@ -205,8 +205,7 @@ pci_parse_sysfs_resource(const char *filename, struct rte_pci_device *dev)
>  		return -1;
>  	}
>  
> -	for (i = 0; i<PCI_MAX_RESOURCE; i++) {
> -
> +	for (i = 0; i < PCI_MAX_RESOURCE; i++) {
>  		if (fgets(buf, sizeof(buf), f) == NULL) {
>  			RTE_LOG(ERR, EAL,
>  				"%s(): cannot read resource\n", __func__);
> @@ -402,8 +401,8 @@ parse_pci_addr_format(const char *buf, int bufsize, uint16_t *domain,
>  		};
>  		char *str[PCI_FMT_NVAL]; /* last element-separator is "." not ":" */
>  	} splitaddr;
> -
>  	char *buf_copy = strndup(buf, bufsize);
> +
>  	if (buf_copy == NULL)
>  		return -1;
>  
> @@ -411,7 +410,7 @@ parse_pci_addr_format(const char *buf, int bufsize, uint16_t *domain,
>  			!= PCI_FMT_NVAL - 1)
>  		goto error;
>  	/* final split is on '.' between devid and function */
> -	splitaddr.function = strchr(splitaddr.devid,'.');
> +	splitaddr.function = strchr(splitaddr.devid, '.');
>  	if (splitaddr.function == NULL)
>  		goto error;
>  	*splitaddr.function++ = '\0';
> @@ -671,7 +670,7 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
>  			if (ret != 0)
>  				return ret;
>  		} else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND &&
> -		           rte_eal_process_type() == RTE_PROC_PRIMARY) {
> +			   rte_eal_process_type() == RTE_PROC_PRIMARY) {
>  			/* unbind current driver */
>  			if (pci_unbind_kernel_driver(dev) < 0)
>  				return -1;


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] pci: rearrange logic from compare loop
  2015-04-13 22:11 ` [dpdk-dev] [PATCH 2/2] pci: rearrange logic from compare loop Stephen Hemminger
@ 2015-04-14  9:30   ` Qiu, Michael
  2015-04-14 17:28     ` Stephen Hemminger
  2015-05-19 10:12   ` Bruce Richardson
  1 sibling, 1 reply; 8+ messages in thread
From: Qiu, Michael @ 2015-04-14  9:30 UTC (permalink / raw)
  To: Stephen Hemminger, dev

On 4/14/2015 6:11 AM, Stephen Hemminger wrote:
> Do some cleanup of pci scan loop.
>   * check errors first
>   * don't initialize variables where not necessary

Why? It should be better to initialize variables when define it.

Thanks,
Michael
>   * cuddle else (follow existing style)
>   * chop off conditional after return
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>
> ---
>  lib/librte_eal/linuxapp/eal/eal_pci.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
> index c98a778..d96b1c4 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
> @@ -337,6 +337,12 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
>  	/* parse driver */
>  	snprintf(filename, sizeof(filename), "%s/driver", dirname);
>  	ret = pci_get_kernel_driver_by_path(filename, driver);
> +	if (ret < 0) {
> +		RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
> +		free(dev);
> +		return -1;
> +	}
> +
>  	if (!ret) {
>  		if (!strcmp(driver, "vfio-pci"))
>  			dev->kdrv = RTE_KDRV_VFIO;
> @@ -346,37 +352,31 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
>  			dev->kdrv = RTE_KDRV_UIO_GENERIC;
>  		else
>  			dev->kdrv = RTE_KDRV_UNKNOWN;
> -	} else if (ret < 0) {
> -		RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
> -		free(dev);
> -		return -1;
>  	} else
>  		dev->kdrv = RTE_KDRV_UNKNOWN;
>  
>  	/* device is valid, add in list (sorted) */
>  	if (TAILQ_EMPTY(&pci_device_list)) {
>  		TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
> -	}
> -	else {
> -		struct rte_pci_device *dev2 = NULL;
> +	} else {
> +		struct rte_pci_device *dev2;
>  		int ret;
>  
>  		TAILQ_FOREACH(dev2, &pci_device_list, next) {
>  			ret = rte_eal_compare_pci_addr(&dev->addr, &dev2->addr);
>  			if (ret > 0)
>  				continue;
> -			else if (ret < 0) {
> +
> +			if (ret < 0) {
>  				TAILQ_INSERT_BEFORE(dev2, dev, next);
> -				return 0;
>  			} else { /* already registered */
>  				dev2->kdrv = dev->kdrv;
>  				dev2->max_vfs = dev->max_vfs;
> -				memmove(dev2->mem_resource,
> -					dev->mem_resource,
> +				memmove(dev2->mem_resource, dev->mem_resource,
>  					sizeof(dev->mem_resource));
>  				free(dev);
> -				return 0;
>  			}
> +			return 0;
>  		}
>  		TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
>  	}


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] pci: rearrange logic from compare loop
  2015-04-14  9:30   ` Qiu, Michael
@ 2015-04-14 17:28     ` Stephen Hemminger
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2015-04-14 17:28 UTC (permalink / raw)
  To: Qiu, Michael; +Cc: dev

There is no need to initialize a variable that is only used as a loop
variable.



On Tue, Apr 14, 2015 at 2:30 AM, Qiu, Michael <michael.qiu@intel.com> wrote:

> On 4/14/2015 6:11 AM, Stephen Hemminger wrote:
> > Do some cleanup of pci scan loop.
> >   * check errors first
> >   * don't initialize variables where not necessary
>
> Why? It should be better to initialize variables when define it.
>
> Thanks,
> Michael
> >   * cuddle else (follow existing style)
> >   * chop off conditional after return
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> >
> > ---
> >  lib/librte_eal/linuxapp/eal/eal_pci.c | 24 ++++++++++++------------
> >  1 file changed, 12 insertions(+), 12 deletions(-)
> >
> > diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c
> b/lib/librte_eal/linuxapp/eal/eal_pci.c
> > index c98a778..d96b1c4 100644
> > --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
> > +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
> > @@ -337,6 +337,12 @@ pci_scan_one(const char *dirname, uint16_t domain,
> uint8_t bus,
> >       /* parse driver */
> >       snprintf(filename, sizeof(filename), "%s/driver", dirname);
> >       ret = pci_get_kernel_driver_by_path(filename, driver);
> > +     if (ret < 0) {
> > +             RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
> > +             free(dev);
> > +             return -1;
> > +     }
> > +
> >       if (!ret) {
> >               if (!strcmp(driver, "vfio-pci"))
> >                       dev->kdrv = RTE_KDRV_VFIO;
> > @@ -346,37 +352,31 @@ pci_scan_one(const char *dirname, uint16_t domain,
> uint8_t bus,
> >                       dev->kdrv = RTE_KDRV_UIO_GENERIC;
> >               else
> >                       dev->kdrv = RTE_KDRV_UNKNOWN;
> > -     } else if (ret < 0) {
> > -             RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
> > -             free(dev);
> > -             return -1;
> >       } else
> >               dev->kdrv = RTE_KDRV_UNKNOWN;
> >
> >       /* device is valid, add in list (sorted) */
> >       if (TAILQ_EMPTY(&pci_device_list)) {
> >               TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
> > -     }
> > -     else {
> > -             struct rte_pci_device *dev2 = NULL;
> > +     } else {
> > +             struct rte_pci_device *dev2;
> >               int ret;
> >
> >               TAILQ_FOREACH(dev2, &pci_device_list, next) {
> >                       ret = rte_eal_compare_pci_addr(&dev->addr,
> &dev2->addr);
> >                       if (ret > 0)
> >                               continue;
> > -                     else if (ret < 0) {
> > +
> > +                     if (ret < 0) {
> >                               TAILQ_INSERT_BEFORE(dev2, dev, next);
> > -                             return 0;
> >                       } else { /* already registered */
> >                               dev2->kdrv = dev->kdrv;
> >                               dev2->max_vfs = dev->max_vfs;
> > -                             memmove(dev2->mem_resource,
> > -                                     dev->mem_resource,
> > +                             memmove(dev2->mem_resource,
> dev->mem_resource,
> >                                       sizeof(dev->mem_resource));
> >                               free(dev);
> > -                             return 0;
> >                       }
> > +                     return 0;
> >               }
> >               TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
> >       }
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] pci: rearrange logic from compare loop
  2015-04-13 22:11 ` [dpdk-dev] [PATCH 2/2] pci: rearrange logic from compare loop Stephen Hemminger
  2015-04-14  9:30   ` Qiu, Michael
@ 2015-05-19 10:12   ` Bruce Richardson
  1 sibling, 0 replies; 8+ messages in thread
From: Bruce Richardson @ 2015-05-19 10:12 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

On Mon, Apr 13, 2015 at 03:11:11PM -0700, Stephen Hemminger wrote:
> Do some cleanup of pci scan loop.
>   * check errors first
>   * don't initialize variables where not necessary
>   * cuddle else (follow existing style)
>   * chop off conditional after return
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

> 
> ---
>  lib/librte_eal/linuxapp/eal/eal_pci.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
> index c98a778..d96b1c4 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
> @@ -337,6 +337,12 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
>  	/* parse driver */
>  	snprintf(filename, sizeof(filename), "%s/driver", dirname);
>  	ret = pci_get_kernel_driver_by_path(filename, driver);
> +	if (ret < 0) {
> +		RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
> +		free(dev);
> +		return -1;
> +	}
> +
>  	if (!ret) {
>  		if (!strcmp(driver, "vfio-pci"))
>  			dev->kdrv = RTE_KDRV_VFIO;
> @@ -346,37 +352,31 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus,
>  			dev->kdrv = RTE_KDRV_UIO_GENERIC;
>  		else
>  			dev->kdrv = RTE_KDRV_UNKNOWN;
> -	} else if (ret < 0) {
> -		RTE_LOG(ERR, EAL, "Fail to get kernel driver\n");
> -		free(dev);
> -		return -1;
>  	} else
>  		dev->kdrv = RTE_KDRV_UNKNOWN;
>  
>  	/* device is valid, add in list (sorted) */
>  	if (TAILQ_EMPTY(&pci_device_list)) {
>  		TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
> -	}
> -	else {
> -		struct rte_pci_device *dev2 = NULL;
> +	} else {
> +		struct rte_pci_device *dev2;
>  		int ret;
>  
>  		TAILQ_FOREACH(dev2, &pci_device_list, next) {
>  			ret = rte_eal_compare_pci_addr(&dev->addr, &dev2->addr);
>  			if (ret > 0)
>  				continue;
> -			else if (ret < 0) {
> +
> +			if (ret < 0) {
>  				TAILQ_INSERT_BEFORE(dev2, dev, next);
> -				return 0;
>  			} else { /* already registered */
>  				dev2->kdrv = dev->kdrv;
>  				dev2->max_vfs = dev->max_vfs;
> -				memmove(dev2->mem_resource,
> -					dev->mem_resource,
> +				memmove(dev2->mem_resource, dev->mem_resource,
>  					sizeof(dev->mem_resource));
>  				free(dev);
> -				return 0;
>  			}
> +			return 0;
>  		}
>  		TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
>  	}
> -- 
> 2.1.4
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [dpdk-dev] [PATCH 0/2] eal-pci: cleanups
  2015-04-13 22:11 [dpdk-dev] [PATCH 0/2] eal-pci: cleanups Stephen Hemminger
  2015-04-13 22:11 ` [dpdk-dev] [PATCH 1/2] pci: cleanup whitespace Stephen Hemminger
  2015-04-13 22:11 ` [dpdk-dev] [PATCH 2/2] pci: rearrange logic from compare loop Stephen Hemminger
@ 2015-08-03 16:03 ` Thomas Monjalon
  2 siblings, 0 replies; 8+ messages in thread
From: Thomas Monjalon @ 2015-08-03 16:03 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

2015-04-13 15:11, Stephen Hemminger:
> Part of my patch-a-day seeries
> 
> Stephen Hemminger (2):
>   pci: cleanup whitespace
>   pci: rearrange logic from compare loop
> 
>  lib/librte_eal/linuxapp/eal/eal_pci.c | 41 +++++++++++++++++------------------
>  1 file changed, 20 insertions(+), 21 deletions(-)
> 
> 

Applied only patch 2 without patch 1 (whitespace cleanup).
There is no rule but accepting such patch for whitespace would open the door
to a lot of minor patches which complexify git history search (git-blame).

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-08-03 16:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-13 22:11 [dpdk-dev] [PATCH 0/2] eal-pci: cleanups Stephen Hemminger
2015-04-13 22:11 ` [dpdk-dev] [PATCH 1/2] pci: cleanup whitespace Stephen Hemminger
2015-04-14  9:29   ` Qiu, Michael
2015-04-13 22:11 ` [dpdk-dev] [PATCH 2/2] pci: rearrange logic from compare loop Stephen Hemminger
2015-04-14  9:30   ` Qiu, Michael
2015-04-14 17:28     ` Stephen Hemminger
2015-05-19 10:12   ` Bruce Richardson
2015-08-03 16:03 ` [dpdk-dev] [PATCH 0/2] eal-pci: cleanups Thomas Monjalon

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).