]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/media/dvb-frontends/cxd2880/cxd2880_stopwatch_port.c
2 * cxd2880_stopwatch_port.c
3 * Sony CXD2880 DVB-T2/T tuner + demodulator driver
4 * time measurement functions
6 * Copyright (C) 2016, 2017 Sony Semiconductor Solutions Corporation
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; version 2 of the License.
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
15 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, see <http://www.gnu.org/licenses/>.
27 #include "cxd2880_common.h"
29 #include <linux/ktime.h>
30 #include <linux/time.h>
31 #include <linux/timekeeping.h>
33 static u32
get_time_count(void)
39 return (u32
)((tp
.tv_sec
* 1000) + (tp
.tv_nsec
/ 1000000));
42 enum cxd2880_ret
cxd2880_stopwatch_start(struct cxd2880_stopwatch
*stopwatch
)
45 return CXD2880_RESULT_ERROR_ARG
;
47 stopwatch
->start_time
= get_time_count();
49 return CXD2880_RESULT_OK
;
52 enum cxd2880_ret
cxd2880_stopwatch_sleep(struct cxd2880_stopwatch
*stopwatch
,
56 return CXD2880_RESULT_ERROR_ARG
;
57 CXD2880_ARG_UNUSED(*stopwatch
);
60 return CXD2880_RESULT_OK
;
63 enum cxd2880_ret
cxd2880_stopwatch_elapsed(struct cxd2880_stopwatch
*stopwatch
,
66 if (!stopwatch
|| !elapsed
)
67 return CXD2880_RESULT_ERROR_ARG
;
68 *elapsed
= get_time_count() - stopwatch
->start_time
;
70 return CXD2880_RESULT_OK
;