From: Kim Phillips Date: Thu, 16 Sep 2010 18:54:53 -0500 Subject: [U-Boot] [PATCH 1/5] mpc83xx/pcie: make it compile with PCIE2 unconfigured In-Reply-To: <1284496841-15353-1-git-send-email-yanok@emcraft.com> References: <20100913201208.461501b3.kim.phillips@freescale.com> <1284496841-15353-1-git-send-email-yanok@emcraft.com> Message-ID: <20100916185453.cb967dd5.kim.phillips@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tue, 14 Sep 2010 22:40:37 +0200 Ilya Yanok wrote: > MPC8308 has only one PCIE host controller so we want it to compile > without CONFIG_SYS_PCIE2_CFG_{BASE,SIZE} defined. > +#if defined(CONFIG_SYS_PCIE2_CFG_BASE) && defined(CONFIG_SYS_PCIE2_SIZE) > #define PCIE_MAX_BUSES 2 > +#else > +#define PCIE_MAX_BUSES 1 > +#endif Technically this should be an indirect function of MPC8308, but what's the problem with leaving MAX_BUSES as 2 always? > + unsigned int *cfg_addr; > + > + if (bus == 0) { > + cfg_addr = (unsigned int *)CONFIG_SYS_PCIE1_CFG_BASE; > + } else { > +#if defined(CONFIG_SYS_PCIE2_CFG_BASE) && defined(CONFIG_SYS_PCIE2_SIZE) > + cfg_addr = (unsigned int *)CONFIG_SYS_PCIE2_CFG_BASE; > +#else > + printf("Second PCIE host controller not configured!\n"); > + return; > +#endif let's reduce the new ifdefs introduced in the file down to one, and still be able remove the 'if (bus)' clauses by adding a static pcie cfg struct array[], to which this and code below it would directly dereference with array[bus]. The single ifdef should protect the second entry in the array. The "second PCIE host controller not configured" check can be made by comparing num_buses with ARRAY_SIZE (array) in mpc83xx_pcie_init prior to calling mpc83xx_pcie_init_bus with an illegal bus value. Kim