summaryrefstree
path: root/kernel/drivers/vision/dsp/dl/dsp-llstack.c
blob: 9c14d0157b67552e9815bea0c33b058d02dc2cbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// SPDX-License-Identifier: GPL-2.0
/*
 * Samsung Exynos SoC series dsp driver
 *
 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
 *              http://www.samsung.com/
 */

#include "dl/dsp-llstack.h"

void dsp_llstack_init(struct dsp_llstack *st)
{
	st->top = -1;
}

int dsp_llstack_push(struct dsp_llstack *st, long long v)
{
	if (st->top >= LLSTACK_MAX - 1)
		return -1;

	st->arr[++st->top] = v;
	return 0;
}

int dsp_llstack_pop(struct dsp_llstack *st, long long *v)
{
	if (st->top == -1)
		return -1;

	*v = st->arr[st->top--];
	return 0;
}