Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp938019pxb; Fri, 22 Jan 2021 03:09:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFEsJpVNQ+OhcC1kOP3vyrNJa/bzQkQjR2EoGGHb2QDs/Vdi5AkMffMqr2OJ0Ow90ZnVpR X-Received: by 2002:a05:6402:1751:: with SMTP id v17mr2821070edx.289.1611313756870; Fri, 22 Jan 2021 03:09:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611313756; cv=none; d=google.com; s=arc-20160816; b=qd9/DyZUC2BFyKBo4DUYnk6mcMkIXW9DBo2TiraeukFw8w+/gjjf9bCXRCTSIe2spo ZXjz0UKVXlPWsc6rkvoaeNWyy0RwdFaXVAN0RyqIeEzIS8/+l0/4H0IimW6cPXBng6Vr ZJ1Ps/NZSDDvoJDYn3u+JKHzTU6re/f1xA/asqKmhi7GD6EdrHxFii7DHIwOB7D9RqKp qGzTZyHuNb4xDvg9KtwNqWbAMHwuj0KBGefjB5vlCMUnrYmiAY8hfEl6SvrU74v9nIvz c9Mf+Qq0rIUmNTSI1QCTCEWI0XVFI9vW10JVZEf1wtXFtVfJjFNNUugyl2L4qv2ZAh/E Ezng== 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=l1OaG7ryvioLgmZ8BmwevSwg84t2pSQg8vMbP0+UiP0=; b=EZUZOwdWOikNq6yW9Ni5eW5e76JLwfT0tv2CYeQRkVDlNIDwT0cIVN3UZkoxEJcccx 1DPS15fOM8HlBR9TVpGpyYfrA3mto/clHI4YRIlVHfYpfgG1edqh9YjjMW7cE1w1btOF qOGC+CvieC25ddw3ipx3Yv00BdWTy9GwnIohPVxnctZjkMlrdRiRWfouQl2fPwKG/v14 bbvDaPCJIZ9mN70EvfHV4Ir8M5B0/dWlK0dCjRe0d+KDRWdoNi+/C6dDxNVePldeT9xW eUxbVBKNPIzwkCLjKqDjdchi8kufnYYdi2dxci2xzgM6/4NGBuLeTK7HajIALhwmkxJ2 g4hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FzdovL8p; 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 o32si3594108edd.357.2021.01.22.03.08.51; Fri, 22 Jan 2021 03:09:16 -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=FzdovL8p; 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 S1727270AbhAVLGr (ORCPT + 99 others); Fri, 22 Jan 2021 06:06:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727142AbhAVJ1n (ORCPT ); Fri, 22 Jan 2021 04:27:43 -0500 Received: from mail-ua1-x930.google.com (mail-ua1-x930.google.com [IPv6:2607:f8b0:4864:20::930]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7150C0613D6 for ; Fri, 22 Jan 2021 01:27:02 -0800 (PST) Received: by mail-ua1-x930.google.com with SMTP id y21so1626520uag.2 for ; Fri, 22 Jan 2021 01:27:02 -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=l1OaG7ryvioLgmZ8BmwevSwg84t2pSQg8vMbP0+UiP0=; b=FzdovL8pedW1EGTRQAn5/nzwscKjRd9z22SyVGPQQ9V1RYg2rGHC0PnaiCqw4mTrbZ xIkeDXRsHnyL3bgoPYVgbcPH1owFWTiHaMTCaz6Ltz5A9owQx3y7yZV8tYoAcBr0czFR yUEj0IIoSpbRwoElxpNolfOzbglz6y4y64VlKbHixYwIhnfPH9micI3AwPB4aInHABpH GY1R8+rI5lyU24Y+4h59p6x4/jDP2yrBmAyRhnaLhF1FdEERsj5wgZjtnTCr1yJVz+lf EBcvS6XVBQ9LNb3T1GwxcmKWrx+Ljh9+KdQa9fz/Qj5ncQtP68hmDLOyj4V13OyciKuy k5Yw== 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=l1OaG7ryvioLgmZ8BmwevSwg84t2pSQg8vMbP0+UiP0=; b=niKuXL29yPujCi4b9c7IUYUpAk1nVA866w7XbOinHh+OhS3dfMwJkFMvMpD/j2yLMR 4zTbSMCA94PfMzOkIKcqYUWakBnhhVwY9nyALFRVMD2oGN9320ql9GTxew1dDgaDtOGp kf+tcaqiY5N/9u5DUrK5/0YV2peSyBw2XjfHbyj5lGjJCmgvEHB/44m89K7hT2gnIqJ1 wN0AFjCIndh+s+MBvbNqzlq7gA0KAd9wMnMG9ew85HNwa6oBeSztz1dSbHdmzyMAX2Ix Ms28YcENDBKGeNtdQjk7xadoEI3OBXxPyhQ5c/ZZ+fHs9Vb9K+Q+r6MGT8ZKC8aqxusq kazg== X-Gm-Message-State: AOAM531iIUWKTYfYZraq6R2Kbb2e49LbHxyhQEhiquTNRYWRExTNnuBM NhuNGYVkxxl5i9PhmWIS0LZD3LHlLhXUQFPZnOvngg== X-Received: by 2002:ab0:768:: with SMTP id h95mr2544908uah.104.1611307621937; Fri, 22 Jan 2021 01:27:01 -0800 (PST) MIME-Version: 1.0 References: <20210122032334.3663056-1-andrew@aj.id.au> In-Reply-To: <20210122032334.3663056-1-andrew@aj.id.au> From: Ulf Hansson Date: Fri, 22 Jan 2021 10:26:25 +0100 Message-ID: Subject: Re: [PATCH] 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 , brendanhiggins@google.com, 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 04:23, 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 > --- > 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) I would like us to avoid #if defined" in code like this. Can you instead declare a function that you can stub in case CONFIG_MMC_SDHCI_OF_ASPEED_TEST is unset? > + 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 > Kind regards Uffe