Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B172C7EE39 for ; Fri, 3 Mar 2023 15:01:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231423AbjCCPBB (ORCPT ); Fri, 3 Mar 2023 10:01:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231337AbjCCPAz (ORCPT ); Fri, 3 Mar 2023 10:00:55 -0500 Received: from new1-smtp.messagingengine.com (new1-smtp.messagingengine.com [66.111.4.221]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7EBC62DAD; Fri, 3 Mar 2023 07:00:49 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id 76ECD58206E; Fri, 3 Mar 2023 09:35:32 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 03 Mar 2023 09:35:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1677854132; x=1677861332; bh=EhQ9pFjZXP4HTv7ya9gpFDV+YiUqRp+E8wi r3tCHXho=; b=I1headauudJSswX9EvaMaMq8BcWzxWf1GaVo8Wlw4FdySSolnyJ TA6uUxYnw+dJBczt/cQHmUGM0xE1M/w2OmW+SnSGEpJTCzVCCo1pUuq2F155BLp8 u27ubW7A0hzJmJsej7z8xMbyZVV89dMs9I10LaSzt5PYlFi8duBYsojDOBz/xBZy MRrjwGMGgPdEE3riBCJM8SIfAYTpSK9nfM2qRwrc4YiK4xBq697RlT46sceAib5y J8Mi7v6p/BMKMyQJ8PIXgdAp9BaNCb7/ZrCW2+vHgeRlkmTeJPysYO5kNI8x35wE 2g1myqJgxY6PPJtNNV+h8NnlBspDFm2i9qA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1677854132; x=1677861332; bh=EhQ9pFjZXP4HTv7ya9gpFDV+YiUqRp+E8wi r3tCHXho=; b=Trcg1C7+2n3zXd+Vk5nrLVQ9hvyeM23w9il2QRgPkTdtwBHNmOY RBkjbOHXWpfW2xJq902uqJFWcD5y6HST8uXHKuSVc6vh94yH3dkKID70ma+RbsCf 6py3z7vMm7lXNxi5wJwH742NhN0NP+XGurZkPMIkPD9BxYMBy1dRZlDqhJNbjCYh 5iM93OEFXWsBLHexd4tQ+PLnEyhzTG/XHWPEyveRApVtPct8oBY/T9f8OL04Q+xm MNvjkwWl6oLh+hq7EE2lr/GBgboGQIs/ReWQmHph7OYTWwSI+HRsqIjH7+/wunXf RwWL8QZADXkRoAoKITIBqoyqf7hn7P1Pzeg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudelledgiedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggugfgjsehtqhertddttddvnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepiedtueffveeiueeftdduvdffffffgeffgfekiefhleelkedtlefhvefh udduhffgnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrgigihhmvgestggvrhhnohdrthgv tghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 3 Mar 2023 09:35:30 -0500 (EST) Date: Fri, 3 Mar 2023 15:35:28 +0100 From: Maxime Ripard To: David Gow Cc: Stephen Boyd , Michael Turquette , linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, patches@lists.linux.dev, Brendan Higgins , Greg Kroah-Hartman , "Rafael J . Wysocki" , Richard Weinberger , Anton Ivanov , Johannes Berg , Vincent Whitchurch , Rob Herring , Frank Rowand , Christian Marangi , Krzysztof Kozlowski , devicetree@vger.kernel.org, linux-um@lists.infradead.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Subject: Re: [PATCH 3/8] kunit: Add test managed platform_device/driver APIs Message-ID: <20230303143528.2dovipmqlms74vp2@houat> References: <20230302013822.1808711-1-sboyd@kernel.org> <20230302013822.1808711-4-sboyd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 03, 2023 at 03:15:31PM +0800, David Gow wrote: > On Thu, 2 Mar 2023 at 09:38, Stephen Boyd wrote: > > > > Introduce KUnit resource wrappers around platform_driver_register(), > > platform_device_alloc(), and platform_device_add() so that test authors > > can register platform drivers/devices from their tests and have the > > drivers/devices automatically be unregistered when the test is done. > > > > This makes test setup code simpler when a platform driver or platform > > device is needed. Add a few test cases at the same time to make sure the > > APIs work as intended. > > > > Cc: Brendan Higgins > > Cc: David Gow > > Cc: Greg Kroah-Hartman > > Cc: "Rafael J. Wysocki" > > Signed-off-by: Stephen Boyd > > --- > > > > Should this be moved to drivers/base/ and called platform_kunit.c? > > The include/kunit/platform_driver.h could also be > > kunit/platform_device.h to match linux/platform_device.h if that is more > > familiar. >=20 > DRM has a similar thing already (albeit with a root_device, which is > more common with KUnit tests generally): > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/i= nclude/drm/drm_kunit_helpers.h >=20 > But that's reasonably drm-specific, so it makes sense that it lives > with DRM stuff. platform_device is a bit more generic. I'd be very happy to get something from the core to address the same thing. I think the main thing we needed that isn't covered by this patch is we wanted the device to be bound to its driver, so with probe being called before calling the test (see 57a84a97bbda). Maxime