i2c: powermac: Simplify reading the "reg" and "i2c-address" property
Subsystems (2)
PATCH 1/1 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.
--- drivers/i2c/busses/i2c-powermac.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-powermac.c +8 -8
@@ -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" ))
Signature · 1 line
2.17.1
Quoted 4 lines · Aishwarya R
Use
of_property_read_u32to read the "reg" and "i2c-address" property instead of usingof_get_propertyto check the return values.Signed-off-by Aishwarya R <[email protected]>
This is quite a fragile driver. Have you tested it on HW?
PATCH 1/1 i2c: powermac: Simplify reading the "reg" and "i2c-address" property
In reply to Aishwarya RQuoted 6 lines
Quoted 4 lines
Use
of_property_read_u32to read the "reg" and "i2c-address" property instead of usingof_get_propertyto check the return values.Signed-off-by Aishwarya R <[email protected]>This is quite a fragile driver. Have you tested it on HW?
This change is not tested with the Hardware.
But of_property_read_u32 is better here than generic of_get_property. This make sure that value read properly independent of system endianess.
Quoted 10 lines · Aishwarya R
Quoted 6 lines
Quoted 4 lines
Use
of_property_read_u32to read the "reg" and "i2c-address" property instead of usingof_get_propertyto check the return values.Signed-off-by Aishwarya R <[email protected]>This is quite a fragile driver. Have you tested it on HW?
This change is not tested with the Hardware.
Butof_property_read_u32is better here than genericof_get_property. This make sure that value read properly independent of system endianess.
This driver is only used on PPC_BE. And it is *very* fragile. The gain is not enough for me to accept it without testing. Maybe Erhard (CCed) is interested. If not, you may find someone on the ppc lists.
Erhard F.
Tested-byQuoted 8 lines · On Tue, 21 Apr 2020 11:37:13 +0200 Wolfram Sang <[email protected]> wrote:
Quoted 7 lines · Aishwarya R
Quoted 6 lines
Quoted 4 lines
Use
of_property_read_u32to read the "reg" and "i2c-address" property instead of usingof_get_propertyto check the return values.Signed-off-by Aishwarya R <[email protected]>This is quite a fragile driver. Have you tested it on HW?
Quoted 8 lines
Quoted 3 lines
This change is not tested with the Hardware.
Butof_property_read_u32is better here than genericof_get_property. This make sure that value read properly independent of system endianess.This driver is only used on
PPC_BE. And it is *very* fragile. The gain is not enough for me to accept it without testing. Maybe Erhard (CCed) is interested. If not, you may find someone on the ppc lists.
I applied the patch on top of kernel 5.6.6 and tested it on a PowerMac G4 3,6 DP and a PowerMac G5 11,2. Both machines run without anything suspicious going on. dmesg | grep i2c looks the same with patch and without patch.
Wolfram Sang
AppliedQuoted 4 lines · Aishwarya R
Use
of_property_read_u32to read the "reg" and "i2c-address" property instead of usingof_get_propertyto check the return values.Signed-off-by Aishwarya R <[email protected]>
Applied to for-next, thanks!