aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2011-05-24 05:04:08 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-06-01 07:34:45 -0400
commit21d2e938d34d201276de3470587a3aa2047c77a1 (patch)
tree39720f57893084f8accf03efbfa815c4b4203c45 /drivers/media
parentc8ef0a5b70a9821b3d75097aba672f531619231b (diff)
[media] anysee: return EOPNOTSUPP for unsupported I2C messages
Check I2C messages and return error properly. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/dvb/dvb-usb/anysee.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/media/dvb/dvb-usb/anysee.c b/drivers/media/dvb/dvb-usb/anysee.c
index 4dc1ca333236..7c327b54308e 100644
--- a/drivers/media/dvb/dvb-usb/anysee.c
+++ b/drivers/media/dvb/dvb-usb/anysee.c
@@ -60,8 +60,6 @@ static int anysee_ctrl_msg(struct dvb_usb_device *d, u8 *sbuf, u8 slen,
60 int act_len, ret; 60 int act_len, ret;
61 u8 buf[64]; 61 u8 buf[64];
62 62
63 if (slen > sizeof(buf))
64 slen = sizeof(buf);
65 memcpy(&buf[0], sbuf, slen); 63 memcpy(&buf[0], sbuf, slen);
66 buf[60] = state->seq++; 64 buf[60] = state->seq++;
67 65
@@ -180,30 +178,37 @@ static int anysee_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msg,
180{ 178{
181 struct dvb_usb_device *d = i2c_get_adapdata(adap); 179 struct dvb_usb_device *d = i2c_get_adapdata(adap);
182 int ret = 0, inc, i = 0; 180 int ret = 0, inc, i = 0;
181 u8 buf[52]; /* 4 + 48 (I2C WR USB command header + I2C WR max) */
183 182
184 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) 183 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
185 return -EAGAIN; 184 return -EAGAIN;
186 185
187 while (i < num) { 186 while (i < num) {
188 if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) { 187 if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) {
189 u8 buf[6]; 188 if (msg[i].len > 2 || msg[i+1].len > 60) {
189 ret = -EOPNOTSUPP;
190 break;
191 }
190 buf[0] = CMD_I2C_READ; 192 buf[0] = CMD_I2C_READ;
191 buf[1] = (msg[i].addr << 1) | 0x01; 193 buf[1] = (msg[i].addr << 1) | 0x01;
192 buf[2] = msg[i].buf[0]; 194 buf[2] = msg[i].buf[0];
193 buf[3] = msg[i].buf[1]; 195 buf[3] = msg[i].buf[1];
194 buf[4] = msg[i].len-1; 196 buf[4] = msg[i].len-1;
195 buf[5] = msg[i+1].len; 197 buf[5] = msg[i+1].len;
196 ret = anysee_ctrl_msg(d, buf, sizeof(buf), msg[i+1].buf, 198 ret = anysee_ctrl_msg(d, buf, 6, msg[i+1].buf,
197 msg[i+1].len); 199 msg[i+1].len);
198 inc = 2; 200 inc = 2;
199 } else { 201 } else {
200 u8 buf[4+msg[i].len]; 202 if (msg[i].len > 48) {
203 ret = -EOPNOTSUPP;
204 break;
205 }
201 buf[0] = CMD_I2C_WRITE; 206 buf[0] = CMD_I2C_WRITE;
202 buf[1] = (msg[i].addr << 1); 207 buf[1] = (msg[i].addr << 1);
203 buf[2] = msg[i].len; 208 buf[2] = msg[i].len;
204 buf[3] = 0x01; 209 buf[3] = 0x01;
205 memcpy(&buf[4], msg[i].buf, msg[i].len); 210 memcpy(&buf[4], msg[i].buf, msg[i].len);
206 ret = anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0); 211 ret = anysee_ctrl_msg(d, buf, 4 + msg[i].len, NULL, 0);
207 inc = 1; 212 inc = 1;
208 } 213 }
209 if (ret) 214 if (ret)