Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp866318pxa; Sat, 1 Aug 2020 08:30:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB1rRpQNHxJ/Ug/rc6Ub6vZ9g5FLMs2scFwHBZUSqyEv/95B0UkoEWVhhT30e6wqpiDxrQ X-Received: by 2002:a17:906:1f53:: with SMTP id d19mr8834882ejk.327.1596295836398; Sat, 01 Aug 2020 08:30:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596295836; cv=none; d=google.com; s=arc-20160816; b=fwqSMDvK+7mwkMZ+PPekOF/IH8o0xSR2KeCxVEcNE8HQ5xZQs8GFzSRUk+DlNnGqs+ oYknQvbNKlBfrU1MeUxNpz2auL1r6GG0BQqtnCKvZNIqesQG1csHCrecv7C2YoO9SEG3 +qpXXD1ena0amFKviNLFHnEpaxQWv3UkNyoshecVixdAUX3Gi6gatoqPAAIFGVohDMLQ HieKZ2uXUH/6mk5nrlZxStPGv7lZkrywed7o0C/p80iZ9D2o2jzYTK7Bwff3fegncZNB BnKvyrv5WiyjIXjXDv9fcDQpZnbeteu0MikrXOUwB3DM1y/pttbS3m+OfaLrZm8J3NRg SDYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=BCDSImVBveqtVx64tGD4VKK2oZ+z9p5HpjqvM2dl8aA=; b=P2KWDnq8b1xHHppl95b9fOC9HsDskv7T3oa37S6KfZqWOaK0yeoSmGXG1wmYf2UElF eaN5OAFyyUCrc3BNrNYONCoRWa3jKl0WxffQtPKH3b/OmBJ1Zmo5lbrtnnmQF0kpLKCL 7r49BKQWBAMoB6OZv9sf92CxfNGSd/SWLLFi9MPsY68knvciiXicEVPySJyQPO6MaFi3 DA3CLkNfXUMO6Kt6/qn7U/CJHEDoMKEYUagLaJgj3+pnxa/WtXx/zuTWDakXKCSSaSde 5UKCiECj2vLNwdTS9PWvAFDtfBnRyMXR86AtVhiwl0Q0XwfCSdh1f4apNa/SvdW6GiXt nhFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="B8/luOJz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v26si7035406ejc.337.2020.08.01.08.30.13; Sat, 01 Aug 2020 08:30:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="B8/luOJz"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726475AbgHAPaD (ORCPT + 99 others); Sat, 1 Aug 2020 11:30:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:39554 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725841AbgHAPaD (ORCPT ); Sat, 1 Aug 2020 11:30:03 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2A7EC2076B; Sat, 1 Aug 2020 15:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596295803; bh=P8T+Tnd7uA29eNwgrQ7qBdEtBlOeKFxgx2mQ8vnK9WQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=B8/luOJzMSlo+rP8VED7ogHEJDNgOoss+z5BJpvM17Gvgff3Q7/KejW4MwThdFVrS w3Jym+NFTwWyiVyCyLnucjBlCvsWnq0NMAuSmbTJQTCC8Hj+4CNgG47eD+ohI0S2nH O89F6geEJHbHGQU1jSEZEH8Tz0uy2Zeu6AFoIiqI= Date: Sat, 1 Aug 2020 16:29:58 +0100 From: Jonathan Cameron To: Christian Eggers Cc: Rob Herring , Andy Shevchenko , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , , , Subject: Re: [PATCH v4 2/2] iio: light: as73211: New driver Message-ID: <20200801162958.56000bd0@archlinux> In-Reply-To: <20200731070114.40471-3-ceggers@arri.de> References: <20200731070114.40471-1-ceggers@arri.de> <20200731070114.40471-3-ceggers@arri.de> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 31 Jul 2020 09:01:14 +0200 Christian Eggers wrote: > Support for AMS AS73211 JENCOLOR(R) Digital XYZ Sensor. > > This driver has no built-in trigger. In order for making triggered > measurements, an external (software) trigger driver like > iio-trig-hrtimer or iio-trig-sysfs is required. > > The sensor supports single and continuous measurement modes. The latter > is not used by design as this would require tight timing synchronization > between hardware and driver without much benefit. > > Datasheet: https://ams.com/documents/20143/36005/AS73211_DS000556_3-01.pdf/a65474c0-b302-c2fd-e30a-c98df87616df > Signed-off-by: Christian Eggers A question inline about flipping to config mode mid capture. > --- > MAINTAINERS | 7 + > drivers/iio/light/Kconfig | 15 + > drivers/iio/light/Makefile | 1 + > drivers/iio/light/as73211.c | 780 ++++++++++++++++++++++++++++++++++++ > 4 files changed, 803 insertions(+) > create mode 100644 drivers/iio/light/as73211.c > ... > + > +static int as73211_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, > + int val, int val2, long mask) > +{ > + struct as73211_data *data = iio_priv(indio_dev); > + int ret; > + > + mutex_lock(&data->mutex); > + > + /* Need to switch to config mode ... */ Is this safe whilst we are doing a capture? You may want to claim_direct_mode for write_raw to ensure we don't get such a race. > + if ((data->osr & AS73211_OSR_DOS_MASK) != AS73211_OSR_DOS_CONFIG) { > + data->osr &= ~AS73211_OSR_DOS_MASK; > + data->osr |= AS73211_OSR_DOS_CONFIG; > + > + ret = i2c_smbus_write_byte_data(data->client, AS73211_REG_OSR, data->osr); > + if (ret < 0) > + goto error_release; > + } > + > + ret = _as73211_write_raw(indio_dev, chan, val, val2, mask); > + > +error_release: > + mutex_unlock(&data->mutex); > + return ret; > +}