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

Commit fdf8f65a authored by Arumuga Durai A's avatar Arumuga Durai A
Browse files

USB: gadget: Add debugfs node to initiate function remote wakeup



In USBCV Function remote wakeup enable test requires to initiate
function wakeup notification from the device. Hence add a debugfs
node to initiate function wakeup notification from the device.
Use below commands to initiate function wakeup notification
for Modem:
echo > /sys/kernel/debug/usb_gbridge/remote_wakeup

and for NMEA:
echo > /sys/kernel/debug/usb_serial0/remote_wakeup

Change-Id: Icf13454355d1ce6eaeb4720cbb4134adfee194ae
CRs-Fixed: 1017394
Signed-off-by: default avatarArumuga Durai A <cadurai@codeaurora.org>
parent 8070c055
Loading
Loading
Loading
Loading
+43 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2011, 2013-2015, The Linux Foundation. All rights reserved.
 * Copyright (c) 2011, 2013-2016, The Linux Foundation. All rights reserved.
 * Linux Foundation chooses to take subject only to the GPLv2 license terms,
 * and distributes only under these terms.
 *
@@ -818,6 +818,40 @@ static ssize_t debug_gbridge_reset_stats(struct file *file,
	return count;
}

static ssize_t gbridge_rw_write(struct file *file, const char __user *ubuf,
					size_t count, loff_t *ppos)
{
	struct gbridge_port *ui_dev = ports[0];
	struct gserial *gser;
	struct usb_function *func;
	struct usb_gadget   *gadget;

	if (!ui_dev) {
		pr_err("%s ui_dev is NULL\n", __func__);
		return -EINVAL;
	}

	gser = ui_dev->port_usb;
	if (!gser) {
		pr_err("%s gser is NULL\n", __func__);
		return -EINVAL;
	}

	func = &gser->func;
	if (!func) {
		pr_err("%s func is NULL\n", __func__);
		return -EINVAL;
	}

	gadget = gser->func.config->cdev->gadget;
	if ((gadget->speed == USB_SPEED_SUPER) && (func->func_is_suspended)) {
		pr_debug("%s Calling usb_func_wakeup\n", __func__);
		usb_func_wakeup(func);
	}

	return count;
}

static int debug_gbridge_open(struct inode *inode, struct file *file)
{
	return 0;
@@ -829,6 +863,11 @@ static const struct file_operations debug_gbridge_ops = {
	.write = debug_gbridge_reset_stats,
};

const struct file_operations gbridge_rem_wakeup_fops = {
	.open = debug_gbridge_open,
	.write = gbridge_rw_write,
};

static void gbridge_debugfs_init(void)
{
	struct dentry *dent;
@@ -838,7 +877,10 @@ static void gbridge_debugfs_init(void)
		return;

	debugfs_create_file("status", 0444, dent, 0, &debug_gbridge_ops);
	debugfs_create_file("remote_wakeup", S_IWUSR,
				dent, 0, &gbridge_rem_wakeup_fops);
}

#else
static void gbridge_debugfs_init(void) {}
#endif
+43 −4
Original line number Diff line number Diff line
@@ -1349,6 +1349,45 @@ const struct file_operations debug_adb_ops = {
	.read = debug_read_status,
};

static ssize_t usb_gser_rw_write(struct file *file, const char __user *ubuf,
				size_t count, loff_t *ppos)
{
	struct gs_port *ui_dev = file->private_data;
	struct gserial *gser;
	struct usb_function *func;
	struct usb_gadget   *gadget;

	if (!ui_dev) {
		pr_err("%s ui_dev is NULL\n", __func__);
		return -EINVAL;
	}

	gser = ui_dev->port_usb;
	if (!gser) {
		pr_err("%s gser is NULL\n", __func__);
		return -EINVAL;
	}

	func = &gser->func;
	if (!func) {
		pr_err("%s func is NULL\n", __func__);
		return -EINVAL;
	}

	gadget = gser->func.config->cdev->gadget;
	if ((gadget->speed == USB_SPEED_SUPER) && (func->func_is_suspended)) {
		pr_debug("%s Calling usb_func_wakeup\n", __func__);
		usb_func_wakeup(func);
	}

	return count;
}

const struct file_operations debug_rem_wakeup_fops = {
	.open = serial_debug_open,
	.write = usb_gser_rw_write,
};

struct dentry *gs_dent;
static void usb_debugfs_init(struct gs_port *ui_dev, int port_num)
{
@@ -1363,6 +1402,8 @@ static void usb_debugfs_init(struct gs_port *ui_dev, int port_num)
			&debug_adb_ops);
	debugfs_create_file("reset", S_IRUGO | S_IWUSR,
			gs_dent, ui_dev, &debug_rst_ops);
	debugfs_create_file("remote_wakeup", S_IWUSR,
			gs_dent, ui_dev, &debug_rem_wakeup_fops);
}

static void usb_debugfs_remove(void)
@@ -1398,6 +1439,7 @@ void gserial_free_line(unsigned char port_num)
{
	struct gs_port	*port;

	usb_debugfs_remove();
	mutex_lock(&ports[port_num].lock);
	if (WARN_ON(!ports[port_num].port)) {
		mutex_unlock(&ports[port_num].lock);
@@ -1430,6 +1472,7 @@ int gserial_alloc_line(unsigned char *line_num)
			continue;
		if (ret)
			return ret;
		usb_debugfs_init(ports[port_num].port, port_num);
		break;
	}
	if (ret)
@@ -1652,9 +1695,6 @@ static int userial_init(void)
		goto fail;
	}

	for (i = 0; i < MAX_U_SERIAL_PORTS; i++)
		usb_debugfs_init(ports[i].port, i);

	pr_debug("%s: registered %d ttyGS* device%s\n", __func__,
			MAX_U_SERIAL_PORTS,
			(MAX_U_SERIAL_PORTS == 1) ? "" : "s");
@@ -1671,7 +1711,6 @@ module_init(userial_init);

static void userial_cleanup(void)
{
	usb_debugfs_remove();
	destroy_workqueue(gserial_wq);
	tty_unregister_driver(gs_tty_driver);
	put_tty_driver(gs_tty_driver);