Re: [PATCH v2] w1:fix byteorder of W1_READ_ROM id under big-endian cpu

From: Evgeniy Polyakov
Date: Sun Aug 27 2017 - 03:36:57 EST


Hi Chen

19.07.2017, 10:58, "Chen Lin" <chen.lin5@xxxxxxxxxx>:
> 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@xxxxxxxxxx>
> Reviewed-by: Jiang Biao <jiang.biao2@xxxxxxxxxx>
> ---
> 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