From patchwork Wed Apr 3 19:30:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabien Parent X-Patchwork-Id: 10884383 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C642217EE for ; Wed, 3 Apr 2019 19:31:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB2BD289C9 for ; Wed, 3 Apr 2019 19:31:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F0CA289E0; Wed, 3 Apr 2019 19:31:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9EAA9289D0 for ; Wed, 3 Apr 2019 19:31:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=j0I4GN7T/dYuLHn1fPuWybUDpFnLasKM1rROEYSFWO8=; b=F4L1L2u40gn2l5 ZRRb4hUTO7slsHEO0MM0rRg3KNy33Gnlhpvq1xEzrBmHLcOJcSBWcKbTfkgX8ymwgNSzPh76nzO8+ 7IgUaUjD5qGYMoWzzlDQ2D72HwxPPr0Fba1ly+3pv9lZmkc3KQrb2eazpexvvJhKXeqjHliSMHYeP yM4KQC9P0jSp+p2OBK04NDhpXxoBsPO2YLn1cHtEsDQ1glUN2YRBNJPX/ZizD/zGVpJjG4+X5q/TA BNpnvlG6eFO93rA3pq0C1LIEztT/tdgXpeZ30hbwA4JloZ84N7HkprPiZ9mEVzDpYD3+qe0xidxPd p1T5dqgfL+03oQ9NZpig==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hBlbR-0003ot-2o; Wed, 03 Apr 2019 19:31:17 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hBlbJ-0003X8-1U for linux-mediatek@lists.infradead.org; Wed, 03 Apr 2019 19:31:11 +0000 Received: by mail-wm1-x342.google.com with SMTP id w15so148544wmc.3 for ; Wed, 03 Apr 2019 12:31:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aZ6nhP8EEvRrGgjeId6P3h0pAV4TUVp+Qlnq4Pegj+s=; b=d5QVtuIA+GDJ3XsaxVBikq5dk0IPw6gI6R2qT4aM0jkXbwsMblfgSxgZmIiECgguzt dHRUS2WrP4RDodZ6+pP4RBAZzt3oICrqrtZPq/57AQJJFAuis2x6DpOJbaH+DdgDE2ye uanm40AccvGVRV03faSGfdwcPwhoo2qWiZCJFN3pEAH9u8hGYIKFW4AkzHpRe1WCTOmq yrfr6AKg5fd04B7/CbOwPcJe3z3ZrtNdm9GOM3wCSmI0mngtBZtyKpeGwpAdPNI3A/ut BQg+vxGzXrP18zFPkeqaSGFfapJhza4eEmg1xzMPfDcmUyfkMdAA2gMRb+GpbkWcDF5s 2+vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aZ6nhP8EEvRrGgjeId6P3h0pAV4TUVp+Qlnq4Pegj+s=; b=hgUcK1sHx52q69oALdoPZy4cjwMJfPO4va5ayUMjjaqaitev+Gx44XLqUiQmbP8ilf s7U9oS5fdpHMb7QuFm8EdzUBm4EsoT3B67FR0eYoZzyykj1UFOZ6qbAK5IR+4AZRiZdc AG3Xjr6GOU3dr/FAawcfSHoiXHSfSsRROzPJ/sndQ/J/TNCpwu2WmbHET+BA7pu2tlnS WeJyX/JK7d2x3TG9ojTU0uIaUiPuQR/kDOJ5HcdtqBjvRmkboKyQU1mar3HNjJ+v3e7C gX3cuE99KwYfdv3nRGGQNw/e6VJQFrjppKcWlxS0tZWczdN6NtY4CLz4kWjqD2G85Xz4 bT3Q== X-Gm-Message-State: APjAAAWMkNLXviH7lMQLLOwq7KW89JHP427Pdqp97IQhsG0zc5pOU4vd 5A+jRGBKQaj6pNfaHaFFfZs7BA== X-Google-Smtp-Source: APXvYqye6yDqe1YdY5P4GgbBa58ZS+KYbCU4R+pk7DijykRBBYVPQvCXhDXtfPAX1fwcPBD9Idhn+A== X-Received: by 2002:a7b:cb04:: with SMTP id u4mr1302892wmj.0.1554319866395; Wed, 03 Apr 2019 12:31:06 -0700 (PDT) Received: from localhost.localdomain (cag06-8-78-203-165-84.fbx.proxad.net. [78.203.165.84]) by smtp.gmail.com with ESMTPSA id t74sm672463wmt.3.2019.04.03.12.31.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 12:31:05 -0700 (PDT) From: Fabien Parent To: ulf.hansson@linaro.org, matthias.bgg@gmail.com, yingjoe.chen@mediatek.com Subject: [PATCH v2] mmc: mtk-sd: check for valid optional memory resource Date: Wed, 3 Apr 2019 21:30:50 +0200 Message-Id: <20190403193050.22180-1-fparent@baylibre.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190403_123109_145598_CD4BD965 X-CRM114-Status: GOOD ( 10.65 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ryder.lee@mediatek.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Fabien Parent , linux-mediatek@lists.infradead.org, jjian.zhou@mediatek.com, chaotian.jing@mediatek.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 'top_base' memory region is optional. Check that the resource is valid before using it. This avoid getting a "invalid resource" error message printed by the kernel. Signed-off-by: Fabien Parent --- V2: Fix invalid condition: check against 'res' variable instead of 'ret'. --- drivers/mmc/host/mtk-sd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c index 833ef0590af8..61bf8704491c 100644 --- a/drivers/mmc/host/mtk-sd.c +++ b/drivers/mmc/host/mtk-sd.c @@ -2123,9 +2123,11 @@ static int msdc_drv_probe(struct platform_device *pdev) } res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - host->top_base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(host->top_base)) - host->top_base = NULL; + if (res) { + host->top_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(host->top_base)) + host->top_base = NULL; + } ret = mmc_regulator_get_supply(mmc); if (ret)