From patchwork Fri Dec 8 10:09:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 13485143 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ia4PYyzt" Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 403FF1723 for ; Fri, 8 Dec 2023 02:10:02 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5cf4696e202so24581777b3.2 for ; Fri, 08 Dec 2023 02:10:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702030201; x=1702635001; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=NkRyaEIclzm+ShIMyVUbqREgKKajNjynsQ0mobEpXzk=; b=Ia4PYyztigFmTktxZsK+SONpo6VUAt6QnxvhqOpLXF33toW7VSD3bVOBWvnjBHTItz 1BiqSNITOd2BrYnyFCj+/YrVNw2lxIHD3FphQaJB2jhaf0Fa18PtGV7e70TwLAwuho+e 9y6HwVXMdCuCn+zRNlHmqWpEuJEDComnl23WQvbPM/Zu5x7Dyhue5mPGDd3xfa9MG4/V 40wNVnsHkktXzmXNVCaLBWL5IN3/3YcN69mbdi93FklJ52rnrxTijOmZJc2q7RFXEir3 kexo8LGk8Ub+r3m7fg8+n861bs3PUZH8aSiVLqBhgd9lCIpX1uu4vbM/owGhXb8AjKIM KsqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702030201; x=1702635001; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NkRyaEIclzm+ShIMyVUbqREgKKajNjynsQ0mobEpXzk=; b=Th1uLu2sUOc2fV3uT8wQwBFlAwozJEZg5DjcfaJBFSmk9ljmQOWZLKx9UbHDJxy1od k8ZZjcZMJ9mbbZsuglVd4JdzltsCrEC67KMq8ORASdmeBdjBf1yjBKR4X1aQLpTgu9YQ cKJ7TLN96jOoCub0FAD3CG9zckjvh4Ah4wsjZmxSRGZIxoS2U17dQPQAzIQHtcNzuqEq rBEIRnvOtASrmwBXrDbSW4RT2VViXwbTElzbdcZfKXDl49opxNeDWV/b85AMRFAjHfnk kneGgc5C/5jl1pm/nLMpTbFNkvHB8LKNiMbLTjPqTRN40gQlU3JzYq3mjYpYyi40PGyB 5R+A== X-Gm-Message-State: AOJu0YxYknPKrwnma9zDt0eWij5EcsAIsrotvqnYdPNXDNuGQc4K5ye/ IjOGWZc3pa+oPKAF7t4bKEvMcGWzvL7/sQ== X-Google-Smtp-Source: AGHT+IHGF3yZf9WJj2lWCzBA+Zp1ww/Jd0TaRJ+ZbfD0tlPqmjYoZLAo7qIUoj8IifBSVJ/CH0LnfRQUmCKMLQ== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a05:690c:3146:b0:5d7:4619:82dd with SMTP id fc6-20020a05690c314600b005d7461982ddmr53175ywb.6.1702030201444; Fri, 08 Dec 2023 02:10:01 -0800 (PST) Date: Fri, 08 Dec 2023 18:09:31 +0800 In-Reply-To: <20231208-kunit_bus-v2-0-e95905d9b325@google.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20231208-kunit_bus-v2-0-e95905d9b325@google.com> X-Mailer: b4 0.13-dev-099c9 Message-ID: <20231208-kunit_bus-v2-3-e95905d9b325@google.com> Subject: [PATCH v2 3/4] overflow: Replace fake root_device with kunit_device From: davidgow@google.com To: Rae Moar , Brendan Higgins , Greg Kroah-Hartman , Matti Vaittinen , Stephen Boyd , Shuah Khan , Jonathan Corbet , Kees Cook , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Maxime Ripard Cc: linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-sound@vger.kernel.org, David Gow Using struct root_device to create fake devices for tests is something of a hack. The new struct kunit_device is meant for this purpose, so use it instead. Reviewed-by: Matti Vaittinen Signed-off-by: David Gow --- lib/overflow_kunit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/overflow_kunit.c b/lib/overflow_kunit.c index 34db0b3aa502..c527f6b75789 100644 --- a/lib/overflow_kunit.c +++ b/lib/overflow_kunit.c @@ -6,6 +6,7 @@ */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -618,7 +619,7 @@ static void overflow_allocation_test(struct kunit *test) } while (0) /* Create dummy device for devm_kmalloc()-family tests. */ - dev = root_device_register(device_name); + dev = kunit_device_register(test, device_name); KUNIT_ASSERT_FALSE_MSG(test, IS_ERR(dev), "Cannot register test device\n"); @@ -634,8 +635,6 @@ static void overflow_allocation_test(struct kunit *test) check_allocation_overflow(devm_kmalloc); check_allocation_overflow(devm_kzalloc); - device_unregister(dev); - kunit_info(test, "%d allocation overflow tests finished\n", count); #undef check_allocation_overflow }