Commit 8ea793aa authored by Florian Mickler's avatar Florian Mickler Committed by Mauro Carvalho Chehab

[media] vp702x: use preallocated buffer

Note: This change is tested to compile only as I don't have the
hardware.
Signed-off-by: default avatarFlorian Mickler <florian@mickler.org>
Cc: Patrick Boettcher <pb@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 9a187c41
...@@ -140,38 +140,44 @@ static int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o, ...@@ -140,38 +140,44 @@ static int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o,
static int vp702x_set_pld_mode(struct dvb_usb_adapter *adap, u8 bypass) static int vp702x_set_pld_mode(struct dvb_usb_adapter *adap, u8 bypass)
{ {
int ret; int ret;
u8 *buf = kzalloc(16, GFP_KERNEL); struct vp702x_device_state *st = adap->dev->priv;
if (!buf) u8 *buf;
return -ENOMEM;
mutex_lock(&st->buf_mutex);
buf = st->buf;
memset(buf, 0, 16);
ret = vp702x_usb_in_op(adap->dev, 0xe0, (bypass << 8) | 0x0e, ret = vp702x_usb_in_op(adap->dev, 0xe0, (bypass << 8) | 0x0e,
0, buf, 16); 0, buf, 16);
kfree(buf); mutex_unlock(&st->buf_mutex);
return ret; return ret;
} }
static int vp702x_set_pld_state(struct dvb_usb_adapter *adap, u8 state) static int vp702x_set_pld_state(struct dvb_usb_adapter *adap, u8 state)
{ {
int ret; int ret;
u8 *buf = kzalloc(16, GFP_KERNEL); struct vp702x_device_state *st = adap->dev->priv;
if (!buf) u8 *buf;
return -ENOMEM;
mutex_lock(&st->buf_mutex);
buf = st->buf;
memset(buf, 0, 16);
ret = vp702x_usb_in_op(adap->dev, 0xe0, (state << 8) | 0x0f, ret = vp702x_usb_in_op(adap->dev, 0xe0, (state << 8) | 0x0f,
0, buf, 16); 0, buf, 16);
kfree(buf);
mutex_unlock(&st->buf_mutex);
return ret; return ret;
} }
static int vp702x_set_pid(struct dvb_usb_adapter *adap, u16 pid, u8 id, int onoff) static int vp702x_set_pid(struct dvb_usb_adapter *adap, u16 pid, u8 id, int onoff)
{ {
struct vp702x_adapter_state *st = adap->priv; struct vp702x_adapter_state *st = adap->priv;
struct vp702x_device_state *dst = adap->dev->priv;
u8 *buf; u8 *buf;
buf = kzalloc(16, GFP_KERNEL);
if (!buf)
return -ENOMEM;
if (onoff) if (onoff)
st->pid_filter_state |= (1 << id); st->pid_filter_state |= (1 << id);
else { else {
...@@ -182,10 +188,16 @@ static int vp702x_set_pid(struct dvb_usb_adapter *adap, u16 pid, u8 id, int onof ...@@ -182,10 +188,16 @@ static int vp702x_set_pid(struct dvb_usb_adapter *adap, u16 pid, u8 id, int onof
id = 0x10 + id*2; id = 0x10 + id*2;
vp702x_set_pld_state(adap, st->pid_filter_state); vp702x_set_pld_state(adap, st->pid_filter_state);
mutex_lock(&dst->buf_mutex);
buf = dst->buf;
memset(buf, 0, 16);
vp702x_usb_in_op(adap->dev, 0xe0, (((pid >> 8) & 0xff) << 8) | (id), 0, buf, 16); vp702x_usb_in_op(adap->dev, 0xe0, (((pid >> 8) & 0xff) << 8) | (id), 0, buf, 16);
vp702x_usb_in_op(adap->dev, 0xe0, (((pid ) & 0xff) << 8) | (id+1), 0, buf, 16); vp702x_usb_in_op(adap->dev, 0xe0, (((pid ) & 0xff) << 8) | (id+1), 0, buf, 16);
kfree(buf); mutex_unlock(&dst->buf_mutex);
return 0; return 0;
} }
...@@ -193,13 +205,10 @@ static int vp702x_set_pid(struct dvb_usb_adapter *adap, u16 pid, u8 id, int onof ...@@ -193,13 +205,10 @@ static int vp702x_set_pid(struct dvb_usb_adapter *adap, u16 pid, u8 id, int onof
static int vp702x_init_pid_filter(struct dvb_usb_adapter *adap) static int vp702x_init_pid_filter(struct dvb_usb_adapter *adap)
{ {
struct vp702x_adapter_state *st = adap->priv; struct vp702x_adapter_state *st = adap->priv;
struct vp702x_device_state *dst = adap->dev->priv;
int i; int i;
u8 *b; u8 *b;
b = kzalloc(10, GFP_KERNEL);
if (!b)
return -ENOMEM;
st->pid_filter_count = 8; st->pid_filter_count = 8;
st->pid_filter_can_bypass = 1; st->pid_filter_can_bypass = 1;
st->pid_filter_state = 0x00; st->pid_filter_state = 0x00;
...@@ -209,12 +218,15 @@ static int vp702x_init_pid_filter(struct dvb_usb_adapter *adap) ...@@ -209,12 +218,15 @@ static int vp702x_init_pid_filter(struct dvb_usb_adapter *adap)
for (i = 0; i < st->pid_filter_count; i++) for (i = 0; i < st->pid_filter_count; i++)
vp702x_set_pid(adap, 0xffff, i, 1); vp702x_set_pid(adap, 0xffff, i, 1);
mutex_lock(&dst->buf_mutex);
b = dst->buf;
memset(b, 0, 10);
vp702x_usb_in_op(adap->dev, 0xb5, 3, 0, b, 10); vp702x_usb_in_op(adap->dev, 0xb5, 3, 0, b, 10);
vp702x_usb_in_op(adap->dev, 0xb5, 0, 0, b, 10); vp702x_usb_in_op(adap->dev, 0xb5, 0, 0, b, 10);
vp702x_usb_in_op(adap->dev, 0xb5, 1, 0, b, 10); vp702x_usb_in_op(adap->dev, 0xb5, 1, 0, b, 10);
mutex_unlock(&dst->buf_mutex);
/*vp702x_set_pld_mode(d, 0); // filter */
//vp702x_set_pld_mode(d, 0); // filter
kfree(b);
return 0; return 0;
} }
...@@ -266,16 +278,15 @@ static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) ...@@ -266,16 +278,15 @@ static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6])
{ {
u8 i, *buf; u8 i, *buf;
struct vp702x_device_state *st = d->priv;
buf = kmalloc(6, GFP_KERNEL); mutex_lock(&st->buf_mutex);
if (!buf) buf = st->buf;
return -ENOMEM;
for (i = 6; i < 12; i++) for (i = 6; i < 12; i++)
vp702x_usb_in_op(d, READ_EEPROM_REQ, i, 1, &buf[i - 6], 1); vp702x_usb_in_op(d, READ_EEPROM_REQ, i, 1, &buf[i - 6], 1);
memcpy(mac, buf, 6); memcpy(mac, buf, 6);
kfree(buf); mutex_unlock(&st->buf_mutex);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment