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

Commit cee765df authored by Ajay Agarwal's avatar Ajay Agarwal
Browse files

usb: misc: ks_bridge: Fail probe if port already in use



If a ksb port with a particular device ID is in use, and the user
connects another device with the same device ID, then we end up
overriding the ksb members with the new values leading to
functionality failure of the first device, among other possible
issues. To avoid that, fail the probe.
While at it, also fix minor checkpatch warning.

Change-Id: I2a5901b8fe49b69b95e3a842c4efcd976425c106
Signed-off-by: default avatarAjay Agarwal <ajaya@codeaurora.org>
parent 7a6d7203
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ struct ks_bridge {
	unsigned long		flags;
};

struct ks_bridge *__ksb[NO_BRIDGE_INSTANCES];
static struct ks_bridge *__ksb[NO_BRIDGE_INSTANCES];

#define DBG_MSG_LEN   40
#define DBG_MAX_MSG   500
@@ -667,6 +667,11 @@ ksb_usb_probe(struct usb_interface *ifc, const struct usb_device_id *id)
	}

	ksb = __ksb[devid];
	if (ksb->ifc) {
		dev_err(&ifc->dev, "%s: Port already in use\n", __func__);
		return -ENODEV;
	}

	ksb->udev = usb_get_dev(udev);
	ksb->ifc = usb_get_intf(ifc);
	ksb->in_pipe = usb_rcvbulkpipe(ksb->udev,
@@ -808,8 +813,8 @@ static void ksb_usb_disconnect(struct usb_interface *ifc)
					msecs_to_jiffies(PENDING_URB_TIMEOUT));
	wake_up(&ksb->ks_wait_q);
	usb_set_intfdata(ifc, NULL);
	usb_put_intf(ifc);
	usb_put_dev(ksb->udev);
	ksb->ifc = NULL;
}

static int ksb_usb_suspend(struct usb_interface *ifc, pm_message_t message)