From patchwork Tue Mar 15 18:26:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 597769 X-Patchwork-Delegate: trini@ti.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 3qPjkr25WDz9t3h for ; Wed, 16 Mar 2016 05:27:00 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 60761A7664; Tue, 15 Mar 2016 19:26:58 +0100 (CET) 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 WSST5MtgWtht; Tue, 15 Mar 2016 19:26:58 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DA439A7534; Tue, 15 Mar 2016 19:26:57 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8F661A7534 for ; Tue, 15 Mar 2016 19:26:55 +0100 (CET) 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 cPH9VQBK6mYQ for ; Tue, 15 Mar 2016 19:26:55 +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-pf0-f170.google.com (mail-pf0-f170.google.com [209.85.192.170]) by theia.denx.de (Postfix) with ESMTPS id 19B38A745C for ; Tue, 15 Mar 2016 19:26:49 +0100 (CET) Received: by mail-pf0-f170.google.com with SMTP id x3so38996137pfb.1 for ; Tue, 15 Mar 2016 11:26:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wpame5gVmpnLTEm9272CrEyMXn9loW+IUJhh8wB0Iyw=; b=J8A+mEux30BNKra1yPf9wU2moCcqgYsXLpDHogbFPkTk4521/XAX6pOa7PahiWw3SC oWdhCMLzBa6TRCRzLfpkpLRtDdXpaXyrfZuiY8bxqbOt8ThXDKMPUdDQt2kP2zqO/MAN gMXdvZTmQEq/941x2IxHTJ7u1WM5Sd+E21N5enmUlxi7VTwenpKWn+i50Ozo/z3czntf hj8Zy0f+In93GO6yFDqBDkQ2+waCj2zU0bFts1fb1alfh7k2AlQJa7BMpnraDoZL9Xi2 kq4dw4LtWCKeOefa9+/7UWT33s42wHuns37FBicsKcreR0ChMoBSbFFWKuXiHCiegZoU BWCw== X-Gm-Message-State: AD7BkJJa9XXlI8rPtWDTvTg8UUXwWjq/AYgjgpS9N67eY6ERGpIb79sqI1glRSQqL7mxBQ== X-Received: by 10.98.87.200 with SMTP id i69mr40426643pfj.63.1458066408276; Tue, 15 Mar 2016 11:26:48 -0700 (PDT) Received: from jteki-Latitude-E7450.amcc.com ([123.236.183.254]) by smtp.gmail.com with ESMTPSA id ux2sm41323291pac.46.2016.03.15.11.26.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Mar 2016 11:26:47 -0700 (PDT) From: Jagan Teki To: u-boot@lists.denx.de Date: Tue, 15 Mar 2016 23:56:33 +0530 Message-Id: <1458066393-3606-1-git-send-email-jteki@openedev.com> X-Mailer: git-send-email 1.9.1 Cc: Jagan Teki , trini@konsulko.com, Christophe Ricard Subject: [U-Boot] [PATCH] spi: omap3: Fix multiple definition of 'priv' X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Global definition of priv seems no-sense to use it for non-dm case and pass the pointer to functions which are common to both dm and non-dm. So, fix this by removing omap3_spi_slave from non-dm and make visible to omap3_spi_priv for both dm and non-dm. Cc: Christophe Ricard Reported-by: Tom Rini Signed-off-by: Jagan Teki --- drivers/spi/omap3_spi.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c index 98ee6d3..2fe34c9 100644 --- a/drivers/spi/omap3_spi.c +++ b/drivers/spi/omap3_spi.c @@ -103,6 +103,9 @@ struct mcspi { }; struct omap3_spi_priv { +#ifndef CONFIG_DM_SPI + struct spi_slave slave; +#endif struct mcspi *regs; unsigned int cs; unsigned int freq; @@ -454,16 +457,9 @@ static void _omap3_spi_claim_bus(struct omap3_spi_priv *priv) #ifndef CONFIG_DM_SPI -struct omap3_spi_slave { - struct spi_slave slave; - struct omap3_spi_priv spi_priv; -}; - -struct omap3_spi_priv *priv; - -static inline struct omap3_spi_slave *to_omap3_spi(struct spi_slave *slave) +static inline struct omap3_spi_priv *to_omap3_spi(struct spi_slave *slave) { - return container_of(slave, struct omap3_spi_slave, slave); + return container_of(slave, struct omap3_spi_priv, slave); } void spi_init(void) @@ -473,13 +469,15 @@ void spi_init(void) void spi_free_slave(struct spi_slave *slave) { - struct omap3_spi_slave *ds = to_omap3_spi(slave); + struct omap3_spi_priv *priv = to_omap3_spi(slave); - free(ds); + free(priv); } int spi_claim_bus(struct spi_slave *slave) { + struct omap3_spi_priv *priv = to_omap3_spi(slave); + _omap3_spi_claim_bus(priv); _omap3_spi_set_wordlen(priv); _omap3_spi_set_mode(priv); @@ -490,6 +488,8 @@ int spi_claim_bus(struct spi_slave *slave) void spi_release_bus(struct spi_slave *slave) { + struct omap3_spi_priv *priv = to_omap3_spi(slave); + /* Reset the SPI hardware */ spi_reset(priv->regs); } @@ -497,7 +497,7 @@ void spi_release_bus(struct spi_slave *slave) struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, unsigned int max_hz, unsigned int mode) { - struct omap3_spi_slave *ds; + struct omap3_spi_priv *priv; struct mcspi *regs; /* @@ -551,29 +551,31 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, return NULL; } - ds = spi_alloc_slave(struct omap3_spi_slave, bus, cs); - if (!ds) { + priv = spi_alloc_slave(struct omap3_spi_priv, bus, cs); + if (!priv) { printf("SPI error: malloc of SPI structure failed\n"); return NULL; } - priv = &ds->spi_priv; - priv->regs = regs; priv->cs = cs; priv->freq = max_hz; priv->mode = mode; - priv->wordlen = ds->slave.wordlen; + priv->wordlen = priv->slave.wordlen; #ifdef CONFIG_OMAP3_SPI_D0_D1_SWAPPED priv->pin_dir = MCSPI_PINDIR_D0_OUT_D1_IN; #endif - return &ds->slave; + return &priv->slave; } int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, void *din, unsigned long flags) -{ return _spi_xfer(priv, bitlen, dout, din, flags); } +{ + struct omap3_spi_priv *priv = to_omap3_spi(slave); + + return _spi_xfer(priv, bitlen, dout, din, flags); +} #else