From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Subject: Re: [PATCH v5 07/10] i3c: master: Add driver for Cadence IP Date: Wed, 11 Jul 2018 16:19:51 +0200 Message-ID: References: <20180622104930.32050-1-boris.brezillon@bootlin.com> <20180622104930.32050-8-boris.brezillon@bootlin.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <20180622104930.32050-8-boris.brezillon@bootlin.com> Sender: linux-kernel-owner@vger.kernel.org To: Boris Brezillon Cc: Wolfram Sang , linux-i2c@vger.kernel.org, Jonathan Corbet , "open list:DOCUMENTATION" , Greg Kroah-Hartman , Przemyslaw Sroka , Arkadiusz Golec , Alan Douglas , Bartosz Folta , Damian Kos , Alicja Jurasik-Urbaniak , Cyprian Wronka , Suresh Punnoose , Rafal Ciepiela , Thomas Petazzoni , Nishanth Menon , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell List-Id: devicetree@vger.kernel.org On Fri, Jun 22, 2018 at 12:49 PM, Boris Brezillon wrote: > Add a driver for Cadence I3C master IP. The driver seems very well-written and shows that the framework got that side of the interface right. Just one thing I noticed: > + > +static void cdns_i3c_master_handle_ibi(struct cdns_i3c_master *master, > + u32 ibir) > + > + for (i = 0; i < IBIR_XFER_BYTES(ibir); i += 4) { > + u32 tmp = readl(master->regs + IBI_DATA_FIFO); > + > + for (j = 0; j < 4 && i + j < dev->ibi->max_payload_len; j++) > + buf[i + j] = tmp >> (j * 8); > + } This seems to be a rather inefficient way to open-code a readsl(). I suppose you need to handle length that is not a multiple of 4, right? Maybe do it like size_t length = IBIR_XFER_BYTES(ibir); readsl(master->regs + IBI_DATA_FIFO, buf, length & ~3); if (length & 3) { u32 tmp = __raw_readl(master->regs + IBI_DATA_FIFO); memcpy(buf + length & ~3, length & 3); } Arnd