Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3811719pxb; Tue, 26 Jan 2021 05:33:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwC2hvLmp+/obN21o+OzQ4sEbvTmhNnJfcPN2OliPZiHDJrkpIR8yvifUv3QWZw+gcBCPfS X-Received: by 2002:a17:906:409:: with SMTP id d9mr3345158eja.70.1611668008899; Tue, 26 Jan 2021 05:33:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611668008; cv=none; d=google.com; s=arc-20160816; b=xTHf5vwFNZZSGmiXa2NgCdmO8i9OFJAk+VQ3eEP9U20vQha2l3n/jDMIzCO3Ar3Qyd 1qW4wZnYqWSbwd3GuOeMwzfqxJAg5PNt10YgGNDsMWsfadNKahoJfGMJlTWuHyUaqdNx z+03oDOHjr9OYDhVztvBlYQmYB69me9bIqYIt8TQapKEdfLjFXDpRB1bUK7JXvMnumjh LcZA6HUxdnYZppeusPmHFeEYiUHdQ+4ULlZlDDWe2U0/DLSHoIPEunVLMLOzero3PK8k s0LFuQsnJCj3H23r3bMhS0fis8BK4NOSstaMOBCBctSJt1RtVOrOldrMigEv+S66LW8U BvRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=pE2rA9pdzYN1jBerf3WiNVIJAFytpn0jAo9ZFgxO1/M=; b=yPThPrUr7dlL/ZySS65BK1ixsw/gc1RNPaiPgYTVZ1lHNbV91847/Upa9LP/dUTTZE s2hhYv3Lxb248uQs+la7VXLexw4tFA1gabQuluHivrl8HawLXmuKbIJ3HgSM1btRMvMM HuK1Cedl7cQ1U1BDuf9MNpRMAizJPMBhnsxIGJHOTGvYup/SCPO66a1JfkoEwW+uDU8l /8czqemrMMw1/gqCPB1CMqAYkLB/QitNiRqOK5XJ0HtC+Cu7e+FyDl5rpXXarUXwheaS 9t17tFQ4LHfz7T5JGi8TpblZeMaQsbqIbo2TX3tZrHF80SPWtcmxH4e3+2uXXDY9J5vU FC0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PWynW+CX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q17si6937757ejd.397.2021.01.26.05.33.01; Tue, 26 Jan 2021 05:33:28 -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=@linaro.org header.s=google header.b=PWynW+CX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404591AbhAZN3j (ORCPT + 99 others); Tue, 26 Jan 2021 08:29:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391754AbhAZJ7F (ORCPT ); Tue, 26 Jan 2021 04:59:05 -0500 Received: from mail-ua1-x934.google.com (mail-ua1-x934.google.com [IPv6:2607:f8b0:4864:20::934]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0244C0613D6 for ; Tue, 26 Jan 2021 01:58:24 -0800 (PST) Received: by mail-ua1-x934.google.com with SMTP id 43so5396145uag.12 for ; Tue, 26 Jan 2021 01:58:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pE2rA9pdzYN1jBerf3WiNVIJAFytpn0jAo9ZFgxO1/M=; b=PWynW+CXh4hXQAiqu5QjPRxngJOpBWu8mFFfD1LOUterEjJP2JA3bcmpjyDxfsJj1v CxlZ80374cIpax4j4WcF1MhZYkttvyOzEW6oo8S7X9BwVgxxCfBSSUWjBMPZMJzs9PEA N660RJ5CFORLMi7jxTE7YVPH1CRRn3Ozv/qDV2pUR6s9MOQd0pOW3S9TH5r1R2kyoo1M vSGf3ptxoVDugLJnGO1LhyqQKJp7HxV6iRFqOfZNLAuA29sKSDrublGMOiflxafyVhZo lcg1wkryF89SBr5FKK0X+vPIOcjiIocWH1iqYizURpvpd5ZR61qnz63iYdQZVabFx1Db TdzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pE2rA9pdzYN1jBerf3WiNVIJAFytpn0jAo9ZFgxO1/M=; b=XPbksreJXGZdvBDfZIM1+EoiDnHnhFdc06vPJ9gG9rU76BjRq7XJAl3JvWrgyhe/ky X93egl7iLrHA7VKpycFU83HMiD8nZLT84UX6S3ovWe+0BSH/nwt87AxoHtS8aRK1Dg7y UdJs0BKkGvEiGqlSKnXewkAQO75Mw/u0/juAH4/RlPNl6+uyfGw9vHCry/fmLJWFEbXw 3eh52u0h+EIb0RBbbXnHc70gTywI1z7btoe02c2LDfgeIk0/b91j1xJo8b4bssRxaUU+ N8rjB3NePtZnaIKNp3gxhR6Y+Y/ypWUmZHJtYu957pxoKuTaWMNnQh7il+W1GE4KAxmx kc/w== X-Gm-Message-State: AOAM531o9Ba26yuPZNpylcpKqNKUwlMyBYYMGchlzFvjm2O3wUAJMqid JsUc0xOqyuj9YRvKmCgIuFBYa5MDpp9vmJmCQZfBFg== X-Received: by 2002:a9f:2271:: with SMTP id 104mr3460350uad.15.1611655103984; Tue, 26 Jan 2021 01:58:23 -0800 (PST) MIME-Version: 1.0 References: <20210122114852.3790565-1-andrew@aj.id.au> In-Reply-To: <20210122114852.3790565-1-andrew@aj.id.au> From: Ulf Hansson Date: Tue, 26 Jan 2021 10:57:47 +0100 Message-ID: Subject: Re: [PATCH v2] mmc: sdhci-of-aspeed: Fix kunit-related build error To: Andrew Jeffery Cc: "linux-mmc@vger.kernel.org" , Adrian Hunter , Joel Stanley , linux-aspeed , Linux ARM , Linux Kernel Mailing List , Brendan Higgins , Randy Dunlap Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 22 Jan 2021 at 12:49, Andrew Jeffery wrote: > > 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 Applied for next, thanks! Kind regards Uffe > --- > > v2: > * Collapse the #ifdef-ery > > drivers/mmc/host/sdhci-of-aspeed-test.c | 9 +++++- > drivers/mmc/host/sdhci-of-aspeed.c | 42 ++++++++++++++++++++++--- > 2 files changed, 45 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..bb67d159b7d8 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_sdc_test_suite_array[] = { > + &aspeed_sdhci_test_suite, > + NULL, > +}; > + > +static struct kunit_suite **aspeed_sdc_test_suites > + __used __section(".kunit_test_suites") = aspeed_sdc_test_suite_array; > diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c > index 3b0d381e1215..7d8692e90996 100644 > --- a/drivers/mmc/host/sdhci-of-aspeed.c > +++ b/drivers/mmc/host/sdhci-of-aspeed.c > @@ -556,6 +556,29 @@ 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" > + > +static inline int aspeed_sdc_tests_init(void) > +{ > + return __kunit_test_suites_init(aspeed_sdc_test_suites); > +} > + > +static inline void aspeed_sdc_tests_exit(void) > +{ > + __kunit_test_suites_exit(aspeed_sdc_test_suites); > +} > +#else > +static inline int aspeed_sdc_tests_init(void) > +{ > + return 0; > +} > + > +static inline void aspeed_sdc_tests_exit(void) > +{ > +} > +#endif > + > static int __init aspeed_sdc_init(void) > { > int rc; > @@ -566,7 +589,18 @@ 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; > + > + rc = aspeed_sdc_tests_init(); > + if (rc < 0) { > + platform_driver_unregister(&aspeed_sdc_driver); > + goto cleanup_sdhci; > + } > + > + return 0; > + > +cleanup_sdhci: > + platform_driver_unregister(&aspeed_sdhci_driver); > > return rc; > } > @@ -574,15 +608,13 @@ module_init(aspeed_sdc_init); > > static void __exit aspeed_sdc_exit(void) > { > + aspeed_sdc_tests_exit(); > + > 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 >