Commit 123ee6e9 authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Li Yang

soc: fsl: qe: qe.c: use of_property_read_* helpers

Instead of manually doing of_get_property/of_find_property and reading
the value by assigning to a u32* or u64* and dereferencing, use the
of_property_read_* functions.

This make the code more readable, and more importantly, is required
for this to work correctly on little-endian platforms.
Reviewed-by: default avatarTimur Tabi <timur@kernel.org>
Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: default avatarLi Yang <leoyang.li@nxp.com>
parent 9dab15b1
...@@ -159,8 +159,7 @@ static unsigned int brg_clk = 0; ...@@ -159,8 +159,7 @@ static unsigned int brg_clk = 0;
unsigned int qe_get_brg_clk(void) unsigned int qe_get_brg_clk(void)
{ {
struct device_node *qe; struct device_node *qe;
int size; u32 brg;
const u32 *prop;
unsigned int mod; unsigned int mod;
if (brg_clk) if (brg_clk)
...@@ -170,9 +169,8 @@ unsigned int qe_get_brg_clk(void) ...@@ -170,9 +169,8 @@ unsigned int qe_get_brg_clk(void)
if (!qe) if (!qe)
return brg_clk; return brg_clk;
prop = of_get_property(qe, "brg-frequency", &size); if (!of_property_read_u32(qe, "brg-frequency", &brg))
if (prop && size == sizeof(*prop)) brg_clk = brg;
brg_clk = *prop;
of_node_put(qe); of_node_put(qe);
...@@ -571,11 +569,9 @@ EXPORT_SYMBOL(qe_upload_firmware); ...@@ -571,11 +569,9 @@ EXPORT_SYMBOL(qe_upload_firmware);
struct qe_firmware_info *qe_get_firmware_info(void) struct qe_firmware_info *qe_get_firmware_info(void)
{ {
static int initialized; static int initialized;
struct property *prop;
struct device_node *qe; struct device_node *qe;
struct device_node *fw = NULL; struct device_node *fw = NULL;
const char *sprop; const char *sprop;
unsigned int i;
/* /*
* If we haven't checked yet, and a driver hasn't uploaded a firmware * If we haven't checked yet, and a driver hasn't uploaded a firmware
...@@ -609,20 +605,11 @@ struct qe_firmware_info *qe_get_firmware_info(void) ...@@ -609,20 +605,11 @@ struct qe_firmware_info *qe_get_firmware_info(void)
strlcpy(qe_firmware_info.id, sprop, strlcpy(qe_firmware_info.id, sprop,
sizeof(qe_firmware_info.id)); sizeof(qe_firmware_info.id));
prop = of_find_property(fw, "extended-modes", NULL); of_property_read_u64(fw, "extended-modes",
if (prop && (prop->length == sizeof(u64))) { &qe_firmware_info.extended_modes);
const u64 *iprop = prop->value;
qe_firmware_info.extended_modes = *iprop;
}
prop = of_find_property(fw, "virtual-traps", NULL); of_property_read_u32_array(fw, "virtual-traps", qe_firmware_info.vtraps,
if (prop && (prop->length == 32)) { ARRAY_SIZE(qe_firmware_info.vtraps));
const u32 *iprop = prop->value;
for (i = 0; i < ARRAY_SIZE(qe_firmware_info.vtraps); i++)
qe_firmware_info.vtraps[i] = iprop[i];
}
of_node_put(fw); of_node_put(fw);
...@@ -633,17 +620,13 @@ EXPORT_SYMBOL(qe_get_firmware_info); ...@@ -633,17 +620,13 @@ EXPORT_SYMBOL(qe_get_firmware_info);
unsigned int qe_get_num_of_risc(void) unsigned int qe_get_num_of_risc(void)
{ {
struct device_node *qe; struct device_node *qe;
int size;
unsigned int num_of_risc = 0; unsigned int num_of_risc = 0;
const u32 *prop;
qe = qe_get_device_node(); qe = qe_get_device_node();
if (!qe) if (!qe)
return num_of_risc; return num_of_risc;
prop = of_get_property(qe, "fsl,qe-num-riscs", &size); of_property_read_u32(qe, "fsl,qe-num-riscs", &num_of_risc);
if (prop && size == sizeof(*prop))
num_of_risc = *prop;
of_node_put(qe); of_node_put(qe);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment