Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 456e7b18 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Mauro Carvalho Chehab
Browse files

media: staging: atomisp: convert timestamps to ktime_t



timespec overflows in 2038 on 32-bit architectures, and the
getnstimeofday() suffers from possible time jumps, so the
timestamps here are better done using ktime_get(), which has
neither of those problems.

In case of ov2680, we don't seem to use the timestamp at
all, so I just remove it.

Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent ea90b171
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -174,7 +174,6 @@ struct ov2680_format {
		struct mutex input_lock;
	struct v4l2_ctrl_handler ctrl_handler;
		struct camera_sensor_platform_data *platform_data;
		struct timespec timestamp_t_focus_abs;
		int vt_pix_clk_freq_mhz;
		int fmt_idx;
		int run_mode;
+8 −11
Original line number Diff line number Diff line
@@ -973,7 +973,7 @@ static int ov5693_t_focus_abs(struct v4l2_subdev *sd, s32 value)
	if (ret == 0) {
		dev->number_of_steps = value - dev->focus;
		dev->focus = value;
		getnstimeofday(&(dev->timestamp_t_focus_abs));
		dev->timestamp_t_focus_abs = ktime_get();
	} else
		dev_err(&client->dev,
			"%s: i2c failed. ret %d\n", __func__, ret);
@@ -993,16 +993,13 @@ static int ov5693_q_focus_status(struct v4l2_subdev *sd, s32 *value)
{
	u32 status = 0;
	struct ov5693_device *dev = to_ov5693_sensor(sd);
	struct timespec temptime;
	const struct timespec timedelay = {
		0,
		min((u32)abs(dev->number_of_steps) * DELAY_PER_STEP_NS,
		(u32)DELAY_MAX_PER_STEP_NS),
	};
	ktime_t temptime;
	ktime_t timedelay = ns_to_ktime(min_t(u32,
			abs(dev->number_of_steps) * DELAY_PER_STEP_NS,
			DELAY_MAX_PER_STEP_NS));

	getnstimeofday(&temptime);
	temptime = timespec_sub(temptime, (dev->timestamp_t_focus_abs));
	if (timespec_compare(&temptime, &timedelay) <= 0) {
	temptime = ktime_sub(ktime_get(), (dev->timestamp_t_focus_abs));
	if (ktime_compare(temptime, timedelay) <= 0) {
		status |= ATOMISP_FOCUS_STATUS_MOVING;
		status |= ATOMISP_FOCUS_HP_IN_PROGRESS;
	} else {
+1 −1
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@ struct ov5693_device {
	struct v4l2_ctrl_handler ctrl_handler;

	struct camera_sensor_platform_data *platform_data;
	struct timespec timestamp_t_focus_abs;
	ktime_t timestamp_t_focus_abs;
	int vt_pix_clk_freq_mhz;
	int fmt_idx;
	int run_mode;