staging: pi433: move get version func to where all other functions are
authorPaulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
Sat, 8 Jan 2022 21:27:28 +0000 (10:27 +1300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 25 Jan 2022 15:29:04 +0000 (16:29 +0100)
As a convention for the pi433 driver, all routines that deals with the
rf69 chip are defined in the rf69.c file. There was an exception to the
rule in which the uC version verification was being done directly
elsewhere. While at it, the Version Register hardcoded value was
replaced with a pre-existing constant in the driver.

This patch adds rf69_get_version function to rf69.c

Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
Link: https://lore.kernel.org/r/20220108212728.GA7784@mail.google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/pi433/pi433_if.c
drivers/staging/pi433/rf69.c
drivers/staging/pi433/rf69.h

index 68c09fa016ed335e7722bf0a463a8467207901cc..051c9052aeebba089bad4652c8b99eb386dd9954 100644 (file)
@@ -1115,8 +1115,8 @@ static int pi433_probe(struct spi_device *spi)
                "spi interface setup: mode 0x%2x, %d bits per word, %dhz max speed",
                spi->mode, spi->bits_per_word, spi->max_speed_hz);
 
-       /* Ping the chip by reading the version register */
-       retval = spi_w8r8(spi, 0x10);
+       /* read chip version */
+       retval = rf69_get_version(spi);
        if (retval < 0)
                return retval;
 
index d64df072d8e8c967ec5a1887ba2f43ac34b35cb0..ee8c81d164e1cf861ec634808c5704771844a0f1 100644 (file)
@@ -102,6 +102,11 @@ static inline int rf69_read_mod_write(struct spi_device *spi, u8 reg,
 
 /*-------------------------------------------------------------------------*/
 
+int rf69_get_version(struct spi_device *spi)
+{
+       return rf69_read_reg(spi, REG_VERSION);
+}
+
 int rf69_set_mode(struct spi_device *spi, enum mode mode)
 {
        static const u8 mode_map[] = {
index b648ba5fff89b9e96431fee4d5ff17bc4c042913..c25942f142a61dbc4cef572cce1a4f3bfa0fa3e4 100644 (file)
@@ -17,6 +17,7 @@
 #define FIFO_SIZE      66              /* bytes */
 #define FIFO_THRESHOLD 15              /* bytes */
 
+int rf69_get_version(struct spi_device *spi);
 int rf69_set_mode(struct spi_device *spi, enum mode mode);
 int rf69_set_data_mode(struct spi_device *spi, u8 data_mode);
 int rf69_set_modulation(struct spi_device *spi, enum modulation modulation);