Browse Source

aan: Add a read_reg hook

Luke Dashjr 11 years ago
parent
commit
ea76ae2c51
3 changed files with 11 additions and 2 deletions
  1. 8 2
      driver-aan.c
  2. 2 0
      driver-aan.h
  3. 1 0
      driver-jingtian.c

+ 8 - 2
driver-aan.c

@@ -102,8 +102,7 @@ bool aan_spi_cmd(struct spi_port * const spi, const uint8_t cmd, const uint8_t c
 	return true;
 }
 
-static
-bool aan_read_reg(struct spi_port * const spi, const uint8_t chip, void * const out_buf, const struct timeval * const tvp_timeout)
+bool aan_read_reg_direct(struct spi_port * const spi, const uint8_t chip, void * const out_buf, const struct timeval * const tvp_timeout)
 {
 	if (!aan_spi_cmd_send(spi, AAN_READ_REG, chip, NULL, 0))
 		return false;
@@ -120,6 +119,13 @@ bool aan_read_reg(struct spi_port * const spi, const uint8_t chip, void * const
 	return true;
 }
 
+static inline
+bool aan_read_reg(struct spi_port * const spi, const uint8_t chip, void * const out_buf, const struct timeval * const tvp_timeout)
+{
+	const struct aan_hooks * const hooks = spi->userp;
+	return hooks->read_reg(spi, chip, out_buf, tvp_timeout);
+}
+
 int aan_detect_spi(int * const out_chipcount, struct spi_port * const * const spi_a, const int spi_n)
 {
 	struct timeval tv_timeout;

+ 2 - 0
driver-aan.h

@@ -12,6 +12,7 @@
 
 struct aan_hooks {
 	void (*precmd)(struct spi_port *);
+	bool (*read_reg)(struct spi_port *, uint8_t chip, void *out_buf, const struct timeval *tvp_timeout);
 };
 
 struct aan_board_data {
@@ -32,6 +33,7 @@ struct aan_chip_data {
 };
 
 extern int aan_detect_spi(int *out_chipcount, struct spi_port * const *spi_a, int spi_n);
+extern bool aan_read_reg_direct(struct spi_port *, uint8_t chip, void *out_buf, const struct timeval *tvp_timeout);
 extern bool aan_init(struct thr_info *);
 extern bool aan_queue_append(struct thr_info *, struct work *);
 extern void aan_queue_flush(struct thr_info *);

+ 1 - 0
driver-jingtian.c

@@ -82,6 +82,7 @@ void jingtian_precmd(struct spi_port * const spi)
 static
 struct aan_hooks jingtian_hooks = {
 	.precmd = jingtian_precmd,
+	.read_reg = aan_read_reg_direct,
 };
 
 static