From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f45.google.com (mail-dl1-f45.google.com [74.125.82.45]) (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 B404235C1B1 for ; Sun, 22 Feb 2026 21:37:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771796233; cv=none; b=Y4dVVzQrCRLgnt31DgHPIlkTj3dm4g90Gbf8CGO+avaUiATprePmFWFAD+VUf6SVYJsbHA43+oe8mP1LIwRYmmXmSmzfnlFuaP38qoMiDpiABKC4811VIu3NjX3oIl5crSN1nytTdeClyn+37CVBjFciswWcQY902pyI7pwdllM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771796233; c=relaxed/simple; bh=j6w1ZqKBSf98wkhfIbCweFEmRiSxHNsz6skq7q2g9vc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=soQAP9NbS+hil3C7jU4wWUK89x077D/njO7YohqGttGHSUGicujvAb0muqtzxC7sLqj4GSCX1I+BrEoMEVaZjD1bLQKonTWdR3aD727i0iIxxvI7egxYzlwDfalvikZLCwKwoOia+sgU64Ur7ZDhrgITfESxMj1CZAp2GPALpJs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EEOTtyc8; arc=none smtp.client-ip=74.125.82.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EEOTtyc8" Received: by mail-dl1-f45.google.com with SMTP id a92af1059eb24-1270be4d125so9375905c88.1 for ; Sun, 22 Feb 2026 13:37:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771796230; x=1772401030; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=b4mMM5qE+qxfR6dazqNKHp062hw1pJNzveR355ArO0Y=; b=EEOTtyc8x3XnfA0xsSJCeW30y0ltev2Nt9gUV2kFoUTuagnigV1coM0yEsmPAGwGdG obpXlaVptmt0pCNp25/donCpllSkM1+IQtGnpSty/s0udjoRmHiStWqAsEAeQTanYRX/ LctqezbKQvjrhnBdv5sZ5PtiO/GT+kzXF2f7WwVhj6dJ2IkY69iTjndP022fYIWWCI1M 9toXbJ0cwTw7X2+9P0E4jD+C8QrvaQ3MUP69hkbxz61pS36ZKPgIomvQqoTfkXrVAAYt HibDvg4v6/8RWU0XipYOqDhxA1bf3pbnxkIs1pgpjpB43I+YURH8poXloNCrpFmeH9t2 96eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771796230; x=1772401030; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b4mMM5qE+qxfR6dazqNKHp062hw1pJNzveR355ArO0Y=; b=j+2qdkYB3YjSJn/TeJ7FchC4jkWFWGRMwuP3CB3qHCs1xxWmKiuwIb+YOofM0Fl5hD eFcI+mTbBojEHK+2AnhHAXwJ7P377NsfJZapNgJemurqyQvxJ520qpLC7E1Fpbk1nWY8 2GH4OBQYB99Y7AaE54V29LpBrzj9ZO5P5fU0d5cjY4NMytUEvb0uM+ivVfP0jjeZk2MS vSopRd0Fqqt1yUVZfwgjGkv3EBebZdp7WlbxCto5F+4+bXK6UGO4J87kOHWaT68drkwZ SWmGBJ+9IuLydk2X/X7QSWWttIjdb2LnHMVs3hv6k1GCmDTTe5GHXUm43iGAl1QWUWBE 7fvg== X-Forwarded-Encrypted: i=1; AJvYcCUv/99YjyNiZaNaadnnjNPOz/72db7mP8HIftibuIyhblCS7GppzheffUQ6uMDxzMnSV7b+qvAZeRGXpLk=@vger.kernel.org X-Gm-Message-State: AOJu0YzTxIcVfUFnGUZ6ThzwcJqf2wdG/NS79VZnjffnBP+2H729FIbT D9nYXgBEWr9Zy2HNRfsw0156l8LuFu6vCUbYwFJpg5HXAVu4zAM9His7 X-Gm-Gg: AZuq6aImf3sG+Vu3rVvgIU4m4YwVNAoY7q/dUaI6AA1VH3/yes224bXf2L3oU78UlHv WEKRTIgrPCgtMCVitMxWmHoqKyjt7cOCGImhPp843HU7v7ZsmxO0zNXblAwydg+36MM1suPb0c0 km339yX7xY6evJ6JYuu+JWvWbzdIgU8r5IOFmDYTI8GutYFjL4RLYvHJS7F2jYBniergLH6P0Mz Ky34fSRhowNQA/dpYHUUdXP/hejSiK/Uiv8/MZ/n5QshvEurxFc6ouxH80RMWDraBogsfXFPl9T O3fwtB0IwGQauV+QY4eyaaGoeDKpPN4yGcaPpqDx6rIfevBLUANPEVUWekEaHcBFCml4b7hdQ2h GcyXQpZYO4PGs9MHq1q/iMCACLF0BEMgVVKdbaKbCchJgztkQE/b8ItHfsRdS+mtaKaa2xRPG6L mNO7GzOPUwL9MrUkST0aB1jHghqYz3MtFiCYxa1n63F90Ng5BibOMAoSjb2iChUQ7ARh1ke021G A== X-Received: by 2002:a05:7022:60a5:b0:123:2d4f:ef20 with SMTP id a92af1059eb24-1276ad2ec3emr2889618c88.31.1771796230364; Sun, 22 Feb 2026 13:37:10 -0800 (PST) Received: from google.com ([2a00:79e0:2ebe:8:c6c:6cca:170e:c77b]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2bd7dbe8293sm3806939eec.16.2026.02.22.13.37.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Feb 2026 13:37:10 -0800 (PST) Date: Sun, 22 Feb 2026 13:37:07 -0800 From: Dmitry Torokhov To: David Lechner Cc: Jonathan Cameron , Nuno =?utf-8?B?U8Oh?= , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Subject: Re: [PATCH v2 3/4] iio: adc: ti-ads7950: switch to using guard() notation Message-ID: References: <20260219022929.3558081-1-dmitry.torokhov@gmail.com> <20260219022929.3558081-4-dmitry.torokhov@gmail.com> <0b9e1c9d-9bee-4fc3-ac19-28d969f65ef2@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0b9e1c9d-9bee-4fc3-ac19-28d969f65ef2@baylibre.com> On Sat, Feb 21, 2026 at 11:34:33AM -0600, David Lechner wrote: > On 2/18/26 8:29 PM, Dmitry Torokhov wrote: > > + scoped_guard(mutex, &st->slock) { > > + error = spi_sync(st->spi, &st->ring_msg); > > + if (error) > > + break; > > I'm not a fan of scoped_guard() because of the hidden for loop in it. > It hides the fact that the break; is breaking out of that for loop. > > It would be more clear/obvious written as: > > do { > guard(mutex)(&st->slock); > > ret = spi_sync(st->spi, &st->ring_msg); > if (ret) > break; > > iio_push_to_buffers_with_timestamp(indio_dev, &st->rx_buf[2], > iio_get_time_ns(indio_dev)); > } while (0); OK. I could also make it scoped_guard(mutex, &st->slock) { ret = spi_sync(st->spi, &st->ring_msg); if (!ret) iio_push_to_buffers_with_timestamp(indio_dev, &st->rx_buf[2], iio_get_time_ns(indio_dev)); } to avoid using "break". I think you will find that scoped_guard() will gain the foothold in the kernel so having implementation that does not follow common pattern might not be the best option. > > > > /* If set as output, return the output */ > > if (st->gpio_cmd_settings_bitmask & BIT(offset)) { > > state = st->cmd_settings_bitmask & BIT(offset); > > - goto out; > > + return state; > > This can return directly instead of using local variable. This will require the explicitly normalizing, which we avoided by introducing "bool state" to begin with... > > > > st->single_tx = TI_ADS7950_GPIO_CMD_SETTINGS(st); > > - ret = spi_sync(st->spi, &st->scan_single_msg); > > + error = spi_sync(st->spi, &st->scan_single_msg); > > Can just return directly here now. I think there is benefit in explicitly calling out the error paths and explicitly return 0 on success. It removes the doubt whether a function can return positive value on success. Thanks. -- Dmitry