diff options
author | Antti Palosaari <crope@iki.fi> | 2014-12-21 18:33:14 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-02-03 16:24:49 -0200 |
commit | c56222a6b25c24f211ecefd6ecc1003a7cb075d4 (patch) | |
tree | 981f01c3f076f2330fa31a08cbc46eb270c85ce6 /drivers/media | |
parent | 5ba4ca1a14c3cf62064c7edc30f05c40dd7ecee2 (diff) | |
download | linux-c56222a6b25c24f211ecefd6ecc1003a7cb075d4.tar.bz2 |
[media] rtl28xxu: move usb buffers to state
Buffer needed for USB control message is small so move it to state
and get rid of alloc/free used for each control message.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 31 | ||||
-rw-r--r-- | drivers/media/usb/dvb-usb-v2/rtl28xxu.h | 1 |
2 files changed, 10 insertions, 22 deletions
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index e3312a21a090..b0d2467398f2 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c @@ -29,20 +29,14 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) { + struct rtl28xxu_dev *dev = d->priv; int ret; unsigned int pipe; u8 requesttype; - u8 *buf; - - buf = kmalloc(req->size, GFP_KERNEL); - if (!buf) { - ret = -ENOMEM; - goto err; - } if (req->index & CMD_WR_FLAG) { /* write */ - memcpy(buf, req->data, req->size); + memcpy(dev->buf, req->data, req->size); requesttype = (USB_TYPE_VENDOR | USB_DIR_OUT); pipe = usb_sndctrlpipe(d->udev, 0); } else { @@ -52,24 +46,17 @@ static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) } ret = usb_control_msg(d->udev, pipe, 0, requesttype, req->value, - req->index, buf, req->size, 1000); - + req->index, dev->buf, req->size, 1000); dvb_usb_dbg_usb_control_msg(d->udev, 0, requesttype, req->value, - req->index, buf, req->size); - - if (ret > 0) - ret = 0; + req->index, dev->buf, req->size); + if (ret < 0) + goto err; /* read request, copy returned data to return buf */ - if (!ret && requesttype == (USB_TYPE_VENDOR | USB_DIR_IN)) - memcpy(req->data, buf, req->size); - - kfree(buf); + if (requesttype == (USB_TYPE_VENDOR | USB_DIR_IN)) + memcpy(req->data, dev->buf, req->size); - if (ret) - goto err; - - return ret; + return 0; err: dev_dbg(&d->intf->dev, "failed=%d\n", ret); return ret; diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h index abf0111a3fda..1b5d7ffb685e 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.h +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.h @@ -69,6 +69,7 @@ struct rtl28xxu_dev { + u8 buf[28]; u8 chip_id; u8 tuner; char *tuner_name; |