staging: iio: resolver: ad2s1210: check return of ad2s1210_initial()
authorDavid Lechner <dlechner@baylibre.com>
Fri, 29 Sep 2023 17:23:09 +0000 (12:23 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 30 Sep 2023 14:37:15 +0000 (15:37 +0100)
This adds a check to the return value of ad2s1210_initial() since it
can fail. The call is also moved before devm_iio_device_register() so
that we don't have to unregister the device if it fails.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://lore.kernel.org/r/20230929-ad2s1210-mainline-v3-4-fa4364281745@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/staging/iio/resolver/ad2s1210.c

index 8fde08887f7f5e594e10b846ad3cd4e77fd124dd..b5e071d7c5fdfa566149db6bc39a671cdebd44a1 100644 (file)
@@ -672,6 +672,10 @@ static int ad2s1210_probe(struct spi_device *spi)
        if (ret < 0)
                return ret;
 
+       ret = ad2s1210_initial(st);
+       if (ret < 0)
+               return ret;
+
        indio_dev->info = &ad2s1210_info;
        indio_dev->modes = INDIO_DIRECT_MODE;
        indio_dev->channels = ad2s1210_channels;
@@ -683,7 +687,6 @@ static int ad2s1210_probe(struct spi_device *spi)
                return ret;
 
        st->fclkin = spi->max_speed_hz;
-       ad2s1210_initial(st);
 
        return 0;
 }