bus/pci: harmonize return value of config read
On Linux, rte_pci_read_config on success returns the number of read bytes, but on BSD it returns 0. Document the return values, and have BSD behave as Linux does. At least one case (bnx2x PMD) treats 0 as an error, so the change makes sense also for that. Signed-off-by: Luca Boccassi <bluca@debian.org> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
This commit is contained in:
parent
075b182b54
commit
e8d435f1f3
@ -441,6 +441,8 @@ int rte_pci_read_config(const struct rte_pci_device *dev,
|
|||||||
{
|
{
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
int size;
|
int size;
|
||||||
|
/* Copy Linux implementation's behaviour */
|
||||||
|
const int return_len = len;
|
||||||
struct pci_io pi = {
|
struct pci_io pi = {
|
||||||
.pi_sel = {
|
.pi_sel = {
|
||||||
.pc_domain = dev->addr.domain,
|
.pc_domain = dev->addr.domain,
|
||||||
@ -471,7 +473,7 @@ int rte_pci_read_config(const struct rte_pci_device *dev,
|
|||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return 0;
|
return return_len;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
|
@ -223,6 +223,8 @@ void rte_pci_unregister(struct rte_pci_driver *driver);
|
|||||||
* The length of the data buffer.
|
* The length of the data buffer.
|
||||||
* @param offset
|
* @param offset
|
||||||
* The offset into PCI config space
|
* The offset into PCI config space
|
||||||
|
* @return
|
||||||
|
* Number of bytes read on success, negative on error.
|
||||||
*/
|
*/
|
||||||
int rte_pci_read_config(const struct rte_pci_device *device,
|
int rte_pci_read_config(const struct rte_pci_device *device,
|
||||||
void *buf, size_t len, off_t offset);
|
void *buf, size_t len, off_t offset);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user