diff mbox

[v7,11/15] msi_init: change return value to 0 on success

Message ID 1465200062-13824-12-git-send-email-caoj.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Cao jin June 6, 2016, 8 a.m. UTC
No caller use its return value as msi capability offset,  in order
to make its return behaviour consistent with msix_init().

cc: Michael S. Tsirkin <mst@redhat.com>
cc: Paolo Bonzini <pbonzini@redhat.com>
cc: Hannes Reinecke <hare@suse.de>
cc: Markus Armbruster <armbru@redhat.com>
cc: Marcel Apfelbaum <marcel@redhat.com>

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
 hw/pci/msi.c      | 6 +++---
 hw/scsi/megasas.c | 2 +-
 hw/scsi/mptsas.c  | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

Comments

Hannes Reinecke June 6, 2016, 8:28 a.m. UTC | #1
On 06/06/2016 10:00 AM, Cao jin wrote:
> No caller use its return value as msi capability offset,  in order
> to make its return behaviour consistent with msix_init().
> 
> cc: Michael S. Tsirkin <mst@redhat.com>
> cc: Paolo Bonzini <pbonzini@redhat.com>
> cc: Hannes Reinecke <hare@suse.de>
> cc: Markus Armbruster <armbru@redhat.com>
> cc: Marcel Apfelbaum <marcel@redhat.com>
> 
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
>  hw/pci/msi.c      | 6 +++---
>  hw/scsi/megasas.c | 2 +-
>  hw/scsi/mptsas.c  | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/pci/msi.c b/hw/pci/msi.c
> index aa6cf49..70464bf 100644
> --- a/hw/pci/msi.c
> +++ b/hw/pci/msi.c
> @@ -173,8 +173,7 @@ bool msi_enabled(const PCIDevice *dev)
>   * If @msi64bit, make the device capable of sending a 64-bit message
>   * address.
>   * If @msi_per_vector_mask, make the device support per-vector masking.
> - * Return the offset of capability MSI in config space on success,
> - * return -errno on error.
> + * Return 0 on success, return -errno on error.
>   *
>   * -ENOTSUP means lacking msi support for a msi-capable platform.
>   * -EINVAL means capability overlap, happens when @offset is non-zero,
> @@ -236,7 +235,8 @@ int msi_init(struct PCIDevice *dev, uint8_t offset,
>          pci_set_long(dev->wmask + msi_mask_off(dev, msi64bit),
>                       0xffffffff >> (PCI_MSI_VECTORS_MAX - nr_vectors));
>      }
> -    return config_offset;
> +
> +    return 0;
>  }
>  
>  void msi_uninit(struct PCIDevice *dev)
> diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
> index 635be13..26119bf 100644
> --- a/hw/scsi/megasas.c
> +++ b/hw/scsi/megasas.c
> @@ -2346,7 +2346,7 @@ static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
>                            "megasas-queue", 0x40000);
>  
>      if (megasas_use_msi(s) &&
> -        msi_init(dev, 0x50, 1, true, false) < 0) {
> +        msi_init(dev, 0x50, 1, true, false)) {
>          s->msi = ON_OFF_AUTO_OFF;
>      }
>      if (megasas_use_msix(s) &&
> diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
> index 4ff4d06..d4773e2 100644
> --- a/hw/scsi/mptsas.c
> +++ b/hw/scsi/mptsas.c
> @@ -1286,7 +1286,7 @@ static void mptsas_scsi_realize(PCIDevice *dev, Error **errp)
>                            "mptsas-diag", 0x10000);
>  
>      if (s->msi != ON_OFF_AUTO_OFF &&
> -        msi_init(dev, 0, 1, true, false) >= 0) {
> +        msi_init(dev, 0, 1, true, false) > 0) {
>          /* TODO check for errors */
>          s->msi_in_use = true;
>      }
> 
Acked-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
Cao jin June 6, 2016, 9:19 a.m. UTC | #2
On 06/06/2016 04:28 PM, Hannes Reinecke wrote:
> On 06/06/2016 10:00 AM, Cao jin wrote:

>> diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
>> index 4ff4d06..d4773e2 100644
>> --- a/hw/scsi/mptsas.c
>> +++ b/hw/scsi/mptsas.c
>> @@ -1286,7 +1286,7 @@ static void mptsas_scsi_realize(PCIDevice *dev, Error **errp)
>>                             "mptsas-diag", 0x10000);
>>
>>       if (s->msi != ON_OFF_AUTO_OFF &&
>> -        msi_init(dev, 0, 1, true, false) >= 0) {
>> +        msi_init(dev, 0, 1, true, false) > 0) {

I am so sorry I made the mistake...it should be msi_init() == 0

>>           /* TODO check for errors */
>>           s->msi_in_use = true;
>>       }
Markus Armbruster June 9, 2016, 3:32 p.m. UTC | #3
Cao jin <caoj.fnst@cn.fujitsu.com> writes:

> No caller use its return value as msi capability offset,  in order
> to make its return behaviour consistent with msix_init().
>
> cc: Michael S. Tsirkin <mst@redhat.com>
> cc: Paolo Bonzini <pbonzini@redhat.com>
> cc: Hannes Reinecke <hare@suse.de>
> cc: Markus Armbruster <armbru@redhat.com>
> cc: Marcel Apfelbaum <marcel@redhat.com>
>
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
>  hw/pci/msi.c      | 6 +++---
>  hw/scsi/megasas.c | 2 +-
>  hw/scsi/mptsas.c  | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/hw/pci/msi.c b/hw/pci/msi.c
> index aa6cf49..70464bf 100644
> --- a/hw/pci/msi.c
> +++ b/hw/pci/msi.c
> @@ -173,8 +173,7 @@ bool msi_enabled(const PCIDevice *dev)
>   * If @msi64bit, make the device capable of sending a 64-bit message
>   * address.
>   * If @msi_per_vector_mask, make the device support per-vector masking.
> - * Return the offset of capability MSI in config space on success,
> - * return -errno on error.
> + * Return 0 on success, return -errno on error.
>   *
>   * -ENOTSUP means lacking msi support for a msi-capable platform.
>   * -EINVAL means capability overlap, happens when @offset is non-zero,
> @@ -236,7 +235,8 @@ int msi_init(struct PCIDevice *dev, uint8_t offset,
>          pci_set_long(dev->wmask + msi_mask_off(dev, msi64bit),
>                       0xffffffff >> (PCI_MSI_VECTORS_MAX - nr_vectors));
>      }
> -    return config_offset;
> +
> +    return 0;
>  }
>  
>  void msi_uninit(struct PCIDevice *dev)
> diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
> index 635be13..26119bf 100644
> --- a/hw/scsi/megasas.c
> +++ b/hw/scsi/megasas.c
> @@ -2346,7 +2346,7 @@ static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
>                            "megasas-queue", 0x40000);
>  
>      if (megasas_use_msi(s) &&
> -        msi_init(dev, 0x50, 1, true, false) < 0) {
> +        msi_init(dev, 0x50, 1, true, false)) {

I'd leave this alone.

>          s->msi = ON_OFF_AUTO_OFF;
>      }
>      if (megasas_use_msix(s) &&
> diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
> index 4ff4d06..d4773e2 100644
> --- a/hw/scsi/mptsas.c
> +++ b/hw/scsi/mptsas.c
> @@ -1286,7 +1286,7 @@ static void mptsas_scsi_realize(PCIDevice *dev, Error **errp)
>                            "mptsas-diag", 0x10000);
>  
>      if (s->msi != ON_OFF_AUTO_OFF &&
> -        msi_init(dev, 0, 1, true, false) >= 0) {
> +        msi_init(dev, 0, 1, true, false) > 0) {
>          /* TODO check for errors */
>          s->msi_in_use = true;
>      }

This one, too.
diff mbox

Patch

diff --git a/hw/pci/msi.c b/hw/pci/msi.c
index aa6cf49..70464bf 100644
--- a/hw/pci/msi.c
+++ b/hw/pci/msi.c
@@ -173,8 +173,7 @@  bool msi_enabled(const PCIDevice *dev)
  * If @msi64bit, make the device capable of sending a 64-bit message
  * address.
  * If @msi_per_vector_mask, make the device support per-vector masking.
- * Return the offset of capability MSI in config space on success,
- * return -errno on error.
+ * Return 0 on success, return -errno on error.
  *
  * -ENOTSUP means lacking msi support for a msi-capable platform.
  * -EINVAL means capability overlap, happens when @offset is non-zero,
@@ -236,7 +235,8 @@  int msi_init(struct PCIDevice *dev, uint8_t offset,
         pci_set_long(dev->wmask + msi_mask_off(dev, msi64bit),
                      0xffffffff >> (PCI_MSI_VECTORS_MAX - nr_vectors));
     }
-    return config_offset;
+
+    return 0;
 }
 
 void msi_uninit(struct PCIDevice *dev)
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index 635be13..26119bf 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -2346,7 +2346,7 @@  static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
                           "megasas-queue", 0x40000);
 
     if (megasas_use_msi(s) &&
-        msi_init(dev, 0x50, 1, true, false) < 0) {
+        msi_init(dev, 0x50, 1, true, false)) {
         s->msi = ON_OFF_AUTO_OFF;
     }
     if (megasas_use_msix(s) &&
diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
index 4ff4d06..d4773e2 100644
--- a/hw/scsi/mptsas.c
+++ b/hw/scsi/mptsas.c
@@ -1286,7 +1286,7 @@  static void mptsas_scsi_realize(PCIDevice *dev, Error **errp)
                           "mptsas-diag", 0x10000);
 
     if (s->msi != ON_OFF_AUTO_OFF &&
-        msi_init(dev, 0, 1, true, false) >= 0) {
+        msi_init(dev, 0, 1, true, false) > 0) {
         /* TODO check for errors */
         s->msi_in_use = true;
     }