From patchwork Mon Jun 15 16:18:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Clayton X-Patchwork-Id: 6610601 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 42DC4C0020 for ; Mon, 15 Jun 2015 16:23:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 524ED2071B for ; Mon, 15 Jun 2015 16:23:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6003D20719 for ; Mon, 15 Jun 2015 16:23:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z4X7y-0006Ya-HJ; Mon, 15 Jun 2015 16:20:50 +0000 Received: from mail-pd0-x22e.google.com ([2607:f8b0:400e:c02::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z4X6p-0004uj-6A for linux-arm-kernel@lists.infradead.org; Mon, 15 Jun 2015 16:19:40 +0000 Received: by pdbnf5 with SMTP id nf5so76356800pdb.2 for ; Mon, 15 Jun 2015 09:19:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IVWLg1OFbb2h9gDJEgV/FRUPg6sK2hSEKq7aBNgdy5E=; b=K5xfAxe3dJ4BZd8zNiIY8xsNzIzjbgRAGvl3vyCt9TG1b8LR0aPWFWmc5XBEfmIc+n chSMEccpp2wtnDHjGwWxjVtw5gUPSs8X+JyjNHcg9nw3z+v4WhPOWEfo+BSirupCld+1 rgvKW4E7bZyVd6RR1P8BremBNfdxKU5vBztb5zO1LxOTAhN0VyX2M9ZVBm/SEmtO0bZO LK4XQTEGuFqkhwnN6Gfwz0QeqIZ6DKi9SIHHez46rwie9nREiOqf6E11WzGaN3kEEt58 LZADgKqL6FpJPSfsEVwF4skM95+f7hjYOKatr+coHOJU9Bq0Aq0dWnI8P01/DeGiE+2y 57DA== X-Received: by 10.70.43.169 with SMTP id x9mr49230296pdl.52.1434385157239; Mon, 15 Jun 2015 09:19:17 -0700 (PDT) Received: from localhost.localdomain (68-185-59-186.static.knwc.wa.charter.com. [68.185.59.186]) by mx.google.com with ESMTPSA id qg5sm12717637pdb.13.2015.06.15.09.19.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Jun 2015 09:19:15 -0700 (PDT) From: Joshua Clayton To: Vinod Koul Subject: [PATCH 03/10] dma: imx-sdma: use a container_of function Date: Mon, 15 Jun 2015 09:18:58 -0700 Message-Id: <1434385144-4432-4-git-send-email-stillcompiling@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1434385144-4432-1-git-send-email-stillcompiling@gmail.com> References: <1434385144-4432-1-git-send-email-stillcompiling@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150615_091939_304012_3574EE0C X-CRM114-Status: GOOD ( 15.21 ) X-Spam-Score: -0.8 (/) Cc: Joshua Clayton , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, Dan Williams , Shawn Guo , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Rather than including a struct sdma_engine pointer in each sdma_channel, introduce to_sdma_engine() to get the parent struct. Signed-off-by: Joshua Clayton --- drivers/dma/imx-sdma.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index c255664..7c8703f 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -246,7 +246,6 @@ struct sdma_engine; * @num_bd max NUM_BD. number of descriptors currently handling */ struct sdma_channel { - struct sdma_engine *sdma; unsigned int channel; enum dma_transfer_direction direction; enum sdma_peripheral_type peripheral_type; @@ -467,6 +466,11 @@ static inline u32 chnenbl_ofs(struct sdma_engine *sdma, unsigned int event) return chnenbl0 + event * 4; } +static struct sdma_engine *to_sdma_engine(struct sdma_channel *sdmac) +{ + return container_of(sdmac, struct sdma_engine, channel[sdmac->channel]); +} + static int sdma_config_ownership(struct sdma_engine *sdma, int channel, bool event_override, bool mcu_override, bool dsp_override) { @@ -687,7 +691,7 @@ static irqreturn_t sdma_int_handler(int irq, void *dev_id) static void sdma_get_pc(struct sdma_channel *sdmac, enum sdma_peripheral_type peripheral_type) { - struct sdma_engine *sdma = sdmac->sdma; + struct sdma_engine *sdma = to_sdma_engine(sdmac); int per_2_emi = 0, emi_2_per = 0; /* * These are needed once we start to support transfers between @@ -776,7 +780,7 @@ static void sdma_get_pc(struct sdma_channel *sdmac, static int sdma_load_context(struct sdma_channel *sdmac) { - struct sdma_engine *sdma = sdmac->sdma; + struct sdma_engine *sdma = to_sdma_engine(sdmac); int channel = sdmac->channel; int load_address; struct sdma_context_data *context = sdma->context; @@ -836,7 +840,7 @@ static int sdma_config_channel(struct sdma_channel *sdmac) { int ret; int channel = sdmac->channel; - struct sdma_engine *sdma = sdmac->sdma; + struct sdma_engine *sdma = to_sdma_engine(sdmac); sdma_disable_channel(sdma, channel); @@ -906,7 +910,7 @@ static int sdma_set_channel_priority(struct sdma_engine *sdma, int channel, static int sdma_request_channel(struct sdma_channel *sdmac) { - struct sdma_engine *sdma = sdmac->sdma; + struct sdma_engine *sdma = to_sdma_engine(sdmac); int channel = sdmac->channel; int ret = -EBUSY; @@ -950,7 +954,7 @@ static dma_cookie_t sdma_tx_submit(struct dma_async_tx_descriptor *tx) static int sdma_alloc_chan_resources(struct dma_chan *chan) { struct sdma_channel *sdmac = to_sdma_chan(chan); - struct sdma_engine *sdma = sdmac->sdma; + struct sdma_engine *sdma = to_sdma_engine(sdmac); struct imx_dma_data *data = chan->private; int prio, ret; @@ -995,7 +999,7 @@ static int sdma_alloc_chan_resources(struct dma_chan *chan) static void sdma_free_chan_resources(struct dma_chan *chan) { struct sdma_channel *sdmac = to_sdma_chan(chan); - struct sdma_engine *sdma = sdmac->sdma; + struct sdma_engine *sdma = to_sdma_engine(sdmac); int channel = sdmac->channel; sdma_disable_channel(sdma, channel); @@ -1022,7 +1026,7 @@ static struct dma_async_tx_descriptor *sdma_prep_slave_sg( unsigned long flags, void *context) { struct sdma_channel *sdmac = to_sdma_chan(chan); - struct sdma_engine *sdma = sdmac->sdma; + struct sdma_engine *sdma = to_sdma_engine(sdmac); int ret, i, count; int channel = sdmac->channel; struct scatterlist *sg; @@ -1123,7 +1127,7 @@ static struct dma_async_tx_descriptor *sdma_prep_dma_cyclic( unsigned long flags) { struct sdma_channel *sdmac = to_sdma_chan(chan); - struct sdma_engine *sdma = sdmac->sdma; + struct sdma_engine *sdma = to_sdma_engine(sdmac); int num_periods = buf_len / period_len; int channel = sdmac->channel; int ret, i = 0, buf = 0; @@ -1201,7 +1205,7 @@ static int sdma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, unsigned long arg) { struct sdma_channel *sdmac = to_sdma_chan(chan); - struct sdma_engine *sdma = sdmac->sdma; + struct sdma_engine *sdma = to_sdma_engine(sdmac); struct dma_slave_config *dmaengine_cfg = (void *)arg; switch (cmd) { @@ -1250,7 +1254,7 @@ static enum dma_status sdma_tx_status(struct dma_chan *chan, static void sdma_issue_pending(struct dma_chan *chan) { struct sdma_channel *sdmac = to_sdma_chan(chan); - struct sdma_engine *sdma = sdmac->sdma; + struct sdma_engine *sdma = to_sdma_engine(sdmac); if (sdmac->status == DMA_IN_PROGRESS) sdma_enable_channel(sdma, sdmac->channel); @@ -1539,7 +1543,6 @@ static int sdma_probe(struct platform_device *pdev) for (i = 0; i < MAX_DMA_CHANNELS; i++) { struct sdma_channel *sdmac = &sdma->channel[i]; - sdmac->sdma = sdma; spin_lock_init(&sdmac->lock); sdmac->chan.device = &sdma->dma_device;