io/spi add a no-implementation of devfs for !linux

Allow users to build with Devfs on all platforms by exporting required
symbols with no implementation.
Users can use tools such as goimports even if their host machine is not linux.

Change-Id: Iad30774e4344774a244dc2f30a767f6243782edd
Reviewed-on: https://go-review.googlesource.com/23923
Reviewed-by: Jaana Burcu Dogan <jbd@google.com>
diff --git a/io/spi/devfs.go b/io/spi/devfs.go
index ec7027a..a24c067 100644
--- a/io/spi/devfs.go
+++ b/io/spi/devfs.go
@@ -46,7 +46,7 @@
 }
 
 // Devfs is an SPI driver that works against the devfs.
-// You need to load the "spidev" module to use this driver.
+// You need to have loaded the "spidev" Linux module to use this driver.
 type Devfs struct {
 	// Dev is the device to be opened.
 	// Device name is usually in the /dev/spidev<bus>.<chip> format.
@@ -65,7 +65,7 @@
 	MaxSpeed int64
 }
 
-// Open opens the provided device with the speicifed options
+// Open opens the provided device with the specified options
 // and returns a connection.
 func (d *Devfs) Open() (driver.Conn, error) {
 	f, err := os.OpenFile(d.Dev, os.O_RDWR, os.ModeDevice)
diff --git a/io/spi/devfs_nonlinux.go b/io/spi/devfs_nonlinux.go
new file mode 100644
index 0000000..0b0a2ec
--- /dev/null
+++ b/io/spi/devfs_nonlinux.go
@@ -0,0 +1,39 @@
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !linux
+
+package spi
+
+import (
+	"errors"
+
+	"golang.org/x/exp/io/spi/driver"
+)
+
+// Devfs is a no-implementation of an SPI driver that works against the devfs.
+// You need to have loaded the Linux "spidev" module to use this driver.
+type Devfs struct {
+	// Dev is the device to be opened.
+	// Device name is usually in the /dev/spidev<bus>.<chip> format.
+	// Required.
+	Dev string
+
+	// Mode is the SPI mode. SPI mode is a combination of polarity and phases.
+	// CPOL is the high order bit, CPHA is the low order. Pre-computed mode
+	// values are Mode0, Mode1, Mode2 and Mode3. The value of the mode argument
+	// can be overriden by the device's driver.
+	// Required.
+	Mode Mode
+
+	// MaxSpeed is the max clock speed (Hz) and can be overriden by the device's driver.
+	// Required.
+	MaxSpeed int64
+}
+
+// Open opens the provided device with the speicifed options
+// and returns a connection.
+func (d *Devfs) Open() (driver.Conn, error) {
+	return nil, errors.New("not implemented on this platform")
+}