/* * Shared helper functions for devices from the ADAU family * * Copyright 2011-2016 Analog Devices Inc. * Author: Lars-Peter Clausen * * Licensed under the GPL-2 or later. */ #include #include #include #include "adau-utils.h" int adau_calc_pll_cfg(unsigned int freq_in, unsigned int freq_out, uint8_t regs[5]) { unsigned int r, n, m, i, j; unsigned int div; if (!freq_out) { r = 0; n = 0; m = 0; div = 0; } else { if (freq_out % freq_in != 0) { div = DIV_ROUND_UP(freq_in, 13500000); freq_in /= div; r = freq_out / freq_in; i = freq_out % freq_in; j = gcd(i, freq_in); n = i / j; m = freq_in / j; div--; } else { r = freq_out / freq_in; n = 0; m = 0; div = 0; } if (n > 0xffff || m > 0xffff || div > 3 || r > 8 || r < 2) return -EINVAL; } regs[0] = m >> 8; regs[1] = m & 0xff; regs[2] = n >> 8; regs[3] = n & 0xff; regs[4] = (r << 3) | (div << 1); if (m != 0) regs[4] |= 1; /* Fractional mode */ return 0; } EXPORT_SYMBOL_GPL(adau_calc_pll_cfg); MODULE_DESCRIPTION("ASoC ADAU audio CODECs shared helper functions"); MODULE_AUTHOR("Lars-Peter Clausen "); MODULE_LICENSE("GPL v2"); '>packet-loop-back net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent <vincent.stehle@laposte.net>2017-01-30 15:06:43 +0100
committerDavid S. Miller <davem@davemloft.net>2017-01-31 13:07:40 -0500
commitc73e44269369e936165f0f9b61f1f09a11dae01c (patch)
treee2188e900ba06302f8ed2746cb07edd3efbc5c35 /include/rxrpc/packet.h
parent040587af31228d82c52267f717c9fcdb65f36335 (diff)
net: thunderx: avoid dereferencing xcv when NULL
This fixes the following smatch and coccinelle warnings: drivers/net/ethernet/cavium/thunder/thunder_xcv.c:119 xcv_setup_link() error: we previously assumed 'xcv' could be null (see line 118) [smatch] drivers/net/ethernet/cavium/thunder/thunder_xcv.c:119:16-20: ERROR: xcv is NULL but dereferenced. [coccinelle] Fixes: 6465859aba1e66a5 ("net: thunderx: Add RGMII interface type support") Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net> Cc: Sunil Goutham <sgoutham@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/rxrpc/packet.h')