mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH v2] w1:fix byteorder of W1_READ_ROM id under big-endian cpu
       [not found] <201708281725129358346@zte.com.cn>
@ 2017-09-05 13:39 ` Evgeniy Polyakov
  0 siblings, 0 replies; 3+ messages in thread
From: Evgeniy Polyakov @ 2017-09-05 13:39 UTC (permalink / raw)
  To: chen.lin5; +Cc: linux-kernel, jiang.biao2

Hi

28.08.2017, 12:25, "chen.lin5@zte.com.cn" <chen.lin5@zte.com.cn>:
> Hi
>
> Q:
>
> But w1_reg_num has a different layout for be/le systems, isn't it enough?
>
> A:
>
> sure, it's right only under the assumption that 'rn' is a  correct layout id.
>
> Here's my example in be system which I encounter before.
>
> buf[0] return from w1_read_8(dev) in code section2 will always be 'family:8', buf[0] store at the first byte of rn, then it will be transport to cb(dev, rn) in code section1,
>
> but it will be parsed to 'crc:8' of the struct w1_reg_num in be system, then there comes the wrong.

Sorry, I do not understand. Do you mean that there is a difference between 2 ways to read ID content in w1_read_block() ?
If it is the case, is it possible, that there is a bug in particular master implementation?

There is a fair number of be devices in the tree already, and no one yet reported that there is an endian issue.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] w1:fix byteorder of W1_READ_ROM id under big-endian cpu
  2017-07-19  8:08 Chen Lin
@ 2017-08-27  7:36 ` Evgeniy Polyakov
  0 siblings, 0 replies; 3+ messages in thread
From: Evgeniy Polyakov @ 2017-08-27  7:36 UTC (permalink / raw)
  To: Chen Lin, linux-kernel; +Cc: jiang.biao2

Hi Chen

19.07.2017, 10:58, "Chen Lin" <chen.lin5@zte.com.cn>:
> The byteorder of para rn(W1_READ_ROM id) pass to w1_slave_found must
> be the same with the byterorder defined in struct w1_reg_num.
>
> The rn read from 'rv = w1_read_block(dev, (u8 *)&rn, 8)' is a byte
> serial and not cpu endian relative, it need to change to cpu endian
> before passed to w1_slave_found.

But w1_reg_num has a different layout for be/le systems, isn't it enough?

> Signed-off-by: Chen Lin <chen.lin5@zte.com.cn>
> Reviewed-by: Jiang Biao <jiang.biao2@zte.com.cn>
> ---
> Forgot the description in v1.
>
> ---
>  drivers/w1/w1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
> index 95ea7e6..c531545 100644
> --- a/drivers/w1/w1.c
> +++ b/drivers/w1/w1.c
> @@ -979,7 +979,7 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb
>                          mutex_unlock(&dev->bus_mutex);
>
>                          if (rv == 8 && rn)
> - cb(dev, rn);
> + cb(dev, le64_to_cpu(rn));
>
>                          break;
>                  }
> --
> 1.8.3.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] w1:fix byteorder of W1_READ_ROM id under big-endian cpu
@ 2017-07-19  8:08 Chen Lin
  2017-08-27  7:36 ` Evgeniy Polyakov
  0 siblings, 1 reply; 3+ messages in thread
From: Chen Lin @ 2017-07-19  8:08 UTC (permalink / raw)
  To: linux-kernel; +Cc: zbr, jiang.biao2, chen.lin5

The byteorder of para rn(W1_READ_ROM id) pass to w1_slave_found must 
be the same with the byterorder defined in struct w1_reg_num. 

The rn read from 'rv = w1_read_block(dev, (u8 *)&rn, 8)' is a byte 
serial and not cpu endian relative, it need to change to cpu endian 
before passed to w1_slave_found.

Signed-off-by: Chen Lin <chen.lin5@zte.com.cn>
Reviewed-by: Jiang Biao <jiang.biao2@zte.com.cn>
---
Forgot the description in v1.

---
 drivers/w1/w1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 95ea7e6..c531545 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -979,7 +979,7 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb
 			mutex_unlock(&dev->bus_mutex);
 
 			if (rv == 8 && rn)
-				cb(dev, rn);
+				cb(dev, le64_to_cpu(rn));
 
 			break;
 		}
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-05 13:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <201708281725129358346@zte.com.cn>
2017-09-05 13:39 ` [PATCH v2] w1:fix byteorder of W1_READ_ROM id under big-endian cpu Evgeniy Polyakov
2017-07-19  8:08 Chen Lin
2017-08-27  7:36 ` Evgeniy Polyakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®