From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (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 648ED2E6CB6 for ; Wed, 18 Feb 2026 23:40:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771458014; cv=none; b=Itb2B9tBfN2Rp/jnlvEWTR0nsRjEWXP7Ehi2hz5nfKaQQInK3zVVUid82z/YSzqULr4arZBP/E7+yWMhMhs6tz0r4xfClnmt8oIizZ/qWDgNO52i8Mcbyzna9AD1dLPjAdkiVK3VGwp89mYcnkawNrWhJP1oOdBS6bYL34qrcd4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771458014; c=relaxed/simple; bh=CBgZWwOQ0quvIbMpH+FyXTwEozhHuVvTtlYLjdZfyZI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hJo+O8w9sg8tBJldlq0hdnXRG6C9luoZPle7Dbtr9ar+wmcHvjecToECT+nx4r9NLF20cnCeWJAE9T7QbRDLciUZictIlFEBc95lnte5NrO7uBeSDA74x1ZX5t1gpu5L+1QcNbQqHugY5WE650H/7diBGWktxniSXBO/wjdvR3M= 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=WCgC55Ih; arc=none smtp.client-ip=209.85.210.54 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="WCgC55Ih" Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-7d4bd4db87aso297155a34.2 for ; Wed, 18 Feb 2026 15:40:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1771458010; x=1772062810; 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=ZMVQf5AvRtVxik9hL/PNE4v6s7C5GzaRdwqbUswM+4s=; b=WCgC55Ih7jAyzcQRxfRkX7BJXn16lQ5jNhCxAr3/e1lyAEfomMDus45WhixWWhQuqp /G4nOmDwzkG0hKjLfJODNycPBkq6M1TOKCFDjFEDLGAfOMBhRVquMOnK1NKYhFk5GfF2 3ECRJF+LWXjV2r5741PpF3p/mfATd88xnzhccINecyKADfqabzZ+5FpyfGLigjS875HV 9xxNNSr4rnA+Wbk0AYpLA5sHizA3dex08vDhlihpOrob6bSGtn3GMdCj0rxicdQGmchp J83dPsgpHKAI/LE5paXBxjk7t/2tscrdsZfztbU0twxLv/vjPYR2lbhBOOkz2urqgRff rdRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771458010; x=1772062810; 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=ZMVQf5AvRtVxik9hL/PNE4v6s7C5GzaRdwqbUswM+4s=; b=kQmxX+SgYRidTdPPs/n0GJ2hH1MetPR9HWCCP2P2j6HaRmqAW5HjP+LI9a1/0WIy/w J2DddQ4FakuXfzIkEV1qwBttB1++aFe3+xSeP1i6+ijaRZUEiH+XfXCIKcFAwQavAMev 5PxxmqaX2J3dfBrfIIks1fckZLcFLFSb3fbiIyJNHlCtfGgNKkaeMKrUC7M886Hl96JL 8I0xnB705qluDJxp4romEwVFz+F6Xq7nsKZPZ7id4hpHGYHBy+RbmxSQhmbicGa6JlQk OOUB2jx3HIzy6VjF/mhfIlqB1WATUfQ2cO1uecG+F/+LIcmaPDUEnD2x/NHVEac+yMt7 50xA== X-Forwarded-Encrypted: i=1; AJvYcCW3xEBxee7kiKuUXnX/Gyx6/jWiXqFra7xmEkwbE6qIVGxIX422FHc1htYl3QwlOAI8kZw8SqIBrWfxPik=@vger.kernel.org X-Gm-Message-State: AOJu0YxSe8PftD1kXALqXxTo3PhlqiiA2IdhKYeIlgcSieOqp/huVB2S HpqgkgIpU0anxvKva2QJd76g6Qzeu8yWIz/QaeyTSACoGpFyBM4/s1sw+zfpKXVA6D4= X-Gm-Gg: AZuq6aJ0C+PAqEhzIJy8NQ7PUdQO8R2a9pSUIk9c+PaAC+3IkURwKoN2XD59lkNfSNO rrdVpZXjE3LZjQqDF5yiab4bPyCd62k9rmCUmoGfyo2mbezPXIlcJaundZlIwv2/WHeNKKzwigF pqOMMsXp1r62HufGpHuAqowJiOCLcYe4dcE3zXJLGVYmhWS1+b5/nkh291dq8cQtEG44HHHipHZ Hre8tKOkutbr+rv/9futAJaAp2Y9lcsPtgP+MX1R1fHT19utrx4W7/gPNbvmt7hp5ymvj5Uq8nt tyfqndY7hZ8VmrZsTv/eflwmSf0fFO1SaW3T2GVGlhXRRF+amU1DUKqIwTT+sCG6oXFdjbpdXbL GPdP9vMHD6IZ90Eo+lX9jnxEYFhF+jR1diz5CwXFIRTcWiEtO9N//jEjbhvr963ZmVWHDUJCXOt ar9wPNMXL5nTH+Zg3pXy6Q4H818NtNh8ub427rdMD5RF/XYiBBbGVY9nxYneBh9WXwgQ6PUuaF X-Received: by 2002:a05:6830:83b2:b0:7cf:d9a3:12cf with SMTP id 46e09a7af769-7d505dc3856mr2774563a34.16.1771458010253; Wed, 18 Feb 2026 15:40:10 -0800 (PST) Received: from ?IPV6:2600:8803:e7e4:500:ab87:97b2:3c7b:da2f? ([2600:8803:e7e4:500:ab87:97b2:3c7b:da2f]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7d4bb66a066sm15763696a34.19.2026.02.18.15.40.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Feb 2026 15:40:09 -0800 (PST) Message-ID: Date: Wed, 18 Feb 2026 17:40:08 -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] iio: adc: ti-ads7950: normalize return value of gpio_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: Content-Language: en-US From: David Lechner In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/18/26 2:52 PM, Dmitry Torokhov wrote: > The GPIO get callback is expected to return 0 or 1 (or a negative error > code). Ensure that the value returned by ti_ads7950_get() for output > pins is normalized to the [0, 1] range. > > Signed-off-by: Dmitry Torokhov > --- > drivers/iio/adc/ti-ads7950.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c > index bbe1ce577789..0c4db18ec4d7 100644 > --- a/drivers/iio/adc/ti-ads7950.c > +++ b/drivers/iio/adc/ti-ads7950.c > @@ -433,7 +433,7 @@ static int ti_ads7950_get(struct gpio_chip *chip, unsigned int offset) > > /* If set as output, return the output */ > if (st->gpio_cmd_settings_bitmask & BIT(offset)) { > - ret = st->cmd_settings_bitmask & BIT(offset); > + ret = !!(st->cmd_settings_bitmask & BIT(offset)); ret = (st->cmd_settings_bitmask & BIT(offset)) ? 1 : 0; Would be consistent with the style of the rest of the function (see below). > goto out; > } > There is actually another bug with the return value of this function: ret = ((st->single_rx >> 12) & BIT(offset)) ? 1 : 0; /* Revert back to original settings */ st->cmd_settings_bitmask &= ~TI_ADS7950_CR_GPIO_DATA; st->single_tx = TI_ADS7950_MAN_CMD_SETTINGS(st); ret = spi_sync(st->spi, &st->scan_single_msg); if (ret) goto out; out: mutex_unlock(&st->slock); return ret; } When the gpio is an input, the function always returns 0 or error, never 1 because ret gets written over. It looks like we need to introduce an extra variable to fix that one. If we make the new variable bool, then we don't have to mess with `!!` or `? 1 : 0` to normalize it. The compiler will do it for us.