Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1040102rwl; Fri, 24 Mar 2023 05:38:26 -0700 (PDT) X-Google-Smtp-Source: AK7set8Q08+BsJPLSYwb/L0VWB83FxvPnrebgHtDXsQhoDNuYd8rcJymwjnbxNWl3b2yTDTjPt67 X-Received: by 2002:a05:6a20:b291:b0:da:717e:6ada with SMTP id ei17-20020a056a20b29100b000da717e6adamr2845091pzb.59.1679661506193; Fri, 24 Mar 2023 05:38:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679661506; cv=none; d=google.com; s=arc-20160816; b=u65HbMXIyzInuO0KE6ieYYbVooFT8/2/jsNva772EHYzZOFROueoLcOACFvqFEJAKa iUIQZn5ZEMOUJlDhTlZrf6upUEKhV+rjuXEz+XyM0Hv59Q0l2v+y8/j7ck2o9AWf6Ouy fNdURz5KF1SOYXZLxs4yLWiEWnmrpraHwCWSiIec+tgJOVcY+1BE61+GJqOZHJovOOmp r4qa1k1JiZz4t2hRC39rnxOaFaOoNbUE1XwdNeYTcgRkwsKGtcTHsdplpmkXIJOJVEH3 8xC736Wg2nr6JOPQH+M8XpNnZCHBNh1uw7sVLyQyqa20x2xNmPJ0Xg9DMQm9wiTgjudG fWrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=afdOnuzoGC2hJ2+nQwyk48eOOUaDI/2Z1f/itKfGaWo=; b=cR3zGxWXvmCYdeaBz8vTmp5cuBJcRouIVnaG/tPgjyEAhFWhQTSBBJD3+MFh3ZFKmm cBDzp+i9Kt4eP6jPTDM9Q624uhxBOU9h0d7iuIV5KBeL+84susJo5fMZWvx5aSh4lF7X eFQJUcPlnh+kWtpHDhlYeWisyIxnwpexT6l4zUmoIwjyCqathQR+I+kBmtcrzrLNPbG5 UR1q/URfvSUO9KdOo0f80vb8Dp8oFLxvvC8Yz/kJ4oKuyPdoVbSrRIMs06YfWpD8mS8M WZ9lG5cGHQkDLoBqG6ZH2/qAO4j69mFW/Rk7SdZIMjjMKlLF56Ff70NZbQK0opzMMFCo 8rdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=Zj2H+tK7; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=TsViZBBd; 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=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s13-20020a63924d000000b0050f6add54fesi15342713pgn.276.2023.03.24.05.38.13; Fri, 24 Mar 2023 05:38:26 -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=@cerno.tech header.s=fm3 header.b=Zj2H+tK7; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=TsViZBBd; 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=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231460AbjCXMgj (ORCPT + 99 others); Fri, 24 Mar 2023 08:36:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231313AbjCXMgi (ORCPT ); Fri, 24 Mar 2023 08:36:38 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C41312F39; Fri, 24 Mar 2023 05:36:37 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id CC28532004ED; Fri, 24 Mar 2023 08:36:34 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 24 Mar 2023 08:36:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc: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=fm3; t=1679661394; x=1679747794; bh=af dOnuzoGC2hJ2+nQwyk48eOOUaDI/2Z1f/itKfGaWo=; b=Zj2H+tK7F7eO6I+zvE 0xVguDgmSQp+fo9etx0v3GaZgfiH85nQGr5z9g1OMrOdDnexZMyNHzMxKhLLKsDm ifGwXC026mGH0O9cm+BLsavrgA103pCTDR9B59UcQHDyxM7CPiA6CJWZCCzPBmNy VpLMxiJ1aBhVCEI7y4Cmvczv8YFwAO4xNfjIotkxJd2btMBz5SgXsNJY1e69ZOzO deyZTnsB28JQrnCXAnRDmlMms5ABY00nCAovD35rRtUVanlo4kPHcEFwvPuQ78Sm vh9seDcht1PdF95NXi0k4/GmSLWNIfEx4V0G8IaV7Jaj1CPHSHNEENfizOh1rFbN 8kBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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=fm2; t=1679661394; x=1679747794; bh=afdOnuzoGC2hJ 2+nQwyk48eOOUaDI/2Z1f/itKfGaWo=; b=TsViZBBdp8szx3UJ/rk9bbUqlm5MJ x0JO7cr6ESljPUGRp8wrccdDHrfGqVHZXIgdC0ZLv2wl4/tUJCziAL24ZsTjaLqY Z9cJ8GkNCpcPh92wbacV5ViUVifhQsgyzX2eVAvZW9SP91NWJcFUrE4CW4yQfqzE t9SD/X+js0QABLUl5gdF6BANZOqkE8zk+g99DKTQmD/L+KJn4t1dvrN8+d59LKVo U98r83luTqlpisBI9O4LkWpXcWpRPo/indLfZQkM3cLVSdzqU4S2VP8ZGQK93nYm t4wAsOleXFQ15zlHelsf9s3CzfJRmVkHeyOctHHvHQgbi7drYWL3MxRwQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdegiedggedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedtleekjeeiudefvdfhieffteelhfeivdeliefgieeugffhvdelieffjeei geetjeenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordhtvggt hh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 24 Mar 2023 08:36:33 -0400 (EDT) Date: Fri, 24 Mar 2023 13:36:32 +0100 From: Maxime Ripard To: Greg Kroah-Hartman Cc: Matti Vaittinen , Matti Vaittinen , "Rafael J. Wysocki" , Brendan Higgins , David Gow , 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 Subject: Re: [PATCH v5 1/8] drivers: kunit: Generic helpers for test device creation Message-ID: <20230324123632.rtb52jh6zeopjwht@houat> References: <25f9758f-0010-0181-742a-b18a344110cf@gmail.com> <20230323101216.w56kz3rudlj23vab@houat> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ixhyyonac24t3jtj" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,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 --ixhyyonac24t3jtj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Mar 23, 2023 at 11:21:58AM +0100, Greg Kroah-Hartman wrote: > On Thu, Mar 23, 2023 at 11:12:16AM +0100, Maxime Ripard wrote: > > On Wed, Mar 22, 2023 at 07:57:10PM +0100, Greg Kroah-Hartman wrote: > > > > > > +/** > > > > > > + * test_kunit_helper_alloc_device - Allocate a mock device for= a KUnit test > > > > > > + * @test: The test context object > > > > > > + * > > > > > > + * This allocates a fake struct &device to create a mock for a= KUnit > > > > > > + * test. The device will also be bound to a fake driver. It wi= ll thus be > > > > > > + * able to leverage the usual infrastructure and most notably = the > > > > > > + * device-managed resources just like a "real" device. > > > > >=20 > > > > > What specific "usual infrastructure" are you wanting to access he= re? > > > > >=20 > > > > > And again, if you want a fake device, make a virtual one, by just > > > > > calling device_create(). > > > > >=20 > > > > > Or are you wanting to do "more" with that device pointer than > > > > > device_create() can give you? > > > >=20 > > > > Personally, I was (am) only interested in devm_ unwinding. I guess = the > > > > device_create(), device_add(), device_remove()... (didn't study this > > > > sequence in details so sorry if there is errors) could've been suff= icient > > > > for me. I haven't looked how much of the code that there is for 'pl= atform > > > > devices' should be duplicated to support that sequence for testabil= ity > > > > purposes. > > >=20 > > > Any device can access devm_ code, there's no need for it to be a > > > platform device at all. > >=20 > > Sure but the resources are only released if the device is part of a bus, > > so it can't be a root_device (or bare device) either >=20 > The resources are not cleaned up when the device is freed no matter if > it's on a bus or not? If so, then that's a bug that needs to be fixed, > and tested :) Please have a look at: https://lore.kernel.org/linux-kselftest/20230324123157.bbwvfq4gsxnlnfwb@hou= at/ I couldn't get an answer on whether it was considered a bug or not last time, but as you can see there's a clear difference between a root device and a platform device that has probed when it comes to resource cleanup. Maxime --ixhyyonac24t3jtj Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZB2ZUAAKCRDj7w1vZxhR xTziAQDzlNBv8r3FNR5xvsqs6kFN7cJ9NsebxwnXFMkkCLheBQEA5tvTfjjuyRCb JuPrsPFwK6lStlKQEqRnhY5AgTCOxgM= =Neh7 -----END PGP SIGNATURE----- --ixhyyonac24t3jtj--