greybus: spi: unregister master on device add fail
authorRui Miguel Silva <rui.silva@linaro.org>
Tue, 15 Dec 2015 19:09:56 +0000 (19:09 +0000)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 15 Dec 2015 22:32:12 +0000 (14:32 -0800)
When registering devices if any of it fail, just cleanup and release spi
master.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/spi.c

index 6e1146d474df1e2ffae752197ff4cbc92fe6d60d..e49dc56495b56b7ee2c8bb569a808d0b8de81d41 100644 (file)
@@ -366,8 +366,12 @@ static int gb_spi_connection_init(struct gb_connection *connection)
        /* now, fetch the devices configuration */
        for (i = 0; i < spi->num_chipselect; i++) {
                ret = gb_spi_setup_device(spi, i);
-               if (ret < 0)
+               if (ret < 0) {
+                       dev_err(&connection->bundle->dev,
+                               "failed to allocated spi device: %d\n", ret);
+                       spi_unregister_master(master);
                        break;
+               }
        }
 
        return ret;