]> git.ipfire.org Git - thirdparty/kernel/stable.git/blobdiff - drivers/gpio/gpio-max7301.c
gpio: max7301: fix driver for use with CONFIG_VMAP_STACK
[thirdparty/kernel/stable.git] / drivers / gpio / gpio-max7301.c
index 05813fbf3daf25f4aeb6ea0233f13c13dd95ad73..647dfbbc4e1cf44ac989a1562e2c2f711fca5d36 100644 (file)
@@ -25,7 +25,7 @@ static int max7301_spi_write(struct device *dev, unsigned int reg,
        struct spi_device *spi = to_spi_device(dev);
        u16 word = ((reg & 0x7F) << 8) | (val & 0xFF);
 
-       return spi_write(spi, (const u8 *)&word, sizeof(word));
+       return spi_write_then_read(spi, &word, sizeof(word), NULL, 0);
 }
 
 /* A read from the MAX7301 means two transfers; here, one message each */
@@ -37,14 +37,8 @@ static int max7301_spi_read(struct device *dev, unsigned int reg)
        struct spi_device *spi = to_spi_device(dev);
 
        word = 0x8000 | (reg << 8);
-       ret = spi_write(spi, (const u8 *)&word, sizeof(word));
-       if (ret)
-               return ret;
-       /*
-        * This relies on the fact, that a transfer with NULL tx_buf shifts out
-        * zero bytes (=NOOP for MAX7301)
-        */
-       ret = spi_read(spi, (u8 *)&word, sizeof(word));
+       ret = spi_write_then_read(spi, &word, sizeof(word), &word,
+                                 sizeof(word));
        if (ret)
                return ret;
        return word & 0xff;