* [PATCH] driver, virtio: Modify the err hanlding logic
@ 2011-04-20 13:21 Liu Yuan
2011-04-27 5:04 ` Rusty Russell
2011-04-27 5:04 ` Rusty Russell
0 siblings, 2 replies; 4+ messages in thread
From: Liu Yuan @ 2011-04-20 13:21 UTC (permalink / raw)
To: Rusty Russell, Michael S. Tsirkin; +Cc: virtualization, linux-kernel
From: Liu Yuan <tailai.ly@taobao.com>
In the function vp_request_msix_vectors(), when
pci_enable_msix() returns 0, there will be
redundant double checks for 'err'. This patch
fixes it to avoid the unnecessary check.
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
---
drivers/virtio/virtio_pci.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 4fb5b2b..2c05376 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -298,10 +298,11 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
/* pci_enable_msix returns positive if we can't get this many. */
err = pci_enable_msix(vp_dev->pci_dev, vp_dev->msix_entries, nvectors);
- if (err > 0)
- err = -ENOSPC;
- if (err)
+ if (err) {
+ if (err > 0)
+ err = -ENOSPC;
goto error;
+ }
vp_dev->msix_vectors = nvectors;
vp_dev->msix_enabled = 1;
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] driver, virtio: Modify the err hanlding logic
@ 2011-04-20 13:21 Liu Yuan
0 siblings, 0 replies; 4+ messages in thread
From: Liu Yuan @ 2011-04-20 13:21 UTC (permalink / raw)
To: Rusty Russell, Michael S. Tsirkin; +Cc: linux-kernel, virtualization
From: Liu Yuan <tailai.ly@taobao.com>
In the function vp_request_msix_vectors(), when
pci_enable_msix() returns 0, there will be
redundant double checks for 'err'. This patch
fixes it to avoid the unnecessary check.
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
---
drivers/virtio/virtio_pci.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 4fb5b2b..2c05376 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -298,10 +298,11 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
/* pci_enable_msix returns positive if we can't get this many. */
err = pci_enable_msix(vp_dev->pci_dev, vp_dev->msix_entries, nvectors);
- if (err > 0)
- err = -ENOSPC;
- if (err)
+ if (err) {
+ if (err > 0)
+ err = -ENOSPC;
goto error;
+ }
vp_dev->msix_vectors = nvectors;
vp_dev->msix_enabled = 1;
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] driver, virtio: Modify the err hanlding logic
2011-04-20 13:21 [PATCH] driver, virtio: Modify the err hanlding logic Liu Yuan
@ 2011-04-27 5:04 ` Rusty Russell
2011-04-27 5:04 ` Rusty Russell
1 sibling, 0 replies; 4+ messages in thread
From: Rusty Russell @ 2011-04-27 5:04 UTC (permalink / raw)
To: Liu Yuan, Michael S. Tsirkin; +Cc: linux-kernel, virtualization
On Wed, 20 Apr 2011 21:21:59 +0800, Liu Yuan <namei.unix@gmail.com> wrote:
> From: Liu Yuan <tailai.ly@taobao.com>
>
> In the function vp_request_msix_vectors(), when
> pci_enable_msix() returns 0, there will be
> redundant double checks for 'err'. This patch
> fixes it to avoid the unnecessary check.
>
> Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
> ---
> drivers/virtio/virtio_pci.c | 7 ++++---
> 1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
> index 4fb5b2b..2c05376 100644
> --- a/drivers/virtio/virtio_pci.c
> +++ b/drivers/virtio/virtio_pci.c
> @@ -298,10 +298,11 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
>
> /* pci_enable_msix returns positive if we can't get this many. */
> err = pci_enable_msix(vp_dev->pci_dev, vp_dev->msix_entries, nvectors);
> - if (err > 0)
> - err = -ENOSPC;
> - if (err)
> + if (err) {
> + if (err > 0)
> + err = -ENOSPC;
> goto error;
> + }
> vp_dev->msix_vectors = nvectors;
> vp_dev->msix_enabled = 1;
This patch is extremely marginal. It theoretically improves efficiency,
but it's in a case we don't care about. The code is quite clear.
My general policy for such marginal improvements is to only accept them
from the maintainer him/herself, so I won't be taking this patch.
Of course, if you produce a series of fixes to the driver with such a
patch as a cleaner, I'm lazy enough that I'd take them all at once :)
Thanks,
Rusty.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] driver, virtio: Modify the err hanlding logic
2011-04-20 13:21 [PATCH] driver, virtio: Modify the err hanlding logic Liu Yuan
2011-04-27 5:04 ` Rusty Russell
@ 2011-04-27 5:04 ` Rusty Russell
1 sibling, 0 replies; 4+ messages in thread
From: Rusty Russell @ 2011-04-27 5:04 UTC (permalink / raw)
To: Liu Yuan, Michael S. Tsirkin; +Cc: virtualization, linux-kernel
On Wed, 20 Apr 2011 21:21:59 +0800, Liu Yuan <namei.unix@gmail.com> wrote:
> From: Liu Yuan <tailai.ly@taobao.com>
>
> In the function vp_request_msix_vectors(), when
> pci_enable_msix() returns 0, there will be
> redundant double checks for 'err'. This patch
> fixes it to avoid the unnecessary check.
>
> Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
> ---
> drivers/virtio/virtio_pci.c | 7 ++++---
> 1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
> index 4fb5b2b..2c05376 100644
> --- a/drivers/virtio/virtio_pci.c
> +++ b/drivers/virtio/virtio_pci.c
> @@ -298,10 +298,11 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
>
> /* pci_enable_msix returns positive if we can't get this many. */
> err = pci_enable_msix(vp_dev->pci_dev, vp_dev->msix_entries, nvectors);
> - if (err > 0)
> - err = -ENOSPC;
> - if (err)
> + if (err) {
> + if (err > 0)
> + err = -ENOSPC;
> goto error;
> + }
> vp_dev->msix_vectors = nvectors;
> vp_dev->msix_enabled = 1;
This patch is extremely marginal. It theoretically improves efficiency,
but it's in a case we don't care about. The code is quite clear.
My general policy for such marginal improvements is to only accept them
from the maintainer him/herself, so I won't be taking this patch.
Of course, if you produce a series of fixes to the driver with such a
patch as a cleaner, I'm lazy enough that I'd take them all at once :)
Thanks,
Rusty.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-04-27 6:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-20 13:21 [PATCH] driver, virtio: Modify the err hanlding logic Liu Yuan
2011-04-27 5:04 ` Rusty Russell
2011-04-27 5:04 ` Rusty Russell
-- strict thread matches above, loose matches on Subject: below --
2011-04-20 13:21 Liu Yuan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.