From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B71FA37DE90; Wed, 8 Apr 2026 19:00:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775674827; cv=none; b=XxMWYd1qNIZVnH2uwJAMed1CSWGiJhvg4tdAfPjOo2eIu8ujW4986zm+P7IByIpW8jt6n3/TQ0iNTdMk4pKNORZmnwTgiRIUU7hoRKa/LPUDlsPQcSp3s/+5PPSG1rFZE7JBRgNDOIrhEGNckqnXz3ivRkMWdpSfi+rJN1ErLXw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775674827; c=relaxed/simple; bh=VjrT1ZJp89cRG+7whp+wcjuF6I7/MWvemaDNw49JIGU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qC+8W3ey6NtmJPMzqOQvO1c9DftzJvGdZRE3pSOQheHSYGR8rQtOfU+d4fhMgX0m3/faSHJik5epoEjwouJsBTuMyPIvfs0NbEcZoF8/vTeJk2SXwm57LdfBMAq3ZfF10tj2i+t2iN4DAhT1bmIpVhp6ZoZ4qcn4uuSV/Mlvy7o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bHUs+93O; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bHUs+93O" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C550C2BC87; Wed, 8 Apr 2026 19:00:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775674827; bh=VjrT1ZJp89cRG+7whp+wcjuF6I7/MWvemaDNw49JIGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bHUs+93OskiNoyJRuAgRGh58j8V8ahnqsHwafBEaxKA1UJwxqGXqTWIiP1mZvjaxi eWJejlGWaPgx5J81CvoCQyMzxg9gbUsjCrTxTtkPZUL7HoLml91x/Wbjwo3PxkDJYD FlXjC+pdGZI41P+HRXPD5mWfWkhafoNdel71fbaQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Lechner , Dmitry Torokhov , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 6.19 216/311] iio: adc: ti-ads7950: do not clobber gpio state in ti_ads7950_get() Date: Wed, 8 Apr 2026 20:03:36 +0200 Message-ID: <20260408175947.469189042@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408175939.393281918@linuxfoundation.org> References: <20260408175939.393281918@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dmitry Torokhov commit d20bbae6e5d408a8a7c2a4344d76dd1ac557a149 upstream. GPIO state was inadvertently overwritten by the result of spi_sync(), resulting in ti_ads7950_get() only returning 0 as GPIO state (or error). Fix this by introducing a separate variable to hold the state. Fixes: c97dce792dc8 ("iio: adc: ti-ads7950: add GPIO support") Reported-by: David Lechner Signed-off-by: Dmitry Torokhov Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/adc/ti-ads7950.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/iio/adc/ti-ads7950.c +++ b/drivers/iio/adc/ti-ads7950.c @@ -427,13 +427,15 @@ static int ti_ads7950_set(struct gpio_ch static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset) { struct ti_ads7950_state *st = gpiochip_get_data(chip); + bool state; int ret; mutex_lock(&st->slock); /* If set as output, return the output */ if (st->gpio_cmd_settings_bitmask & BIT(offset)) { - ret = (st->cmd_settings_bitmask & BIT(offset)) ? 1 : 0; + state = st->cmd_settings_bitmask & BIT(offset); + ret = 0; goto out; } @@ -444,7 +446,7 @@ static int ti_ads7950_get(struct gpio_ch if (ret) goto out; - ret = ((st->single_rx >> 12) & BIT(offset)) ? 1 : 0; + state = (st->single_rx >> 12) & BIT(offset); /* Revert back to original settings */ st->cmd_settings_bitmask &= ~TI_ADS7950_CR_GPIO_DATA; @@ -456,7 +458,7 @@ static int ti_ads7950_get(struct gpio_ch out: mutex_unlock(&st->slock); - return ret; + return ret ?: state; } static int ti_ads7950_get_direction(struct gpio_chip *chip,