Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1703228
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/2] usb: mtu3: add a vbus debugfs interface |
| Date | 2017-08-03 18:10 +0200 |
| Message-ID | <uaqRc-2ml-23@gated-at.bofh.it> (permalink) |
| References | <uajPI-5RD-21@gated-at.bofh.it> <uaqRc-2ml-17@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/2] usb: mtu3: add a vbus debugfs interface Chunfeng Yun <chunfeng.yun@mediatek.com> - 2017-08-03 10:40 +0200
Re: [PATCH 1/2] usb: mtu3: add a vbus debugfs interface Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-03 18:10 +0200
Re: [PATCH 1/2] usb: mtu3: add a vbus debugfs interface Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-08-03 18:10 +0200
Re: [PATCH 1/2] usb: mtu3: add a vbus debugfs interface Chunfeng Yun <chunfeng.yun@mediatek.com> - 2017-08-04 04:20 +0200
csiph-web