cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

cxd2880_integ.c (1353B)


      1// SPDX-License-Identifier: GPL-2.0
      2/*
      3 * cxd2880_integ.c
      4 * Sony CXD2880 DVB-T2/T tuner + demodulator driver
      5 * integration layer common functions
      6 *
      7 * Copyright (C) 2016, 2017, 2018 Sony Semiconductor Solutions Corporation
      8 */
      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}