From: Douglas Gilbert <dgilbert-qazKcTl6WRFWk0Htik3J/w@public.gmane.org>
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH] i2c-dev: relax ban on I2C_M_RECV_LEN
Date: Sat, 04 Feb 2012 16:42:29 -0500 [thread overview]
Message-ID: <4F2DA645.3080604@interlog.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 531 bytes --]
The I2C_M_RECV_LEN flag indicates that the length of
an I2C response is in the first byte read. So the maximum
size of the read buffer using this option is 256 bytes.
Currently the i2c-dev driver returns EINVAL when an
attempt is made to use ioctl(I2C_RDWR) with the
I2C_M_RECV_LEN flag set. That is overly paranoid:
ChangeLog:
- allow I2C_M_RECV_LEN flag in the i2c-dev driver as
long as the associated buffer length can cope with
the worst case size (which is 256 bytes).
Doug Gilbert
[Please cc responses to me]
[-- Attachment #2: i2c-dev_mrecv_len1.patch --]
[-- Type: text/x-patch, Size: 634 bytes --]
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 57a45ce8..b8f226a0 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -270,9 +270,10 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
res = 0;
for (i = 0; i < rdwr_arg.nmsgs; i++) {
/* Limit the size of the message to a sane amount;
- * and don't let length change either. */
+ * with I2C_M_RECV_LEN require worst case len. */
if ((rdwr_pa[i].len > 8192) ||
- (rdwr_pa[i].flags & I2C_M_RECV_LEN)) {
+ ((rdwr_pa[i].flags & I2C_M_RECV_LEN) &&
+ (rdwr_pa[i].len < 256))) {
res = -EINVAL;
break;
}
next reply other threads:[~2012-02-04 21:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-04 21:42 Douglas Gilbert [this message]
[not found] ` <4F2DA645.3080604-qazKcTl6WRFWk0Htik3J/w@public.gmane.org>
2012-02-20 15:29 ` [PATCH] i2c-dev: relax ban on I2C_M_RECV_LEN Jean Delvare
[not found] ` <20120220162939.5ce96d52-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-02-21 3:45 ` Douglas Gilbert
[not found] ` <4F43133F.5040906-qazKcTl6WRFWk0Htik3J/w@public.gmane.org>
2012-02-21 7:31 ` Jean Delvare
[not found] ` <20120221083126.3bda01f3-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-02-21 8:19 ` 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=4F2DA645.3080604@interlog.com \
--to=dgilbert-qazkctl6wrfwk0htik3j/w@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 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).