static int vp702x_fe_refresh_state(struct vp702x_fe_state *st)
{
+ struct vp702x_device_state *dst = st->d->priv;
u8 *buf;
if (time_after(jiffies, st->next_status_check)) {
- buf = kmalloc(10, GFP_KERNEL);
- if (!buf) {
- deb_fe("%s: buffer alloc failed\n", __func__);
- return -ENOMEM;
- }
+ mutex_lock(&dst->buf_mutex);
+ buf = dst->buf;
+
vp702x_usb_in_op(st->d, READ_STATUS, 0, 0, buf, 10);
st->lock = buf[4];
vp702x_usb_in_op(st->d, READ_TUNER_REG_REQ, 0x15, 0, buf, 1);
st->sig = buf[0];
-
+ mutex_unlock(&dst->buf_mutex);
st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000;
- kfree(buf);
}
return 0;
}
struct dvb_frontend_parameters *fep)
{
struct vp702x_fe_state *st = fe->demodulator_priv;
+ struct vp702x_device_state *dst = st->d->priv;
u32 freq = fep->frequency/1000;
/*CalFrequency*/
/* u16 frequencyRef[16] = { 2, 4, 8, 16, 32, 64, 128, 256, 24, 5, 10, 20, 40, 80, 160, 320 }; */
u64 sr;
u8 *cmd;
- cmd = kzalloc(10, GFP_KERNEL);
- if (!cmd)
- return -ENOMEM;
+ mutex_lock(&dst->buf_mutex);
+
+ cmd = dst->buf;
+ memset(cmd, 0, 10);
cmd[0] = (freq >> 8) & 0x7f;
cmd[1] = freq & 0xff;
else
deb_fe("tuning succeeded.\n");
- kfree(cmd);
+ mutex_unlock(&dst->buf_mutex);
+
return 0;
}
static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe,
struct dvb_diseqc_master_cmd *m)
{
- int ret;
u8 *cmd;
struct vp702x_fe_state *st = fe->demodulator_priv;
-
- cmd = kzalloc(10, GFP_KERNEL);
- if (!cmd)
- return -ENOMEM;
+ struct vp702x_device_state *dst = st->d->priv;
deb_fe("%s\n",__func__);
- if (m->msg_len > 4) {
- ret = -EINVAL;
- goto out;
- }
+ if (m->msg_len > 4)
+ return -EINVAL;
+
+ mutex_lock(&dst->buf_mutex);
+ cmd = dst->buf;
cmd[1] = SET_DISEQC_CMD;
cmd[2] = m->msg_len;
memcpy(&cmd[3], m->msg, m->msg_len);
deb_fe("diseqc cmd failed.\n");
else
deb_fe("diseqc cmd succeeded.\n");
- ret = 0;
-out:
- kfree(cmd);
- return ret;
+
+ mutex_unlock(&dst->buf_mutex);
+
+ return 0;
}
static int vp702x_fe_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst)
static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
{
struct vp702x_fe_state *st = fe->demodulator_priv;
+ struct vp702x_device_state *dst = st->d->priv;
u8 *buf;
deb_fe("%s\n",__func__);
- buf = kmalloc(10, GFP_KERNEL);
- if (!buf)
- return -ENOMEM;
-
st->tone_mode = tone;
if (tone == SEC_TONE_ON)
st->lnb_buf[2] = 0x00;
st->lnb_buf[7] = vp702x_chksum(st->lnb_buf, 0, 7);
+
+ mutex_lock(&dst->buf_mutex);
+
+ buf = dst->buf;
memcpy(buf, st->lnb_buf, 8);
vp702x_usb_inout_op(st->d, buf, 8, buf, 10, 100);
else
deb_fe("set_tone cmd succeeded.\n");
- kfree(buf);
+ mutex_unlock(&dst->buf_mutex);
+
return 0;
}
voltage)
{
struct vp702x_fe_state *st = fe->demodulator_priv;
+ struct vp702x_device_state *dst = st->d->priv;
u8 *buf;
deb_fe("%s\n",__func__);
- buf = kmalloc(10, GFP_KERNEL);
- if (!buf)
- return -ENOMEM;
-
st->voltage = voltage;
if (voltage != SEC_VOLTAGE_OFF)
st->lnb_buf[4] = 0x00;
st->lnb_buf[7] = vp702x_chksum(st->lnb_buf, 0, 7);
+
+ mutex_lock(&dst->buf_mutex);
+
+ buf = dst->buf;
memcpy(buf, st->lnb_buf, 8);
vp702x_usb_inout_op(st->d, buf, 8, buf, 10, 100);
else
deb_fe("set_voltage cmd succeeded.\n");
- kfree(buf);
+ mutex_unlock(&dst->buf_mutex);
return 0;
}