Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux...
[firefly-linux-kernel-4.4.55.git] / drivers / gpio / gpio-max7301.c
index c6c535c1310e76e172ae7874a8ac92eed7b67e02..3b16ab7016301f0ff27cb2b05b070b377918d986 100644 (file)
@@ -56,12 +56,13 @@ static int max7301_probe(struct spi_device *spi)
        int ret;
 
        /* bits_per_word cannot be configured in platform data */
-       spi->bits_per_word = 16;
+       if (spi->dev.platform_data)
+               spi->bits_per_word = 16;
        ret = spi_setup(spi);
        if (ret < 0)
                return ret;
 
-       ts = kzalloc(sizeof(struct max7301), GFP_KERNEL);
+       ts = devm_kzalloc(&spi->dev, sizeof(struct max7301), GFP_KERNEL);
        if (!ts)
                return -ENOMEM;
 
@@ -70,8 +71,6 @@ static int max7301_probe(struct spi_device *spi)
        ts->dev = &spi->dev;
 
        ret = __max730x_probe(ts);
-       if (ret)
-               kfree(ts);
        return ret;
 }