cxd2880_common.c (493B)
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * cxd2880_common.c 4 * Sony CXD2880 DVB-T2/T tuner + demodulator driver 5 * common functions 6 * 7 * Copyright (C) 2016, 2017, 2018 Sony Semiconductor Solutions Corporation 8 */ 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 else 20 return (int)(GENMASK(bitlen - 1, 0) & value); 21}