Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp7364580rwl; Thu, 23 Mar 2023 03:23:49 -0700 (PDT) X-Google-Smtp-Source: AK7set+MIjB1vDAFYaF3XuOfwiF1mHXNtz6pLFrCAexPzZrnHq3b0gt2wgaPyjS6AhWPnip3bP3K X-Received: by 2002:a17:903:120a:b0:19c:df17:7c8e with SMTP id l10-20020a170903120a00b0019cdf177c8emr7166273plh.68.1679567028991; Thu, 23 Mar 2023 03:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679567028; cv=none; d=google.com; s=arc-20160816; b=GhKc3oJdxyVlDcXCPQcvRYmvkfRQT5mAS5YBnNBeaPd4VvTGpt9sltVA7xtVHtvKau nUEJs/4SsfOGfr5UeO6hJ3DtW0CLTX1U0R3Yz0g0Xsjn1irKzRyn/RmA0TJkENQJwkY6 sJE/Kz5ep6CZE8WSvPyiMEEHBMSQrnmLpwFoHTNNI3VLixESCqmac8qKuAUCiGBJ16eA hYPoNNcP2M8I8Omwtcskb5zH0Pv6vUuwqycsi4vZIWLTy9ehEwCVsKi+/3tKxAJgr7Jx LA2QQe1ypO3ooQgzKebHvHzYQzoCiu0VJOfom0hOZ+wlR03L1QVe+YCvrDOrF0JkzuJu llzw== 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:dkim-signature; bh=wkSx7eslJK30lufTQf+Udyw8dC6g+Wotys1N6/3svcE=; b=ONRSb/P3NhN0PgSfmgTLw+a5FIzI1LFVPVRu/B0Xc6nnVg6i+qBPGlEXTy759ARNCx X5mhY5np2n3YTReMpyNtzYo7iJe6y8P2Mm858+T9Sv+0UHBLrR+TB3tsLFnfNjZwA4Mm AOgYbe4wsCOKxwbz9GuhfEYORmgDpECczQTWKk4hle6ECtk9l65CwEV5voo63o81ulkR fhj0wxg98mIjSB0oDj52jcAPGwWbfFpAJaxfu37t7xQqWj0N4iBsDw5ugWSWHnIcRrrv u2sihH8gRqvtYS7o93yaEAP1FETh/BPHUw02YdbGaqFrE31AJcLhyWSwJyIbZGpKpwZ4 x7ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pR7xEzh+; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020a63574c000000b004fbb2e0e958si16910717pgm.736.2023.03.23.03.23.13; Thu, 23 Mar 2023 03:23:48 -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=@linuxfoundation.org header.s=korg header.b=pR7xEzh+; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230241AbjCWKWi (ORCPT + 99 others); Thu, 23 Mar 2023 06:22:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbjCWKWg (ORCPT ); Thu, 23 Mar 2023 06:22:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2164D52B; Thu, 23 Mar 2023 03:22:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6496EB82055; Thu, 23 Mar 2023 10:22:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7136C433D2; Thu, 23 Mar 2023 10:22:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1679566953; bh=1nfT8Rc7boLFxMEOqe2mpQaNUrd14bwQB4DnxjJCq1g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pR7xEzh+c16R6uPuvPSBbyL9NhyC5n8pzkVPj8qllPuMGPZ1Qgbn5g02VESrPSxrD Y0on6jmc1Md4itsbfAwy6SjHmzEOV9iiSN5uSiFgERjImMJ3K3aWXU7CvvoqXMaDbZ 6IrYeVOG+IbEF9gKHCuMhqxOHpohSt3Pl526riDA= Date: Thu, 23 Mar 2023 11:21:58 +0100 From: Greg Kroah-Hartman To: Maxime Ripard 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: References: <25f9758f-0010-0181-742a-b18a344110cf@gmail.com> <20230323101216.w56kz3rudlj23vab@houat> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230323101216.w56kz3rudlj23vab@houat> X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,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 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 will thus be > > > > > + * able to leverage the usual infrastructure and most notably the > > > > > + * device-managed resources just like a "real" device. > > > > > > > > What specific "usual infrastructure" are you wanting to access here? > > > > > > > > And again, if you want a fake device, make a virtual one, by just > > > > calling device_create(). > > > > > > > > Or are you wanting to do "more" with that device pointer than > > > > device_create() can give you? > > > > > > 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 sufficient > > > for me. I haven't looked how much of the code that there is for 'platform > > > devices' should be duplicated to support that sequence for testability > > > purposes. > > > > Any device can access devm_ code, there's no need for it to be a > > platform device at all. > > 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 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 :) thanks, greg k-h