mirror of
https://github.com/torvalds/linux
synced 2024-09-06 18:01:05 +00:00
powerpc/fsl_soc: improve and simplify get_brgfreq
Use of_property_read_u32 instead of the generic of_get_property to simplify the code. In addition move the declaration of brgfreq into get_brgfreq because it's private to this function. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> [scottwood: minor whitespace fixes] Signed-off-by: Scott Wood <oss@buserror.net>
This commit is contained in:
parent
5bda6c0eb7
commit
47a48a9210
|
@ -100,23 +100,17 @@ EXPORT_SYMBOL(fsl_get_sys_freq);
|
||||||
|
|
||||||
#if defined(CONFIG_CPM2) || defined(CONFIG_QUICC_ENGINE) || defined(CONFIG_8xx)
|
#if defined(CONFIG_CPM2) || defined(CONFIG_QUICC_ENGINE) || defined(CONFIG_8xx)
|
||||||
|
|
||||||
static u32 brgfreq = -1;
|
|
||||||
|
|
||||||
u32 get_brgfreq(void)
|
u32 get_brgfreq(void)
|
||||||
{
|
{
|
||||||
|
static u32 brgfreq = -1;
|
||||||
struct device_node *node;
|
struct device_node *node;
|
||||||
const unsigned int *prop;
|
|
||||||
int size;
|
|
||||||
|
|
||||||
if (brgfreq != -1)
|
if (brgfreq != -1)
|
||||||
return brgfreq;
|
return brgfreq;
|
||||||
|
|
||||||
node = of_find_compatible_node(NULL, NULL, "fsl,cpm-brg");
|
node = of_find_compatible_node(NULL, NULL, "fsl,cpm-brg");
|
||||||
if (node) {
|
if (node) {
|
||||||
prop = of_get_property(node, "clock-frequency", &size);
|
of_property_read_u32(node, "clock-frequency", &brgfreq);
|
||||||
if (prop && size == 4)
|
|
||||||
brgfreq = *prop;
|
|
||||||
|
|
||||||
of_node_put(node);
|
of_node_put(node);
|
||||||
return brgfreq;
|
return brgfreq;
|
||||||
}
|
}
|
||||||
|
@ -129,15 +123,11 @@ u32 get_brgfreq(void)
|
||||||
node = of_find_node_by_type(NULL, "qe");
|
node = of_find_node_by_type(NULL, "qe");
|
||||||
|
|
||||||
if (node) {
|
if (node) {
|
||||||
prop = of_get_property(node, "brg-frequency", &size);
|
of_property_read_u32(node, "brg-frequency", &brgfreq);
|
||||||
if (prop && size == 4)
|
if (brgfreq == -1 || !brgfreq)
|
||||||
brgfreq = *prop;
|
if (!of_property_read_u32(node, "bus-frequency",
|
||||||
|
&brgfreq))
|
||||||
if (brgfreq == -1 || brgfreq == 0) {
|
brgfreq /= 2;
|
||||||
prop = of_get_property(node, "bus-frequency", &size);
|
|
||||||
if (prop && size == 4)
|
|
||||||
brgfreq = *prop / 2;
|
|
||||||
}
|
|
||||||
of_node_put(node);
|
of_node_put(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue