From patchwork Sun Apr 28 20:28:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 327 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 6F91C3F08F for ; Sun, 28 Apr 2019 22:29:34 +0200 (CEST) Received: by mail-pf1-f197.google.com with SMTP id q27sf3018469pfn.16 for ; Sun, 28 Apr 2019 13:29:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1556483373; cv=pass; d=google.com; s=arc-20160816; b=hJep3maKcxrHCFoob4scmAnexp4tfoQ35jd/qYqjRLvmGELLjoZ+Zq8CQs88B40ALN RfzbCH+wBp7/yeLAr8GWteTVD05HTqfgzsZQ1btjx9dG2ueu0rhhmvpVA+Tgwygt3Tkc Pm++4KEHoTPb32aS9QmSs44ZO+AJSY9IIFjXmKsOylEVqb+TjvBSeItrFSWSJbYrN/Yw ja08WEggsogEo/j1J2lJTzohUzPjPWcsZ4qn15u1UIU4wm3BC9gk0WcurS8gtEEHJcZf 20E0RPanWGJm5n/m0sUpOsJpmQcVkTg7PrbcXcMS/WIn1UISb4/RTVVH8NRjLTM4/BLP jlIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=2OFBhCh4RHntOGfrMM9Mb/L660rhN04lww8cpWSBi/E=; b=CiEWz0cY273GnHbIoBv7cXMyTGkb4GxNvAkdexCXU9ucpRPuhfjkpJZRcCbLfhWPtV OAgjwU51AtGjZa56FHM3wu1t96e1HJAuTIUSm757ScikG8XDqmg6UhVtMSqAtNPgE3x9 YVq4WS42m2P+CD23QFAyZEVv8u/ux5q4o/0WSCsuYGw++fynDGjs/TOsem6es7O0miWs FHaVOPEbemNLFsA8u16K4tAd7zjzCLLTixXiyLsPsGJuW36dgnaNA0MUD1VWAmHMBLo/ laFUC0FDEKTIdmR87mSnS09uijhFwh5Os4cmR+hZhfxuwA6LId0DHAyXZocZCUnvjR2X IMuw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ifooX0V5; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=2OFBhCh4RHntOGfrMM9Mb/L660rhN04lww8cpWSBi/E=; b=C1aMiMHKpJ2DpuVOhLQEJm2pGQiLU+elcdhbX5sbIkGfjtPHGTE2twz98w+kVmHtCo +ZrP0CRgXDE8KUx7vGClBNnpdo9yWAOuWAqllcC701eCLduscCy97jHJ8uBIWmTVxkZr UQmVRoZ4HKeNBmgxrLk+xT9mqETUQBWQvOR5A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=2OFBhCh4RHntOGfrMM9Mb/L660rhN04lww8cpWSBi/E=; b=DrGRkrystG5BD9Oenog6mOmEZcE6wjT/2hyo9PZZxNvxYslFkyZyzecFK6lD5oA3xc eXaJL8IJWKGV/rcCnQzDkYe5DkZsG3P23Si7or7zCz55a+M0h5oo+zwoIWVDVo7V6H23 i469zgG7GJhFjzn2UqSBPkN6mRDVFfd/1g1dgRG4AnLdrPQDoKK1SuBcvqT56EXBDd2Q TUx0KWT8E9Xu/jcHEOvGe38aBln+EMi/EOZZO5u61QbtZDOcpbMvM1AY9/7G2oy/bJPp asSjpzFrf4aIjUsSJotdEQOyI4m28gaQhps3ippjSPb3RZtiQPPxLhJjEttesuK1BgO5 ATIA== X-Gm-Message-State: APjAAAWaDcZqYGN6L+tJ4JF7xItSgv8h1NuORItUq/5liNgby0pWmI7/ +cDrjuqPmuHexTj/DETo3kMixZHu X-Google-Smtp-Source: APXvYqz91xgt7zsVbEq6KZwokbRnPvwAv+37GmcME2F+PyD+m1Ldx0Pkxcsa7fgEVfD3GdCLnmVSLA== X-Received: by 2002:a63:bf0d:: with SMTP id v13mr32617404pgf.186.1556483373246; Sun, 28 Apr 2019 13:29:33 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:bd8a:: with SMTP id q10ls4215083pls.5.gmail; Sun, 28 Apr 2019 13:29:33 -0700 (PDT) X-Received: by 2002:a17:902:9693:: with SMTP id n19mr49823646plp.92.1556483372851; Sun, 28 Apr 2019 13:29:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556483372; cv=none; d=google.com; s=arc-20160816; b=ZNyqJ82eqTYkzV1Q/5e+YJdBpWf4cmh0osh5qaT3bOAfw2lHLZ6YSIMGrHL4DbIJfa zcHsvQvdU/ZVu70QeSonjOOKqRp4aUjuHL7WF7IDYJVLoaUyVc9uW8zmuzpGs1fYNCy5 5C5AsDZslDqN/ElQv+fXUSeeydOeXTBY/TzidtRzCbqR0Cq4A1GJop64as+YYLDVxvgW BJvm3zU52uoEnOLaxhPo9mCN3qz6Xe0p2k00RCdVO135v6xkA+cZ7EG8/2/AyI2vVvmm sml7chgZu68C6JqtTlZPWcwe43RYA6OMNXPO8mqzrMc5L05+mLhyoXNQYH4WJC8R/Efb 3okA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=p2yOgWDOu2LU09nRm/oHIlXZTD47h62ToxLJhnnyR9E=; b=UGXR2HZeK1Miw5+fZE2fbtCAAkIip+pO7f1ED517MoEyPAvO6UYqjFEFtQ9wspnZtV ZhxW7XHU4MACLJhfAljcE/cjNkhAKZ1qvSNoaQxk5ciax1211+2C6AeHWyFW2wCsn66d YlvlHyjiuo6qzzhieUYoaHTXKfFBml/4oUsvnhxYxm5kVBqqdQZ/cAPKuCUjv9NLjr9H +bIMkKwSV63v5wg5D4D9lk1F8Fd5HfP+wITXpcj8qL6nRZdGIlZ96CRdpokjlb24iOh7 d/hQlbFBSNZVjYu/XPA4V0HYM2BTT1icTNyPvhvwGVJLkNqnWw74IS59kufbf8VnhE7i A6KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ifooX0V5; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 1sor31642597plz.0.2019.04.28.13.29.32 for (Google Transport Security); Sun, 28 Apr 2019 13:29:32 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:9a95:: with SMTP id w21mr58785332plp.74.1556483372584; Sun, 28 Apr 2019 13:29:32 -0700 (PDT) Received: from localhost.localdomain ([115.97.185.144]) by smtp.gmail.com with ESMTPSA id x66sm68841439pfb.78.2019.04.28.13.29.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Apr 2019 13:29:32 -0700 (PDT) From: Jagan Teki To: Heiko Schocher , Tom Rini Cc: u-boot@lists.denx.de, linux-amarula@amarulasolutions.com, Mario Six Subject: [PATCH v2 11/19] spi: mpc8xxx: Reduce scope of loop variables Date: Mon, 29 Apr 2019 01:58:46 +0530 Message-Id: <20190428202854.8590-12-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190428202854.8590-1-jagan@amarulasolutions.com> References: <20190428202854.8590-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ifooX0V5; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Mario Six The transmission loop starts with setting some variables, which are only used inside the loop. Reduce the scope to the loop to make the declaration and initialization of these variables coincide. In the case of char_size this also always initializes the variable immediately with the final value actually used in the loop (instead of the placeholder value 32). Signed-off-by: Mario Six --- drivers/spi/mpc8xxx_spi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c index a2e698ea17..2a0f3cc06a 100644 --- a/drivers/spi/mpc8xxx_spi.c +++ b/drivers/spi/mpc8xxx_spi.c @@ -88,10 +88,8 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din, ulong flags) { spi8xxx_t *spi = &((immap_t *)(CONFIG_SYS_IMMR))->spi; - uint tmpdout, tmpdin, event; + u32 tmpdin; int num_blks = DIV_ROUND_UP(bitlen, 32); - int tm; - uchar char_size = 32; debug("%s: slave %u:%u dout %08X din %08X bitlen %u\n", __func__, slave->bus, slave->cs, *(uint *)dout, *(uint *)din, bitlen); @@ -104,8 +102,9 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din, /* Handle data in 32-bit chunks */ while (num_blks--) { - tmpdout = 0; - char_size = (bitlen >= 32 ? 32 : bitlen); + int tm; + u32 tmpdout = 0; + uchar char_size = (bitlen >= 32 ? 32 : bitlen); /* Shift data so it's msb-justified */ tmpdout = *(u32 *)dout >> (32 - char_size); @@ -145,7 +144,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din, * The NE event must be read and cleared first */ for (tm = 0; tm < SPI_TIMEOUT; ++tm) { - event = in_be32(&spi->event); + u32 event = in_be32(&spi->event); bool have_ne = event & SPI_EV_NE; bool have_nf = event & SPI_EV_NF;