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: 13901952 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 11BB32046BE for ; Tue, 10 Dec 2024 19:14:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733858052; cv=none; b=IqG4PgVDhQNmn1D2DoJbWrpIjZrl8g3e0FqKARVuZY5nwVTgbSHzEu1wSSobiL0Whh47DkxUex0zKg/GduoDuduYCPSbxrMxN0Hv2cBc0uS+LEh0jAuRNriucEv9PTHhti/pgivfEJlSa2CzhG8IDFhYj8O1HK+Orsdk8UHXMZE= 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.174 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-f174.google.com with SMTP id d9443c01a7336-2163bd70069so28752285ad.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=i4DKBA2C3XE8BLXKSYwoAzoqfe6ko/GqcRxf2GrL5cK3UmLE+HgpSoNLwty9+MUmxK HL+1+hT+ceCt+PI6NyuZnHvupWAAq2+ZGcn19SwXxTXtd2ExNEoU88yfmwjSZSODlof7 uAA54YS/vzdtjlyJ/a854P8p2zEMmSOIWspchCG03sHFtNXmiDXuaSfGY/HB6P/DEnBb j1hCt0qGr/AbDxQ07aHMvyLQLL9Xy6oLKIke4L99hlralH2yu3n1rGvQuR7ahN+hPuRp jwpMWTYAREJlcwmEJ1Xw0djNF2TogxpnGNPuh0IzuNe0aPbwavXVCXnEEha7GZjT8wXp gajA== X-Forwarded-Encrypted: i=1; AJvYcCVydU5pQXWMH5WrFZ2rW9IBm9QWbO3d/ST/iA30WdpXKQnxMN0Mh1QHxcUvN+sfKABCC3YevV8AgufM@vger.kernel.org X-Gm-Message-State: AOJu0YzFf7ZJrWYwHSM/xvm+hoanllBQxeVn955NMBH3I6w6tI9QCfjA GzDto+0y7O2lip/pnK2k5y/wkm1N1Iq+1MPVPHBkAaIyZZOtE2x4N/8EfiXvzw== X-Gm-Gg: ASbGncuYsJb4hpmCnCxzb1hoSu+zLhA1hnHa1p0LHF9ckj4fNChJi0zUhJnJzqVAjA2 XlrMmUxAEA2zhVeqfnpc6RMQyj+jYMyOM6npRkVVvIO6x2arDbpEOiKQiubp9Rh9fuebaOis8UI AF7Oatl8JvIiochUJF8Wl2AY5J43NvwqMYA7WG15uGFPmDw9PIro2Mt0oHXPrD2SwrE1ImZvu1l 5FRZ2EDLCEbmXdssEB2vNw4fZcUSqDpNrHWeVIHS5HoKdXtTzWE6Qxz75tX+v/bEwtEU/Joeo1P b3jKIBC5/QvzPfU0 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-acpi@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: 13901953 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 BDB7F1C3F13 for ; Tue, 10 Dec 2024 19:14:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733858054; cv=none; b=hky/wHbWIMsFBAnGp2Xxwaxxp9CEPXQ6LExgm+vwlsgF4rZMScZbJX/4bVyDKJaXHIJzSquedxOFHlyIrgIt3C4KZZHMigoPTGfRJpxpWmNNJPBLfkKz4lb4Aaa22ii5yOEO/pFqzV4ZgHSkEGzE9zDWizkUkSIqes+/Lpm6bW8= 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.173 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-f173.google.com with SMTP id d9443c01a7336-2163b0c09afso28852945ad.0 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=IoXbx6fhg6+wTUMPDwk1r3B3/agjBx4kfksMZDnzN9YUSlZ5D5obPu7xZ4obr6vlpv +bAkL2UGFOJmL6FRXL3qCSxaQ0pNhccW34jza6vZHjHIFUKG/xIjBFeU57JiWZrQMgMV A+LnGsnWC9hXi3R5u6mm/u3KIhkH94hTr/L8WShmrx2dOvZHGkYLtjDds12fOv/DYcKh ZlGoaknQDeDwlN3m2dqLAgMf50eaCdLxFls2XRiJjpWX/TNDDQS2Y04FAiV6gOERSwEQ EDjvvyPAUV5S+3P2p1Ei9vDUXtZU30N/EULx+5wEXPYqTb1OMZRN/UJcbg60K7t1/hAb vQOw== X-Forwarded-Encrypted: i=1; AJvYcCWt/s22pi0UfbevRnsfDwisY02RXMAbaBHzO8iOV8zCHMPTuqDpDNsrlnI+PrevkWPDwWPl8D0TJAHw@vger.kernel.org X-Gm-Message-State: AOJu0YyUGZwvUSdcpcAcZPkiSQOIEKOPe9Fh71kLTVFu/TjR42dcgBae TzT6FS868SVcrEGJrCc3r/9AxS+dba1ocKRbWLNCIA5mz9TFnUKnnrIdcnkzjg== X-Gm-Gg: ASbGncsHSejFwVBnG4LrOKnvqWd/CM0FBXgtPqUW6FDg/8nlmVdBSlUs4UpsAR/o4vm 5OPuj5UkVdr2nWY8fo59g9syhHNW/zlIeueCZHc/ZhhkbTiI9VgFko1bn1CE+tTJlsAO5TCnb5f DJVgG85A4KHN+XI7hhEAS02+o9fZ3CEvamvAltjeno7QDWMK5L244rYCOzB04kNvy1seYqdEol+ CAi55TB0JzSUjayWrzCZCFpdoolzmEGsT/U957tkqeGQUt5RtQE4Tga4J2sDMIMGcUB7HHxQ+N8 34r+Yu7vJauYiJL1 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-acpi@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: 13901955 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 47CDE2046BE for ; Tue, 10 Dec 2024 19:14:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733858058; cv=none; b=LzNsygQRIGzAtWOw/5s9UwkBjOadQtfSj/JATleMOjtIQzlsQ3e54Ir9qBUFjElwxSvBnb9RGtsEH6S6qqy4TABFF47VuOLQKLw+Z7SiPl/XWnL4T7p3amwOghWWSHhVHHm6s9lEeEPNjvu7qOkVwOi8ZKkVL4TZohaBE6JJ8wU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733858058; c=relaxed/simple; bh=P4g5rM5+vT8QGYunnxWP/KgERAFX3h+8woBAFgIYFAg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I0mc/Bg7nQDDVo9H7SjvM7Ob4j+oaYMmlzMNV4ctmtGGHDhD7u9m1iSkzj2eosT82bUlxmMWHEx6qf0Av4uTWxnX/AWfk3TD3G29Lnjqw9hM404IGaEaEyMwwd9nG/eBIfVz7p3/8UKICVelVyk2jyC95nhA+hyvBK95dwTigN4= 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.170 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-f170.google.com with SMTP id d9443c01a7336-21654fdd5daso22921335ad.1 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=FIro1/3xsk7tKh56l51M/cZoQpH8BfVOrR8Hv5n06ADM7VsUlTTWD6eMwAHg6Jhkdg m6ZYmX/jJmEBPjQ2ljY2UMxqLmJJdVfBcciyCA3DkWTvfev3LbMaZUjyp5xoSv6LTx6h j/qVGZwjIXTrobK/55eByBHbBt731xZ4gjhXxQKHidaeVo5tJyBq+vD7RjkMtaN4K94D mxLp/4dNSFKlnUJwKwswwL1YG7Qte7uP7NYTLE6yVrbNg7u5IFvp35YgLV1FC98RnSdB ZmUqv8u9Jow9Rxb3cpQqTaO/RC7WnuSTFWqNutaTgTh2UN7Sczjs8PylusCtzM9gL/+G QfAg== X-Forwarded-Encrypted: i=1; AJvYcCWqHYLYJknsgy3TIQee/FrkYVY8kZeP53VkHk1atvnJDz+GaP+K7V2Y3GqXowmz/Dsfh6p1GmzL8kOm@vger.kernel.org X-Gm-Message-State: AOJu0YzIJZWL/WKpEXilCxn1SLsR2mXD8n4b83XOCOEhRtdPmKk2J1f2 dG39I25ff3o/Clt7LA8FaVxayZNc3bKiQDtQwCGn5CTp6D5R8/3svHUDDxTRrg== X-Gm-Gg: ASbGnctqZgO1XtdxZWCBiELS/fqpkUFyWofcN5zfaVXbThkv04pzmrT6XVLAkPzLC/g cQ44MYpOodejq1hBVqEZ+lmnyzv5FcVyHHolC9sXMAkqFxDa8NXEwoOwWFoauoYKXdDb6N9ZvnU ezUAi9brZTRVie+6vxRZOgEZcJspFmodS36adAipnpEXMoQA6mPqyjdW8XlwsdXbIQKh2hvEqzb JKzcw+tmNyvpRGnD6WTezQixynneDspw8pSMaIxTbSO/poHUgnRiGK6pe9c9NZI5Z0wmVgVVdjv 3tlgreF4nC3PYY7R 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-acpi@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: 13901954 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 A155121422B for ; Tue, 10 Dec 2024 19:14:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733858058; cv=none; b=jMvYxfQ0oXkV/D7Q/CFA2hd5LyedCfz/ITcfGDbJgiSV+M1Kw+o4oGsai0dOjOyybuLmEN3YxIDEQe7N63Td/4ztEX9O3av7bwvy8ffA4fR23nCWaPeU9A1HJt3slxOr2M+w9W5Fvk02Sp1v/imZq7xsEXgSTIWpyftEVlVoMPo= 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.173 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-f173.google.com with SMTP id d9443c01a7336-21661be2c2dso17831505ad.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=ZZw4C5XTj2zS05E1JVtL9q1xLNsiQhav1AYj+OswQR/BqHYBi9xFXK5vXciCAakXze 7qi831JZIre8d6/OXtOoMWclsvJDa4OLaydoofb8kvN4b8V/XQYfVkhMdCjRn7EZaJWo rvA5yi08TR+dThm6lYce91z+HGwid6bvXFRhbH9xcSH6c4YwLmb4xK/Vp/homxpkUYcM 7LYe7NohB/tyC67IibokXAMYyh4gQVTmhwsxcHJd10p9x2xmg21KF9TVo0yHfDt18e3G id5v0Tak7Im/eX/2hru/utRR51wQkmQmVimj0+yvHIvKYcOTNTiHKw/ss2pfzaW4nHTB tMQA== X-Forwarded-Encrypted: i=1; AJvYcCVOdDE545/5vH1dwiWwNq0/zY8BpU8EMCo5I/7mpfR7Zem9D4NKdQuICzOlXb/4u+ByJgFHJisPB3EA@vger.kernel.org X-Gm-Message-State: AOJu0YzF3QrgtzenE5DfCMY031kxYlkauckuBFqDJi9yeyo/+bT0wxBd 5nfXgbdfPMB/h13UctMLAnYy+p4SK/ceLGsK130JsY8XFRLP5aszGFLS3A3MuVt5SiWVGTsWSkI = X-Gm-Gg: ASbGnctJD2UQkUtsp9bKii31k1ALUfg8bA+pOFCPIjqlBEeor8yjK2I0Dj1lDdQrz4m z0QW2Tlnl+Gim81Zt8/QyraQbLWLns/df/+UW2RIiW7Otzpz3Z97t4/9iodB8jkbOnO8G8NtvZ6 QdQhkMoVkj6gEf7HvXe80FyF5FyDOUt4UZA2cT4bYBWE+X/FdrFZqDSQC/2qSMQGiYKHc8hnJkM RLOlTJKCI455FxpQ8r7AK6SSeDw/RrS6JP3ARFgNaL3Hz/rXF7lvi2iP/K8oNXw0vAViXne0yLc KhUeJm5dDRXSUJK+ 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-acpi@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), {} };