mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-19 09:04:51 +08:00
756d36790a
Of_node_put supports NULL as its argument, so the initial test is not necessary. Suggested by Uwe Kleine-König. The semantic patch that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ expression e; @@ -if (e) of_node_put(e); // </smpl> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
34 lines
747 B
C
34 lines
747 B
C
/**
|
|
* mpc5xxx_get_bus_frequency - Find the bus frequency for a device
|
|
* @node: device node
|
|
*
|
|
* Returns bus frequency (IPS on MPC512x, IPB on MPC52xx),
|
|
* or 0 if the bus frequency cannot be found.
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/of_platform.h>
|
|
#include <linux/export.h>
|
|
#include <asm/mpc5xxx.h>
|
|
|
|
unsigned long mpc5xxx_get_bus_frequency(struct device_node *node)
|
|
{
|
|
struct device_node *np;
|
|
const unsigned int *p_bus_freq = NULL;
|
|
|
|
of_node_get(node);
|
|
while (node) {
|
|
p_bus_freq = of_get_property(node, "bus-frequency", NULL);
|
|
if (p_bus_freq)
|
|
break;
|
|
|
|
np = of_get_parent(node);
|
|
of_node_put(node);
|
|
node = np;
|
|
}
|
|
of_node_put(node);
|
|
|
|
return p_bus_freq ? *p_bus_freq : 0;
|
|
}
|
|
EXPORT_SYMBOL(mpc5xxx_get_bus_frequency);
|