From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 071A3C2BA83 for ; Sat, 15 Feb 2020 10:10:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CD60F2081E for ; Sat, 15 Feb 2020 10:10:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726002AbgBOJ4w (ORCPT ); Sat, 15 Feb 2020 04:56:52 -0500 Received: from shards.monkeyblade.net ([23.128.96.9]:33490 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbgBOJ4w (ORCPT ); Sat, 15 Feb 2020 04:56:52 -0500 Received: from localhost (unknown [IPv6:2601:601:9f00:477::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 541C015D54AD5; Sat, 15 Feb 2020 01:56:51 -0800 (PST) Date: Sat, 15 Feb 2020 01:56:47 -0800 (PST) Message-Id: <20200215.015647.1085864163503366086.davem@davemloft.net> To: marex@denx.de Cc: netdev@vger.kernel.org, lukas@wunner.de, ynezz@true.cz, yuehaibing@huawei.com Subject: Re: [PATCH 2/3] net: ks8851-ml: Fix 16-bit data access From: David Miller In-Reply-To: <925845a7-c79b-a434-ca1c-bc9b660aa3ba@denx.de> References: <20200210184139.342716-2-marex@denx.de> <20200215.012458.724817187941650024.davem@davemloft.net> <925845a7-c79b-a434-ca1c-bc9b660aa3ba@denx.de> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Sat, 15 Feb 2020 01:56:51 -0800 (PST) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Marek Vasut Date: Sat, 15 Feb 2020 10:47:56 +0100 > On 2/15/20 10:24 AM, David Miller wrote: >> From: Marek Vasut >> Date: Mon, 10 Feb 2020 19:41:38 +0100 >> >>> @@ -197,7 +197,7 @@ static inline void ks_inblk(struct ks_net *ks, u16 *wptr, u32 len) >>> { >>> len >>= 1; >>> while (len--) >>> - *wptr++ = (u16)ioread16(ks->hw_addr); >>> + *wptr++ = swab16(ioread16(ks->hw_addr)); >> >> I agree with the other feedback, the endianness looks wrong here. >> >> The ioread16() translates whatever is behind ks->hw_addr into cpu >> endianness. >> >> This is either always little endian (for example), which means that >> unconditionally swapping this doesn't seem to make sense. > > So what is the suggestion to fix this properly ? once you know the endianness coming out of ioread16() you can then use le16_to_cpu() or be16_to_cpu() as appropriate.