Browse Source

lowl-spi: Move knc_spi_txrx to linux_spi_txrx

Luke Dashjr 11 years ago
parent
commit
0357019bdc
3 changed files with 19 additions and 17 deletions
  1. 1 17
      driver-knc.c
  2. 17 0
      lowl-spi.c
  3. 1 0
      lowl-spi.h

+ 1 - 17
driver-knc.c

@@ -214,23 +214,7 @@ fail:
 	return false;
 }
 
-static
-bool knc_spi_txrx(struct spi_port * const spi)
-{
-	const void * const wrbuf = spi_gettxbuf(spi);
-	void * const rdbuf = spi_getrxbuf(spi);
-	const size_t bufsz = spi_getbufsz(spi);
-	const int fd = spi->fd;
-	struct spi_ioc_transfer xf = {
-		.tx_buf = (uintptr_t) wrbuf,
-		.rx_buf = (uintptr_t) rdbuf,
-		.len = bufsz,
-		.delay_usecs = spi->delay,
-		.speed_hz = spi->speed,
-		.bits_per_word = spi->bits,
-	};
-	return (ioctl(fd, SPI_IOC_MESSAGE(1), &xf) > 0);
-}
+#define knc_spi_txrx  linux_spi_txrx
 
 static
 void knc_clean_flush(struct spi_port * const spi)

+ 17 - 0
lowl-spi.c

@@ -196,6 +196,23 @@ bool sys_spi_txrx(struct spi_port *port)
 	return true;
 }
 
+bool linux_spi_txrx(struct spi_port * const spi)
+{
+	const void * const wrbuf = spi_gettxbuf(spi);
+	void * const rdbuf = spi_getrxbuf(spi);
+	const size_t bufsz = spi_getbufsz(spi);
+	const int fd = spi->fd;
+	struct spi_ioc_transfer xf = {
+		.tx_buf = (uintptr_t) wrbuf,
+		.rx_buf = (uintptr_t) rdbuf,
+		.len = bufsz,
+		.delay_usecs = spi->delay,
+		.speed_hz = spi->speed,
+		.bits_per_word = spi->bits,
+	};
+	return (ioctl(fd, SPI_IOC_MESSAGE(1), &xf) > 0);
+}
+
 #endif
 
 static

+ 1 - 0
lowl-spi.h

@@ -80,6 +80,7 @@ bool spi_txrx(struct spi_port *port)
 }
 
 extern bool sys_spi_txrx(struct spi_port *);
+extern bool linux_spi_txrx(struct spi_port *);
 
 void spi_bfsb_select_bank(int bank);