From patchwork Tue Dec 10 19:13:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 848971 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F05111C3F13 for ; Tue, 10 Dec 2024 19:14:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733858052; cv=none; b=Pt+boTPJuVL7/HlMRhPK593bZoh0RA70kh0Ayc+mp69euLQncsJeFoqXoxVkLI8Ba6JEr570jHpa1/azQXWrOZDWfO399Zl3wKPUvpDct2H2U+uMr9vaDK2lsMmJJOt3hdRAHz8XrhzuFzowvih2s6A52VDyhOQ4vnekWg+c0mg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733858052; c=relaxed/simple; bh=LMzslre59gBSKbdGtmcX0vce8kxfJLik/pThTrlPDJs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sBbMNjgBu7hf6/pFNo5T3sFIZD+mGy2GTsbWziwhmGkxbU/UzP4gTi1WGnSlrFVhND0pHDtWPp0SSkJAQZ+677HJ+AVV7X3WvnGwuWBLy9oEwB3fZhMCMpEdXSbs0PZcNbpgxUDYPZSJ5sNgCJXo5UPANWPBv306sIY4UR3bBP8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=RM9p7KhX; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="RM9p7KhX" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2163bd70069so28752295ad.0 for ; Tue, 10 Dec 2024 11:14:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733858050; x=1734462850; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S1VV7jv6a8iTXSgTXT3A313mUq1AvY1/xt0iu6Jh1cU=; b=RM9p7KhXbG7UG1Of1i4R+n5+d8vVJzeyCJq2QPh6Wb1H2ypCegcHUHbAQ4/gPNU2C9 yKeB//7Mspd6DeIIUZe4KWftJCTwBNjEE6abjqNGiz1GmUxwHgr2ZUjSDjEhednwTjsX qjV26SJDXiKLJ/wR1UsH/lgwwIxGj119p0HmQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733858050; x=1734462850; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S1VV7jv6a8iTXSgTXT3A313mUq1AvY1/xt0iu6Jh1cU=; b=kABh5hKO4DmhLRIwdSZVJuCjCmRnVPJYLSn2ftyDkL8QB6xKQQKeWrF1LC+6QQcka6 A6IDkXyHges63rdUGjKao751/6jbUn1Xz+NLxnRqXaeY7njHZyHlB3vvTBnXtj2mpm/i XTFxdMqXqDj2a5geIkwoJ1KQd14TxKrkR/kfj90vuonyC+2qGlAGbuT5naZm/hjGNCm+ VLgj9fAuTzChDUNqn9gD2h3RLSvRIhKJHTVASN/JQPUNpzbwFDt/kvgSOrmNKFf5NmQb USOEtX+VZujLy+aiU2mYJjkOFYccJfQ88n3ClEu8Sye+54+4HRkIe5lKP9VtWfhPTlWn r1uw== X-Forwarded-Encrypted: i=1; AJvYcCUfrFFVshfFN3psQD9bFGFZOgZqWq8lB9C+vi2dhnmemeFgi3/1FWyC+6XDxILixck0zMsGYoWPV8sBEsBf4tQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyBqdVgjMv4qrQk+02EpSgg9qLlp+wYbkLF1jLVger8f/io9gA8 R4IA4U1ehty8dI4mB/sPf79v/6J85y4WNtglG/1ztfdHDk5Smd+v6iJeZE9x1A== X-Gm-Gg: ASbGncuIYA+SjMymCMWQ/23LklFL0xQNydDx7jsBo9Bo6Fpn+KwcGDr3siquU0SSdCG +gaWZ8EtnKMfiJxyqp1ut76gX3IuA+AqLulZ6nM6jouAm1CRhgWHhOlCCw2/c/YzqA4LaqIVIJc Yk7wcypOHR9+1qSQ05aJbqiqkuxbmXIdx0g8id36UvdJ43hdAIp2YEmFfW/yPuLt8gct2w5wQKV PeI4vSY75gjs94xnzJxsiUMtVExuroGT3UvXbiKCXsISeI9HYvIgdn6eqzJAgeAu0NoF0SSDgjn LF/pyFKgmnkqg9UA X-Google-Smtp-Source: AGHT+IE6haXYh8F2R8TB8U0iP9CV9F+e16h/v+MqPXwC2fQ7dKZF73gUnBnR/i+bSQwBHLpqHOAl6w== X-Received: by 2002:a17:902:d481:b0:216:4d1f:5c83 with SMTP id d9443c01a7336-217786a9bb7mr3112145ad.47.1733858050369; Tue, 10 Dec 2024 11:14:10 -0800 (PST) Received: from localhost ([2a00:79e0:2e14:7:cf2b:44dd:668c:5818]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-216353ab708sm53576155ad.182.2024.12.10.11.14.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Dec 2024 11:14:10 -0800 (PST) From: Brian Norris To: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" , Maxime Ripard , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Rob Herring , David Gow , Rae Moar , linux-acpi@vger.kernel.org, Brian Norris Subject: [PATCH 1/4] drivers: base: Don't match devices with NULL of_node/fwnode/etc Date: Tue, 10 Dec 2024 11:13:30 -0800 Message-ID: <20241210191353.533801-2-briannorris@chromium.org> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241210191353.533801-1-briannorris@chromium.org> References: <20241210191353.533801-1-briannorris@chromium.org> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 of_find_device_by_node(), bus_find_device_by_of_node(), bus_find_device_by_fwnode(), ..., all produce arbitrary results when provided with a NULL of_node, fwnode, ACPI handle, etc. This is counterintuitive, and the source of a few bugs, such as the one fixed by commit 5c8418cf4025 ("PCI/pwrctrl: Unregister platform device only if one actually exists"). It's hard to imagine a good reason that these device_match_*() APIs should return 'true' for a NULL argument. Augment these to return 0 (false). Signed-off-by: Brian Norris --- drivers/base/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 94865c9d8adc..2b7b13fc36d7 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -5246,13 +5246,13 @@ EXPORT_SYMBOL_GPL(device_match_name); int device_match_of_node(struct device *dev, const void *np) { - return dev->of_node == np; + return np && dev->of_node == np; } EXPORT_SYMBOL_GPL(device_match_of_node); int device_match_fwnode(struct device *dev, const void *fwnode) { - return dev_fwnode(dev) == fwnode; + return fwnode && dev_fwnode(dev) == fwnode; } EXPORT_SYMBOL_GPL(device_match_fwnode); @@ -5264,13 +5264,13 @@ EXPORT_SYMBOL_GPL(device_match_devt); int device_match_acpi_dev(struct device *dev, const void *adev) { - return ACPI_COMPANION(dev) == adev; + return adev && ACPI_COMPANION(dev) == adev; } EXPORT_SYMBOL(device_match_acpi_dev); int device_match_acpi_handle(struct device *dev, const void *handle) { - return ACPI_HANDLE(dev) == handle; + return handle && ACPI_HANDLE(dev) == handle; } EXPORT_SYMBOL(device_match_acpi_handle); From patchwork Tue Dec 10 19:13:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 849502 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1EF4214234 for ; Tue, 10 Dec 2024 19:14:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733858054; cv=none; b=pYfGhoSRCu/eWsQzk9q/JPyk32DkOTOoXuB7IBoqc3bsDib5MFr9rZuTf1EKt45NWFck+E1yPQV7qasd1sg4VQWCgyOCusqbBTzTAfVTw7sLXwh+IBcah8XurCEigkZGj3KJG81pKIsyHG2xSotH525eba0iG8882FiPsTmpCyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733858054; c=relaxed/simple; bh=Ktozs3TxtIvoiWuLqIp07E08Wer0m0MdC4yIE4HkHSw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AGCkzQh49tB/9D+WYXV8L4WmhpZxeH16dMq28q2oZaLUyFAfLRWPUQyV0obN2kJViQxb/TvxA14g7IqOWVnwGKSo9diJLTqfJkCmPktRFIayQs82I6+OzMxomMrX1s+Tm+SMxsTprySPcnMHp3ZrlgeJP0+o0eRn8IJvol/8uLs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=XB/+Kbto; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XB/+Kbto" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-21628b3fe7dso34303115ad.3 for ; Tue, 10 Dec 2024 11:14:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733858052; x=1734462852; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MGZYGe93XYnwpPCetlELRil+jhnZS6KVmyET+MljDnQ=; b=XB/+KbtoK485fcPDblLVqiGT6DX1xihh1Ve5l7HEkMPSkewF80yzVGt6fPxfug8uyP EJ9Oi9fdwbmBg1mg4V3h6HTdXqltcSiSmuA8+4PRwTFLEGz98iT9DOzO3aUMiBQuOrYk 57R9ODayhgz6A9n3Ie8qfHD01jUY7cKYfpjzU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733858052; x=1734462852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MGZYGe93XYnwpPCetlELRil+jhnZS6KVmyET+MljDnQ=; b=FxC297A5u9vazOcbW+jH9mdLorQF+NslFIshxA73JXaDsWzSez5yTUrFo6fXaJtard gChEphQS+1UtqxlFqPgPausn7B2H9BPKPK4ZIf2nMP3ayrhfhWf9kqoajbATqfGLNkke ZccWIZk8o8Z1qapHw0RA3qo6S133k4fI8xs+HF90zgZC6drN/HNG5bfV3Ma0BaSvuWlf FBgL5DjlVvE1G2d/JIC58vcxIcnl/3cZAKVtrs5za4371LrYYELrfFT6gLJsIikVHfDC 6knqJ+v1v+bp5JlYa7CSQ8KWT9c2Daiz/xq4SFJEQbOhJPQdbmUX3J9NonMM1qfEqMWD lRTQ== X-Forwarded-Encrypted: i=1; AJvYcCVbnfwZMAwrJwVx2OLQ0tjk/setwy6AWO7gIgaxo0VsDskaSzAiJ2kT5atzSkBSiQimr6lwSlBoU9PMc2XVhZE=@vger.kernel.org X-Gm-Message-State: AOJu0YyOoguiXKeMYtTfif26myehkbSZwmJdCFf9drrzT8j3tBAFiAbv +sEI/36024LFd5NOxUb/4S1kEU7O2jDfbPXMYE8xHpAdbQL40bhRwQ+PxcUQDNJZ9bHTlAPMqXg = X-Gm-Gg: ASbGnctFk9C3lfvOMyP6G0ZMwUJFOjTse3QbQXEPz2Yj+qo/NFaxtKaLklE/m7okemt /ZBmnf9RNwlB7SDsYUcUrzvlV1G9gedehSVOVmMXKTxfoVOhihgPH0BWKFoOJeyVYKdsVC9V1Qy QDwiTIMnLRBaDCFHLS9Aq6f9HJrXPDr2hme5lYUb+VKatmF0GKYr8mIDeoFCDRxJMWBSVAUXWmz qxygMTKoojaVHH00zzPalbpp4vyI16gyjsQ1NI3978/R0xR/IH+/im/J8VMsYlQ5eL9Hbyxdkwn sG6g2ZwEpOb/nQSV X-Google-Smtp-Source: AGHT+IERXAaqqiMd5mOzuFLvZrQd9StHnBG8/hIZg4z03BXT5k24eR9dZkYbgceUnjEuaFJTxHifoQ== X-Received: by 2002:a17:903:18f:b0:216:7761:cc4d with SMTP id d9443c01a7336-2177869bfe5mr3528915ad.55.1733858052118; Tue, 10 Dec 2024 11:14:12 -0800 (PST) Received: from localhost ([2a00:79e0:2e14:7:cf2b:44dd:668c:5818]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7fd37745f99sm6188134a12.10.2024.12.10.11.14.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Dec 2024 11:14:11 -0800 (PST) From: Brian Norris To: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" , Maxime Ripard , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Rob Herring , David Gow , Rae Moar , linux-acpi@vger.kernel.org, Brian Norris Subject: [PATCH 2/4] drivers: base: test: Enable device model tests with KUNIT_ALL_TESTS Date: Tue, 10 Dec 2024 11:13:31 -0800 Message-ID: <20241210191353.533801-3-briannorris@chromium.org> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241210191353.533801-1-briannorris@chromium.org> References: <20241210191353.533801-1-briannorris@chromium.org> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Per commit bebe94b53eb7 ("drivers: base: default KUNIT_* fragments to KUNIT_ALL_TESTS"), it seems like we should default to KUNIT_ALL_TESTS. This enables these platform_device tests for common configurations, such as with: ./tools/testing/kunit/kunit.py run Signed-off-by: Brian Norris --- drivers/base/test/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/base/test/Kconfig b/drivers/base/test/Kconfig index 5c7fac80611c..2756870615cc 100644 --- a/drivers/base/test/Kconfig +++ b/drivers/base/test/Kconfig @@ -12,6 +12,7 @@ config TEST_ASYNC_DRIVER_PROBE config DM_KUNIT_TEST tristate "KUnit Tests for the device model" if !KUNIT_ALL_TESTS depends on KUNIT + default KUNIT_ALL_TESTS config DRIVER_PE_KUNIT_TEST tristate "KUnit Tests for property entry API" if !KUNIT_ALL_TESTS From patchwork Tue Dec 10 19:13:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 848970 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46FC4204684 for ; Tue, 10 Dec 2024 19:14:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733858056; cv=none; b=UcRvAlgnTTrvYh/O2cfkJTI5OIZmThCTkVu1gam21/g0Yfxf59m/eZrAJXgjfYYmjv+8th0Wmr0kqpLvIFqm0CYOhN20kCZsrqG0SWHVXrIAek+zb/EpgorRBBFcVs0POi/Tl+Mx1RTj1/Po+z6p0LjmFoBvaeIoilbqc9R5F8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733858056; c=relaxed/simple; bh=P4g5rM5+vT8QGYunnxWP/KgERAFX3h+8woBAFgIYFAg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b2HazP0sZ0Vpfkl3wjTsrdeY8Le6sRdsKDTu1Cbapv0FgHwtLp4Q3caJ2+R/wAjKJNKtKiuQ9mzY4BBdk5CTWwE8ChsU4lh0eLKksixcfVL8DByvaIg10gnDzRbG3LprpkZm8+JyA86R6i6DVRtatr8pjQ+8h/IxaIL+gEecAiY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=WlMqwKrf; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="WlMqwKrf" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-216728b1836so10506705ad.0 for ; Tue, 10 Dec 2024 11:14:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733858054; x=1734462854; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t5b9XYsu4O+lmiHBc5HtDX/VKh9pMQ/nh/9V8laOoEk=; b=WlMqwKrfeIwp0P41CrA+Zj9t45RW8SEmlQ/tdqAF0JdsgY6Sr3lgLPTwnPLFJmKIcV qGMPm6K+eXnRPlgFj1+Ml61thPxxzyr/NJ45maIE2JxRY9Zo7pqpQw3QlKZe+4w6aZ+y WZ/1iFwKtXHJi8xQfXL8Jrrm0y3vo57Cei6bY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733858054; x=1734462854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t5b9XYsu4O+lmiHBc5HtDX/VKh9pMQ/nh/9V8laOoEk=; b=b0cuHVB7FGmBdWd2Y4PRvoAMO83XN+leC+KLHs9WrcUR6rXwzFHmMQUWTQXqdjUdZ8 n01Ovh9vndPJUnaF/A3C5hgd6kM7pq1V2Q6BOvJ/QCh3oTCQHQyg2Gn8NvQjeykoYBtb Qac4sTLHCX1ot5DrVYeND0Bxbj4TAp/rM7mxMWYQHVEkOxpbSGbcbnB3KD9f3fEH4SC6 VTZ7fumPdQlIEOFcKoEC8nw38YAGLT3v4cDOHpii+Sqa1OUtJdUPss+rmDRrlJja4WL3 XNbDfrbLda20WaVjDkJ+6GFQEDBm9t668Wmg3ZnZu9COyfhKoSqvSiPCqXoYQxQ91tDq 7iRA== X-Forwarded-Encrypted: i=1; AJvYcCXiV3P3HeoxhBLOHiOIb58vve3qLcB5K84Qo6xPjEn4s6nffj3IDPLKHq+syK9vOwtR9CQGkq2o8CCq24T38RU=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+dT+j/FTCSRyIMsao3fx/CW6hWFCVaO9+Us4vJ/D/JvtYEUc9 smubn3qu5FL3yr4Kf7YrnAZcmzlRtDWbDQLNRMtPSkekOhrCgNPgVnEDhRahFw== X-Gm-Gg: ASbGnctIuM9q6tVLE3mo2buMKUNXumRh8DF9JcKG7K2CI2yJhAyujeVmrAsmNTBwFnj eyAXk8c8UiQPI9fXPKlgfpuikidXQN6VDWhuFlUq7xmaQ/RwfNqkvT5ULPmpd1mqhNPGiPoPKS5 kpG4sosHorgH7aJLPgNgFgfd9z5UODaExiYV0KUyXY47F3SaySALbL7t3Leo6oG6iQpWxTrY/cc ocVOuvcgmMgJ+L48OwFVk4tRtrhCtOyHnt8Gjp64x3555Tegu5j4n/YyWabyPwhqaFGiopVxUja PeXxtUf5OLoqr24y X-Google-Smtp-Source: AGHT+IEXiv8Ym3Q4nPBKFIlRwqhDrPPK9Ud52JE4zWYY3RQI+KC6JJeue0TzMBRAN1JYYwitRq9xzQ== X-Received: by 2002:a17:902:fc86:b0:215:94e0:17 with SMTP id d9443c01a7336-217783b776amr4525505ad.23.1733858053991; Tue, 10 Dec 2024 11:14:13 -0800 (PST) Received: from localhost ([2a00:79e0:2e14:7:cf2b:44dd:668c:5818]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-7fd3af6ef9csm5920470a12.62.2024.12.10.11.14.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Dec 2024 11:14:13 -0800 (PST) From: Brian Norris To: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" , Maxime Ripard , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Rob Herring , David Gow , Rae Moar , linux-acpi@vger.kernel.org, Brian Norris Subject: [PATCH 3/4] drivers: base: test: Drop "devm" from platform-device-test names Date: Tue, 10 Dec 2024 11:13:32 -0800 Message-ID: <20241210191353.533801-4-briannorris@chromium.org> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241210191353.533801-1-briannorris@chromium.org> References: <20241210191353.533801-1-briannorris@chromium.org> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This is a reasonably-helpful base for generic platform_device tests, and I'd like to add more tests that aren't specifically about "devm" functions. Drop the devm namings for the suite, for clarity. Signed-off-by: Brian Norris --- drivers/base/test/platform-device-test.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/base/test/platform-device-test.c b/drivers/base/test/platform-device-test.c index ea05b8785743..fd871bb9e143 100644 --- a/drivers/base/test/platform-device-test.c +++ b/drivers/base/test/platform-device-test.c @@ -15,7 +15,7 @@ struct test_priv { struct device *dev; }; -static int platform_device_devm_init(struct kunit *test) +static int platform_device_init(struct kunit *test) { struct test_priv *priv; @@ -203,7 +203,7 @@ static void probed_platform_device_devm_register_get_unregister_with_devm_test(s platform_driver_unregister(&fake_driver); } -static struct kunit_case platform_device_devm_tests[] = { +static struct kunit_case platform_device_tests[] = { KUNIT_CASE(platform_device_devm_register_unregister_test), KUNIT_CASE(platform_device_devm_register_get_unregister_with_devm_test), KUNIT_CASE(probed_platform_device_devm_register_unregister_test), @@ -211,13 +211,13 @@ static struct kunit_case platform_device_devm_tests[] = { {} }; -static struct kunit_suite platform_device_devm_test_suite = { - .name = "platform-device-devm", - .init = platform_device_devm_init, - .test_cases = platform_device_devm_tests, +static struct kunit_suite platform_device_test_suite = { + .name = "platform-device", + .init = platform_device_init, + .test_cases = platform_device_tests, }; -kunit_test_suite(platform_device_devm_test_suite); +kunit_test_suite(platform_device_test_suite); MODULE_DESCRIPTION("Test module for platform devices"); MODULE_AUTHOR("Maxime Ripard "); From patchwork Tue Dec 10 19:13:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 849501 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BF24214228 for ; Tue, 10 Dec 2024 19:14:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733858058; cv=none; b=XM9tpzBR8xMdU/Q3uwzvOScvQjybMHp+Ou5NFYmOQWc6ubmKbiRmgkhYBdz0KuWjKBfUvGdz9NU7LGiHReeiHTVrAeXO1g447Nzp4AgQ0TjhqdIMJDv1OBUP8G+yR3zlJPY0mu1lf3cNRPa7Yw9JLhy439G5odP8PZPmTCRRUt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733858058; c=relaxed/simple; bh=NLP51W0TMbF+X/IdSKOCuEkPNumCeamZMXG9xpfX5Vk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O2CeoYjEHzATWc3iVUThAAWiSdwasROWgQSAlZQMZHJKEUTd6Ejcb9qxElavYcj6MTXdVC4EjBpqeydsVE/XRpbu2/39DDLuSI2nrwslAEXCGioxNdnilAu8VEyIKaVBcujJI/IoA7V1unFQXmVW/dmQxElotIr1VAHe4VHVxg4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=aCIj2G0X; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="aCIj2G0X" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-21661be2c2dso17831495ad.1 for ; Tue, 10 Dec 2024 11:14:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733858056; x=1734462856; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3kNBPAUQqn1SlMteLp0cLp4n0uTA6dQm9HM53DlHwKA=; b=aCIj2G0XlgDBZR3Arw8z4zE6aLrErUBMwC13oxZ5uvCnDc6iqIGg7i86aY7WcFijzh HrdlMfYOvgdnLC/IDYcV1hxwJiP2BPCrrr5+qSmZm7/NAs5ptn2OprwtdICvFjab8bC2 eKd8sJaC+dgEh2fBbPIRTV2VECunpVbv31FIQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733858056; x=1734462856; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3kNBPAUQqn1SlMteLp0cLp4n0uTA6dQm9HM53DlHwKA=; b=AjCqz8c3JGDqNOgHkRc5OhGUKuY3VnX4cuKbXlH4yD7guaARymPOPakDtr/MU737ls Kho2inGoqAujQdkWsUShBQcrsC8BcZ6srTAWwfx9lxglxa0h/iooRnKZuUcVq6v9iJBB X13q1XQC99f6YyB8NueOlXjwSK/muhRHK/7cj1f+xvhzNOGvE1HS08aT2MiYy7bC7Aur At3MY9L62etopEnIJOSCo0Mw5qOZALhZOqihWpEh/0Ze8RAOo5PzysSoB+Dc/suSwFwv YNbEzBlTiTn2wH/CLTh+2KmP36aZmNNNTyHCm6Van8oQU2MZ1EMQFC1Q3t3wDGT0ed9f r6vQ== X-Forwarded-Encrypted: i=1; AJvYcCU5dGO9qvzOCrS9858780NHeAHQZRNJz8LFzQKgFPSuI/sasHxljHpVfDdquPXttLIkf1pmzoWLhVS+Bn4wZQY=@vger.kernel.org X-Gm-Message-State: AOJu0YyZzl24JRHsVuzz+WYEEu3s8Bf4EotkeYBiJN9jtjqyJIKWJ44S 8r3G2RWkelFYURvl8Jos7rO+Yz6355pneK6NdL81y3GcoRSOwmUN0fP4UIjETA== X-Gm-Gg: ASbGncv7dQHfL3XTU4E/CMvRjy0rw0kJDL10Lt4jZ4eXWgo8si1LGtjUk64EIHIHQAY tQKPfqC4NantJK30+EnYYdpYxlqnZsJzwuMKikPssqj50PyCfx3sJDZzu4bDzEpncE5+bWawvBO X3pnhyt9k1ruCoSid2CRaVGddaDsp7zlXL2HTkuE+3tUVHCZYok6mEfn/1O/mC8QNUxIpQYQcIk itgT8/kNfuqAwU12D/hd3U8GtuF3ugPI3jWHSJuq5LoE7x5FhG99uUf5hlbOVTvvcxSk9hyaTxj QLu2bWPCfFIEC9Hj X-Google-Smtp-Source: AGHT+IFcWIgqQVS1ad8XvDlZW1SpkmPZ4PPE2Z6bjTkyVgR7q6YqNhJGD2CRAjafvPEWFkkLP8m7xw== X-Received: by 2002:a17:903:1cd:b0:216:526a:53df with SMTP id d9443c01a7336-217786a2d42mr3306145ad.54.1733858055890; Tue, 10 Dec 2024 11:14:15 -0800 (PST) Received: from localhost ([2a00:79e0:2e14:7:cf2b:44dd:668c:5818]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-21659e7b7eesm33797255ad.9.2024.12.10.11.14.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Dec 2024 11:14:15 -0800 (PST) From: Brian Norris To: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" , Maxime Ripard , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Rob Herring , David Gow , Rae Moar , linux-acpi@vger.kernel.org, Brian Norris Subject: [PATCH 4/4] drivers: base: test: Add ...find_device_by...(... NULL) tests Date: Tue, 10 Dec 2024 11:13:33 -0800 Message-ID: <20241210191353.533801-5-briannorris@chromium.org> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241210191353.533801-1-briannorris@chromium.org> References: <20241210191353.533801-1-briannorris@chromium.org> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We recently updated these device_match*() (and therefore, various *find_device_by*()) functions to return a consistent 'false' value when trying to match a NULL handle. Add tests for this. This provides regression-testing coverage for the sorts of bugs that underly commit 5c8418cf4025 ("PCI/pwrctrl: Unregister platform device only if one actually exists"). Signed-off-by: Brian Norris --- drivers/base/test/platform-device-test.c | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/base/test/platform-device-test.c b/drivers/base/test/platform-device-test.c index fd871bb9e143..f9d1a269a479 100644 --- a/drivers/base/test/platform-device-test.c +++ b/drivers/base/test/platform-device-test.c @@ -2,7 +2,9 @@ #include +#include #include +#include #include #define DEVICE_NAME "test" @@ -203,11 +205,37 @@ static void probed_platform_device_devm_register_get_unregister_with_devm_test(s platform_driver_unregister(&fake_driver); } +static void platform_device_find_by_null_test(struct kunit *test) +{ + struct platform_device *pdev; + int ret; + + pdev = platform_device_alloc(DEVICE_NAME, PLATFORM_DEVID_NONE); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev); + + ret = platform_device_add(pdev); + KUNIT_ASSERT_EQ(test, ret, 0); + + KUNIT_EXPECT_PTR_EQ(test, of_find_device_by_node(NULL), NULL); + + KUNIT_EXPECT_PTR_EQ(test, bus_find_device_by_of_node(&platform_bus_type, NULL), NULL); + KUNIT_EXPECT_PTR_EQ(test, bus_find_device_by_fwnode(&platform_bus_type, NULL), NULL); + KUNIT_EXPECT_PTR_EQ(test, bus_find_device_by_acpi_dev(&platform_bus_type, NULL), NULL); + + KUNIT_EXPECT_FALSE(test, device_match_of_node(&pdev->dev, NULL)); + KUNIT_EXPECT_FALSE(test, device_match_fwnode(&pdev->dev, NULL)); + KUNIT_EXPECT_FALSE(test, device_match_acpi_dev(&pdev->dev, NULL)); + KUNIT_EXPECT_FALSE(test, device_match_acpi_handle(&pdev->dev, NULL)); + + platform_device_unregister(pdev); +} + static struct kunit_case platform_device_tests[] = { KUNIT_CASE(platform_device_devm_register_unregister_test), KUNIT_CASE(platform_device_devm_register_get_unregister_with_devm_test), KUNIT_CASE(probed_platform_device_devm_register_unregister_test), KUNIT_CASE(probed_platform_device_devm_register_get_unregister_with_devm_test), + KUNIT_CASE(platform_device_find_by_null_test), {} };