Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp724625pxb; Thu, 21 Jan 2021 19:28:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5vhzpbJE2Rtx/HZ6/dDgT5Fw2er5cPuCb616vHcYvZ0HK+3BcPuy2z2tpPgWEVor3LUri X-Received: by 2002:a17:906:3881:: with SMTP id q1mr1698607ejd.490.1611286109226; Thu, 21 Jan 2021 19:28:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611286109; cv=none; d=google.com; s=arc-20160816; b=Q9xf+QcUJdtYWLBHD/f28CuyT9wMMQ6En9gQBCgLhLTHszxu7uxIw/IgpriqbKxYVf jzDODJBbZkH+L/CJPuNWnuE1MOA4vh/+GcDI6xYwxe99qjmP3JcNYD1iBa3J9g4uRDUA C2ssJKDMP7Db/nTOFmNxZSSIybaBcAPdbeDqxLgWDZMNt21MWmz58zjEJk4+BOeDmNrZ 5DM/PiIU+aTuDw0FLR4qosydyiwrZ2ci+jTyU36cnvN9QNR/vMbxYhWBt3/Jx6UsehGN MFYjsMQEMjpv1g2bRz2zb1hE6qp3LsDcsAkcLXc/0rMvB+8Kc+C23rGBPerCvFQcE8o8 xt+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=uHl38MxIF2SnkIQDM+hVwSbWSGwnRbserqxthYXHezg=; b=IgOYxAZ87oycjHQc2qOtT+vvLs2yEcbpHrXvjpoRU8bn76BSR8DAyyJWmst+YU4vKA v7frBDdZdQ++qO33k9Ql3st/U0xUbnWPqhTYLNNic97VNzhVviR3+HvQfFH7QMwkXUJa EldLXnaKPxov7J6aDmgIcDYIpYu4zwHKdy5RzPt+S2LVtBy9T906beIFJKomdhrMDq4A RXMRLA12AgW+Gn3qrOFHMDrifxce8NIuAMwhVs+boe72vImtVluuuwNA9lU708mCX7N+ dTqWUHikqWKZOAmlDrZNgST6RiMcf9RxzoLFMG6tbHTvGM2xckrcqWGY7jIeb882oXQI xVwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aj.id.au header.s=fm1 header.b=KO663zyD; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=WSeMlxF1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu3si2947848edb.319.2021.01.21.19.28.04; Thu, 21 Jan 2021 19:28:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@aj.id.au header.s=fm1 header.b=KO663zyD; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=WSeMlxF1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726016AbhAVDYx (ORCPT + 99 others); Thu, 21 Jan 2021 22:24:53 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:35509 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbhAVDYv (ORCPT ); Thu, 21 Jan 2021 22:24:51 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 5266C5C0243; Thu, 21 Jan 2021 22:23:45 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 21 Jan 2021 22:23:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=uHl38MxIF2SnkIQDM+hVwSbWSG wnRbserqxthYXHezg=; b=KO663zyD/3pyTPh3b/pPhr2bd0HVJGuaA/lBksmvQP cN7tshvTGCOBs74DqkOpfZYANgKwKcUeUYvmuBbqAFtKH4xTWy2iD4VazUiR9g+5 kv6nHUj2LfapSc2zvx30tZI2qQPCBHM529Bm305pWWAFYLdL2r0JBXpIAQWfOCyw Q+WRtuNapGdfuvyAdVA/oLQEHA0GEjg128g/XxThHUfo/W496wd74hUpFN9/QX3A yHVagsSc0U+NCNwOpMOvnuoAgmB2XU+QYOXXIa962+GgZ4P8gPtjjIk5mXQgPdji KLqLG9oC7UB5Ie2k0bzl/5MGdCpQpqsqWbThHjZXP3IQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=uHl38MxIF2SnkIQDM +hVwSbWSGwnRbserqxthYXHezg=; b=WSeMlxF1oXVSNgcZDTUxOWVIAYmq1AsvW jFQK6rSVcs6L0Bw4ty3WcmVdMKK3nCjB3tQT0Xs+mAnIcwD7toxnTYAGLa6E2JxN 4W4/pm/psWfs5JRczaAzV1D1woDgpIsINAfIsXiJ2r/Mcw6HtcUdk9rU5r6NNQ58 5o2dlDqdo1EPptEMyUqrY8FQGyeenIC7UfQKVb+pDQX2k5E/Kg8KXXkDJm/iVUCD J8P4L9TwLdCBiKrFeHWc7lROX6qVquG/nW40v2UFIDRQ4tyyDB31bbcjfiwEUzi0 lESx1AQrUC0C9AHFS/9ogsiCaC7NWrWJHWGB5ZkFe+pAD2hI6y07w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudehgdehkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomheptehnughrvgifucfl vghffhgvrhihuceorghnughrvgifsegrjhdrihgurdgruheqnecuggftrfgrthhtvghrnh epkefhieffjeevfeevhedtieeihfefvdejledvvddthefftedujeethfeuueelfedtnecu kfhppedvtdefrdehjedrvdduhedrvdefvdenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvfiesrghjrdhiugdrrghu X-ME-Proxy: Received: from localhost.localdomain (203-57-215-232.dyn.iinet.net.au [203.57.215.232]) by mail.messagingengine.com (Postfix) with ESMTPA id 18841108005B; Thu, 21 Jan 2021 22:23:40 -0500 (EST) From: Andrew Jeffery To: linux-mmc@vger.kernel.org Cc: adrian.hunter@intel.com, ulf.hansson@linaro.org, joel@jms.id.au, linux-aspeed@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, brendanhiggins@google.com, Randy Dunlap Subject: [PATCH] mmc: sdhci-of-aspeed: Fix kunit-related build error Date: Fri, 22 Jan 2021 13:53:34 +1030 Message-Id: <20210122032334.3663056-1-andrew@aj.id.au> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Randy found that with the following Kconfig settings we have duplicate definitions (e.g. __inittest()) in sdhci-of-aspeed due to competing module_init()/module_exit() calls from kunit and driver the itself. ``` CONFIG_MMC_SDHCI_OF_ASPEED=m CONFIG_MMC_SDHCI_OF_ASPEED_TEST=y ``` Conditionally open-code the kunit initialisation to avoid the error. Fixes: 7efa02a981d6 ("mmc: sdhci-of-aspeed: Add KUnit tests for phase calculations") Reported-by: Randy Dunlap Signed-off-by: Andrew Jeffery --- drivers/mmc/host/sdhci-of-aspeed-test.c | 9 ++++++++- drivers/mmc/host/sdhci-of-aspeed.c | 27 ++++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/host/sdhci-of-aspeed-test.c b/drivers/mmc/host/sdhci-of-aspeed-test.c index 34070605b28b..e5edda6c6e60 100644 --- a/drivers/mmc/host/sdhci-of-aspeed-test.c +++ b/drivers/mmc/host/sdhci-of-aspeed-test.c @@ -95,4 +95,11 @@ static struct kunit_suite aspeed_sdhci_test_suite = { .name = "sdhci-of-aspeed", .test_cases = aspeed_sdhci_test_cases, }; -kunit_test_suite(aspeed_sdhci_test_suite); + +static struct kunit_suite *aspeed_sdhci_test_suite_array[] = { + &aspeed_sdhci_test_suite, + NULL, +}; + +static struct kunit_suite **aspeed_sdhci_test_suites + __used __section(".kunit_test_suites") = aspeed_sdhci_test_suite_array; diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c index 3b0d381e1215..1446f23a2bfb 100644 --- a/drivers/mmc/host/sdhci-of-aspeed.c +++ b/drivers/mmc/host/sdhci-of-aspeed.c @@ -556,6 +556,10 @@ static struct platform_driver aspeed_sdc_driver = { .remove = aspeed_sdc_remove, }; +#if defined(CONFIG_MMC_SDHCI_OF_ASPEED_TEST) +#include "sdhci-of-aspeed-test.c" +#endif + static int __init aspeed_sdc_init(void) { int rc; @@ -566,7 +570,20 @@ static int __init aspeed_sdc_init(void) rc = platform_driver_register(&aspeed_sdc_driver); if (rc < 0) - platform_driver_unregister(&aspeed_sdhci_driver); + goto cleanup_sdhci; + +#if defined(CONFIG_MMC_SDHCI_OF_ASPEED_TEST) + rc = __kunit_test_suites_init(aspeed_sdhci_test_suites); + if (rc < 0) { + platform_driver_unregister(&aspeed_sdc_driver); + goto cleanup_sdhci; + } +#endif + + return 0; + +cleanup_sdhci: + platform_driver_unregister(&aspeed_sdhci_driver); return rc; } @@ -574,15 +591,15 @@ module_init(aspeed_sdc_init); static void __exit aspeed_sdc_exit(void) { +#if defined(CONFIG_MMC_SDHCI_OF_ASPEED_TEST) + __kunit_test_suites_exit(aspeed_sdhci_test_suites); +#endif + platform_driver_unregister(&aspeed_sdc_driver); platform_driver_unregister(&aspeed_sdhci_driver); } module_exit(aspeed_sdc_exit); -#if defined(CONFIG_MMC_SDHCI_OF_ASPEED_TEST) -#include "sdhci-of-aspeed-test.c" -#endif - MODULE_DESCRIPTION("Driver for the ASPEED SD/SDIO/SDHCI Controllers"); MODULE_AUTHOR("Ryan Chen "); MODULE_AUTHOR("Andrew Jeffery "); -- 2.27.0