Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp5124448imm; Tue, 26 Jun 2018 06:21:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK0Z9FDuoE/8Y/CkXp1MSbn/tna541m/YHfaK88qCHDK6jS/0i2h5E4Bna0y/rgCasLkRGZ X-Received: by 2002:a17:902:5388:: with SMTP id c8-v6mr1649008pli.130.1530019262128; Tue, 26 Jun 2018 06:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530019262; cv=none; d=google.com; s=arc-20160816; b=srlLa3JQsOgkL8QIOYDdCndeRR9ypVbEASOVzmmZGk3FocgsC3jmVAfFBBAtBdyQYv ZXMdJw+EfexViPGhBpijjZhT7/HK27Q4hZpUoGb2Qrv/LaqtAsvgp0K5fcfpFURktbir WzljspceD3XA5WaazNhIeOuwWP05ZmkTK0mj6LuowqaK/YGRC1bFd/U6uMsfNrHUPx/Y 2SkXZQvxAfU8hLBriZI60QRzTJOjQ4pzp7nVi3oRnszdkx06afGYF1aTCKUqnB2Umtcp 4JOktjvCBldgxpU7OoODDSWprJatDh9/tV1VaQPgrXhAOoQo44545lQeu2+lG+XVL8W+ AIYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=iUNLSbEqacKffS9XcCC8/Tdf0F5xPPIFvnNdromEtow=; b=Km5bkqGKHWAx9XVayuXXesLgjpL2PSgcY7hs6m54gjH09eHiQjO1tKkPUbjiZX6BvR ruEfud4OzjXzGjhdLBfrCgZbwIDt/Lf/chdAdSAkoBY/Kzg6vhjyWbFAZmoU3WQwFk3s XLk/dRQC0b5uHI980eNuNlDQ+BDuPyzWKWid5RtFrPBMQ6PMsWT8HZULru1CmmZ/9n9v 8PUyDV8EkjxIXDu4eJq6RqnD+w+/y4f0KKqQi6UbRJdNjWXrZmncgmJDMo+RPUcMPLKp 78nZjL9nJN1HGQe7dxDBF6BU8niyerPZ0/fNfPsapiSBfNSabTC5fr0Aa3KmICnQCbu1 yEeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Y9qcBb1p; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h189-v6si1350448pge.66.2018.06.26.06.20.48; Tue, 26 Jun 2018 06:21:02 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Y9qcBb1p; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935650AbeFZNSs (ORCPT + 99 others); Tue, 26 Jun 2018 09:18:48 -0400 Received: from mail-vk0-f68.google.com ([209.85.213.68]:43419 "EHLO mail-vk0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934063AbeFZNSq (ORCPT ); Tue, 26 Jun 2018 09:18:46 -0400 Received: by mail-vk0-f68.google.com with SMTP id d74-v6so9978054vke.10; Tue, 26 Jun 2018 06:18:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=iUNLSbEqacKffS9XcCC8/Tdf0F5xPPIFvnNdromEtow=; b=Y9qcBb1pGQTqYxB4h06q7f/KbPTB5BYX7ulS7Nj9oG9VNT45ClluVlygBYaQm4cWc+ Yb23a2H341Zb2idZ5mRx4nWkgwx0c96UOwN0vAAEOAW+gMfqIUwH9a21oDXcaxSNKc1+ Dba/nArbOu3zythK1Rvn12eHdAJh/SvdvmUx/L730fzQ75xgmWzaWDV9c/8Pi7UVQLN2 ER1F7JxXvGU8u9j9/ARVBofSZGi8Ke9xROe5Euxhf9Vxj6LCUVYTSxtYN01rhcgfXCPy mRz5aZ92qKwzaO3/f+Gd/Ot93jNAjLErNVa07rCaA84UE4sY6WmWKICyUQgSoeGVl31K zl7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=iUNLSbEqacKffS9XcCC8/Tdf0F5xPPIFvnNdromEtow=; b=Is9N3Xut3bGrxY1Wk1rfN0YfCyQRG841/xE2J0ha7QSDPawJRKAA7A/jLC7G3PEtAR 2E1kOaVKNDNhrC2j6f4L4fHvJ4AJin/wXRviWU+2sypy2G1IlkEZRdzKFd+B2QMPOttT GCWKhaSi70P+ehj2MhdPW2GiDgyaGNofwAbBQwd6FmhJSZvF6Ra/W+jHLSXwkbYsfYB2 JhCyEeRnzMJovIWRxUDiWmldftjY3wqdYYaT7/3T2GWWTMtc/VsvgR5tmWRpYTUAOXqg zL0bWjRS3tdn3ZnMVF/wFYXfmuVRqMkB/k6cwGVXJOR7qreqSwAbo6SHjdddtTLeuqt8 /BLA== X-Gm-Message-State: APt69E1jWEn+19ejLjojeIn/m6J2Af252Y3iu8C4z+wRX4E96Aj/Hj4A jwVjcq3C/70bGkFB8IjbrmHLfmwLeVPZRa4pMB8= X-Received: by 2002:a1f:d1c5:: with SMTP id i188-v6mr909984vkg.131.1530019125189; Tue, 26 Jun 2018 06:18:45 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:8b02:0:0:0:0:0 with HTTP; Tue, 26 Jun 2018 06:18:44 -0700 (PDT) In-Reply-To: <4046ba78-b6c0-c09b-43e2-e3c2e550be9f@exceet.de> References: <1527686082-15142-1-git-send-email-frieder.schrempf@exceet.de> <1527686082-15142-4-git-send-email-frieder.schrempf@exceet.de> <4046ba78-b6c0-c09b-43e2-e3c2e550be9f@exceet.de> From: Andy Shevchenko Date: Tue, 26 Jun 2018 16:18:44 +0300 Message-ID: Subject: Re: [PATCH 03/11] spi: Add a driver for the Freescale/NXP QuadSPI controller To: Frieder Schrempf Cc: "linux-mtd@lists.infradead.org" , Yogesh Narayan Gaur , "boris.brezillon@bootlin.com" , "linux-spi@vger.kernel.org" , "dwmw2@infradead.org" , "computersforpeace@gmail.com" , "marek.vasut@gmail.com" , "richard@nod.at" , "miquel.raynal@bootlin.com" , "broonie@kernel.org" , David Wolfe , Fabio Estevam , Prabhakar Kushwaha , Han Xu , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 26, 2018 at 3:26 PM, Frieder Schrempf wrote: > On 08.06.2018 22:27, Andy Shevchenko wrote: >> On Fri, Jun 8, 2018 at 2:54 PM, Yogesh Narayan Gaur >> wrote: >>> +static int fsl_qspi_check_buswidth(struct fsl_qspi *q, u8 width) { >>> + switch (width) { >>> + case 1: >>> + case 2: >>> + case 4: >>> + return 0; >>> + } >> if (!is_power_of_2(width) || width >=3D 8) >> return -E...; >> >> return 0; >> >> ? > Your proposition is a bit shorter, but I think it's slightly harder to re= ad. OK. >>> + >>> + return -ENOTSUPP; >>> +} >>> + for (i =3D 0; i < op->data.nbytes; i +=3D 4) { >>> + u32 val =3D 0; >>> + >>> + memcpy(&val, op->data.buf.out + i, >>> + min_t(unsigned int, op->data.nbytes - i, 4)); >> You may easily avoid this conditional on each iteration. > Do you mean something like this, or are there better ways? > > u32 val =3D 0; > > for (i =3D 0; i < ALIGN_DOWN(op->data.nbytes, 4); i +=3D 4) > { > memcpy(&val, op->data.buf.out + i, 4); > val =3D fsl_qspi_endian_xchg(q, val); > qspi_writel(q, val, base + QUADSPI_TBDR); > } > > memcpy(&val, op->data.buf.out + i, op->data.nbytes); > val =3D fsl_qspi_endian_xchg(q, val); > qspi_writel(q, val, base + QUADSPI_TBDR); Something like this, though last part should go under if (IS_ALIGNED(...)) (My comment was about moving out an invariant conditional) >>> + val =3D fsl_qspi_endian_xchg(q, val); >>> + qspi_writel(q, val, base + QUADSPI_TBDR); >>> + } >>> +MODULE_AUTHOR("Freescale Semiconductor Inc."); MODULE_AUTHOR("Boris >>> +Brezillion "); MODULE_AUTHOR("Frieder >>> +Schrempf "); MODULE_LICENSE("GPL v2"); >> Wrong indentation. > What is wrong? Some newlines are missing here between the MODULE_ macros, > but in my original patch it seems correct. It should be like MODULE_FOO(...); MODULE_BAR(...); MODULE_BAZ(...); One macro =E2=80=94 one line. --=20 With Best Regards, Andy Shevchenko