diff options
| -rw-r--r-- | drivers/media/usb/dvb-usb/cxusb.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c index 5d7b4eaa6a3c..51620e02292f 100644 --- a/drivers/media/usb/dvb-usb/cxusb.c +++ b/drivers/media/usb/dvb-usb/cxusb.c | |||
| @@ -59,23 +59,24 @@ static int cxusb_ctrl_msg(struct dvb_usb_device *d, | |||
| 59 | u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen) | 59 | u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen) |
| 60 | { | 60 | { |
| 61 | struct cxusb_state *st = d->priv; | 61 | struct cxusb_state *st = d->priv; |
| 62 | int ret, wo; | 62 | int ret; |
| 63 | 63 | ||
| 64 | if (1 + wlen > MAX_XFER_SIZE) { | 64 | if (1 + wlen > MAX_XFER_SIZE) { |
| 65 | warn("i2c wr: len=%d is too big!\n", wlen); | 65 | warn("i2c wr: len=%d is too big!\n", wlen); |
| 66 | return -EOPNOTSUPP; | 66 | return -EOPNOTSUPP; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | wo = (rbuf == NULL || rlen == 0); /* write-only */ | 69 | if (rlen > MAX_XFER_SIZE) { |
| 70 | warn("i2c rd: len=%d is too big!\n", rlen); | ||
| 71 | return -EOPNOTSUPP; | ||
| 72 | } | ||
| 70 | 73 | ||
| 71 | mutex_lock(&d->data_mutex); | 74 | mutex_lock(&d->data_mutex); |
| 72 | st->data[0] = cmd; | 75 | st->data[0] = cmd; |
| 73 | memcpy(&st->data[1], wbuf, wlen); | 76 | memcpy(&st->data[1], wbuf, wlen); |
| 74 | if (wo) | 77 | ret = dvb_usb_generic_rw(d, st->data, 1 + wlen, st->data, rlen, 0); |
| 75 | ret = dvb_usb_generic_write(d, st->data, 1 + wlen); | 78 | if (!ret && rbuf && rlen) |
| 76 | else | 79 | memcpy(rbuf, st->data, rlen); |
| 77 | ret = dvb_usb_generic_rw(d, st->data, 1 + wlen, | ||
| 78 | rbuf, rlen, 0); | ||
| 79 | 80 | ||
| 80 | mutex_unlock(&d->data_mutex); | 81 | mutex_unlock(&d->data_mutex); |
| 81 | return ret; | 82 | return ret; |
