Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1966128lqo; Sun, 19 May 2024 07:04:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5ShMw5HfflTVpbftI+KN0u6G/zdDLduMd/1HrKEm5418mr0V0OelyDgCGuRPTxMMWuA7HNykisqswzrYT4yyabO4iY8/euj0kkLnInQ== X-Google-Smtp-Source: AGHT+IHJWFac60Fajt16hgpqobsEFPoRmx72LaqSVJbhMlhNJQuX0pZpzCwmNAm1lgKNuPzst2tA X-Received: by 2002:a05:620a:5e0b:b0:792:b8c4:31a6 with SMTP id af79cd13be357-792c75ab874mr2793844285a.35.1716127454595; Sun, 19 May 2024 07:04:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716127454; cv=pass; d=google.com; s=arc-20160816; b=0Qfg25XwlLbP9YGUcNDwJ53E7S5RMVvAAJzpQpUjFIx9FqM8KqegHUQv7OwB55MYIE ZmFyeyW4PlILGaGVs3DShU2QYmOfvHA584g+wAWHqxeXZxrfUEVX3XkpFQYTYqpStmpa GhbEgRX8z05H7HxKsx7ooBcpigIABd9ZSuVJB1mcJe7PV9oqJEAxnMZmcRgSBuzZrnlc 3Dsrj6UzUE7lUsSwDIafGpAkyOFenCWk7aW8gwNdVfFLwC/5RpQmIA1Gaqr62JREXLzy 3queoOfXMgmWZcqrNwxPpesTxeysozDJyo7azKU3n9oOK4swoWgK1fXUML1nqVZJAoWm fW/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=auJlzyku0z78rksqzmbHHPEKfGvj73lY2NcohZ7SB9g=; fh=tr0vZ+5e5BvNCXUZcarsGLtTSKlAsSds9Df1cdlqEH0=; b=ilHOKjol7OD5sBNA/OHAuaUHz+eTepA6oigEOLHBWdUbhFQRkzCRgkWc60rpNpEVu3 CtN6CYTZAxf0oRhDxJ9iOmUSjmNbL8Hu5hP3JE/JTz2G2HavnncJQhJtnkRG6Uz4FPdq pGqhBoW0qY3RpF41XwfpDsiZajMfpknzdRXgGh0GoEzH9CjOulmtG16xK9HvAVuz5Vaa is0kPYt5uRqO+H59F8PzlhKMf7c4xmSg6TE/bRHctkN7Abt2TfqYtYdU53ZZFvcEMvQW UjkrbgVL0TDVozzv/92cRKi88BGnAOESkCAjf1G9fAhUTTtGRjwDFMSrzel8R6oYtw6x N8BA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fCQVH7hn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-183119-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183119-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-792f4878481si35464485a.481.2024.05.19.07.04.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 May 2024 07:04:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183119-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fCQVH7hn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-183119-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183119-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4380E1C20EBD for ; Sun, 19 May 2024 14:04:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E8F5048CC7; Sun, 19 May 2024 14:04:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fCQVH7hn" 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 122A3481CD; Sun, 19 May 2024 14:04:04 +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=1716127445; cv=none; b=e5d/rVjLoOwLld8LGx9oA/M4QAr3Vv5WqA/qxgRoEoLDi+CN9vBwrZwSbUX4CDpBjVp1xmq/dbW4vPRyKlbFtn/T6WCFDWsSRzdgkllgMSsk+UzK2lBdOUt3frfKXKaLS7OmjMl/bS2JW0KuELpac8JyJVPh+9gA+Ai0+u0XYuM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716127445; c=relaxed/simple; bh=kX5c/j3XbB6lfj9z5eriyWxGnhGXhpYNAAdgOsLVHyk=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RGi1VVD1ii33h5QsDu1BvaIcbfeTwtFpBDcfql62EMvd442o+mTGmgBHHoY3cVZSm0UDqpEWa01bXq5HNthTn4qi8f/toCIOjJmxFtQdPXDXrnFsi6XFU6Lb3svIP/nI3QL1NYLdnSoU9Pyli+gaQlfXowTkGb6WHWLeRiquyjo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fCQVH7hn; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F55DC32781; Sun, 19 May 2024 14:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716127444; bh=kX5c/j3XbB6lfj9z5eriyWxGnhGXhpYNAAdgOsLVHyk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fCQVH7hn3otSFLPQmanPzWBTNHre8jj/IOWcSdxgGX9ACat1VZzWqjkUD1cmKoauL vGJ0VsxxFk9yZNQeuYYHijja3mreZuyqjypaq4qT8SGKIXnudmRAcO2QcQ+SNnS+Dn i085mrJVmNV66K5jiw3bAQ+J25l0a7DcR6KYqa3t7Zz7nUUpLnyj5OfoeS4QOjb8z7 fGVfU2FQmk+dYKowfqcPRZ1kBP+crjvfHo/425I9qvSgy5/tos/4FMdsgyMDCG08VK DlPDClFPkAEtWZqVulUqfFWGm0UQXOrWz0ReOl5YTZ89dc4dL41/XDxrDrxgEZc4/D Zg+LPqI3POhlA== Date: Sun, 19 May 2024 15:03:51 +0100 From: Jonathan Cameron To: Christophe JAILLET Cc: Gustavo Silva , robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, lars@metafoo.de, gerald.loacker@wolfvision.net, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/6] iio: chemical: ens160: add triggered buffer support Message-ID: <20240519150351.6c248b1d@jic23-huawei> In-Reply-To: References: <20240512210444.30824-1-gustavograzs@gmail.com> <20240512210444.30824-5-gustavograzs@gmail.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.42; x86_64-pc-linux-gnu) 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=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 13 May 2024 21:13:07 +0200 Christophe JAILLET wrote: > Le 12/05/2024 =C3=A0 23:04, Gustavo Silva a =C3=A9crit=C2=A0: > > ENS160 supports a data ready interrupt. Use it in combination with > > triggered buffer for continuous data readings. > >=20 > > Signed-off-by: Gustavo Silva > > --- =20 >=20 > ... >=20 > > +static irqreturn_t ens160_trigger_handler(int irq, void *p) > > +{ > > + struct iio_poll_func *pf =3D p; > > + struct iio_dev *indio_dev =3D pf->indio_dev; > > + struct ens160_data *data =3D iio_priv(indio_dev); > > + __le16 val; > > + int ret, i, j =3D 0; > > + > > + mutex_lock(&data->mutex); > > + > > + for_each_set_bit(i, indio_dev->active_scan_mask, > > + indio_dev->masklength) { > > + ret =3D regmap_bulk_read(data->regmap, > > + ENS160_REG_DATA_TVOC + 2 * i, &val, 2U); > > + if (ret) > > + goto err; > > + > > + data->scan.chans[j++] =3D val; =20 >=20 > Is it safe? How can we know if it has been only *partly* updated? Does=20 > it matter to know? You've lost me. What do you mean by partly updated?=20 This won't push anything to the kfifo etc unless all succeeded. Or is there a race with something else in here? >=20 > CJ >=20 > > + } > > + > > + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, > > + pf->timestamp); > > +err: > > + mutex_unlock(&data->mutex); > > + iio_trigger_notify_done(indio_dev->trig); > > + > > + return IRQ_HANDLED; > > +} =20 >=20 > ...