From patchwork Sat Nov 30 03:38:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 295542 X-Patchwork-Delegate: sonic.adi@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id EE9682C00A7 for ; Sat, 30 Nov 2013 14:38:46 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5A04AA7506; Sat, 30 Nov 2013 04:38:45 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6f3VfTurXgjC; Sat, 30 Nov 2013 04:38:40 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 055E8A747A; Sat, 30 Nov 2013 04:38:40 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BD799A747A for ; Sat, 30 Nov 2013 04:38:34 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VuSYGhtE+Hjc for ; Sat, 30 Nov 2013 04:38:29 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pd0-f180.google.com (mail-pd0-f180.google.com [209.85.192.180]) by theia.denx.de (Postfix) with ESMTPS id 5BC62A7405 for ; Sat, 30 Nov 2013 04:38:22 +0100 (CET) Received: by mail-pd0-f180.google.com with SMTP id q10so14673293pdj.39 for ; Fri, 29 Nov 2013 19:38:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=OLa7WZO4YMBuG0fQBOiTEkyrDVkdkbM4qWpY2G2SgjU=; b=ghXSasbQZsnvRPNgCENMXlAHW3tzssJICaeD4Sa+uQYb1Vuy4MlTRYqnIg32LBRpjM Qy1Ib7LwjHCB2/bXKTBVVckAtxFe/jl6ZFJpRy/gdlvicZ2av0+OgXGgrHWf/AX4RAXn WqRPmMDZyz2hXwBwLA+LrFz94jV3R8Ccxxlatt8GVVazIVzcSdTsG47g0WYCGQsvBjGc 8CVFLDznCNwMo/Uopq5YLLzOPPrQg7P93f7dMHAWlDXD+CwgiCEH7X5uY+Q4/sryo7v0 T7MJORLEcGymHyVpm4d/sbVcoKKPdaO5MRve/a/XEyLEYReBqu2oUK00KeBbtbu6aZRV LTKg== X-Gm-Message-State: ALoCoQnyjx72mh+0xuCIKshtKpWbktsMl3m2Lrw6iemLRPqnlyw1Y1Xwpuv7yRFW6+p/ItL4OjD2 X-Received: by 10.68.66.33 with SMTP id c1mr19444880pbt.73.1385782701561; Fri, 29 Nov 2013 19:38:21 -0800 (PST) Received: from [10.118.50.142] ([60.245.64.174]) by mx.google.com with ESMTPSA id gg10sm105527857pbc.46.2013.11.29.19.38.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 19:38:21 -0800 (PST) Message-ID: <1385782695.28549.2.camel@phoenix> From: Axel Lin To: Sonic Zhang , Jagannadha Sutradharudu Teki Date: Sat, 30 Nov 2013 11:38:15 +0800 X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 Cc: u-boot@lists.denx.de, Scott Jiang Subject: [U-Boot] [PATCH 1/2] spi: bfin_spi: Remove unnecessary test for bus and pins[bus] X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de For invalid bus number, current code returns NULL in the default case of switch-case statements. In additional, pins[bus] is always not NULL because it is the address of specific row of the two-dimensional array. Thus this patch removes these unnecessary test. Signed-off-by: Axel Lin Acked-by: Scott Jiang --- Also adjust the code position to avoid checkpatch.pl warning: ERROR: trailing statements should be on next line drivers/spi/bfin_spi.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/spi/bfin_spi.c b/drivers/spi/bfin_spi.c index bb88f30..aa89d89 100644 --- a/drivers/spi/bfin_spi.c +++ b/drivers/spi/bfin_spi.c @@ -162,21 +162,22 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, if (!spi_cs_is_valid(bus, cs)) return NULL; - if (bus >= ARRAY_SIZE(pins) || pins[bus] == NULL) { - debug("%s: invalid bus %u\n", __func__, bus); - return NULL; - } switch (bus) { #ifdef SPI0_CTL - case 0: mmr_base = SPI0_CTL; break; + case 0: + mmr_base = SPI0_CTL; break; #endif #ifdef SPI1_CTL - case 1: mmr_base = SPI1_CTL; break; + case 1: + mmr_base = SPI1_CTL; break; #endif #ifdef SPI2_CTL - case 2: mmr_base = SPI2_CTL; break; + case 2: + mmr_base = SPI2_CTL; break; #endif - default: return NULL; + default: + debug("%s: invalid bus %u\n", __func__, bus); + return NULL; } bss = spi_alloc_slave(struct bfin_spi_slave, bus, cs);