Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp483727ybg; Fri, 18 Oct 2019 02:53:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdJ6hDGNdJcBOrzKrAxLQQCGSD+v16//4+XwYidDSz7kbEigsuCCj6HuC17LCYpXT2fzpI X-Received: by 2002:a50:d615:: with SMTP id x21mr8632395edi.297.1571392386633; Fri, 18 Oct 2019 02:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571392386; cv=none; d=google.com; s=arc-20160816; b=XT+7R3beuoKF9e5kYNIJ3TWOEWMECwAunhh1JBvo+QKayA4IpZg0rHIDATsvvu9+D1 5NE1M4QOrfGJTkg4eM5WW5IpsbUru317yJCiZ8ELgfCifOL3Nz/eLpg4y1vGqBEdRb3p lXm5pwTOQ4o4Wgh0t1UKUh0wvC9+6KaNGQ41GJcYA3J5Wh6zjD2wSG136/ZosUlZZMFh VgNLSmclMAMvfCb6XWdlXsJeilumC8R6KrpAq4TRx8msupC7QVMUtLqTFgtPqorLXGZW b3o+CDwkLKxhAfmL9md5vKabaF3bEfTwCmwL4Q2JN3aBDCvYZL1M79wDEMereqMTL+9c W9Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=DpbexsAaJKGXtyeEN5Jk64plg1Z6QAlcAhFxTzBWpB0=; b=HkpnFaeIRLDyYJWhwNQ2LRo7Qt320leMwOkn9/LwHJts+lDoP/TtidTOp4TDC+JW/M Nu5CKRkPVxyyf1tPjLQxl8EjJqsh/ETIYfeM6EwGsyycI4ArjUvxbqsQL10HIFcpDeMx SqCFLStdIi8EDo9fps+22vsscaN7AgM7mAcLd9RFJ2bmpGBpjMUGGEU7bfx9bu0WyVjB NkUCISp8UytF80ZJ3OzD4l0DhlCDum5GzETYtVtmMTjizmpDf8i1MLgbjP+Cxz5cg2Zr IskGI1jb2aBPGnjUnO7Ti39OsvXXeGD/xhoZHnAq8qiNYE99vCG239h6mfG4YQhDpq/g edmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b47si3592462edc.45.2019.10.18.02.52.43; Fri, 18 Oct 2019 02:53:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407867AbfJQG5j (ORCPT + 99 others); Thu, 17 Oct 2019 02:57:39 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:32902 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392691AbfJQG5j (ORCPT ); Thu, 17 Oct 2019 02:57:39 -0400 Received: by mail-oi1-f196.google.com with SMTP id a15so1272803oic.0; Wed, 16 Oct 2019 23:57:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DpbexsAaJKGXtyeEN5Jk64plg1Z6QAlcAhFxTzBWpB0=; b=naRJZscLNaz8RRrCMCCL8mkDxUYxseHyq6ogcswZh+/E7vSWPvhag8UtsdrdDjgyPl AHhMfUh59TRuMLHEYjYs88In29hgmczsHNNJNKtqy17Z/cV2ZpDpCed6hBKKyy3PJ4Xj BKEjmwv5GOA+0dqI0w9xz2utwTi3iAjXk5mEHOKc4PRWiJPZBVmFeVsvPAvsWLcnGqnh IOBv3ZC2wZTgwnk2Dl5lUgDpBX7gd/rUn+cQVkIF5rGQ3/Rqy7Cjc71suLnQfp/2zRQJ K+cH/E5n5uFnib8ZKPaoh7Wffh5oTcoXxvy8tSLatLAF4jTcK5BSEX1oqyqVwM/7/VkR rCNg== X-Gm-Message-State: APjAAAWMZCC2YHHwdt2UvQmhHAphG4QMikRUkzDvfRlb3JA3JToEocUg r+4GansHalsXAEYoxfGnkIM5pbIghKzFeP08uPSHQ9gp X-Received: by 2002:a54:4e89:: with SMTP id c9mr1775447oiy.148.1571295458039; Wed, 16 Oct 2019 23:57:38 -0700 (PDT) MIME-Version: 1.0 References: <20191015155044.11858-1-ben.dooks@codethink.co.uk> <20191016122656.3jpmes4rnz47u5wc@verge.net.au> In-Reply-To: From: Geert Uytterhoeven Date: Thu, 17 Oct 2019 08:57:26 +0200 Message-ID: Subject: Re: [PATCH] usb: renesas_usbhs: fix __le16 warnings To: Yoshihiro Shimoda , Simon Horman Cc: "linux-kernel@lists.codethink.co.uk" , Greg Kroah-Hartman , Geert Uytterhoeven , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Ben Dooks (Codethink)" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Shimoda-san, Simon, On Thu, Oct 17, 2019 at 4:18 AM Yoshihiro Shimoda wrote: > > From: Simon Horman, Sent: Wednesday, October 16, 2019 9:27 PM > > > > diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c > > > index 4c3de777ef6c..a3c30b609433 100644 > > > --- a/drivers/usb/renesas_usbhs/common.c > > > +++ b/drivers/usb/renesas_usbhs/common.c > > > @@ -162,17 +162,17 @@ void usbhs_usbreq_get_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req) > > > req->bRequest = (val >> 8) & 0xFF; > > > req->bRequestType = (val >> 0) & 0xFF; > > > > > > - req->wValue = usbhs_read(priv, USBVAL); > > > - req->wIndex = usbhs_read(priv, USBINDX); > > > - req->wLength = usbhs_read(priv, USBLENG); > > > + req->wValue = cpu_to_le16(usbhs_read(priv, USBVAL)); > > > + req->wIndex = cpu_to_le16(usbhs_read(priv, USBINDX)); > > > + req->wLength = cpu_to_le16(usbhs_read(priv, USBLENG)); > > > > usbhs_read is backed by readl which performs > > a le->cpu conversion. Rather than have a double conversion > > perhaps it would be nicer to introduce usbhs_read_le. > > Likewise for write. > > I'm afraid but, I could not understand these comments. > At the moment, the usbhs_{read,write}() call io{read,write}16(), > not {read,write}l(). > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/renesas_usbhs/common.c?h=v5.4-rc3#n62 ioread16() and readw() don't do byteswapping on ARM, as ARM is little-endian. Likewise, cpu_to_le16() is a no-op on ARM. Double swapping would matter only on a big-endian platform, and could indeed be avoided by introducing usbhs_read_le*() functions that are just wrappers around __raw_read16() on big-endian. However, until the Renesas USBHS IP core ends up on a big-endian platform, it's not worth doing that, IMHO. > > > } > > > > > > void usbhs_usbreq_set_val(struct usbhs_priv *priv, struct usb_ctrlrequest *req) > > > { > > > usbhs_write(priv, USBREQ, (req->bRequest << 8) | req->bRequestType); > > > - usbhs_write(priv, USBVAL, req->wValue); > > > - usbhs_write(priv, USBINDX, req->wIndex); > > > - usbhs_write(priv, USBLENG, req->wLength); > > > + usbhs_write(priv, USBVAL, le16_to_cpu(req->wValue)); > > > + usbhs_write(priv, USBINDX, le16_to_cpu(req->wIndex)); > > > + usbhs_write(priv, USBLENG, le16_to_cpu(req->wLength)); > > > > > > usbhs_bset(priv, DCPCTR, SUREQ, SUREQ); > > > } Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds