All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Cao jin <caoj.fnst@cn.fujitsu.com>
Cc: mst@redhat.com, qemu-devel@nongnu.org, pbonzini@redhat.com,
	leon.alrae@imgtec.com, aurelien@aurel32.net, rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH 2/5] igd-passthrough-i440FX: convert to realize()
Date: Fri, 18 Dec 2015 16:37:00 -0200	[thread overview]
Message-ID: <20151218183700.GZ3774@thinpad.lan.raisama.net> (raw)
In-Reply-To: <1450436632-23980-3-git-send-email-caoj.fnst@cn.fujitsu.com>

On Fri, Dec 18, 2015 at 07:03:49PM +0800, Cao jin wrote:
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
>  hw/pci-host/piix.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
> index 715208b..e3840f0 100644
> --- a/hw/pci-host/piix.c
> +++ b/hw/pci-host/piix.c
> @@ -761,7 +761,7 @@ static const IGDHostInfo igd_host_bridge_infos[] = {
>      {0xa8, 4},  /* SNB: base of GTT stolen memory */
>  };
>  
> -static int host_pci_config_read(int pos, int len, uint32_t val)
> +static int host_pci_config_read(int pos, int len, uint32_t val, Error **errp)

You don't need the return value anymore, if you report errors
through the errp parameter. The function can be void, now.

>  {
>      char path[PATH_MAX];
>      int config_fd;
> @@ -772,15 +772,18 @@ static int host_pci_config_read(int pos, int len, uint32_t val)
>      int ret = 0;
>  
>      if (rc >= size || rc < 0) {
> +        error_setg(errp, "No such device");
>          return -ENODEV;
>      }
>  
>      config_fd = open(path, O_RDWR);
>      if (config_fd < 0) {
> +        error_setg(errp, "No such device");
>          return -ENODEV;
>      }
>  
>      if (lseek(config_fd, pos, SEEK_SET) != pos) {
> +        error_setg(errp, "lseek err: %s", strerror(errno));

What about error_setg_errno()?

>          ret = -errno;
>          goto out;
>      }
> @@ -789,13 +792,14 @@ static int host_pci_config_read(int pos, int len, uint32_t val)
>      } while (rc < 0 && (errno == EINTR || errno == EAGAIN));
>      if (rc != len) {
>          ret = -errno;
> +        error_setg(errp, "read err: %s", strerror(errno));

Same here.

>      }
>  out:
>      close(config_fd);
>      return ret;
>  }
>  
> -static int igd_pt_i440fx_initfn(struct PCIDevice *pci_dev)
> +static void igd_pt_i440fx_realize(struct PCIDevice *pci_dev, Error **errp)
>  {
>      uint32_t val = 0;
>      int rc, i, num;
> @@ -805,14 +809,12 @@ static int igd_pt_i440fx_initfn(struct PCIDevice *pci_dev)
>      for (i = 0; i < num; i++) {
>          pos = igd_host_bridge_infos[i].offset;
>          len = igd_host_bridge_infos[i].len;
> -        rc = host_pci_config_read(pos, len, val);
> +        rc = host_pci_config_read(pos, len, val, errp);
>          if (rc) {

The usual pattern for error checking and propagation is:

    Error *err;
    host_pci_config_read(pos, len, val, &err);
    if (err) {
        error_propagate(errp, local_err);
        return;
    }

> -            return -ENODEV;
> +            return;
>          }
>          pci_default_write_config(pci_dev, pos, val, len);
>      }
> -
> -    return 0;
>  }
>  
>  static void igd_passthrough_i440fx_class_init(ObjectClass *klass, void *data)
> @@ -820,7 +822,7 @@ static void igd_passthrough_i440fx_class_init(ObjectClass *klass, void *data)
>      DeviceClass *dc = DEVICE_CLASS(klass);
>      PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
>  
> -    k->init = igd_pt_i440fx_initfn;
> +    k->realize = igd_pt_i440fx_realize;
>      dc->desc = "IGD Passthrough Host bridge";
>  }
>  
> -- 
> 2.1.0
> 
> 
> 

-- 
Eduardo

  reply	other threads:[~2015-12-18 18:37 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-18 11:03 [Qemu-devel] [PATCH 0/5] Convert to realize() Cao jin
2015-12-18 11:03 ` [Qemu-devel] [PATCH 1/5] SH PCI Host: convert " Cao jin
2015-12-18 17:59   ` Paolo Bonzini
2016-01-10 18:13     ` Michael Tokarev
2015-12-18 11:03 ` [Qemu-devel] [PATCH 2/5] igd-passthrough-i440FX: " Cao jin
2015-12-18 18:37   ` Eduardo Habkost [this message]
2015-12-18 21:18     ` Markus Armbruster
2015-12-20 11:59       ` Cao jin
2016-01-11 14:32         ` Markus Armbruster
2016-01-12  2:24           ` Cao jin
2015-12-20 11:56     ` Cao jin
2015-12-18 11:03 ` [Qemu-devel] [PATCH 3/5] PXB: " Cao jin
2015-12-18 18:01   ` Paolo Bonzini
2015-12-20 11:38     ` Cao jin
2015-12-21 10:39       ` Cao jin
2015-12-21 15:49       ` Paolo Bonzini
2015-12-22  3:58         ` Cao jin
2015-12-22  7:34           ` Marcel Apfelbaum
2015-12-22  9:16             ` Cao jin
2015-12-22  9:35               ` Marcel Apfelbaum
2015-12-22  9:52                 ` Cao jin
2015-12-22 11:40                 ` Cao jin
2015-12-20 10:22   ` Marcel Apfelbaum
2015-12-20 10:48     ` Cao jin
2015-12-20 11:21       ` Marcel Apfelbaum
2015-12-21  2:59         ` Cao jin
2015-12-21 10:08           ` Marcel Apfelbaum
2015-12-21 10:19             ` Cao jin
2015-12-18 11:03 ` [Qemu-devel] [PATCH 4/5] gt64120: " Cao jin
2015-12-18 17:59   ` Paolo Bonzini
2016-01-10 18:12     ` Michael Tokarev
2015-12-18 11:03 ` [Qemu-devel] [PATCH 5/5] xen-pvdevice: " Cao jin
2015-12-18 18:00   ` Paolo Bonzini
2015-12-21  5:52     ` Cao jin
2015-12-21 15:00       ` Stefano Stabellini
2015-12-21 15:15   ` Stefano Stabellini
2015-12-22  1:24     ` Cao jin
2015-12-22  2:40       ` Cao jin
2015-12-18 11:08 ` [Qemu-devel] [PATCH 0/5] Convert " Cao jin

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=20151218183700.GZ3774@thinpad.lan.raisama.net \
    --to=ehabkost@redhat.com \
    --cc=aurelien@aurel32.net \
    --cc=caoj.fnst@cn.fujitsu.com \
    --cc=leon.alrae@imgtec.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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 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.