Update the Open API to OpenRO and OpenRW

This commit is contained in:
zvonkok 2022-02-16 10:44:32 +01:00
parent 2c175dcdbf
commit 1f718a1568
2 changed files with 5 additions and 5 deletions

View File

@ -52,7 +52,7 @@ func TestNvpci(t *testing.T) {
require.Equal(t, 0, len(capabilities.Extended), "Wrong number of extended PCI capabilities") require.Equal(t, 0, len(capabilities.Extended), "Wrong number of extended PCI capabilities")
resource0 := devices[0].Resources[0] resource0 := devices[0].Resources[0]
bar0, err := resource0.Open() bar0, err := resource0.OpenRW()
require.Nil(t, err, "Error opening bar0") require.Nil(t, err, "Error opening bar0")
defer func() { defer func() {
err := bar0.Close() err := bar0.Close()

View File

@ -36,8 +36,8 @@ type MemoryResource struct {
Path string Path string
} }
// Open read write mmio region // OpenRW read write mmio region
func (mr *MemoryResource) Open() (mmio.Mmio, error) { func (mr *MemoryResource) OpenRW() (mmio.Mmio, error) {
rw, err := mmio.OpenRW(mr.Path, 0, int(mr.End-mr.Start+1)) rw, err := mmio.OpenRW(mr.Path, 0, int(mr.End-mr.Start+1))
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to open file for mmio: %v", err) return nil, fmt.Errorf("failed to open file for mmio: %v", err)
@ -51,8 +51,8 @@ func (mr *MemoryResource) Open() (mmio.Mmio, error) {
return nil, fmt.Errorf("unknown endianness for mmio: %v", err) return nil, fmt.Errorf("unknown endianness for mmio: %v", err)
} }
// OpenReadOnly read only mmio region // OpenRO read only mmio region
func (mr *MemoryResource) OpenReadOnly() (mmio.Mmio, error) { func (mr *MemoryResource) OpenRO() (mmio.Mmio, error) {
ro, err := mmio.OpenRO(mr.Path, 0, int(mr.End-mr.Start+1)) ro, err := mmio.OpenRO(mr.Path, 0, int(mr.End-mr.Start+1))
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to open file for mmio: %v", err) return nil, fmt.Errorf("failed to open file for mmio: %v", err)