* [PATCH 1/2] usb: mtu3: add a vbus debugfs interface
@ 2017-08-03 8:37 Chunfeng Yun
2017-08-03 8:37 ` [PATCH 2/2] MAINTAINERS: add entry for mediatek usb3 DRD IP driver Chunfeng Yun
2017-08-03 16:00 ` [PATCH 1/2] usb: mtu3: add a vbus debugfs interface Greg Kroah-Hartman
0 siblings, 2 replies; 7+ messages in thread
From: Chunfeng Yun @ 2017-08-03 8:37 UTC (permalink / raw)
To: Greg Kroah-Hartman, Felipe Balbi, Mathias Nyman, Matthias Brugger
Cc: Chunfeng Yun, linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek
Provides a new vbus debugfs interface used to turn on/off vbus
regulator, it also can be used to get/put reference count of
vbus, due to sometimes we need keep it alive when manually switch
mtu3 to device mode.
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
drivers/usb/mtu3/mtu3_dr.c | 75 +++++++++++++++++++++++++++++++++++++++-----
1 file changed, 67 insertions(+), 8 deletions(-)
diff --git a/drivers/usb/mtu3/mtu3_dr.c b/drivers/usb/mtu3/mtu3_dr.c
index 11a0d3b..6c75916 100644
--- a/drivers/usb/mtu3/mtu3_dr.c
+++ b/drivers/usb/mtu3/mtu3_dr.c
@@ -322,23 +322,82 @@ static ssize_t ssusb_mode_write(struct file *file,
.release = single_release,
};
-static void ssusb_debugfs_init(struct ssusb_mtk *ssusb)
+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];
+
+ if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+ return -EFAULT;
+
+ if (!strncmp(buf, "on", 2)) {
+ ssusb_set_vbus(otg_sx, 1);
+ } else if (!strncmp(buf, "off", 3)) {
+ ssusb_set_vbus(otg_sx, 0);
+ } else {
+ dev_err(ssusb->dev, "wrong setting\n");
+ return -EINVAL;
+ }
+
+ 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 int ssusb_debugfs_init(struct ssusb_mtk *ssusb)
{
struct dentry *root;
struct dentry *file;
root = debugfs_create_dir(dev_name(ssusb->dev), usb_debug_root);
if (IS_ERR_OR_NULL(root)) {
- if (!root)
- dev_err(ssusb->dev, "create debugfs root failed\n");
- return;
+ dev_err(ssusb->dev, "create debugfs root failed\n");
+ goto err_dbgfs;
}
ssusb->dbgfs_root = root;
- file = debugfs_create_file("mode", S_IRUGO | S_IWUSR, root,
- ssusb, &ssusb_mode_fops);
- if (!file)
- dev_dbg(ssusb->dev, "create debugfs mode failed\n");
+ file = debugfs_create_file("mode", 0644, root, ssusb, &ssusb_mode_fops);
+ if (!file) {
+ dev_err(ssusb->dev, "create debugfs mode failed\n");
+ goto err_dbgfs;
+ }
+
+ file = debugfs_create_file("vbus", 0644, root, ssusb, &ssusb_vbus_fops);
+ if (!file) {
+ dev_err(ssusb->dev, "create debugfs vbus failed\n");
+ goto err_dbgfs;
+ }
+
+ return 0;
+
+err_dbgfs:
+ debugfs_remove_recursive(ssusb->dbgfs_root);
+ return -ENOMEM;
}
static void ssusb_debugfs_exit(struct ssusb_mtk *ssusb)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] MAINTAINERS: add entry for mediatek usb3 DRD IP driver
2017-08-03 8:37 [PATCH 1/2] usb: mtu3: add a vbus debugfs interface Chunfeng Yun
@ 2017-08-03 8:37 ` Chunfeng Yun
2017-08-03 9:23 ` Felipe Balbi
2017-08-03 16:00 ` [PATCH 1/2] usb: mtu3: add a vbus debugfs interface Greg Kroah-Hartman
1 sibling, 1 reply; 7+ messages in thread
From: Chunfeng Yun @ 2017-08-03 8:37 UTC (permalink / raw)
To: Greg Kroah-Hartman, Felipe Balbi, Mathias Nyman, Matthias Brugger
Cc: Chunfeng Yun, linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek
Add myself as maintainer of MediaTek USB3 DRD IP driver
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
MAINTAINERS | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 205d397..0f0bcc7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8472,6 +8472,13 @@ M: Sean Wang <sean.wang@mediatek.com>
S: Maintained
F: drivers/char/hw_random/mtk-rng.c
+MEDIATEK USB3 DRD IP DRIVER
+M: Chunfeng Yun <chunfeng.yun@mediatek.com>
+L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
+L: linux-mediatek@lists.infradead.org (moderated for non-subscribers)
+S: Maintained
+F: drivers/usb/mtu3/
+
MEGACHIPS STDPXXXX-GE-B850V3-FW LVDS/DP++ BRIDGES
M: Peter Senna Tschudin <peter.senna@collabora.com>
M: Martin Donnelly <martin.donnelly@ge.com>
--
1.7.9.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] MAINTAINERS: add entry for mediatek usb3 DRD IP driver
2017-08-03 8:37 ` [PATCH 2/2] MAINTAINERS: add entry for mediatek usb3 DRD IP driver Chunfeng Yun
@ 2017-08-03 9:23 ` Felipe Balbi
2017-08-03 10:20 ` Chunfeng Yun
0 siblings, 1 reply; 7+ messages in thread
From: Felipe Balbi @ 2017-08-03 9:23 UTC (permalink / raw)
To: Chunfeng Yun, Greg Kroah-Hartman, Mathias Nyman, Matthias Brugger
Cc: Chunfeng Yun, linux-usb, linux-kernel, linux-arm-kernel, linux-mediatek
[-- Attachment #1: Type: text/plain, Size: 806 bytes --]
Hi,
Chunfeng Yun <chunfeng.yun@mediatek.com> writes:
> Add myself as maintainer of MediaTek USB3 DRD IP driver
>
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> MAINTAINERS | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 205d397..0f0bcc7 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -8472,6 +8472,13 @@ M: Sean Wang <sean.wang@mediatek.com>
> S: Maintained
> F: drivers/char/hw_random/mtk-rng.c
>
> +MEDIATEK USB3 DRD IP DRIVER
> +M: Chunfeng Yun <chunfeng.yun@mediatek.com>
> +L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
> +L: linux-mediatek@lists.infradead.org (moderated for non-subscribers)
everything USB should go to linux-usb too.
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] MAINTAINERS: add entry for mediatek usb3 DRD IP driver
2017-08-03 9:23 ` Felipe Balbi
@ 2017-08-03 10:20 ` Chunfeng Yun
0 siblings, 0 replies; 7+ messages in thread
From: Chunfeng Yun @ 2017-08-03 10:20 UTC (permalink / raw)
To: Felipe Balbi
Cc: Greg Kroah-Hartman, Mathias Nyman, Matthias Brugger, linux-usb,
linux-kernel, linux-arm-kernel, linux-mediatek
On Thu, 2017-08-03 at 12:23 +0300, Felipe Balbi wrote:
> Hi,
>
> Chunfeng Yun <chunfeng.yun@mediatek.com> writes:
> > Add myself as maintainer of MediaTek USB3 DRD IP driver
> >
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> > MAINTAINERS | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 205d397..0f0bcc7 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -8472,6 +8472,13 @@ M: Sean Wang <sean.wang@mediatek.com>
> > S: Maintained
> > F: drivers/char/hw_random/mtk-rng.c
> >
> > +MEDIATEK USB3 DRD IP DRIVER
> > +M: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > +L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
> > +L: linux-mediatek@lists.infradead.org (moderated for non-subscribers)
>
> everything USB should go to linux-usb too.
Ok, I'll add it, thanks
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] usb: mtu3: add a vbus debugfs interface
2017-08-03 8:37 [PATCH 1/2] usb: mtu3: add a vbus debugfs interface Chunfeng Yun
2017-08-03 8:37 ` [PATCH 2/2] MAINTAINERS: add entry for mediatek usb3 DRD IP driver Chunfeng Yun
@ 2017-08-03 16:00 ` Greg Kroah-Hartman
2017-08-03 16:01 ` Greg Kroah-Hartman
1 sibling, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-03 16:00 UTC (permalink / raw)
To: Chunfeng Yun
Cc: Felipe Balbi, Mathias Nyman, Matthias Brugger, linux-usb,
linux-kernel, linux-arm-kernel, linux-mediatek
On Thu, Aug 03, 2017 at 04:37:18PM +0800, Chunfeng Yun wrote:
> +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];
> +
> + if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
> + return -EFAULT;
> +
> + if (!strncmp(buf, "on", 2)) {
> + ssusb_set_vbus(otg_sx, 1);
> + } else if (!strncmp(buf, "off", 3)) {
> + ssusb_set_vbus(otg_sx, 0);
kstrtobool() is better to use here.
> +static int ssusb_debugfs_init(struct ssusb_mtk *ssusb)
> {
> struct dentry *root;
> struct dentry *file;
>
> root = debugfs_create_dir(dev_name(ssusb->dev), usb_debug_root);
> if (IS_ERR_OR_NULL(root)) {
That test is wrong, you should never need to care about the return value
of a debugfs call. You can always just use it in your next call (if it
is a dentry *), or just ignore it.
> - if (!root)
> - dev_err(ssusb->dev, "create debugfs root failed\n");
> - return;
> + dev_err(ssusb->dev, "create debugfs root failed\n");
> + goto err_dbgfs;
> }
> ssusb->dbgfs_root = root;
>
> - file = debugfs_create_file("mode", S_IRUGO | S_IWUSR, root,
> - ssusb, &ssusb_mode_fops);
> - if (!file)
> - dev_dbg(ssusb->dev, "create debugfs mode failed\n");
> + file = debugfs_create_file("mode", 0644, root, ssusb, &ssusb_mode_fops);
> + if (!file) {
> + dev_err(ssusb->dev, "create debugfs mode failed\n");
Same here, do not care, as it does not matter. Actually, you don't even
need to keep the file pointer around, right?
> + goto err_dbgfs;
> + }
> +
> + file = debugfs_create_file("vbus", 0644, root, ssusb, &ssusb_vbus_fops);
> + if (!file) {
Same here, you don't care if debugfs fails or not, it should never
affect your code flow.
And don't you need to remove the directory when your module/hardware is
removed? I don't see that happening here as you are not saving root off
anywhere.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] usb: mtu3: add a vbus debugfs interface
2017-08-03 16:00 ` [PATCH 1/2] usb: mtu3: add a vbus debugfs interface Greg Kroah-Hartman
@ 2017-08-03 16:01 ` Greg Kroah-Hartman
2017-08-04 2:11 ` Chunfeng Yun
0 siblings, 1 reply; 7+ messages in thread
From: Greg Kroah-Hartman @ 2017-08-03 16:01 UTC (permalink / raw)
To: Chunfeng Yun
Cc: Felipe Balbi, Mathias Nyman, Matthias Brugger, linux-usb,
linux-kernel, linux-arm-kernel, linux-mediatek
On Thu, Aug 03, 2017 at 09:00:57AM -0700, Greg Kroah-Hartman wrote:
> On Thu, Aug 03, 2017 at 04:37:18PM +0800, Chunfeng Yun wrote:
> > +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];
> > +
> > + if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
> > + return -EFAULT;
> > +
> > + if (!strncmp(buf, "on", 2)) {
> > + ssusb_set_vbus(otg_sx, 1);
> > + } else if (!strncmp(buf, "off", 3)) {
> > + ssusb_set_vbus(otg_sx, 0);
>
> kstrtobool() is better to use here.
>
> > +static int ssusb_debugfs_init(struct ssusb_mtk *ssusb)
> > {
> > struct dentry *root;
> > struct dentry *file;
> >
> > root = debugfs_create_dir(dev_name(ssusb->dev), usb_debug_root);
> > if (IS_ERR_OR_NULL(root)) {
>
> That test is wrong, you should never need to care about the return value
> of a debugfs call. You can always just use it in your next call (if it
> is a dentry *), or just ignore it.
>
> > - if (!root)
> > - dev_err(ssusb->dev, "create debugfs root failed\n");
> > - return;
> > + dev_err(ssusb->dev, "create debugfs root failed\n");
> > + goto err_dbgfs;
> > }
> > ssusb->dbgfs_root = root;
> >
> > - file = debugfs_create_file("mode", S_IRUGO | S_IWUSR, root,
> > - ssusb, &ssusb_mode_fops);
> > - if (!file)
> > - dev_dbg(ssusb->dev, "create debugfs mode failed\n");
> > + file = debugfs_create_file("mode", 0644, root, ssusb, &ssusb_mode_fops);
> > + if (!file) {
> > + dev_err(ssusb->dev, "create debugfs mode failed\n");
>
> Same here, do not care, as it does not matter. Actually, you don't even
> need to keep the file pointer around, right?
>
> > + goto err_dbgfs;
> > + }
> > +
> > + file = debugfs_create_file("vbus", 0644, root, ssusb, &ssusb_vbus_fops);
> > + if (!file) {
>
> Same here, you don't care if debugfs fails or not, it should never
> affect your code flow.
>
> And don't you need to remove the directory when your module/hardware is
> removed? I don't see that happening here as you are not saving root off
> anywhere.
Oh nevermind, you do save it, sorry for the noise...
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] usb: mtu3: add a vbus debugfs interface
2017-08-03 16:01 ` Greg Kroah-Hartman
@ 2017-08-04 2:11 ` Chunfeng Yun
0 siblings, 0 replies; 7+ messages in thread
From: Chunfeng Yun @ 2017-08-04 2:11 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Felipe Balbi, Mathias Nyman, Matthias Brugger, linux-usb,
linux-kernel, linux-arm-kernel, linux-mediatek
On Thu, 2017-08-03 at 09:01 -0700, Greg Kroah-Hartman wrote:
> On Thu, Aug 03, 2017 at 09:00:57AM -0700, Greg Kroah-Hartman wrote:
> > On Thu, Aug 03, 2017 at 04:37:18PM +0800, Chunfeng Yun wrote:
> > > +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];
> > > +
> > > + if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
> > > + return -EFAULT;
> > > +
> > > + if (!strncmp(buf, "on", 2)) {
> > > + ssusb_set_vbus(otg_sx, 1);
> > > + } else if (!strncmp(buf, "off", 3)) {
> > > + ssusb_set_vbus(otg_sx, 0);
> >
> > kstrtobool() is better to use here.
Ok
> >
> > > +static int ssusb_debugfs_init(struct ssusb_mtk *ssusb)
> > > {
> > > struct dentry *root;
> > > struct dentry *file;
> > >
> > > root = debugfs_create_dir(dev_name(ssusb->dev), usb_debug_root);
> > > if (IS_ERR_OR_NULL(root)) {
> >
> > That test is wrong, you should never need to care about the return value
> > of a debugfs call. You can always just use it in your next call (if it
> > is a dentry *), or just ignore it.
Ok, I'll just test NULL pointer, and ignore other ERROR value
> >
> > > - if (!root)
> > > - dev_err(ssusb->dev, "create debugfs root failed\n");
> > > - return;
> > > + dev_err(ssusb->dev, "create debugfs root failed\n");
> > > + goto err_dbgfs;
> > > }
> > > ssusb->dbgfs_root = root;
> > >
> > > - file = debugfs_create_file("mode", S_IRUGO | S_IWUSR, root,
> > > - ssusb, &ssusb_mode_fops);
> > > - if (!file)
> > > - dev_dbg(ssusb->dev, "create debugfs mode failed\n");
> > > + file = debugfs_create_file("mode", 0644, root, ssusb, &ssusb_mode_fops);
> > > + if (!file) {
> > > + dev_err(ssusb->dev, "create debugfs mode failed\n");
> >
> > Same here, do not care, as it does not matter. Actually, you don't even
> > need to keep the file pointer around, right?
Yes, you are right
> >
> > > + goto err_dbgfs;
> > > + }
> > > +
> > > + file = debugfs_create_file("vbus", 0644, root, ssusb, &ssusb_vbus_fops);
> > > + if (!file) {
> >
> > Same here, you don't care if debugfs fails or not, it should never
> > affect your code flow.
Ok
Thanks a lot
> >
> > And don't you need to remove the directory when your module/hardware is
> > removed? I don't see that happening here as you are not saving root off
> > anywhere.
>
> Oh nevermind, you do save it, sorry for the noise...
>
> greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-08-04 2:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-03 8:37 [PATCH 1/2] usb: mtu3: add a vbus debugfs interface Chunfeng Yun
2017-08-03 8:37 ` [PATCH 2/2] MAINTAINERS: add entry for mediatek usb3 DRD IP driver Chunfeng Yun
2017-08-03 9:23 ` Felipe Balbi
2017-08-03 10:20 ` Chunfeng Yun
2017-08-03 16:00 ` [PATCH 1/2] usb: mtu3: add a vbus debugfs interface Greg Kroah-Hartman
2017-08-03 16:01 ` Greg Kroah-Hartman
2017-08-04 2:11 ` Chunfeng Yun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).