usb: gsdio: Update port_count before opening SDIO channel
Driver registers a platform driver to be notified when
the SDIO channels are ready to be opened. If the SDIO
channels can be opened at the time of platform device's
registration then probe function gets called immediately
and fails because port_count is not yet updated.
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
diff --git a/drivers/usb/gadget/u_sdio.c b/drivers/usb/gadget/u_sdio.c
index 09d898f..3441839 100644
--- a/drivers/usb/gadget/u_sdio.c
+++ b/drivers/usb/gadget/u_sdio.c
@@ -1060,12 +1060,13 @@
for (i = 0; i < count; i++) {
mutex_init(&sdio_ports[i].lock);
ret = gsdio_port_alloc(i, &coding, sport_info + i);
+ n_sdio_ports++;
if (ret) {
+ n_sdio_ports--;
pr_err("%s: sdio logical port allocation failed\n",
__func__);
goto free_sdio_ports;
}
- n_sdio_ports++;
port_info++;
#ifdef DEBUG