summaryrefslogtreecommitdiff
path: root/io-module/mtac_gpiob.c
diff options
context:
space:
mode:
Diffstat (limited to 'io-module/mtac_gpiob.c')
-rw-r--r--io-module/mtac_gpiob.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/io-module/mtac_gpiob.c b/io-module/mtac_gpiob.c
index 3f9631d..0485494 100644
--- a/io-module/mtac_gpiob.c
+++ b/io-module/mtac_gpiob.c
@@ -30,6 +30,43 @@ static bool gpiob_get_dev_info_from_modalias(const char* modalias, int* port, ch
return true;
}
+/* Generic SPI functions */
+static inline int spi_writen(struct spi_device *spi, const u8 *buf, size_t len)
+{
+ int tmp;
+ u8 *tx;
+
+ tx = kmalloc(len, GFP_KERNEL);
+ if (!tx) {
+ return -ENOMEM;
+ }
+
+ memcpy(tx, buf, len);
+ tmp = spi_write(spi, tx, len);
+
+ kfree(tx);
+
+ return tmp;
+}
+
+static inline int spi_readn(struct spi_device *spi, u8 *buf, size_t len)
+{
+ int tmp;
+ u8 *rx;
+
+ rx = kmalloc(len, GFP_KERNEL);
+ if (!rx) {
+ return -ENOMEM;
+ }
+
+ tmp = spi_read(spi, rx, len);
+ memcpy(buf, rx, len);
+
+ kfree(rx);
+
+ return tmp;
+}
+
static int mts_spi_ap_probe(struct spi_device *spi)
{
int tmp;