io: open devices with device mode
Change-Id: I2aff9aecb02c044329b48511d30c477db1cb6354
Reviewed-on: https://go-review.googlesource.com/22511
Reviewed-by: Johan Euphrosine <proppy@google.com>
Reviewed-by: Jaana Burcu Dogan <jbd@google.com>
diff --git a/io/i2c/devfs.go b/io/i2c/devfs.go
index 481713b..177ccca 100644
--- a/io/i2c/devfs.go
+++ b/io/i2c/devfs.go
@@ -37,7 +37,7 @@
// TODO(jbd): Support I2C_RETRIES and I2C_TIMEOUT at the driver and implementation level.
func (d *Devfs) Open(bus, addr int) (driver.Conn, error) {
- f, err := os.OpenFile(fmt.Sprintf("/dev/i2c-%d", bus), os.O_RDWR, 0)
+ f, err := os.OpenFile(fmt.Sprintf("/dev/i2c-%d", bus), os.O_RDWR, os.ModeDevice)
if err != nil {
return nil, err
}
diff --git a/io/spi/devfs.go b/io/spi/devfs.go
index 0df5ee6..f4a2177 100644
--- a/io/spi/devfs.go
+++ b/io/spi/devfs.go
@@ -50,7 +50,7 @@
// Open Devfs /dev/spidev<bus>.<chip> and returns a connection.
func (d *Devfs) Open(bus, chip int) (driver.Conn, error) {
n := fmt.Sprintf("/dev/spidev%d.%d", bus, chip)
- f, err := os.OpenFile(n, os.O_RDWR, 0)
+ f, err := os.OpenFile(n, os.O_RDWR, os.ModeDevice)
if err != nil {
return nil, err
}