From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] tegra20: add pinctrl driver
Date: Mon, 6 May 2013 22:47:39 +0200 [thread overview]
Message-ID: <20130506204739.GD30509@game.jcrosoft.org> (raw)
In-Reply-To: <20130506195903.GJ32299@pengutronix.de>
On 21:59 Mon 06 May , Sascha Hauer wrote:
> On Mon, May 06, 2013 at 05:27:25PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > +
> > > +static struct pinctrl_ops pinctrl_tegra20_ops = {
> > > + .set_state = pinctrl_tegra20_set_state,
> > > +};
> > > +
> > > +static int pinctrl_tegra20_probe(struct device_d *dev)
> > > +{
> > > + struct pinctrl_tegra20 *ctrl;
> > > + int i, ret = 0;
> > no need the init of ret
> > > +
> > > + ctrl = xzalloc(sizeof(*ctrl));
> > > +
> > > + /*
> > > + * Tegra pincontrol is split out into four independent memory ranges:
> > > + * tristate control, function mux, pullup/down control, pad control
> > > + * (from lowest to highest hardware address).
> > > + * We are only interested in the first three for now.
> > > + */
> > > + for (i = 0; i <= 2; i++) {
> > > + ctrl->regs[i] = dev_request_mem_region(dev, i);
>
> The return values of dev_request_mem_region should be checked for new
> drivers. I know 98% of the code currently does not do this and it was a
> mistake. The above may fail if regions overlap or there are other bugs
> in the devicetree. Having this silently fail means that the actual
> register accesses do a NULL pointer deref later.
why not simply put a BUG in the request_mem
>
> > > + }
> > drop {}
> >
> > but use a specific name will simplify debug
>
> I don't think this should be mandatory.
the issue is that a number can be easly endup to a hiden typo (no compile
error) where a ttypo in the name will no compile.
>
> >
> > and make the code easier
> > > +
> > > + ctrl->pinctrl.dev = dev;
> > > + ctrl->pinctrl.ops = &pinctrl_tegra20_ops;
> > > +
> > > + ret = pinctrl_register(&ctrl->pinctrl);
> > > + if (ret)
> > > + free(ctrl);
> > report an error message
>
> The core will answer with an error message here. There is no need to
> litter the code with error messages which only add to the binary size.
> The above may fail for a developer but really should not fail for a user.
> A developer has enough information with the probe functions error code.
pinctrl_register print no error message
it's good to known why we failled no just that the probe return -Exxx
and this will not impact the binary size if we put a dev_warn or dev_debug
as we can drop them with the printk level
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-05-06 20:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-06 14:56 Lucas Stach
2013-05-06 14:56 ` [PATCH 2/2] tegra: paz00: import pinconfig from Linux Lucas Stach
2013-05-06 15:27 ` [PATCH 1/2] tegra20: add pinctrl driver Jean-Christophe PLAGNIOL-VILLARD
2013-05-06 19:59 ` Sascha Hauer
2013-05-06 20:47 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2013-05-08 6:28 ` Sascha Hauer
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=20130506204739.GD30509@game.jcrosoft.org \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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