brintos

brintos / linux-shallow public Read only

0
0
Text · 1.3 KiB · 5302ab0 Raw
73 lines · c
1// SPDX-License-Identifier: GPL-2.02/*3 * cxd2880_integ.c4 * Sony CXD2880 DVB-T2/T tuner + demodulator driver5 * integration layer common functions6 *7 * Copyright (C) 2016, 2017, 2018 Sony Semiconductor Solutions Corporation8 */9 10#include <linux/ktime.h>11#include <linux/errno.h>12 13#include "cxd2880_tnrdmd.h"14#include "cxd2880_tnrdmd_mon.h"15#include "cxd2880_integ.h"16 17int cxd2880_integ_init(struct cxd2880_tnrdmd *tnr_dmd)18{19	int ret;20	ktime_t start;21	u8 cpu_task_completed = 0;22 23	if (!tnr_dmd)24		return -EINVAL;25 26	ret = cxd2880_tnrdmd_init1(tnr_dmd);27	if (ret)28		return ret;29 30	start = ktime_get();31 32	while (1) {33		ret =34		    cxd2880_tnrdmd_check_internal_cpu_status(tnr_dmd,35						     &cpu_task_completed);36		if (ret)37			return ret;38 39		if (cpu_task_completed)40			break;41 42		if (ktime_to_ms(ktime_sub(ktime_get(), start)) >43					CXD2880_TNRDMD_WAIT_INIT_TIMEOUT)44			return -ETIMEDOUT;45 46		usleep_range(CXD2880_TNRDMD_WAIT_INIT_INTVL,47			     CXD2880_TNRDMD_WAIT_INIT_INTVL + 1000);48	}49 50	return cxd2880_tnrdmd_init2(tnr_dmd);51}52 53int cxd2880_integ_cancel(struct cxd2880_tnrdmd *tnr_dmd)54{55	if (!tnr_dmd)56		return -EINVAL;57 58	atomic_set(&tnr_dmd->cancel, 1);59 60	return 0;61}62 63int cxd2880_integ_check_cancellation(struct cxd2880_tnrdmd *tnr_dmd)64{65	if (!tnr_dmd)66		return -EINVAL;67 68	if (atomic_read(&tnr_dmd->cancel) != 0)69		return -ECANCELED;70 71	return 0;72}73