Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c19cf4fd authored by Jack Pham's avatar Jack Pham
Browse files

usb: bam: Only call msm_hw_disable_bam for CI controller



The msm_hw_disable_bam() function may be defined if
CONFIG_USB_CI13XXX_MSM is enabled, but it is invalid to
call it if the USB 2.0 controller is not actually prsent
or enabled. Make sure to call it only if USB BAM is known
to be set up for the CI_CTRL bam type.

Also hide its usage in the gadget drivers by abstracting the
calls within the usb_bam_a2_reset() function.

Change-Id: Ie6633ec8c40367fadeeafba2f009b0bfad3c229e
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 7724ba3f
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -2172,12 +2172,12 @@ int usb_bam_connect_ipa(struct usb_bam_connect_ipa_params *ipa_params)
	     (ctx.pipes_enabled_per_bam[cur_bam] == 0)) {
		spin_unlock(&usb_bam_lock);

		if (cur_bam != HSIC_CTRL)
		if (cur_bam == CI_CTRL)
			msm_hw_bam_disable(1);

		sps_device_reset(ctx.h_bam[cur_bam]);

		if (cur_bam != HSIC_CTRL)
		if (cur_bam == CI_CTRL)
			msm_hw_bam_disable(0);

		/* On re-connect assume out from lpm for HOST BAM */
@@ -2759,8 +2759,14 @@ int usb_bam_a2_reset(bool to_reconnect)
	pr_debug("%s: pipes disconnection success\n", __func__);
	/* Reset A2 (USB/HSIC) BAM */
	if (to_reset_bam) {
		if (bam == CI_CTRL)
			msm_hw_bam_disable(1);

		if (sps_device_reset(ctx.h_bam[bam]))
			pr_err("%s: BAM reset failed\n", __func__);

		if (bam == CI_CTRL)
			msm_hw_bam_disable(0);
	}

	if (!to_reconnect)
+0 −5
Original line number Diff line number Diff line
@@ -1506,8 +1506,6 @@ static int gbam_peer_reset_cb(void *param)
	gadget = dev->cdev->gadget;

	pr_debug("%s: reset by peer\n", __func__);
	/* Disable BAM */
	msm_hw_bam_disable(1);

	/* Reset BAM */
	ret = usb_bam_a2_reset(0);
@@ -1516,9 +1514,6 @@ static int gbam_peer_reset_cb(void *param)
		return ret;
	}

	/* Enable BAM */
	msm_hw_bam_disable(0);

	/* Unregister the peer reset callback */
	if (d->trans == USB_GADGET_XPORT_BAM2BAM && port->port_num == 0)
		usb_bam_register_peer_reset_cb(NULL, NULL);
+0 −6
Original line number Diff line number Diff line
@@ -630,9 +630,6 @@ static int bam_data_peer_reset_cb(void *param)

	pr_debug("%s: reset by peer\n", __func__);

	/* Disable BAM */
	msm_hw_bam_disable(1);

	/* Reset BAM */
	ret = usb_bam_a2_reset(0);
	if (ret) {
@@ -640,9 +637,6 @@ static int bam_data_peer_reset_cb(void *param)
		return ret;
	}

	/* Enable BAM */
	msm_hw_bam_disable(0);

	/* Unregister the peer reset callback */
	usb_bam_register_peer_reset_cb(NULL, NULL);