From: Lucas Stach <dev@lynxeye.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 10/25] i2c: add Tegra driver
Date: Mon, 12 May 2014 20:55:15 +0200 [thread overview]
Message-ID: <1399920915.2292.4.camel@tellur> (raw)
In-Reply-To: <20140512114936.GG5858@pengutronix.de>
Am Montag, den 12.05.2014, 13:49 +0200 schrieb Sascha Hauer:
> On Mon, May 12, 2014 at 09:07:51AM +0200, Lucas Stach wrote:
> > Signed-off-by: Lucas Stach <dev@lynxeye.de>
> > ---
> > drivers/i2c/busses/Kconfig | 4 +
> > drivers/i2c/busses/Makefile | 1 +
> > drivers/i2c/busses/i2c-tegra.c | 708 +++++++++++++++++++++++++++++++++++++++++
> > 3 files changed, 713 insertions(+)
> > create mode 100644 drivers/i2c/busses/i2c-tegra.c
> >
[...]
> > +
> > +static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
> > + int num)
> > +{
> > + struct tegra_i2c_dev *i2c_dev = to_tegra_i2c_dev(adap);
> > + int i;
> > + int ret = 0;
> > +
> > + ret = tegra_i2c_clock_enable(i2c_dev);
> > + if (ret < 0) {
> > + dev_err(i2c_dev->dev, "Clock enable failed %d\n", ret);
> > + return ret;
> > + }
> > +
> > + for (i = 0; i < num; i++) {
> > + enum msg_end_type end_type = MSG_END_STOP;
> > + if (i < (num - 1))
> > + end_type = MSG_END_REPEAT_START;
> > + ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i], end_type);
> > + if (ret)
> > + break;
> > + }
> > + tegra_i2c_clock_disable(i2c_dev);
> > + return ret ?: i;
>
> What does this return when ret is true? ret? I've never seen this.
This is present in the Linux source this is based on. I've just had to
look it up and apparently it's a GNU extension which uses the first
operand implicitly as the second. So yep, this is returning ret if true.
Will change this as it's really confusing.
>
> > + i2c_dev = xzalloc(sizeof(*i2c_dev));
> > + if (!i2c_dev) {
> > + dev_err(dev, "Could not allocate struct tegra_i2c_dev");
> > + return -ENOMEM;
> > + }
>
> No need to check the result of xzalloc.
>
Ok, will remove.
> > + ret = tegra_i2c_clock_enable(i2c_dev);
> > + if (ret < 0) {
> > + dev_err(i2c_dev->dev, "Clock enable failed %d\n", ret);
> > + return ret;
> > + }
>
> Indentation broken here. tegra_i2c_init below also calls
> tegra_i2c_clock_enable, so this should be unnecessary here, right?
Right, this is a leftover from debugging. Thanks for spotting.
>
> > + ret = tegra_i2c_init(i2c_dev);
> > + if (ret) {
> > + dev_err(dev, "Failed to initialize i2c controller");
> > + return ret;
> > + }
> > +
>
> Sascha
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-05-12 18:52 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-12 7:07 [PATCH 00/25] Tegra-next Lucas Stach
2014-05-12 7:07 ` [PATCH 01/25] reset: add reset controller framework Lucas Stach
2014-05-12 7:07 ` [PATCH 02/25] tegra: lowlevel: add function to fetch chipid Lucas Stach
2014-05-12 7:07 ` [PATCH 03/25] reset: add tegra reset controller Lucas Stach
2014-05-12 7:07 ` [PATCH 04/25] clk: tegra: reset UARTS from clock controller Lucas Stach
2014-05-12 7:07 ` [PATCH 05/25] mci: tegra: add reset control Lucas Stach
2014-05-12 7:07 ` [PATCH 06/25] clk: tegra: remove device reset hack Lucas Stach
2014-05-12 7:07 ` [PATCH 07/25] clk: tegra: allow to register clocks with 16 bit divider Lucas Stach
2014-05-12 7:07 ` [PATCH 08/25] clk: tegra30: register i2c clocks Lucas Stach
2014-05-12 7:07 ` [PATCH 09/25] clk: tegra20: " Lucas Stach
2014-05-12 7:07 ` [PATCH 10/25] i2c: add Tegra driver Lucas Stach
2014-05-12 11:49 ` Sascha Hauer
2014-05-12 18:55 ` Lucas Stach [this message]
2014-05-12 7:07 ` [PATCH 11/25] ARM: tegra: beaver: activate sdmmc1 voltage rail Lucas Stach
2014-05-12 7:07 ` [PATCH 12/25] ARM: tegra: beaver: adjust pinmux to make sdmmc1 work Lucas Stach
2014-05-12 7:07 ` [PATCH 13/25] mci: tegra: apply pad autocalibration on T30 Lucas Stach
2014-05-12 7:07 ` [PATCH 14/25] mci: tegra: don't set 8bit mode unconditionally Lucas Stach
2014-05-12 7:07 ` [PATCH 15/25] pinctrl: tegra30: parse drive groups Lucas Stach
2014-05-12 7:07 ` [PATCH 16/25] scripts: tegra: import cbootimage Lucas Stach
2014-05-12 7:07 ` [PATCH 17/25] tegra: cbootimage: remove noisy output Lucas Stach
2014-05-12 7:07 ` [PATCH 18/25] Makefile.lib: add rule to built Tegra BCTs Lucas Stach
2014-05-12 7:08 ` [PATCH 19/25] images: add Tegra20 image build rules Lucas Stach
2014-05-12 7:08 ` [PATCH 20/25] images: add Tegra30 " Lucas Stach
2014-05-12 7:08 ` [PATCH 21/25] ARM: boards: colibri t20: import BCT cfgs Lucas Stach
2014-05-12 7:08 ` [PATCH 22/25] images: tegra: build all Toradex Colibri images Lucas Stach
2014-05-12 7:08 ` [PATCH 23/25] ARM: boards: beaver: import BCT cfg Lucas Stach
2014-05-12 7:08 ` [PATCH 24/25] images: tegra: build NVidia Beaver image Lucas Stach
2014-05-12 7:08 ` [PATCH 25/25] images: tegra: rename ac100 image Lucas Stach
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=1399920915.2292.4.camel@tellur \
--to=dev@lynxeye.de \
--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