public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Chunfeng Yun <chunfeng.yun@mediatek.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH 1/2] usb: mtu3: add a vbus debugfs interface
Date: Thu, 3 Aug 2017 09:01:35 -0700	[thread overview]
Message-ID: <20170803160135.GC20736@kroah.com> (raw)
In-Reply-To: <20170803160057.GB20736@kroah.com>

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

  reply	other threads:[~2017-08-03 16:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2017-08-04  2:11     ` Chunfeng Yun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170803160135.GC20736@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=chunfeng.yun@mediatek.com \
    --cc=felipe.balbi@linux.intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=matthias.bgg@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox