From patchwork Thu Jul 5 10:41:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastian Hecht X-Patchwork-Id: 169122 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 689862C007A for ; Thu, 5 Jul 2012 20:47:11 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SmjXp-0001qS-Fh; Thu, 05 Jul 2012 10:44:21 +0000 Received: from mail-bk0-f49.google.com ([209.85.214.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SmjWy-0001la-2y for linux-mtd@lists.infradead.org; Thu, 05 Jul 2012 10:43:29 +0000 Received: by bkcji2 with SMTP id ji2so2785704bkc.36 for ; Thu, 05 Jul 2012 03:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=yV3Wa13XOBaCZiLreERpQYeU+V4bzSvxfEiCJfJOADY=; b=XkVYuNrEVsa4nYBRiPk0wX16UXkJX1rnatqqDIJCkYo5/WLd1i6dDjOfKR23BZXUC5 sGasLJjVyV/G6RW8+tBS32cCPatD6lgtZf4l7invmiI0b6Iu1YM6HCi99BiV3PcbuDi2 pWgXAJQDKw0S3VIgvMeh5jjRXwM4hPMxOMnIM8H2PlBxt2qhzVUHLt4eXf8o9aRWuXkr bwcrhAf5e3OfJL9KpsPKBB6TbgmeBkgUD7KAsKG/FOxgJF3jM9kcErzZyKX45VWa59+s 3Cu4KfSTBV1jP2wn+eIPfLrv6VdLUUT+YfAEQEe/Z3CGPpoGPdUvcgYhJuecbg7Elh2a 6wYg== Received: by 10.204.129.89 with SMTP id n25mr13753400bks.83.1341484881611; Thu, 05 Jul 2012 03:41:21 -0700 (PDT) Received: from ipanema.abspannwerk.de (p5DDC6169.dip.t-dialin.net. [93.220.97.105]) by mx.google.com with ESMTPS id c18sm356393bkv.8.2012.07.05.03.41.20 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jul 2012 03:41:20 -0700 (PDT) From: Bastian Hecht To: linux-mtd@lists.infradead.org Subject: [PATCH 1/2] mtd: sh_flctl: Use memcpy() instead of using a loop Date: Thu, 5 Jul 2012 12:41:01 +0200 Message-Id: <1341484862-24033-1-git-send-email-hechtb@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (hechtb[at]googlemail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.49 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Bastian Hecht , Linux-SH X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Elemets have been copied "manually" in a loop. Better use memcpy(). Signed-off-by: Bastian Hecht Reviewed-by: Simon Horman --- drivers/mtd/nand/sh_flctl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c index 0d9cce7..e4f31ef 100644 --- a/drivers/mtd/nand/sh_flctl.c +++ b/drivers/mtd/nand/sh_flctl.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -748,10 +749,9 @@ static void flctl_select_chip(struct mtd_info *mtd, int chipnr) static void flctl_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) { struct sh_flctl *flctl = mtd_to_flctl(mtd); - int i, index = flctl->index; + int index = flctl->index; - for (i = 0; i < len; i++) - flctl->done_buff[index + i] = buf[i]; + memcpy(&flctl->done_buff[index], buf, len); flctl->index += len; } @@ -780,10 +780,11 @@ static uint16_t flctl_read_word(struct mtd_info *mtd) static void flctl_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) { - int i; + struct sh_flctl *flctl = mtd_to_flctl(mtd); + int index = flctl->index; - for (i = 0; i < len; i++) - buf[i] = flctl_read_byte(mtd); + memcpy(buf, &flctl->done_buff[index], len); + flctl->index += len; } static int flctl_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)