LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@iki.fi>
To: Todor Tomov <todor.tomov@linaro.org>
Cc: mchehab@kernel.org, hverkuil@xs4all.nl,
laurent.pinchart@ideasonboard.com, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/2] media: Add a driver for the ov7251 camera sensor
Date: Thu, 26 Apr 2018 09:50:10 +0300 [thread overview]
Message-ID: <20180426065010.a67iqsaicpgu7m5b@valkosipuli.retiisi.org.uk> (raw)
In-Reply-To: <1524673246-14175-3-git-send-email-todor.tomov@linaro.org>
Hi Todor,
On Wed, Apr 25, 2018 at 07:20:46PM +0300, Todor Tomov wrote:
...
> +static int ov7251_write_reg(struct ov7251 *ov7251, u16 reg, u8 val)
> +{
> + u8 regbuf[3];
> + int ret;
> +
> + regbuf[0] = reg >> 8;
> + regbuf[1] = reg & 0xff;
> + regbuf[2] = val;
> +
> + ret = i2c_master_send(ov7251->i2c_client, regbuf, 3);
> + if (ret < 0) {
> + dev_err(ov7251->dev, "%s: write reg error %d: reg=%x, val=%x\n",
> + __func__, ret, reg, val);
> + return ret;
> + }
> +
> + return 0;
How about:
return ov7251_write_seq_regs(ov7251, reg, &val, 1);
And put the function below ov2751_write_seq_regs().
> +}
> +
> +static int ov7251_write_seq_regs(struct ov7251 *ov7251, u16 reg, u8 *val,
> + u8 num)
> +{
> + const u8 maxregbuf = 5;
> + u8 regbuf[maxregbuf];
> + u8 nregbuf = sizeof(reg) + num * sizeof(*val);
> + int ret = 0;
> +
> + if (nregbuf > maxregbuf)
> + return -EINVAL;
> +
> + regbuf[0] = reg >> 8;
> + regbuf[1] = reg & 0xff;
> +
> + memcpy(regbuf + 2, val, num);
> +
> + ret = i2c_master_send(ov7251->i2c_client, regbuf, nregbuf);
> + if (ret < 0) {
> + dev_err(ov7251->dev, "%s: write seq regs error %d: first reg=%x\n",
This line is over 80...
If you're happy with these, I can make the changes, too; they're trivial.
> + __func__, ret, reg);
> + return ret;
> + }
> +
> + return 0;
> +}
--
Kind regards,
Sakari Ailus
e-mail: sakari.ailus@iki.fi
next prev parent reply other threads:[~2018-04-26 6:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-25 16:20 [PATCH v4 0/2] Add support for " Todor Tomov
2018-04-25 16:20 ` [PATCH v4 1/2] dt-bindings: media: Binding document for OV7251 " Todor Tomov
2018-04-25 16:20 ` [PATCH v4 2/2] media: Add a driver for the ov7251 " Todor Tomov
2018-04-26 6:50 ` Sakari Ailus [this message]
2018-04-26 7:04 ` Todor Tomov
2018-04-26 7:16 ` Sakari Ailus
2018-04-26 12:04 ` Sakari Ailus
2018-04-26 12:40 ` Todor Tomov
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=20180426065010.a67iqsaicpgu7m5b@valkosipuli.retiisi.org.uk \
--to=sakari.ailus@iki.fi \
--cc=hverkuil@xs4all.nl \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=todor.tomov@linaro.org \
--subject='Re: [PATCH v4 2/2] media: Add a driver for the ov7251 camera sensor' \
/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
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).