* [PATCH] i2c: powermac: Simplify reading the "reg" and "i2c-address" property
@ 2020-04-08 10:03 Aishwarya R
2020-04-15 11:12 ` Wolfram Sang
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Aishwarya R @ 2020-04-08 10:03 UTC (permalink / raw)
Cc: aishwaryarj100, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, Wolfram Sang, Greg Kroah-Hartman,
Thomas Gleixner, Richard Fontana, linux-i2c, linuxppc-dev,
linux-kernel
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>
---
drivers/i2c/busses/i2c-powermac.c | 16 ++++++++--------
1 file 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"))
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] i2c: powermac: Simplify reading the "reg" and "i2c-address" property
2020-04-08 10:03 [PATCH] i2c: powermac: Simplify reading the "reg" and "i2c-address" property Aishwarya R
@ 2020-04-15 11:12 ` Wolfram Sang
2020-04-15 13:19 ` Aishwarya R
2020-04-26 8:32 ` Wolfram Sang
2 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2020-04-15 11:12 UTC (permalink / raw)
To: Aishwarya R
Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
Greg Kroah-Hartman, Thomas Gleixner, Richard Fontana, linux-i2c,
linuxppc-dev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 323 bytes --]
On Wed, Apr 08, 2020 at 03:33:53PM +0530, Aishwarya R wrote:
> 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>
This is quite a fragile driver. Have you tested it on HW?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] i2c: powermac: Simplify reading the "reg" and "i2c-address" property
2020-04-08 10:03 [PATCH] i2c: powermac: Simplify reading the "reg" and "i2c-address" property Aishwarya R
2020-04-15 11:12 ` Wolfram Sang
@ 2020-04-15 13:19 ` Aishwarya R
2020-04-21 9:37 ` Wolfram Sang
2020-04-26 8:32 ` Wolfram Sang
2 siblings, 1 reply; 6+ messages in thread
From: Aishwarya R @ 2020-04-15 13:19 UTC (permalink / raw)
To: wsa
Cc: aishwaryarj100, Michael Ellerman, Benjamin Herrenschmidt,
Paul Mackerras, Greg Kroah-Hartman, Kate Stewart,
Richard Fontana, Thomas Gleixner, linux-i2c, linuxppc-dev,
linux-kernel
>> 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>
> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] i2c: powermac: Simplify reading the "reg" and "i2c-address" property
2020-04-15 13:19 ` Aishwarya R
@ 2020-04-21 9:37 ` Wolfram Sang
2020-04-22 21:07 ` Erhard F.
0 siblings, 1 reply; 6+ messages in thread
From: Wolfram Sang @ 2020-04-21 9:37 UTC (permalink / raw)
To: Aishwarya R, Erhard F.
Cc: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
Greg Kroah-Hartman, Kate Stewart, Richard Fontana,
Thomas Gleixner, linux-i2c, linuxppc-dev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 750 bytes --]
On Wed, Apr 15, 2020 at 06:49:14PM +0530, Aishwarya R wrote:
> >> 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>
>
> > 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.
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.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] i2c: powermac: Simplify reading the "reg" and "i2c-address" property
2020-04-21 9:37 ` Wolfram Sang
@ 2020-04-22 21:07 ` Erhard F.
0 siblings, 0 replies; 6+ messages in thread
From: Erhard F. @ 2020-04-22 21:07 UTC (permalink / raw)
To: Wolfram Sang
Cc: Aishwarya R, Michael Ellerman, Benjamin Herrenschmidt,
Paul Mackerras, Greg Kroah-Hartman, Kate Stewart,
Richard Fontana, Thomas Gleixner, linux-i2c, linuxppc-dev,
linux-kernel
On Tue, 21 Apr 2020 11:37:13 +0200
Wolfram Sang <wsa@the-dreams.de> wrote:
> On Wed, Apr 15, 2020 at 06:49:14PM +0530, Aishwarya R wrote:
> > >> 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>
> >
> > > 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.
>
> 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.
Tested-by: Erhard Furtner <erhard_f@mailbox.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] i2c: powermac: Simplify reading the "reg" and "i2c-address" property
2020-04-08 10:03 [PATCH] i2c: powermac: Simplify reading the "reg" and "i2c-address" property Aishwarya R
2020-04-15 11:12 ` Wolfram Sang
2020-04-15 13:19 ` Aishwarya R
@ 2020-04-26 8:32 ` Wolfram Sang
2 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2020-04-26 8:32 UTC (permalink / raw)
To: Aishwarya R
Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
Greg Kroah-Hartman, Thomas Gleixner, Richard Fontana, linux-i2c,
linuxppc-dev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 294 bytes --]
On Wed, Apr 08, 2020 at 03:33:53PM +0530, Aishwarya R wrote:
> 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>
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-04-26 8:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-08 10:03 [PATCH] i2c: powermac: Simplify reading the "reg" and "i2c-address" property Aishwarya R
2020-04-15 11:12 ` Wolfram Sang
2020-04-15 13:19 ` Aishwarya R
2020-04-21 9:37 ` Wolfram Sang
2020-04-22 21:07 ` Erhard F.
2020-04-26 8:32 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).