From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f98.google.com (mail-qv1-f98.google.com [209.85.219.98]) (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 5FFAC44BC8E for ; Thu, 30 Apr 2026 17:37:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.98 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777570671; cv=none; b=X5usUJocOxmuCq98uP6gqWmnaUOfMa74kAG71/Ada48ppZwzLNBUDZtxvy/RrnliwDKDIkmOmca9YcE64sILR2GMsBg/WUzGI0iqxpQrbTe6SOZbM6+ryUcPw6MNLlgLlmE2DeGtp/ml+HSqLY9oLTSfswW7xdhMcLyP54CEGEk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777570671; c=relaxed/simple; bh=5gnK1tx9R1TIqAr0DRz3D3VEyLs5AMY8kWNvCmjXrIA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=B9+tGp3n//knStTpH2h6PbnFC26zqP6E2UvBxsfhK2liaEW6BsPuq2P19glP549cgZbO+q9SLF+W1xqY83S2B2WBUUkt/1L7XttQM4iYm79ty7VMrxrkOXb0Q0wTeZ8ibaO2PCbR2ERA6o+/CbiMAbust85mP36RI0PDBFbM/60= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=embeddedTS.com; spf=pass smtp.mailfrom=embeddedts.com; dkim=pass (1024-bit key) header.d=embeddedts.com header.i=@embeddedts.com header.b=b3xAbvZK; arc=none smtp.client-ip=209.85.219.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=embeddedTS.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=embeddedts.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=embeddedts.com header.i=@embeddedts.com header.b="b3xAbvZK" Received: by mail-qv1-f98.google.com with SMTP id 6a1803df08f44-8b3d6b215cfso16231956d6.3 for ; Thu, 30 Apr 2026 10:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embeddedts.com; s=google; t=1777570667; x=1778175467; 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; bh=JwA7m5EZ1edlmfqcnWuJCjFmtNnRxo71q5/2JyXSmfY=; b=b3xAbvZKBh+Sv1rUR+6E8p65WT3rDeNjsvM3i9KEfaGSzM+KLEwNJaDwBZPve0HDsO Sd7AD3pPkEk4ev/z2peub/8mpkr9EexfZK8vQABZFfeIETzS8SVZpEmBIsnX3D90ahrE Qy+KbhnCNXnPCUI/8fZ/uupQmCBnw9KH2SpDE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777570667; x=1778175467; 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; bh=JwA7m5EZ1edlmfqcnWuJCjFmtNnRxo71q5/2JyXSmfY=; b=rrGGTgYQd7h6j+fEfvU8TaoirftisJ9DY9EmFIfCcRu6K6rum2WHaAN+4XXCaYZ23Y eQO+4Uvc96iC8h/puW3WmVqZW/qwfaAn8LUcVBcY/6gAG6e8MCXNYSgG2BvhASvS036/ 0W97dtWS6frhCUErZLOuvqfNPFCBv18vuNqyU6Piu3HJkgqlrzCLHAUTPTWviN/5K4WX O1l7BFB+6BNSFOp8AOl33bplKgZZ8DIZ0LanwVqdQIoPMy1+RhfSAI61mW3bwSZUU5la Smk0hK0wV8c+WzDI8xd8HsVhJfdRa4ukSpuPe6OKAz+6bgG2fo5zuEDrHyft7uz/BIRd wXBQ== X-Forwarded-Encrypted: i=1; AFNElJ/VJyzIUlYCK1NabeiL248da1UE1jEzH6odCHAtOvwrIQ0Lqb2lgxCYh5d0SL32bxdsx8FFYNXy3EsyKNg=@vger.kernel.org X-Gm-Message-State: AOJu0YyDWujyMb1E2KgybRONvR+KXL5+Y9hmyLiUdShYtkAuEsq9fODl xTKwpZtDBHUJ3oGBCGd7a9rJwAp49qwBt6Rwg5rDJaK9duuzvKjvsekA8Dx5vbnys5XeCkoEvOq LaiWFtZJdJwceyn7sVXWnQ6OoJolOGHS0Xtj2 X-Gm-Gg: AeBDieuWXe7HJz7fjzt40guIPJv1lK4WTmikmD/Tyv2Y/Dusx+9Be9voT505tlMfAgp MmIq2wgNeyli+bBzGQmIiaaQWOg2mfCD+jKstfzfio877/YWuvgTrKGeFgl0qHkaC71nthXueOl bbnZd5PEOzhvvG/tjNhNwmwBGnSXEcg5u9nMLpQn2o+6a0PslcZ1B6QUQ2TXSvX8Apnczh9P6nR 3eb/TqoW084ooOcx2THn+XZZv/vDWq+NWl+EqzNVWwFGRZOfQa+TXArsoNBJfJPmqTXD3KVWqsV BdRKhzAIo1I4pkb0v6hAPQmMog3BGGIWMw/Jg+B6suUEkVitNiN2Yn7v8nNqUQuW6B7unk8gt0Y ys2a2rPdHv+D24W2h71bE2trGyp4i1Bzog5wcCxOc/Xjbm6qgUpzYvtg9TYY= X-Received: by 2002:ad4:5bea:0:b0:89c:8a0f:55a0 with SMTP id 6a1803df08f44-8b3fe7b6ab2mr56073336d6.16.1777570667338; Thu, 30 Apr 2026 10:37:47 -0700 (PDT) Received: from tornado.. (wsip-70-191-90-18.ph.ph.cox.net. [70.191.90.18]) by smtp-relay.gmail.com with ESMTPS id 6a1803df08f44-8b3ff315986sm1535706d6.6.2026.04.30.10.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 10:37:47 -0700 (PDT) X-Relaying-Domain: embeddedts.com From: Kris Bahnsen To: Dmitry Torokhov , Marek Vasut Cc: Kris Bahnsen , stable@vger.kernel.org, Mark Featherston , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] Input: ads7846 - don't use scratch for tx_buf when clearing register Date: Thu, 30 Apr 2026 17:37:38 +0000 Message-Id: <20260430173739.3843425-1-kris@embeddedTS.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The workaround for XPT2046 clears the command register, giving the touchscreen controller a NOP. The change incorrectly re-uses the req->scratch variable which is used as rx_buf for xfer[5], so by the time xfer[6] occurs, the contents of req->scratch may not be 0. It was found that the touchscreen controller can end up in a completely unresponsive state due to it being given a command the driver does not expect. Instead, rely on the spi_transfer behavior of tx_buf being NULL to transmit all 0 bits and use the scratch variable for the rx_buf for both the 1 byte command to and 2 byte response from the controller. This change was tested on real TSC2046 and ADS7843 controllers, but not the XPT2046 the workaround was originally created for. Confirming that the original modification to clear the command register does not impact either real controller. Fixes: 781a07da9bb94 ("Input: ads7846 - add dummy command register clearing cycle") Cc: stable@vger.kernel.org Co-developed-by: Mark Featherston Signed-off-by: Mark Featherston Signed-off-by: Kris Bahnsen --- V1 -> V2: Don't use rx_buf when clearing command reg V2 -> V3: Modify original 2 xfer command to eliminate dev_err() output on xfer with len and NULL buffers drivers/input/touchscreen/ads7846.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 4b39f7212d35c..488bcc8393293 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -403,8 +403,7 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) spi_message_add_tail(&req->xfer[5], &req->msg); /* clear the command register */ - req->scratch = 0; - req->xfer[6].tx_buf = &req->scratch; + req->xfer[6].rx_buf = &req->scratch; req->xfer[6].len = 1; spi_message_add_tail(&req->xfer[6], &req->msg); base-commit: dd6c438c3e64a5ff0b5d7e78f7f9be547803ef1b -- 2.34.1