From: ben-linux@fluff.org (Ben Dooks)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/1] fix i2c_msg.len not aligning with i2c_master_send
Date: Thu, 4 Feb 2010 07:37:59 +0000 [thread overview]
Message-ID: <20100204073759.GC13267@trinity.fluff.org> (raw)
In-Reply-To: <309424b61002032204y37307236q94ab3a502b0526e0@mail.gmail.com>
On Thu, Feb 04, 2010 at 02:04:03PM +0800, zhangfei gao wrote:
> Hi, Jean
>
>
> We found type of i2c_msg.len is __u16, while parameter count in
> i2c_master_send is int.
> The mismatch will truncate count from int to u16.
> For example we downloading firmware which is more than 64K (64K+8) via i2c,
> i2c would transfer u16 (8 bytes) in fact.
I would be wary of changing the i2c_msg structure as this is exported to
userspace.
I think a better fix would be to test the count parameter to i2c_master_send
and return something like EMSGSIZE to inform the user it is too long.
If you really want i2c transfers of 64K and above, then you might have to
add a new struct i2c_msg and update all the callsites to use it. Either that
or chain a set of msgs together and pass them to the i2c controller in one
go.
Please discuss on the i2c list.
> >From 69ec7599bf0fa28441281be1df76a2f573bb9127 Mon Sep 17 00:00:00 2001
> From: Zhangfei Gao <zgao6@marvell.com>
> Date: Fri, 5 Feb 2010 05:12:19 +0800
> Subject: [PATCH] i2c: i2c_msg.len modify to __u32 type
>
> int i2c_master_send(struct i2c_client *client,const char *buf ,int
> count)
> {
> ~
> msg.len = count;
> ~
> }
> Parameter count would truncate from int to __u16
>
> Signed-off-by: Zhangfei Gao <zgao6@marvell.com>
> ---
> include/linux/i2c.h | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> index 57d41b0..4769ce9 100644
> --- a/include/linux/i2c.h
> +++ b/include/linux/i2c.h
> @@ -491,7 +491,7 @@ struct i2c_msg {
> #define I2C_M_IGNORE_NAK 0x1000 /* if I2C_FUNC_PROTOCOL_MANGLING */
> #define I2C_M_NO_RD_ACK 0x0800 /* if I2C_FUNC_PROTOCOL_MANGLING
> */
> #define I2C_M_RECV_LEN 0x0400 /* length will be first received
> byte */
> - __u16 len; /* msg length */
> + __u32 len; /* msg length */
> __u8 *buf; /* pointer to msg data */
> };
>
> --
> 1.6.0.4
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
--
Ben
Q: What's a light-year?
A: One-third less calories than a regular year.
next prev parent reply other threads:[~2010-02-04 7:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-04 6:04 [PATCH 1/1] fix i2c_msg.len not aligning with i2c_master_send zhangfei gao
2010-02-04 7:37 ` Ben Dooks [this message]
[not found] ` <20100204073759.GC13267-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org>
2010-02-04 8:25 ` zhangfei gao
2010-02-04 8:25 ` zhangfei gao
[not found] ` <309424b61002032204y37307236q94ab3a502b0526e0-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-04 9:35 ` Jean Delvare
2010-02-04 9:35 ` Jean Delvare
2010-02-04 12:38 ` zhangfei gao
2010-02-04 12:38 ` zhangfei gao
2010-02-04 12:47 ` Eric Miao
2010-02-04 12:47 ` Eric Miao
[not found] ` <f17812d71002040447y4b6f889o1137ae6149559994-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-04 13:14 ` Jean Delvare
2010-02-04 13:14 ` Jean Delvare
[not found] ` <20100204141451.3e0f865e-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-02-05 5:51 ` zhangfei gao
2010-02-05 5:51 ` zhangfei gao
[not found] ` <309424b61002042151i2a762d41md3521a820fd45622-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-05 11:12 ` Eric Miao
2010-02-05 11:12 ` Eric Miao
2010-02-21 11:20 ` Jean Delvare
2010-02-21 11:20 ` Jean Delvare
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=20100204073759.GC13267@trinity.fluff.org \
--to=ben-linux@fluff.org \
--cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.