From: Tomasz Figa <tfiga@chromium.org>
To: Ben Kao <ben.kao@intel.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
"Yeh, Andy" <andy.yeh@intel.com>
Subject: Re: [PATCH v2] media: ov8856: Add support for OV8856 sensor
Date: Tue, 15 Jan 2019 12:22:52 +0900 [thread overview]
Message-ID: <CAAFQd5B1nkEDou9Jj78sMnB-pc+qx-76i8hk0mdb-sjj6TkCfw@mail.gmail.com> (raw)
In-Reply-To: <1547176516-18074-1-git-send-email-ben.kao@intel.com>
Hi Ben,
On Fri, Jan 11, 2019 at 12:12 PM Ben Kao <ben.kao@intel.com> wrote:
>
> This patch adds driver for Omnivision's ov8856 sensor,
> the driver supports following features:
[snip]
> +static int ov8856_write_reg(struct ov8856 *ov8856, u16 reg, u16 len, u32 __val)
> +{
> + struct i2c_client *client = v4l2_get_subdevdata(&ov8856->sd);
> + unsigned int buf_i, val_i;
> + u8 buf[6];
> + u8 *val_p;
> + __be32 val;
> +
> + if (len > 4)
> + return -EINVAL;
> +
> + buf[0] = reg >> 8;
> + buf[1] = reg & 0xff;
The two lines above can be simplified into one put_unaligned_be16(reg, buf);
> +
> + val = cpu_to_be32(__val);
> + val_p = (u8 *)&val;
> + buf_i = 2;
> + val_i = 4 - len;
> +
> + while (val_i < 4)
> + buf[buf_i++] = val_p[val_i++];
All the code above can be simplified into:
val <<= 8 * (4 - len);
put_unaligned_be32(val, buf + 2);
> +
> + if (i2c_master_send(client, buf, len + 2) != len + 2)
> + return -EIO;
> +
> + return 0;
> +}
Best regards,
Tomasz
next prev parent reply other threads:[~2019-01-15 3:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-11 3:15 [PATCH v2] media: ov8856: Add support for OV8856 sensor Ben Kao
2019-01-14 14:32 ` Sakari Ailus
2019-01-15 3:22 ` Tomasz Figa [this message]
2019-01-15 5:18 ` Yeh, Andy
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=CAAFQd5B1nkEDou9Jj78sMnB-pc+qx-76i8hk0mdb-sjj6TkCfw@mail.gmail.com \
--to=tfiga@chromium.org \
--cc=andy.yeh@intel.com \
--cc=ben.kao@intel.com \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@linux.intel.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;
as well as URLs for NNTP newsgroup(s).