linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Serge Semin <fancer.lancer@gmail.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: srinivas.kandagatla@linaro.org, andrew@lunn.ch,
	robh+dt@kernel.org, mark.rutland@arm.com,
	Sergey.Semin@t-platforms.ru, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v4 1/2] eeprom: Add IDT 89HPESx EEPROM/CSR driver
Date: Fri, 13 Jan 2017 12:47:52 +0300	[thread overview]
Message-ID: <20170113094752.GA9404@mobilestation> (raw)
In-Reply-To: <20170113072235.GA12825@kroah.com>

On Fri, Jan 13, 2017 at 08:22:35AM +0100, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Fri, Jan 13, 2017 at 01:54:17AM +0300, Serge Semin wrote:
> > On Wed, Jan 11, 2017 at 09:21:19AM +0100, Greg KH <gregkh@linuxfoundation.org> wrote:
> > > > +	/* Return failure if root directory doesn't exist */
> > > > +	if (!csr_dbgdir) {
> > > > +		dev_dbg(dev, "No Debugfs root directory");
> > > > +		return -EINVAL;
> > > > +	}
> > > 
> > > If debugfs is not enabled, don't error out, just keep going, it should
> > > never stop kernel code from running properly.
> > > 
> > > Also, this test isn't really doing what you think it is doing...
> > > 
> > 
> > I see, it must be replaced with IS_ERR_OR_NULL() test.
> 
> No!  That's a pain, when the debugfs interface was created its goal was
> to make it _easy_ to use, not hard.  IS_ERR_OR_NULL() is hard, and
> messy, don't do that.
> 
> > But I don't think,
> > it would be good to get rid of dev_dbg() completely here. In case if
> > debugging is enabled, user would understand why csr-node isn't created within
> > DebugFS directory. I don't see the reasoning why one shouldn't know a source
> > of possible problems.
> > (See the next comment as continue of the discussion)
> 
> Why would a user care about debugfs?
> 
> > > > +	/* Create Debugfs directory for CSR file */
> > > > +	snprintf(fname, CSRNAME_LEN, "%d-%04hx", cli->adapter->nr, cli->addr);
> > > > +	pdev->csr_dir = debugfs_create_dir(fname, csr_dbgdir);
> > > > +	if (IS_ERR_OR_NULL(pdev->csr_dir)) {
> > > > +		dev_err(dev, "Failed to create CSR node directory");
> > > > +		return -EINVAL;
> > > 
> > > Again, don't do this, you really don't care if debugfs worked or not.
> > > 
> > 
> > Actually the driver doesn't stop the kernel code from running, if it finds out
> > any problem with DebugFS CSR-node creation. The function just logs the error
> > and return error status. Take a look the place the method is called:
> > 1489        /* Create debugfs files */
> > 1490        (void)idt_create_dbgfs_files(pdev);
> > The initialization code doesn't check the return value at all, so the driver
> > will proceed with further code.
> > Why did I make the function with return value? Because it's a good style to
> > always return a status of function code execution if it may fail, but only
> > caller will decide whether to check the return value or not.
> 
> There is only one type of error that a debugfs call can return, and that
> is if debugfs is not enabled in the build.  That's it, you don't need to
> care about any of that.
> 
> > Regarding the error printing. In case if the code gets to this check, one can
> > be sure the DebugFS works properly, so in case if the driver failed to create
> > the corresponding sub-directory or node, it is really error to have any failure
> > at this point, and a user should be notified. But still the driver won't stop
> > functioning, since the caller doesn't check the return value.
> > 
> > Hopefully you'll understand my point.
> 
> Please understand mine, debugfs is supposed to be easy to use, you are
> not testing things properly here, and when you are, it doesn't matter.
> Just call the functions, save the return results if you need to (for
> dentries and the like), and move on.  No error handling needed AT ALL!
> 
> Yes, it feels "odd" for kernel code, but remember, this is only for
> debugging.  Your code should not have any different codepaths for if the
> debugging logic worked or not.  It doesn't care at all.  So please, make
> it simple.
> 
> > > > +	dev_dbg(dev, "Debugfs-files created");
> > > 
> > > You do know about ftrace, right?  Please remove all of these
> > > "trace-like" debugging lines, they aren't needed for anyone.
> > > 
> > 
> > Ok, I'll remove all these prints, even though I do find these prints being
> > handy to have initialization process printed on debugging stage.
> 
> Then use ftrace, that is what it is there for, don't roll your own
> driver-specific-functionality please.
> 
> thanks,
> 
> greg k-h

Ok, I see your point and do as you say.

Thanks,
Serge

  reply	other threads:[~2017-01-13  9:47 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-02 23:13 [PATCH] Add IDT 89HPESx EEPROM/CSR driver Serge Semin
2016-10-30 13:53 ` Greg KH
2016-11-24 18:42   ` Serge Semin
2016-11-28 22:38 ` [PATCH v2 0/2] eeprom: " Serge Semin
2016-11-28 22:38   ` [PATCH v2 1/2] " Serge Semin
2016-11-29 19:34     ` Greg KH
2016-11-29 19:37     ` Greg KH
2016-11-29 21:16       ` Serge Semin
2016-11-29 21:24         ` Greg KH
2016-11-29 21:45           ` Serge Semin
2016-11-28 22:38   ` [PATCH v2 2/2] eeprom: Add IDT 89HPESx driver bindings file Serge Semin
2016-11-29 19:34     ` Greg KH
2016-11-29 21:15       ` Serge Semin
2016-12-05 14:46     ` Rob Herring
2016-12-05 15:25       ` Serge Semin
2016-12-05 17:27         ` Rob Herring
2016-12-05 19:04           ` Serge Semin
2016-12-09  1:57             ` Serge Semin
2016-12-12 23:04             ` Rob Herring
2016-12-13 14:08               ` Serge Semin
2016-11-29 22:27   ` [PATCH v3 0/2] eeprom: Add IDT 89HPESx EEPROM/CSR driver Serge Semin
2016-11-29 22:27     ` [PATCH v3 1/2] " Serge Semin
2016-11-29 22:27     ` [PATCH v3 2/2] eeprom: Add IDT 89HPESx driver dts-binding file Serge Semin
2016-12-13 14:22     ` [PATCH v4 0/2] eeprom: Add IDT 89HPESx EEPROM/CSR driver Serge Semin
2016-12-13 14:22       ` [PATCH v4 1/2] " Serge Semin
2017-01-11  8:21         ` Greg KH
2017-01-12 22:54           ` Serge Semin
2017-01-13  7:22             ` Greg KH
2017-01-13  9:47               ` Serge Semin [this message]
2016-12-13 14:22       ` [PATCH v4 2/2] eeprom: Add IDT 89HPESx driver bindings file Serge Semin
2017-01-13 12:16       ` [PATCH v5 0/2] eeprom: Add IDT 89HPESx EEPROM/CSR driver Serge Semin
2017-01-13 12:16         ` [PATCH v5 1/2] " Serge Semin
2017-01-13 12:16         ` [PATCH v5 2/2] eeprom: Add IDT 89HPESx driver bindings file Serge Semin
2017-01-18 22:34           ` Rob Herring

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=20170113094752.GA9404@mobilestation \
    --to=fancer.lancer@gmail.com \
    --cc=Sergey.Semin@t-platforms.ru \
    --cc=andrew@lunn.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    /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;
as well as URLs for NNTP newsgroup(s).