diff options
author | Aishwarya R <aishwaryarj100@gmail.com> | 2020-04-08 13:03:53 +0300 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2020-04-26 11:31:27 +0300 |
commit | 6b98bf01d2af40141cc7d831a1d2064f6f25e45e (patch) | |
tree | ac3051fe475b253365c2d245f054594494eb54f8 /drivers/i2c/busses/i2c-powermac.c | |
parent | 1b9e68533299253f5c7d87ccc4cd39ed0dccb37d (diff) | |
download | linux-6b98bf01d2af40141cc7d831a1d2064f6f25e45e.tar.xz |
i2c: powermac: Simplify reading the "reg" and "i2c-address" property
Use of_property_read_u32 to read the "reg" and "i2c-address" property
instead of using of_get_property to check the return values.
Signed-off-by: Aishwarya R <aishwaryarj100@gmail.com>
Tested-by: Erhard Furtner <erhard_f@mailbox.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/busses/i2c-powermac.c')
-rw-r--r-- | drivers/i2c/busses/i2c-powermac.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c index d565714c1f13..81506c2dab65 100644 --- a/drivers/i2c/busses/i2c-powermac.c +++ b/drivers/i2c/busses/i2c-powermac.c @@ -207,18 +207,18 @@ static u32 i2c_powermac_get_addr(struct i2c_adapter *adap, struct pmac_i2c_bus *bus, struct device_node *node) { - const __be32 *prop; - int len; + u32 prop; + int ret; /* First check for valid "reg" */ - prop = of_get_property(node, "reg", &len); - if (prop && (len >= sizeof(int))) - return (be32_to_cpup(prop) & 0xff) >> 1; + ret = of_property_read_u32(node, "reg", &prop); + if (ret == 0) + return (prop & 0xff) >> 1; /* Then check old-style "i2c-address" */ - prop = of_get_property(node, "i2c-address", &len); - if (prop && (len >= sizeof(int))) - return (be32_to_cpup(prop) & 0xff) >> 1; + ret = of_property_read_u32(node, "i2c-address", &prop); + if (ret == 0) + return (prop & 0xff) >> 1; /* Now handle some devices with missing "reg" properties */ if (of_node_name_eq(node, "cereal")) |