Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions gpioioctl/gpio.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,12 @@ func newGPIOChip(path string) (*GPIOChip, error) {
line_info.offset = uint32(line)
err := ioctl_gpio_v2_line_info(chip.fd, &line_info)
if err != nil {
log.Println("newGPIOChip get line info", err)
// older kernels don't support the GPIO v2 API. In this case the above syscall returns an EINVAL
// error. That's ok, in this case just don't continue accessing this GPIO chip with this interface
// any further.
if err.Error() == "invalid argument" {
return nil, nil
}
return nil, fmt.Errorf("reading line info: %w", err)
}
line := newGPIOLine(uint32(line), string(line_info.name[:]), string(line_info.consumer[:]), chip.fd)
Expand Down Expand Up @@ -616,9 +621,9 @@ func (d *driverGPIO) Init() (bool, error) {
var chip *GPIOChip
for _, item := range items {
chip, err = newGPIOChip(item)
if err == nil {
if chip != nil && err == nil {
chips = append(chips, chip)
} else {
} else if err != nil {
log.Println("gpioioctl.driverGPIO.Init() Error", err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion sysfs/gpio.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ func (d *driverGPIO) String() string {
}

func (d *driverGPIO) Prerequisites() []string {
return []string{"ioctl-gpio"}
return nil
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's really some dependency on ioctl-gpio we could move it to the After() below...!?

}

func (d *driverGPIO) After() []string {
Expand Down
2 changes: 1 addition & 1 deletion sysfs/gpio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func TestPin_readInt(t *testing.T) {
}

func TestGPIODriver(t *testing.T) {
if len((&driverGPIO{}).Prerequisites()) != 1 {
if len((&driverGPIO{}).Prerequisites()) != 0 {
t.Fatal("unexpected GPIO prerequisites")
}
}
Expand Down
Loading