From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.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 E110C1E1E04 for ; Sat, 21 Feb 2026 17:21:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771694506; cv=none; b=dVjH2Boo/x/grLAuNBEk132aOfCo1DSbeEKGmlW9mnaSuAyEVh97Y0Ht9dzGVQaMxUyE3QPr2dKKtgflhBL9ixty1mTPzaILHqqggKAsrwQUumkyUHmeMZIg79ceZ/6lnct23qxVoTch6+aibqZg1mg10HCOg+ZZhDY714eD8Xs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771694506; c=relaxed/simple; bh=HX8Wjejxs9SblZXe1zexUK/AgCbHBl2YK9FZzjvdrF8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=YzdRjZozMuZQfTyZ5sIo460NjWi/jicnXPQn8Ocq3ApN4CapoGeKuSeZTih0YXp91vwkoQW+NejFkn8s9HH+fkBI+u6wD4QIeBo5UEJ9AmtC3ncnrtjvRSXa1XjKkcub43DNsz4lU6ANYX2A0gVAfyOVy5KM03ZYHi1mhd0JltA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=1dMp0pvB; arc=none smtp.client-ip=209.85.167.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="1dMp0pvB" Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-45f18e8f2f5so2024587b6e.3 for ; Sat, 21 Feb 2026 09:21:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1771694504; x=1772299304; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=FxXe4ilYefGxi3OGmxieGZpHIIMSFQ3LuTkepN5BPTs=; b=1dMp0pvBBcT72yRVmnDpVDdmkyvFOhFe9V4klVqf6d2mk+UUQAZhYDMcCTF21ebmpt z++ZqktLNWYodL72ZYcb914pgFJHgDZz0K08ucmQkxe0wTrhVtU+tEtHAENg1rgK4qtY x9fx4q52HQBGw+793fo8nkuduB9kCtJ67wIuVsSMdnAFWBc8+MqnTEgYKbNUvEO9TxYN KRrnG/bAWD09+P/4Nrr3QeMnmPV95Kl410bx7/KzeinLAPM5YDzPSg2othCqSfukGllm rDVPcLPs0ItrlmIItJqxA9BcCthufi+tmsmmJ8vOvTug8NyVfyhsB8UMha5zpSuJ1yTF 5aEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771694504; x=1772299304; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FxXe4ilYefGxi3OGmxieGZpHIIMSFQ3LuTkepN5BPTs=; b=QnbpIOkSzr7q6vmZnMXXv7qidRohOWPJOgBzgN7MCI60fSXVhAgFPNS3fZVn7HTWrj uiZ3DDfq6GX6R82NA3TnIkEeEMmMnxtSdOVXZoOVfH4NO0Zy6T+Qn055NbdS7Fv5Llks 9/nHUSYDfQp5AYHp3HHJsjMhTXd4sza5s5bDylkFtpk+1Ov5pZQNX3Rfft3fzSsy6LLt du59nTRxWpCwZalIDLLdwW2KvoPjjzTCt/WXOeBvYJUvuhACVm6/iwP6Ay5UfOEhxilR pVeUBHYTLFsW7m2m6L1uQzO5p/tUTiIEEscXfcgdxBm+54iULSrOvl19INW6Uidn1aCx cEWg== X-Forwarded-Encrypted: i=1; AJvYcCXO2u4W+w9YawQj+GWVpqhWIWLfBQ1Y0gaOZ1YT4vc6oEaGjUjAYOrUtr17BRYDLkMNWBusqPK7wvgtG+k=@vger.kernel.org X-Gm-Message-State: AOJu0YzN0CHFik327uYMsT8uIAjKBEUM2dpnd+Fx7dJLoURpjlzmyfe3 H/ZdkzMNjRirJq5ghaaJN1vyIhEf1j0EijFx2qoH+yln4Olkjrq6dQfr4MuA0hOqhiw= X-Gm-Gg: AZuq6aJgNZA0ofXI+aHW7/GTFAbta2b2eKZtFr0XdEfTiae4TvzaZZ5kQcViBaWcVZh iKxFn/YP7fZiK/PlzFG9ezxqLOjix/owFkNvzcKxbCC8Z95DxgtJRXWEzMkYCkOJtDYPI3oBl/0 zicdTgQlA5gCkjroP95NACK9AH2uiActkxosAyEyDZyylbipnycg9iq0grUKCktbETQu7rKbMld 3gzxHCM5kiNncjyYiGMwTXkcxPDhZIbWlIc9fnvyvhSO8x2g9Y5tbnT7h5/hzujAn32Uj/KoCcS scgPEuKqcJGJhMSOeGnLi2OnmHTIOaszVjkehmXamGzaDqODNHgcEm2LBGm91nDk04Wt4Ns3XP1 gy4OZdOAIAei65JNro3VKYTpmFKct39GOuZiVd6aWIqfVqVNpdb8xzEoW9W1FSzRGzUUOzaMpHZ gSAakx7/YLw0fqqueyYYqWDqIVVX0LwcMQq30fBpzTrzHo6/AXwJylke2g942PO+cfC5RCjg== X-Received: by 2002:a05:6808:23d1:b0:462:a915:31aa with SMTP id 5614622812f47-4644640b4c0mr2054950b6e.63.1771694503792; Sat, 21 Feb 2026 09:21:43 -0800 (PST) Received: from ?IPV6:2600:8803:e7e4:500:611:96af:f385:64bf? ([2600:8803:e7e4:500:611:96af:f385:64bf]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4644a012dc7sm1839578b6e.6.2026.02.21.09.21.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 21 Feb 2026 09:21:43 -0800 (PST) Message-ID: <6c8809a2-04fd-4044-a07e-8b74c964ead6@baylibre.com> Date: Sat, 21 Feb 2026 11:21:42 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/4] iio: adc: ti-ads7950: do not clobber gpio state in ti_ads7950_get() To: Dmitry Torokhov , Jonathan Cameron Cc: =?UTF-8?Q?Nuno_S=C3=A1?= , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org References: <20260219022929.3558081-1-dmitry.torokhov@gmail.com> <20260219022929.3558081-3-dmitry.torokhov@gmail.com> Content-Language: en-US From: David Lechner In-Reply-To: <20260219022929.3558081-3-dmitry.torokhov@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/18/26 8:29 PM, Dmitry Torokhov wrote: > GPIO state was inadvertently overwritten by the result of sip_sync, > reuniting in ti_ads7950_get() only returning 0 as gpio state (or error). > > Fix this by introducing a separate variable to hold the state. > > Reported-by: David Lechner This should have a Fixes: tag since it is fixing a real bug. Also, fixes should come first in the series. > Signed-off-by: Dmitry Torokhov > --- > drivers/iio/adc/ti-ads7950.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c > index b8cc39fc39fb..2a7d4a1d9fa9 100644 > --- a/drivers/iio/adc/ti-ads7950.c > +++ b/drivers/iio/adc/ti-ads7950.c > @@ -427,13 +427,14 @@ static int ti_ads7950_set(struct gpio_chip *chip, unsigned int offset, > static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset) > { > struct ti_ads7950_state *st = gpiochip_get_data(chip); > - int ret; > + int ret = 0; > + bool state; > > 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); I agree it would be better to put... ret = 0; here. > goto out; > } > > @@ -444,7 +445,7 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset) > 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 +457,7 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset) > out: > mutex_unlock(&st->slock); > > - return ret; > + return ret ?: state;> } > > static int ti_ads7950_get_direction(struct gpio_chip *chip,