media: dvb_frontend: cleanup dvb_frontend_ioctl_properties()
Use a switch() on this function, just like on other ioctl handlers and handle parameters inside each part of the switch. That makes it easier to integrate with the already existing ioctl handler function. Reviewed-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
@@ -1954,21 +1954,25 @@ static int dvb_frontend_ioctl_properties(struct file *file,
|
|||||||
struct dvb_frontend *fe = dvbdev->priv;
|
struct dvb_frontend *fe = dvbdev->priv;
|
||||||
struct dvb_frontend_private *fepriv = fe->frontend_priv;
|
struct dvb_frontend_private *fepriv = fe->frontend_priv;
|
||||||
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
|
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
|
||||||
int err = 0;
|
int err, i;
|
||||||
|
|
||||||
struct dtv_properties *tvps = parg;
|
|
||||||
struct dtv_property *tvp = NULL;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
dev_dbg(fe->dvb->device, "%s:\n", __func__);
|
dev_dbg(fe->dvb->device, "%s:\n", __func__);
|
||||||
|
|
||||||
if (cmd == FE_SET_PROPERTY) {
|
switch(cmd) {
|
||||||
dev_dbg(fe->dvb->device, "%s: properties.num = %d\n", __func__, tvps->num);
|
case FE_SET_PROPERTY: {
|
||||||
dev_dbg(fe->dvb->device, "%s: properties.props = %p\n", __func__, tvps->props);
|
struct dtv_properties *tvps = parg;
|
||||||
|
struct dtv_property *tvp = NULL;
|
||||||
|
|
||||||
/* Put an arbitrary limit on the number of messages that can
|
dev_dbg(fe->dvb->device, "%s: properties.num = %d\n",
|
||||||
* be sent at once */
|
__func__, tvps->num);
|
||||||
if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS))
|
dev_dbg(fe->dvb->device, "%s: properties.props = %p\n",
|
||||||
|
__func__, tvps->props);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Put an arbitrary limit on the number of messages that can
|
||||||
|
* be sent at once
|
||||||
|
*/
|
||||||
|
if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
|
tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
|
||||||
@@ -1977,23 +1981,34 @@ static int dvb_frontend_ioctl_properties(struct file *file,
|
|||||||
|
|
||||||
for (i = 0; i < tvps->num; i++) {
|
for (i = 0; i < tvps->num; i++) {
|
||||||
err = dtv_property_process_set(fe, tvp + i, file);
|
err = dtv_property_process_set(fe, tvp + i, file);
|
||||||
if (err < 0)
|
if (err < 0) {
|
||||||
goto out;
|
kfree(tvp);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
(tvp + i)->result = err;
|
(tvp + i)->result = err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->state == DTV_TUNE)
|
if (c->state == DTV_TUNE)
|
||||||
dev_dbg(fe->dvb->device, "%s: Property cache is full, tuning\n", __func__);
|
dev_dbg(fe->dvb->device, "%s: Property cache is full, tuning\n", __func__);
|
||||||
|
|
||||||
} else if (cmd == FE_GET_PROPERTY) {
|
kfree(tvp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FE_GET_PROPERTY: {
|
||||||
|
struct dtv_properties *tvps = parg;
|
||||||
|
struct dtv_property *tvp = NULL;
|
||||||
struct dtv_frontend_properties getp = fe->dtv_property_cache;
|
struct dtv_frontend_properties getp = fe->dtv_property_cache;
|
||||||
|
|
||||||
dev_dbg(fe->dvb->device, "%s: properties.num = %d\n", __func__, tvps->num);
|
dev_dbg(fe->dvb->device, "%s: properties.num = %d\n",
|
||||||
dev_dbg(fe->dvb->device, "%s: properties.props = %p\n", __func__, tvps->props);
|
__func__, tvps->num);
|
||||||
|
dev_dbg(fe->dvb->device, "%s: properties.props = %p\n",
|
||||||
|
__func__, tvps->props);
|
||||||
|
|
||||||
/* Put an arbitrary limit on the number of messages that can
|
/*
|
||||||
* be sent at once */
|
* Put an arbitrary limit on the number of messages that can
|
||||||
if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS))
|
* be sent at once
|
||||||
|
*/
|
||||||
|
if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
|
tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp));
|
||||||
@@ -2008,28 +2023,32 @@ static int dvb_frontend_ioctl_properties(struct file *file,
|
|||||||
*/
|
*/
|
||||||
if (fepriv->state != FESTATE_IDLE) {
|
if (fepriv->state != FESTATE_IDLE) {
|
||||||
err = dtv_get_frontend(fe, &getp, NULL);
|
err = dtv_get_frontend(fe, &getp, NULL);
|
||||||
if (err < 0)
|
if (err < 0) {
|
||||||
goto out;
|
kfree(tvp);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < tvps->num; i++) {
|
for (i = 0; i < tvps->num; i++) {
|
||||||
err = dtv_property_process_get(fe, &getp, tvp + i, file);
|
err = dtv_property_process_get(fe, &getp, tvp + i, file);
|
||||||
if (err < 0)
|
if (err < 0) {
|
||||||
goto out;
|
kfree(tvp);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
(tvp + i)->result = err;
|
(tvp + i)->result = err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy_to_user((void __user *)tvps->props, tvp,
|
if (copy_to_user((void __user *)tvps->props, tvp,
|
||||||
tvps->num * sizeof(struct dtv_property))) {
|
tvps->num * sizeof(struct dtv_property))) {
|
||||||
err = -EFAULT;
|
kfree(tvp);
|
||||||
goto out;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
kfree(tvp);
|
||||||
} else
|
break;
|
||||||
err = -EOPNOTSUPP;
|
}
|
||||||
|
default:
|
||||||
out:
|
return -ENOTSUPP;
|
||||||
kfree(tvp);
|
} /* switch */
|
||||||
return err;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dtv_set_frontend(struct dvb_frontend *fe)
|
static int dtv_set_frontend(struct dvb_frontend *fe)
|
||||||
|
Reference in New Issue
Block a user