Commit 90135c96 authored by Mike Isely's avatar Mike Isely Committed by Mauro Carvalho Chehab

V4L/DVB (12122): pvrusb2: De-obfuscate code which handles routing schemes

This change does not change any outward behavior; it merely chops down
some large if-conditions with embedded assignments into something a
little more maintainable for others (I of course never had a problem
with this...).
Signed-off-by: default avatarMike Isely <isely@pobox.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 81e804c9
...@@ -67,12 +67,11 @@ void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) ...@@ -67,12 +67,11 @@ void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
u32 input; u32 input;
pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)", pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
hdw->input_val); hdw->input_val);
if ((sid < ARRAY_SIZE(routing_schemes)) && sp = (sid < ARRAY_SIZE(routing_schemes)) ?
((sp = routing_schemes[sid]) != NULL) && routing_schemes[sid] : NULL;
(hdw->input_val >= 0) && if ((sp == NULL) ||
(hdw->input_val < sp->cnt)) { (hdw->input_val < 0) ||
input = sp->def[hdw->input_val]; (hdw->input_val >= sp->cnt)) {
} else {
pvr2_trace(PVR2_TRACE_ERROR_LEGS, pvr2_trace(PVR2_TRACE_ERROR_LEGS,
"*** WARNING *** subdev v4l2 set_input:" "*** WARNING *** subdev v4l2 set_input:"
" Invalid routing scheme (%u)" " Invalid routing scheme (%u)"
...@@ -80,6 +79,7 @@ void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) ...@@ -80,6 +79,7 @@ void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
sid, hdw->input_val); sid, hdw->input_val);
return; return;
} }
input = sp->def[hdw->input_val];
sd->ops->audio->s_routing(sd, input, 0, 0); sd->ops->audio->s_routing(sd, input, 0, 0);
} }
} }
......
...@@ -114,13 +114,11 @@ void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) ...@@ -114,13 +114,11 @@ void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
const struct routing_scheme *sp; const struct routing_scheme *sp;
unsigned int sid = hdw->hdw_desc->signal_routing_scheme; unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
if ((sid < ARRAY_SIZE(routing_schemes)) && sp = (sid < ARRAY_SIZE(routing_schemes)) ?
((sp = routing_schemes[sid]) != NULL) && routing_schemes[sid] : NULL;
(hdw->input_val >= 0) && if ((sp == NULL) ||
(hdw->input_val < sp->cnt)) { (hdw->input_val < 0) ||
vid_input = sp->def[hdw->input_val].vid; (hdw->input_val >= sp->cnt)) {
aud_input = sp->def[hdw->input_val].aud;
} else {
pvr2_trace(PVR2_TRACE_ERROR_LEGS, pvr2_trace(PVR2_TRACE_ERROR_LEGS,
"*** WARNING *** subdev cx2584x set_input:" "*** WARNING *** subdev cx2584x set_input:"
" Invalid routing scheme (%u)" " Invalid routing scheme (%u)"
...@@ -128,7 +126,8 @@ void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) ...@@ -128,7 +126,8 @@ void pvr2_cx25840_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
sid, hdw->input_val); sid, hdw->input_val);
return; return;
} }
vid_input = sp->def[hdw->input_val].vid;
aud_input = sp->def[hdw->input_val].aud;
pvr2_trace(PVR2_TRACE_CHIPS, pvr2_trace(PVR2_TRACE_CHIPS,
"subdev cx2584x set_input vid=0x%x aud=0x%x", "subdev cx2584x set_input vid=0x%x aud=0x%x",
vid_input, aud_input); vid_input, aud_input);
......
...@@ -85,12 +85,12 @@ void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) ...@@ -85,12 +85,12 @@ void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)", pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
hdw->input_val); hdw->input_val);
if ((sid < ARRAY_SIZE(routing_schemes)) &&
((sp = routing_schemes[sid]) != NULL) && sp = (sid < ARRAY_SIZE(routing_schemes)) ?
(hdw->input_val >= 0) && routing_schemes[sid] : NULL;
(hdw->input_val < sp->cnt)) { if ((sp == NULL) ||
input = sp->def[hdw->input_val]; (hdw->input_val < 0) ||
} else { (hdw->input_val >= sp->cnt)) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS, pvr2_trace(PVR2_TRACE_ERROR_LEGS,
"*** WARNING *** subdev v4l2 set_input:" "*** WARNING *** subdev v4l2 set_input:"
" Invalid routing scheme (%u)" " Invalid routing scheme (%u)"
...@@ -98,6 +98,7 @@ void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd) ...@@ -98,6 +98,7 @@ void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
sid, hdw->input_val); sid, hdw->input_val);
return; return;
} }
input = sp->def[hdw->input_val];
sd->ops->video->s_routing(sd, input, 0, 0); sd->ops->video->s_routing(sd, input, 0, 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