From patchwork Mon Jan 25 15:50:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8110191 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B16959F859 for ; Mon, 25 Jan 2016 15:51:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C401B2034A for ; Mon, 25 Jan 2016 15:51:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BF40420172 for ; Mon, 25 Jan 2016 15:51:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932951AbcAYPvI (ORCPT ); Mon, 25 Jan 2016 10:51:08 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:54830 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932889AbcAYPvF (ORCPT ); Mon, 25 Jan 2016 10:51:05 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0M2dAz-1a5NDL3iPV-00sO6N; Mon, 25 Jan 2016 16:50:35 +0100 From: Arnd Bergmann To: Ulf Hansson Cc: linux-arm-kernel@lists.infradead.org, Peter Ujfalusi , Arnd Bergmann , Kishon Vijay Abraham I , Andreas Fenkart , Tony Lindgren , Roger Quadros , linux-mmc@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mmc: omap_hsmmc: don't print uninitialized variables Date: Mon, 25 Jan 2016 16:50:20 +0100 Message-Id: <1453737031-1959584-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:l2vviwc4lcmyUGkpg4niSosFS17hccUcsezF+SXNbvF34QdQ76t GAxipn1bx2oI8aZVcO/CXPmSoFhfQM7Z2uq39mcng66/U17ZTP26MK60yJGlHTfNgbrkaAw F98zjwYiiEVrsBo0gfEpTz9zV4Isr+0av0k1QfdO/oxmntqQCsumBbmOavBvkhiSrOkUCpe YVwxDgkF0HJq2x/l04k9A== X-UI-Out-Filterresults: notjunk:1; V01:K0:qSkd/Nv/MbI=:K4gcwtiaHTSohsv1GCUFSd f5FqJpkhszTiDcQqfgw+UKlR3D4IAJeyGqje9KDB4xeMFrJU52bfUUtjvxaX6vvXJVy6dTvD1 AySe6C9RWV3qyywkf10oF2FGfH28DIYRUKlUmvN+ZHwY3wNCsK2q5CJj7HlpW+/Titn9u+4/6 VLuztL7oSxcDEFdPI07d+/qvxFEEOJkAgzQQnh5dcWtzpTb/XKs9X9QpLrARDXfXB6C+Bj6m/ mCIUTXV5FXQe1uNxPxccDZONeCx0paMlqUcp126G6MNTbheIpGciLvoz2edRqEs1ocguipzoT PmGcg5X5M9oKNbih64+GFUWKSESXySkprHJzbO55Wm/blVHuVPJHEBMqgcAL5quKwgVNM3cGv fjDDzMpeEWrIrYjb9Bxe8bTegapPbHhWTUlflei+hzgf57cNNutf9Hu+dlUYWjg3HO6qtcVwq 1lIgSr5iGuKMR8IUPNG8aKuL3a33581ad31sZJeyoMuo3XvBIPTN2ylU0FswvFQoiqNRmapHS dxpFW46N6/YtDh92mdiGdNkYK3YbGNAYeKiB9T+heMgsWuR7UqxCL1P6NPxSQOups3wDIX01K Mlu1ExT9FOb4fBQ57ZWIakLyMuG0Lua+hxzWSr2MJR1T0Qb9uY/HqfDdJjydiKNB5xGBtWttd NEeV9PEuEto7MIn6k1QsSRoAC3aKgPFdr9JqKBLVfn3ynntpkHeYCo5mguM3ZfV965as= Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 When DT based probing is used but the DMA request fails, the driver will print uninitialized stack data from the rx_req and tx_req variables, as indicated by this warning: drivers/mmc/host/omap_hsmmc.c: In function 'omap_hsmmc_probe': drivers/mmc/host/omap_hsmmc.c:2162:3: warning: 'rx_req' may be used uninitialized in this function [-Wmaybe-uninitialized] dev_err(mmc_dev(host->mmc), "unable to obtain RX DMA engine channel %u\n", rx_req); This restructures the function to separate the simple DT probe from the more complex platform data code path, and only prints the information that is actually available and needed in case of an error, which makes it nicer to read and avoids the warning. Signed-off-by: Arnd Bergmann --- drivers/mmc/host/omap_hsmmc.c | 48 +++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index b6639ea0bf18..e06b1881b6a1 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -2002,8 +2002,6 @@ static int omap_hsmmc_probe(struct platform_device *pdev) struct resource *res; int ret, irq; const struct of_device_id *match; - dma_cap_mask_t mask; - unsigned tx_req, rx_req; const struct omap_mmc_of_data *data; void __iomem *base; @@ -2133,7 +2131,17 @@ static int omap_hsmmc_probe(struct platform_device *pdev) omap_hsmmc_conf_bus_power(host); - if (!pdev->dev.of_node) { + host->tx_chan = dma_request_slave_channel(&pdev->dev, "tx"); + host->rx_chan = dma_request_slave_channel(&pdev->dev, "rx"); + if (!host->tx_chan || !host->rx_chan) { + dma_cap_mask_t mask; + unsigned tx_req, rx_req; + + dev_err(mmc_dev(host->mmc), "falling back to manual DMA configuration\n"); + + dma_cap_zero(mask); + dma_cap_set(DMA_SLAVE, mask); + res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx"); if (!res) { dev_err(mmc_dev(host->mmc), "cannot get DMA TX channel\n"); @@ -2141,6 +2149,12 @@ static int omap_hsmmc_probe(struct platform_device *pdev) goto err_irq; } tx_req = res->start; + host->tx_chan = dma_request_channel(mask, omap_dma_filter_fn, &tx_req); + if (!host->rx_chan) { + dev_err(mmc_dev(host->mmc), "unable to obtain TX DMA engine channel %u\n", tx_req); + ret = -ENXIO; + goto err_irq; + } res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx"); if (!res) { @@ -2149,29 +2163,13 @@ static int omap_hsmmc_probe(struct platform_device *pdev) goto err_irq; } rx_req = res->start; - } - - dma_cap_zero(mask); - dma_cap_set(DMA_SLAVE, mask); - - host->rx_chan = - dma_request_slave_channel_compat(mask, omap_dma_filter_fn, - &rx_req, &pdev->dev, "rx"); + host->tx_chan = dma_request_channel(mask, omap_dma_filter_fn, &rx_req); - if (!host->rx_chan) { - dev_err(mmc_dev(host->mmc), "unable to obtain RX DMA engine channel %u\n", rx_req); - ret = -ENXIO; - goto err_irq; - } - - host->tx_chan = - dma_request_slave_channel_compat(mask, omap_dma_filter_fn, - &tx_req, &pdev->dev, "tx"); - - if (!host->tx_chan) { - dev_err(mmc_dev(host->mmc), "unable to obtain TX DMA engine channel %u\n", tx_req); - ret = -ENXIO; - goto err_irq; + if (!host->tx_chan) { + dev_err(mmc_dev(host->mmc), "unable to obtain RX DMA engine channel %u\n", rx_req); + ret = -ENXIO; + goto err_irq; + } } /* Request IRQ for MMC operations */