usb: gbam: Update port_count before opening BAM channel
Driver registers a platform driver to be notified when
the BAM channels are ready to be opened. If the BAM
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_bam.c b/drivers/usb/gadget/u_bam.c
index a047cfc..e44b339 100644
--- a/drivers/usb/gadget/u_bam.c
+++ b/drivers/usb/gadget/u_bam.c
@@ -791,12 +791,13 @@
}
for (i = 0; i < count; i++) {
+ n_bam_ports++;
ret = gbam_port_alloc(i);
if (ret) {
+ n_bam_ports--;
pr_err("%s: Unable to alloc port:%d\n", __func__, i);
goto free_bam_ports;
}
- n_bam_ports++;
}
gbam_debugfs_init();