Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5bda6c0e authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Scott Wood
Browse files

powerpc/fsl_soc: improve and simplify fsl_get_sys_freq



Use of_property_read_u32 instead of the generic of_get_property to
simplify the code. In addition move the declaration of sysfreq
into fsl_get_sys_freq because it's private to this function.

Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarScott Wood <oss@buserror.net>
parent 00b6cfc4
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -77,13 +77,10 @@ phys_addr_t get_immrbase(void)

EXPORT_SYMBOL(get_immrbase);

static u32 sysfreq = -1;

u32 fsl_get_sys_freq(void)
{
	static u32 sysfreq = -1;
	struct device_node *soc;
	const u32 *prop;
	int size;

	if (sysfreq != -1)
		return sysfreq;
@@ -92,12 +89,9 @@ u32 fsl_get_sys_freq(void)
	if (!soc)
		return -1;

	prop = of_get_property(soc, "clock-frequency", &size);
	if (!prop || size != sizeof(*prop) || *prop == 0)
		prop = of_get_property(soc, "bus-frequency", &size);

	if (prop && size == sizeof(*prop))
		sysfreq = *prop;
	of_property_read_u32(soc, "clock-frequency", &sysfreq);
	if (sysfreq == -1 || !sysfreq)
		of_property_read_u32(soc, "bus-frequency", &sysfreq);

	of_node_put(soc);
	return sysfreq;