Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp888518rwl; Fri, 24 Mar 2023 03:29:58 -0700 (PDT) X-Google-Smtp-Source: AKy350Z/Cpsre9ouSqENEuMwGR5Nt2auHpMnt6jJfyO1ItH6ygiJxKkkWKxcx/YNM4L+zvlghB+e X-Received: by 2002:a17:906:4b0f:b0:92f:33ca:c9a3 with SMTP id y15-20020a1709064b0f00b0092f33cac9a3mr2044860eju.71.1679653798388; Fri, 24 Mar 2023 03:29:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679653798; cv=none; d=google.com; s=arc-20160816; b=laCxXmmJigFmPV5O5Hb/GHj30a+YBuGKQuzL2KYP4zPJ4LOzceUNCHCLcsuBsH2C7b p4cC8qFHMfUbtTny5EOWv0jo9uEV+HW08OY4aNn1maU5IE8wuG+wkVLkizEq1A0AnRgj 0RLwcOYaMjNt1wSwupmsY/ZQ89v7L7GhTjF3GYvhe8ZAQu0LnV6xC8WqBQ2d8RHtTP+y ls6W0OofCkQY0lWB7GZY5doUEq2uJ4LIlgBjdIibkQgCU35MX1ykM8AH2D0JPOUHKzIx kL3UO7tZqOj6aiVEWoiguC9DE4wzjZdiVQ9ByrHG+vwFdqLu+M2piOxAbNmnk5UsmmIb bZew== 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=zKI80BGooykUH8804XqZbqpXI1kCkxjaQ/+9IzL2Xiw=; b=Upwdy5PWRlV8zdb6axe3DPctredKMNBxzOfPiCwH1nZ7G1b9fVzl3XYDVAUE6iy/sr k4HuaDh7SaCNqGamBktn1XNwPoOu9v+SJtzVWtvmQHz0iG7EiL1npX3hAIExIoRdiSE4 J3guUb1RV7WUrJXi/NFGG4/bXrwsORASGR8EUFbPvW1CVyNK24Lu7IwYqzBeBJM9A1u0 3Q3BaA+stz/4a/0y2kS9sk70IvH7dsff9vNdrCxxuBvGSO/FSXXisYkvLWPlbW5A5Swv dL4q5WV2sliXBNnW2LeMFUCWy8wF450SAUZI0ixLcR0CTk72RhMhdCyTqLEJg/sQTWyr iYcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Kxa+q4AE; 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 d4-20020a50fb04000000b004fef30e1027si19750454edq.621.2023.03.24.03.29.34; Fri, 24 Mar 2023 03:29:58 -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=Kxa+q4AE; 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 S231311AbjCXKRf (ORCPT + 99 others); Fri, 24 Mar 2023 06:17:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229753AbjCXKRe (ORCPT ); Fri, 24 Mar 2023 06:17:34 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72A65136EF; Fri, 24 Mar 2023 03:17:33 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id s8so1532913lfr.8; Fri, 24 Mar 2023 03:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679653051; 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=zKI80BGooykUH8804XqZbqpXI1kCkxjaQ/+9IzL2Xiw=; b=Kxa+q4AEQT1i6IRajV6+FKmGNg92TFnsE6gP+npUIx5KFknE0M5js0opulMYuUKoP1 hhojoDbNZfNRJu0Y1brF9qq2z0bXV95RWJf7/Ox0JDxliXiFtYnPBDvXhdVTAwjlHJZV jOA+hIxZTYT+OW1lHthZDFkBRSe26bC4yrs9mAGGVHgI8HV9IMS4f6GBcXSkAnkpcDGU KahndWPQnDiNwQBPLA7erzgzeaxFl7oIk4v9gU4YpiKS/8y8T3jsz6VLM9G3JnQt+mpt ctg1qKo5TeSkVMpSQjuChZp4n7LFAL/FD18RDYugCyn8TtDbSPsU6H5sEcpaf1/Tt0dV 8YaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679653051; 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=zKI80BGooykUH8804XqZbqpXI1kCkxjaQ/+9IzL2Xiw=; b=b9xlIIKJ4TEa1Dff++QizEHFumk2FGgbT1u1OLi3/Ad/XG3M57bYS9Z412fJn+FYhP MEzW2zT1kPiN+0USZU6nPh26a3s+YQQi6XwPtj7xukRTD9WrpWbLYpauzw+jZtaqYgxs DI8U/3mqB4E2SAE64lSnVPWviNWmJyztQRoUPCIV0VHlGOaAHejmjBPThFICKOHqgkL0 UEslzLRI2P92BUjrYClskAKOfZTXwuq6hSF3Mzzgo6gnJQtjQ+s3qW3+RuEHwIsWvRx9 KLcSB7Hm7eT0d40aQ3QHsOjGs0CKZqXgKtI5yf9/zsK8PvEQl/BHg5qwqncxoxI9uQOE fcbA== X-Gm-Message-State: AAQBX9dfcdShrkZzdumpnOktF7cuJ12lMjey9eSR85DnuXoVkF1NAU3h TQntyZzJkT5DTxN7nu1uEdo= X-Received: by 2002:ac2:530d:0:b0:4e9:a9e6:2752 with SMTP id c13-20020ac2530d000000b004e9a9e62752mr630594lfh.22.1679653051591; Fri, 24 Mar 2023 03:17:31 -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 d24-20020ac25458000000b004eae6283565sm1669239lfn.299.2023.03.24.03.17.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 03:17:31 -0700 (PDT) Message-ID: Date: Fri, 24 Mar 2023 12:17:30 +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 12:05, Matti Vaittinen wrote: > 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. There's one thing though. If the goal is to do a direct replacement and if automatic device deletion upon test completion / test abort is planned - then it should be there also for these initial wrappers. If these wrappers don't yet include the automatic device clean-up - then it probably makes more sense to just do the kunit_root_device_* defines because the tests are likely to need removing the explicit device clean-ups when proper APIs are finished. Yours, -- Matti -- Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~