From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) (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 2D2FF381E86 for ; Wed, 29 Jul 2026 05:35:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785303346; cv=none; b=Iv1lFb9jqUcdjlXk6DJMz6ZneDwogUctJFX0uFsrA3axsW/QqblcmiY1uSRkGntMoeFMgW64xIjP6A6DsY+whgjjb9YcVK6OVBQiPDq2g9zRIXcHZpGA3kOp4OyE7s+Q1NQEqzprYOJd+cPS/6+FI+eqQqQWJdC56S/9KXWCkrc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785303346; c=relaxed/simple; bh=BBPvNa9NJr6CbVXU+Zf4d0TESsrXu46Thrx+s3xq67o=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=j3u91rZsbgX/1L01rIRRYZf2uS5lFQs0uNU+QfQ2fSEetuxcBK2A4ljkZahEDyINZpBgr1RWKG9vhzg375ZEtw//Gm6KZy6eGrgpdco/641c/QONOPwQC7K6cf4BMbFMv+jFspkZz5IryYM62Fi7mDIMEDsu4d6+d+QlKHUI388= 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=ItLQ0l55; arc=none smtp.client-ip=209.85.216.45 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="ItLQ0l55" Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-38e08baf860so603604a91.2 for ; Tue, 28 Jul 2026 22:35:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785303344; x=1785908144; 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=tH8w4Ad7nQtBY5y7Ola8fN7/o/nUCedgysqG3JBFuDE=; b=ItLQ0l55dj5dCdZ9CgLsEtKpb3HA6tki+EI6N2OygSKFXVo4Nalyq1ne7gS3vV0gk6 kvxlUPDL8KuqRROg0mb86mmGs+hdQdvQYyj8Gp0yzRVbblQShmtgQZ8T86SacGmlYRfU 89Qlq4kNfoRpnSnTOWjKjztLxrJ5Bc4mUFPaQCpsbDNCbq9gOf6QqU0Yoxj+nESKlLEj zoORNM5NNyUTyWJFStv2tAVMw6jcr8TnXi2FZtrd0mLgDbv+xiIOFiYuh+iilJLqdn96 h/yo+k2GlQuoBO4LL05uj4r+uS5U7u4cppPJiH18Csi8kJiPvjCT9OgtR9/lALXkpzsg j9gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785303344; x=1785908144; 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=tH8w4Ad7nQtBY5y7Ola8fN7/o/nUCedgysqG3JBFuDE=; b=Ko4CUA4APfdiY1RDSVguu041XScyqu6rwARDnX2tCG6R/zMDCpl0uViL/3aosMcu3L cyOH2f1uFYhp1rfYEdMOLnFG1fVVWaQiy+462Lv+BU4eca1JJmEaSsRAtvXoefat1W5S 2m2mxgBLHmdjOpqx6gNfZUtWai7FD0af6QKEyVRnnmQJ4sIJz+Wonf2TKr8PTU5Xqxsk VWYmndKa0HkJSPFJ/kpAB3I5ckjleRjn6Re6RCf0MhcGMwb/etSUuz+9FHuU6G40mCCF 0AoVjdUxkFUlG3cqZi/PSkiYPuGHcx3JPGIX+g8VEKLjcQlTcKN5laCf6S8IM7vC86G/ 2H7Q== X-Forwarded-Encrypted: i=1; AHgh+Rqzm5kJM7a+G8ap+n6u03uqph1y543XKHg5du6bXYpb8q52/HzDIf2c6ZBV+4o1OM+vzdrxKQFm8C8Enwg=@vger.kernel.org X-Gm-Message-State: AOJu0Yze94aqHP2/NrDdC+baSQ+PrkpVMNOdUBJl7mJVoWc5FEAyx4mW DqLnKAxrwYU9frlXZhmYMfCKyQLvS/Eyps/sjUbm3+5zEGtp0BoRZxRkULo3nitS/8M= X-Gm-Gg: AR+sD12mmpdwl7T1JuPOPaSrJj7BXe97thMgKYnH2WVaD9k4EvkjA7lnFBRG93CRaOO sd5zwAT7CSGTh2daGHvX5Zt+FIlPlEWFks26avqX7AJY9VbtKYtLOjpvglHddUuDaffD1TmgBwv oRzyXRRd2iM3Sff9i89UakMcANW/q3xUGfWX0cUdm+nxcizE52uTmpCBtpOI67znzH1+5VBbAmo xGcPFuCCnBvIYsoCd4gYSHipjGiB0touRVIiyWqje5YxoTRZKrmYy1bZzi0npR4RPFwBhhi0ez8 xEMKK/9OMAnzE63cSl8BR3eg20szn2kQbPlbCnVMZWLG9/uM94FHfPMxRiM78reuJvtmgSyJQ6P q/MntIjcac61MCd+Ybd9afKFSzyVK5UiVJD6Td5vWYe8uCHZkrCbuCRnCOF9ckTtLl6Aj0lBaID eP+Q63wKx2iMPoCjmlfHn0hEw4Aajm0gHrtjRjz0lmSkYHCt9LTtrVWwlqR4LR X-Received: by 2002:a17:90b:5106:b0:387:e0db:3d8f with SMTP id 98e67ed59e1d1-38f6a588a2fmr5454870a91.42.1785303344429; Tue, 28 Jul 2026 22:35:44 -0700 (PDT) Received: from kdev.. ([108.180.130.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38f64111441sm2228870a91.1.2026.07.28.22.35.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2026 22:35:44 -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 v2] spi: sprd-adi: Fix probe succeeding without registering the controller Date: Wed, 29 Jul 2026 05:35:43 +0000 Message-ID: <20260729053543.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. 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. 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 Reviewed-by: Baolin Wang Signed-off-by: Babanpreet Singh --- Changes in v2: - Add the fallthrough; Baolin Wang asked for [1], and carry his Reviewed-by. The v1 case carried only a comment, so gcc's -Wimplicit-fallthrough never fired and W=1 was clean either way; this makes the intent explicit rather than fixing a warning. - Trim two sentences of build-verification detail out of the changelog. v1: https://lore.kernel.org/all/20260726072221.7-1-bbnpreetsingh@gmail.com/ [1] https://lore.kernel.org/all/7792d078-f80e-42f4-9217-190ef5fb8573@linux.alibaba.com/ drivers/spi/spi-sprd-adi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c index e7d83c16b46c..a6baaf02b3c8 100644 --- a/drivers/spi/spi-sprd-adi.c +++ b/drivers/spi/spi-sprd-adi.c @@ -553,6 +553,12 @@ 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. + */ + fallthrough; case -ENOENT: dev_info(&pdev->dev, "no hardware spinlock supplied\n"); break; -- 2.43.0