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 83BEA255E47; Mon, 12 May 2025 17:54:58 +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=1747072498; cv=none; b=oN3JUhtbuDH7cx5auoe8yvJIGsjpTJZ3AQlukXqMN7fT4t4YUQO37gO0eqwVYNVKo4Qpv9IYoa0SmYgV7gLKeUdpX3gr3U6GImO9cjuoJO49tIuHXqdbNFN2oXzQ8wIXp8oJMLEkl5ojlnlkgn+j/08T/JcoP5s97Vn4YefWeh4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747072498; c=relaxed/simple; bh=HSTehoG2wpqCwNU1MkG0Tp4gSFgYrMJGhr5bgDI26TA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KBucJQMkkgNlmtgd2iAnCHZLHJWoKtzW/IKJ9VFkHzQVjwbRcU5UoRtbnGHCRMNzzs5PFOWmVKGUHwtnD9gArIRtOJOJbi8OZfdQ5S2OHQh2trX49BbkgIVNI7sBMmcEAiIIY9vsSPNyvbIvweMbVFbDcU3wP3bGy1kvL7CBCy4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=JW/wDRla; 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="JW/wDRla" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E553EC4CEE7; Mon, 12 May 2025 17:54:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1747072498; bh=HSTehoG2wpqCwNU1MkG0Tp4gSFgYrMJGhr5bgDI26TA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JW/wDRlaiXvxSgyP3de+YfQal4vJuWP8mIgC8TGW+IRJJMReHzF3cd+C9NnP1Vbni KodWzlJMS4Rrm+oVwDMW/8kUUCRxA57qMV4S0U7qqMWH/BQQxx5NmTtaVzXGuy/vdy QZ5nF+JI3QLmAT3FFWrID45eSccmfsQCL9MREIcU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gabriel Shahrouzi , =?UTF-8?q?Nuno=20S=C3=A1?= , Jonathan Cameron Subject: [PATCH 6.1 29/92] staging: iio: adc: ad7816: Correct conditional logic for store mode Date: Mon, 12 May 2025 19:45:04 +0200 Message-ID: <20250512172024.310441868@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250512172023.126467649@linuxfoundation.org> References: <20250512172023.126467649@linuxfoundation.org> User-Agent: quilt/0.68 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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gabriel Shahrouzi commit 2e922956277187655ed9bedf7b5c28906e51708f upstream. The mode setting logic in ad7816_store_mode was reversed due to incorrect handling of the strcmp return value. strcmp returns 0 on match, so the `if (strcmp(buf, "full"))` block executed when the input was not "full". This resulted in "full" setting the mode to AD7816_PD (power-down) and other inputs setting it to AD7816_FULL. Fix this by checking it against 0 to correctly check for "full" and "power-down", mapping them to AD7816_FULL and AD7816_PD respectively. Fixes: 7924425db04a ("staging: iio: adc: new driver for AD7816 devices") Cc: stable@vger.kernel.org Signed-off-by: Gabriel Shahrouzi Acked-by: Nuno Sá Link: https://lore.kernel.org/stable/20250414152920.467505-1-gshahrouzi%40gmail.com Link: https://patch.msgid.link/20250414154050.469482-1-gshahrouzi@gmail.com Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/adc/ad7816.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -136,7 +136,7 @@ static ssize_t ad7816_store_mode(struct struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ad7816_chip_info *chip = iio_priv(indio_dev); - if (strcmp(buf, "full")) { + if (strcmp(buf, "full") == 0) { gpiod_set_value(chip->rdwr_pin, 1); chip->mode = AD7816_FULL; } else {