From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.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 5DA4832E728 for ; Sun, 26 Jul 2026 07:22:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785050544; cv=none; b=M0W57rw0wGOtYlukY/MXRNQKqPq+Rv08KqrJNPh50c2Z5vylerpeAsxNvODo74OYGPNoCe7dPqGZMwkVgfCVgkYXGlAWw9qEbYvRKe5d+Edd+TID32ltMG5R29ZREKltmPBd/xTQNvNAqZpFUpf/skJSVcFIcSPI8Sj4tNCc5KE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785050544; c=relaxed/simple; bh=DNC6Q9R6tFKQWo6Vyk42M9qQGGwCkIPajaqmxo8sjmY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=i8jKuT1G4PTwSenSk5SwygupO5YqgPd1az6xfZHkkst+ZEUp22+Vniw0e3447IZTj3htwZiFkN+8ZjeeCL9Cc537Dy1bXEJkdgIPhf2tG4wnHjNHmbU1LI7koZ/2nsi1o0xeec7xTk7D420h9v6xrstqt+yn1cOE0xFOKQI6Dno= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HuYG/w11; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HuYG/w11" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-8485b358552so1814668b3a.2 for ; Sun, 26 Jul 2026 00:22:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785050543; x=1785655343; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=p7I2i4OrtuamUjaD5MYy4r8wCU1Supcz4UPlETqL+tw=; b=HuYG/w11S6ohag69SPuGVU3/kOTCM/5v/MPkEgDrSZdW13t4aXyq2IZdKOoWyrJboS /gflIHo2F/WyjwHUlLo2dS5uRSB1UhC2JLuOqZJHxHa37awKp6chfyiezu+Uc6FBuA64 OjUDPAji8rJSdKlAjYmc4jBNV4PdVBG3HFWG/WXEOYizw+LdTXgXdvNa35Wsw9gh4r5s 1Al3Q7a3YhYu+MaUDHueC+KpXhsXE25/Qztev8KC6JmwEu8F+rFVdP1zQsllVv9r8cR6 MkjsaK9oR9cgDsvJCNUJd9pT3lRbsuB/z8vRyWLXnn33XH+Vy30r537U+2083DUBXRGj g8rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785050543; x=1785655343; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=p7I2i4OrtuamUjaD5MYy4r8wCU1Supcz4UPlETqL+tw=; b=b7INtkggpC1Zy6n1xhwKYQ4/1q2cOOtJLXpbT72x7W6/GamQnRU77hxquFXnDPaSIh CuuC0aD8cKmldmNEsGWCixtdQws6j3OQtf9OIQ184SMHEc2PU1P4plrX2p1/rs1mLOII dPERRwsRachY+6uVilQt6zo1BQN0+MMZ8R/NQ6RbwoLUnbvff48VHocFG4kpCmqb94H/ Cmgx9PxpO9+nZOTlORpjEVyMEKRbhpcdx6USvVok5uAwwKtEEazhfKZkxiRZPZRoCgxD gm0r9A/YDMstub2/ZWEl8OyEU57ko4gmDYMogV83O308hTe2CT2FZf1tKHP2/CvCMF0e 2DVA== X-Forwarded-Encrypted: i=1; AHgh+RpdMy/DeMpOAAbtjEjJdsmoGFTPGvyjkLrfX1prdTKH8EGOKsUl7dFhfpUGKUWkVwoCkr7RKzoMP0yHbcE=@vger.kernel.org X-Gm-Message-State: AOJu0YySsf42QnAyrrKjQw/mWRwn4cEJuEt0LYC5mdg6HJpoyxOmROmd EjpCZTpShpaD3BHOPyWkenhy8gK6C1J52CQRKYGNHf3XqbrZpWmZTyrv X-Gm-Gg: AR+sD12QcwPZa1Zu+yu/SAL/yP1RVi8Ua7ox0mJf5lW8gB2uaHEaQvqWYAHd4YvbXIA glWc+KTMAkqwEAVT2DcVpnU8GtGbf3OfTZYoNMjhRqvqvj7kKKlFg8kq+Z4TWLY+AfGOcJAohAO TFSlUTMx5fMLXmctRWhBURyAlwk7t35qvQzKFhgulFLhWobK48pMqHc9JttxC5KItwAD12Tc8lK SC+XZYtZQlZOQ70OJt74UIzeQtAz1sh9zvjF4ZO8yooTm7pm4alCpGCFEqiVVdfjOnk6WINKfT0 toFFXtmjh3v6yN49+Gb3u+2ygVgBPQHQKFmGz6S0c8Xj7/J+3UBzYUmgdzoA9/qsLx4jHLDprL1 OFRfeZBRbg3F6P/q5+zetF+UR3yLU6dth7hIVJmysIi7O/sek8yc90cp6VBl3daXnqBmbiSyLk0 oriY/1/sBAqPwA X-Received: by 2002:a05:6a20:9f46:b0:3c4:46ca:3350 with SMTP id adf61e73a8af0-3c67dae9748mr4518322637.6.1785050542641; Sun, 26 Jul 2026 00:22:22 -0700 (PDT) Received: from kdev.. ([108.180.130.139]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cbbb660ee91sm1863606a12.7.2026.07.26.00.22.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jul 2026 00:22:22 -0700 (PDT) From: Babanpreet Singh To: Mark Brown Cc: Orson Zhai , Baolin Wang , Chunyan Zhang , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Babanpreet Singh Subject: [PATCH] spi: sprd-adi: Fix probe succeeding without registering the controller Date: Sun, 26 Jul 2026 07:22:21 +0000 Message-ID: <20260726072221.7-1-bbnpreetsingh@gmail.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit With CONFIG_HWSPINLOCK=n the of_hwspin_lock_get_id() stub returns 0 unconditionally. In sprd_adi_probe() the guard if (ret > 0 || (IS_ENABLED(CONFIG_HWSPINLOCK) && ret == 0)) is false for that 0, so it takes the else branch, where the switch has no case for 0 and lands in default: return dev_err_probe(&pdev->dev, ret, "failed to find hwlock id\n"); dev_err_probe() returns its err argument unchanged, so probe logs "failed to find hwlock id" and then returns 0, reporting success. sprd_adi_hw_init(), the restart handler and devm_spi_register_controller() are all skipped: the device binds but no SPI controller is ever registered. Since the stub is a constant-returning static inline, the compiler folds the whole remainder of probe away as dead code - an object built in that configuration contains no reference to devm_spi_register_controller() at all. The hardware spinlock is optional for this controller and the -ENOENT arm already covers "no hardware spinlock supplied". Treat the stub's 0 the same way and continue without a lock; all four users of sadi->hwlock already test it for NULL. This is not reachable on production kernels. Kconfig has depends on HWSPINLOCK || (COMPILE_TEST && !HWSPINLOCK) so the affected configuration exists only under COMPILE_TEST, where no real hardware is present. Object code for CONFIG_HWSPINLOCK=y builds is byte-identical before and after this change. Found by smatch: drivers/spi/spi-sprd-adi.c:560 sprd_adi_probe() warn: passing zero to 'dev_err_probe' Fixes: f9adf61e983f ("spi: sprd: adi: Change hwlock to be optional") Assisted-by: Claude:claude-opus-5 Signed-off-by: Babanpreet Singh --- drivers/spi/spi-sprd-adi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c index e7d83c16b46c..7c29115c5b8b 100644 --- a/drivers/spi/spi-sprd-adi.c +++ b/drivers/spi/spi-sprd-adi.c @@ -553,6 +553,11 @@ static int sprd_adi_probe(struct platform_device *pdev) return -ENXIO; } else { switch (ret) { + case 0: + /* + * Only reachable with CONFIG_HWSPINLOCK=n, where the + * of_hwspin_lock_get_id() stub returns 0. + */ case -ENOENT: dev_info(&pdev->dev, "no hardware spinlock supplied\n"); break; -- 2.43.0