Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp864646rwl; Fri, 24 Mar 2023 03:07:45 -0700 (PDT) X-Google-Smtp-Source: AKy350aiwzqy+pZ2mNkFLFunK3XCsh/i5ta4rkqGTVwKMMN1tj8RDpFXT5C+RELTGu16axmx3E/x X-Received: by 2002:a05:6402:8d9:b0:4fe:19cb:4788 with SMTP id d25-20020a05640208d900b004fe19cb4788mr2204645edz.42.1679652465401; Fri, 24 Mar 2023 03:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679652465; cv=none; d=google.com; s=arc-20160816; b=tXiFWn062zQx12zIKl+fwBgoGKqjUG70006V5znyiwlLq+N7PoqH8zAZlJfWnbzPvk u/EdI81iXOopuJQnGpu2CGzLm22BhCycHeXBNbenNa/+rhu3bBWNhSFFHQpaZaAERu5K CowdhkDRuYsMmNCkI2oDTTOltNIacHufvCntcFgq2bEPhHKJyJe/OByZDH1m+7gWf5sh pO4oHEO+XkLKfLtMWoyfoSzshA4MbuejHJC6dxM3ppLwSNcDcvaRkdof4E066BjvF9sB Yk25RhibmGoHI2RU/L7xW8FZD0Dr0Us0KsI815lZINUYFl0w0x7j4KUPBbDonqn5XNUc eiGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=d1TdhMKIxAO9718z/MG/SMpXLVDcRq3DxeQ0go+1GVk=; b=aMZE0fSMlNNRinGb4S/g+4oTxJT7nZKXGFdDP+4QJVmL8+Al/+4VFVNslH80pK6QV+ c2uqkiReZy47hoRV2FoYq7rEYo3m852h6lpxAPbY6Ae4ombLwdh9zPDW08zs8rwRXkDc me+vLE10lWLaf545JfuLQ1MlFjQHj5CQ2UFvKIVKcUCHsuJm1o8kc9Z6CfgfhQAJE1hc Dof8KZMV6tYLz7Vjx5aPi9PdWyRdcgp6txNYEh5Fgws1Q5ZQBJ2QM2iYMakNciF29qgz 9jLYhkv3Vtk7mbAFtu7LY2reOv61QkJiNKD4/5ED29gzkwJwnmmf11Mwf3tnhdN2yIDi 97Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RaLPMMFO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d13-20020aa7d68d000000b004fc63fada98si20583483edr.30.2023.03.24.03.07.16; Fri, 24 Mar 2023 03:07:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RaLPMMFO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231539AbjCXKFW (ORCPT + 99 others); Fri, 24 Mar 2023 06:05:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231520AbjCXKFU (ORCPT ); Fri, 24 Mar 2023 06:05:20 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D5171C7DA; Fri, 24 Mar 2023 03:05:17 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id h9so1136748ljq.2; Fri, 24 Mar 2023 03:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679652315; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=d1TdhMKIxAO9718z/MG/SMpXLVDcRq3DxeQ0go+1GVk=; b=RaLPMMFOyaI9u8rXGs0GTWVtWsWGaGWiknbmvXNAyp1jvuaq02QNOtzfoG/9zL8hfG NTE2EJO+C4FO5KR6p6SoS9JhYJxgS3UUTy06LVP1Xk/gio6G2gLUtnKAZQAEJSlX1AiO lo58C74R5ASAxTd0dFFtxt/V8YQXRC+SQWK3A8UwbnzTGTSEUf+J92PTILDVD+cknn+U GhnoHc1hwDS6SPcBf1rliwymo6FsPhlCB4wmx9NELGbAtoGSjNQSPWs2sMk7QXlXqqKL J42HzuQ129aA0BklN+546KpN4Y15rDA8zcfmdj2Gbz3zh+CaYlRmPTbpJ7Qj5+MLdc2v +SEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679652315; h=content-transfer-encoding:in-reply-to:subject:from:references:cc:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=d1TdhMKIxAO9718z/MG/SMpXLVDcRq3DxeQ0go+1GVk=; b=scQ4YNLR13Ua2ZB1U0qB6SL2eCwrpgIX8eRlJUE3hsDFe3NcKld+Olw4MdIiTBgZDJ kbo4heMa4nHv9qtwfHqctwy1gtl+bhuIvZK5DISoEbbqxNS976vadTotb31HA7KF9Jcl hl8IAcEEAMGB9GGQ1wTpP4fozkxOzDV7vRfYhWHqRAMOcJDxOFzKb7rtDTFtG+hlcwsX S9aMNnGWZD7RPsCb18iCJl6ySLqyCC7AJpVoEPOfJPHlXPYiqLIp0IBsgBepGkuUo/J6 s5JohBl7aZKOD9s2miavi8gB7SeQVPlcDFM/Z7d1vj4l1J1DrbXsIDaKlSihYnGbJd30 gZBg== X-Gm-Message-State: AAQBX9fHwqvxHIve6H8MB2iJyI2FgV/kJvzC9GYioZMD49ijW47bw4D+ OBgPZZOsn34e4YXcMl3q4BoQbRjvIGs= X-Received: by 2002:a2e:7003:0:b0:29d:286a:4502 with SMTP id l3-20020a2e7003000000b0029d286a4502mr665455ljc.23.1679652315182; Fri, 24 Mar 2023 03:05:15 -0700 (PDT) Received: from ?IPV6:2001:14ba:16f3:4a00::1? (dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::1]) by smtp.gmail.com with ESMTPSA id z21-20020ac24195000000b004dc4b00a1eesm3315584lfh.261.2023.03.24.03.05.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 03:05:14 -0700 (PDT) Message-ID: Date: Fri, 24 Mar 2023 12:05:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: en-US, en-GB To: David Gow Cc: Maxime Ripard , Greg Kroah-Hartman , Matti Vaittinen , "Rafael J. Wysocki" , Brendan Higgins , Andy Shevchenko , Heikki Krogerus , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Stephen Boyd , Jonathan Cameron , linux-iio@vger.kernel.org References: <25f9758f-0010-0181-742a-b18a344110cf@gmail.com> <20230323101216.w56kz3rudlj23vab@houat> <8a03a6fb-39b9-cd17-cc10-ece71111357d@gmail.com> <20230323122925.kqdnomr7i46qnyo4@houat> <590189b3-42d9-ab12-fccd-37338595cb6f@gmail.com> <20230323163639.xtwpid2uunwnzai4@houat> <97f60824-7067-62cc-2882-d998072886ce@gmail.com> From: Matti Vaittinen Subject: Re: [PATCH v5 1/8] drivers: kunit: Generic helpers for test device creation In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/24/23 11:52, David Gow wrote: > On Fri, 24 Mar 2023 at 14:51, Matti Vaittinen wrote: >> >> On 3/24/23 08:34, David Gow wrote: >>> On Fri, 24 Mar 2023 at 14:11, Matti Vaittinen wrote: >>> I think that sounds like a good strategy for now, and we can work on a >>> set of 'generic helpers' which have an associated bus and struct >>> kunit_device in the meantime. If we can continue to use >>> root_device_register until those are ready, that'd be very convenient. >> >> Would it be a tiny bit more acceptable if we did add a very simple: >> >> #define kunit_root_device_register(name) root_device_register(name) >> #define kunit_root_device_unregister(dev) root_device_unregister(dev) >> >> to include/kunit/device.h (or somesuch) >> >> This should help us later to at least spot the places where >> root_device_[un]register() is abused and (potentially mass-)covert them >> to use the proper helpers when they're available. >> > > Great idea. > > The code I've been playing with has the following in include/kunit/device.h: > > /* Register a new device against a KUnit test. */ > struct device *kunit_device_register(struct kunit *test, const char *name); > /* Unregister a device created by kunit_device_register() early (i.e., > before test cleanup). */ > void kunit_device_unregister(struct kunit *test, struct device *dev); > > If we used the same names, and just forwarded them to > root_device_register() and root_device_unregister() for now > (discarding the struct kunit pointer), then I expect we could just > swap out the implementation to gain the extra functionality. > > It's a little less explicit, though, so I could see the value in using > macros with "root_device" in the name to make the current > implementation clearer, and the eventual change more obvious. I think it makes sense to avoid the mass-conversions if the signatures for kunit_device_register() and kunit_device_unregister() are expected to be known by now. If there is no objections I'll add those wrappers + the include/kunit/device.h to v6 of this series. I think I'll try to hold back sending the v6 until next Monday - unless I get really bored during the weekend ;) Yours, -- Matti -- Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~