Skip to contentSkip to conversation

staging: atomisp: simplify if statement in atomisp_get_sensor_fps()

PATCH New Daeseok Youn 1 participant 1 message Mar 21, 2017

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH v2 2/4 staging: atomisp: simplify if statement in atomisp_get_sensor_fps()

If v4l2_subdev_call() gets the global frame interval values, it returned 0 and it could be checked whether numerator is zero or not.

If the numerator is not zero, the fps could be calculated in this function. If not, it just returns 0.

---
V2: split error handling, the first check is for the result from v4l2_subdev_call(),
another check is for fi.interval.numerator > 0. it is more understandable and simpler than before.

 .../media/atomisp/pci/atomisp2/atomisp_cmd.c       | 24 ++++++++++------------
 1 file changed, 11 insertions(+), 13 deletions(-)
drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c +11 -13
index 8bdb224..811331d 100644
@@ -153,21 +153,19 @@ struct atomisp_acc_pipe *atomisp_to_acc_pipe(struct video_device *dev)
 
 static unsigned short atomisp_get_sensor_fps(struct atomisp_sub_device *asd)
 {
-	struct v4l2_subdev_frame_interval frame_interval;
+	struct v4l2_subdev_frame_interval fi;
 	struct atomisp_device *isp = asd->isp;
-	unsigned short fps;
 
-	if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-	    video, g_frame_interval, &frame_interval)) {
-		fps = 0;
-	} else {
-		if (frame_interval.interval.numerator)
-			fps = frame_interval.interval.denominator /
-			    frame_interval.interval.numerator;
-		else
-			fps = 0;
-	}
-	return fps;
+	int ret;
+
+	ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
+			       video, g_frame_interval, &fi);
+
+	if (ret)
+		return 0;
+
+	return (fi.interval.numerator > 0) ?
+	       (fi.interval.denominator / fi.interval.numerator) : 0;
 }
 
 /*
Signature · 1 line
1.9.1