[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [Qemu-devel] [PATCH V4 05/10] Introduce HostPCIDevice to access a pci device on the host.
On Fri, Nov 18, 2011 at 15:06, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> wrote: >> +static int host_pci_config_read(HostPCIDevice *d, int pos, void *buf, int >> len) >> +{ >> + Â Âint fd = host_pci_config_fd(d); >> + Â Âint res = 0; >> + >> +again: >> + Â Âres = pread(fd, buf, len, pos); >> + Â Âif (res != len) { >> + Â Â Â Âif (res < 0 && (errno == EINTR || errno == EAGAIN)) { >> + Â Â Â Â Â Âgoto again; >> + Â Â Â Â} >> + Â Â Â Âfprintf(stderr, "host_pci_config: read failed: %s (fd: %i)\n", >> + Â Â Â Â Â Â Â Âstrerror(errno), fd); >> + Â Â Â Âreturn -errno; >> + Â Â} >> + Â Âreturn 0; >> +} >> +static int host_pci_config_write(HostPCIDevice *d, >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â int pos, const void *buf, int len) >> +{ >> + Â Âint fd = host_pci_config_fd(d); >> + Â Âint res = 0; >> + >> +again: >> + Â Âres = pwrite(fd, buf, len, pos); >> + Â Âif (res != len) { >> + Â Â Â Âif (res < 0 && (errno == EINTR || errno == EAGAIN)) { >> + Â Â Â Â Â Âgoto again; >> + Â Â Â Â} >> + Â Â Â Âfprintf(stderr, "host_pci_config: write failed: %s\n", >> + Â Â Â Â Â Â Â Âstrerror(errno)); >> + Â Â Â Âreturn -errno; >> + Â Â} >> + Â Âreturn 0; >> +} >> + >> +int host_pci_get_byte(HostPCIDevice *d, int pos, uint8_t *p) >> +{ >> + Âuint8_t buf; >> + Âif (host_pci_config_read(d, pos, &buf, 1)) { >> + Â Â Âreturn -1; > > Would it make sense to use the nice enum you decleraed at the > top of the file? ÂOr not? I should probably return -errno instead, I mean the return value of host_pci_config_read/write. I just introduce the enum to have a differente value than -errno for some internal function (get_ressource/get_hex_value), so I don't think that the enum can really by used outside of this file, yet. (I will change the rest of the patch as you sugest in your comment) Thanks, -- Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |