diff options
author | Chunfeng Yun <chunfeng.yun@mediatek.com> | 2019-03-21 03:53:47 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-03-26 08:40:14 +0100 |
commit | 4aab6ad24a101b9fa3779acc27eefd8a730a6f63 (patch) | |
tree | c92238af447232e0c72d6a6989ab890bf036e904 /drivers/usb/mtu3/mtu3_dr.c | |
parent | usb: mtu3: add debugfs interface files (diff) | |
download | linux-4aab6ad24a101b9fa3779acc27eefd8a730a6f63.tar.xz linux-4aab6ad24a101b9fa3779acc27eefd8a730a6f63.zip |
usb: mtu3: move vbus and mode debugfs interfaces into mtu3_debugfs.c
Due to the separated debugfs files are added, move vbus and mode
debugfs interfaces related with dual-role switch from mtu3_dr.c
into mtu3_debugfs.c
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/mtu3/mtu3_dr.c')
-rw-r--r-- | drivers/usb/mtu3/mtu3_dr.c | 113 |
1 files changed, 3 insertions, 110 deletions
diff --git a/drivers/usb/mtu3/mtu3_dr.c b/drivers/usb/mtu3/mtu3_dr.c index 3f86ae1e73e8..ff2956272e15 100644 --- a/drivers/usb/mtu3/mtu3_dr.c +++ b/drivers/usb/mtu3/mtu3_dr.c @@ -7,16 +7,9 @@ * Author: Chunfeng Yun <chunfeng.yun@mediatek.com> */ -#include <linux/debugfs.h> -#include <linux/irq.h> -#include <linux/kernel.h> -#include <linux/of_device.h> -#include <linux/pinctrl/consumer.h> -#include <linux/seq_file.h> -#include <linux/uaccess.h> - #include "mtu3.h" #include "mtu3_dr.h" +#include "mtu3_debug.h" #define USB2_PORT 2 #define USB3_PORT 3 @@ -270,7 +263,7 @@ static int ssusb_extcon_register(struct otg_switch_mtk *otg_sx) * This is useful in special cases, such as uses TYPE-A receptacle but also * wants to support dual-role mode. */ -static void ssusb_mode_manual_switch(struct ssusb_mtk *ssusb, int to_host) +void ssusb_mode_manual_switch(struct ssusb_mtk *ssusb, int to_host) { struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; @@ -285,106 +278,6 @@ static void ssusb_mode_manual_switch(struct ssusb_mtk *ssusb, int to_host) } } -static int ssusb_mode_show(struct seq_file *sf, void *unused) -{ - struct ssusb_mtk *ssusb = sf->private; - - seq_printf(sf, "current mode: %s(%s drd)\n(echo device/host)\n", - ssusb->is_host ? "host" : "device", - ssusb->otg_switch.manual_drd_enabled ? "manual" : "auto"); - - return 0; -} - -static int ssusb_mode_open(struct inode *inode, struct file *file) -{ - return single_open(file, ssusb_mode_show, inode->i_private); -} - -static ssize_t ssusb_mode_write(struct file *file, - const char __user *ubuf, size_t count, loff_t *ppos) -{ - struct seq_file *sf = file->private_data; - struct ssusb_mtk *ssusb = sf->private; - char buf[16]; - - if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) - return -EFAULT; - - if (!strncmp(buf, "host", 4) && !ssusb->is_host) { - ssusb_mode_manual_switch(ssusb, 1); - } else if (!strncmp(buf, "device", 6) && ssusb->is_host) { - ssusb_mode_manual_switch(ssusb, 0); - } else { - dev_err(ssusb->dev, "wrong or duplicated setting\n"); - return -EINVAL; - } - - return count; -} - -static const struct file_operations ssusb_mode_fops = { - .open = ssusb_mode_open, - .write = ssusb_mode_write, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static int ssusb_vbus_show(struct seq_file *sf, void *unused) -{ - struct ssusb_mtk *ssusb = sf->private; - struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; - - seq_printf(sf, "vbus state: %s\n(echo on/off)\n", - regulator_is_enabled(otg_sx->vbus) ? "on" : "off"); - - return 0; -} - -static int ssusb_vbus_open(struct inode *inode, struct file *file) -{ - return single_open(file, ssusb_vbus_show, inode->i_private); -} - -static ssize_t ssusb_vbus_write(struct file *file, - const char __user *ubuf, size_t count, loff_t *ppos) -{ - struct seq_file *sf = file->private_data; - struct ssusb_mtk *ssusb = sf->private; - struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; - char buf[16]; - bool enable; - - if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) - return -EFAULT; - - if (kstrtobool(buf, &enable)) { - dev_err(ssusb->dev, "wrong setting\n"); - return -EINVAL; - } - - ssusb_set_vbus(otg_sx, enable); - - return count; -} - -static const struct file_operations ssusb_vbus_fops = { - .open = ssusb_vbus_open, - .write = ssusb_vbus_write, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static void ssusb_debugfs_init(struct ssusb_mtk *ssusb) -{ - struct dentry *root = ssusb->dbgfs_root; - - debugfs_create_file("mode", 0644, root, ssusb, &ssusb_mode_fops); - debugfs_create_file("vbus", 0644, root, ssusb, &ssusb_vbus_fops); -} - void ssusb_set_force_mode(struct ssusb_mtk *ssusb, enum mtu3_dr_force_mode mode) { @@ -417,7 +310,7 @@ int ssusb_otg_switch_init(struct ssusb_mtk *ssusb) INIT_WORK(&otg_sx->vbus_work, ssusb_vbus_work); if (otg_sx->manual_drd_enabled) - ssusb_debugfs_init(ssusb); + ssusb_dr_debugfs_init(ssusb); else ret = ssusb_extcon_register(otg_sx); |