brintos

brintos / linux-shallow public Read only

0
0
Text · 493 B · d6f5af6 Raw
22 lines · c
1// SPDX-License-Identifier: GPL-2.02/*3 * cxd2880_common.c4 * Sony CXD2880 DVB-T2/T tuner + demodulator driver5 * common functions6 *7 * Copyright (C) 2016, 2017, 2018 Sony Semiconductor Solutions Corporation8 */9 10#include "cxd2880_common.h"11 12int cxd2880_convert2s_complement(u32 value, u32 bitlen)13{14	if (!bitlen || bitlen >= 32)15		return (int)value;16 17	if (value & (u32)(1 << (bitlen - 1)))18		return (int)(GENMASK(31, bitlen) | value);19	else20		return (int)(GENMASK(bitlen - 1, 0) & value);21}22