Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1823122ybv; Fri, 21 Feb 2020 04:07:47 -0800 (PST) X-Google-Smtp-Source: APXvYqxccguUYlCnF0/cC2hU/hpS2u+S4Nqnaba+ebblFJrnzDcAOgH/4r1BcSznUYcC83W23aek X-Received: by 2002:a05:6808:994:: with SMTP id a20mr1689290oic.67.1582286867880; Fri, 21 Feb 2020 04:07:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582286867; cv=none; d=google.com; s=arc-20160816; b=a25ZSJQNjmRGIM7hkMOBNfTWrEzah7aeulPohaM0Kk2Xe/KFLv4gGz5O7gkIKOTrtI IOY2cMa8TpngiO5G4R61IYiRG3+dO+H4QltWnEqf1RW75VO3b5/ZpetmsaN+f/oj8/a3 6/1OE83wEHJy6uLfqfBmPddGZweJmk4OshQf1dht5FHsNwZpHi9pMajSRpqxSadowh8p kRLruwxJbI0BhYNG0vXhANHv3uAHdD+lNSjYvZBD04Ady722Wl8bg7l+rYLRDy0KWemd sWNAi0pEHaWe6BaRVMkReogZLDVLKMvROz3viiWjpUd7+B/3domp4zYwolhnCegQwLt/ qNeg== 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=aZi1kkgWIN7Nf6NEh1ThqjTM4XFrHvZ24sdQr4Inq68=; b=cjRbvYLAfG+VXchQzdfkl28J2/XwO6nQZOe3pMJZGP1IbClA4QodZZz2qGAPHNhsRU 5wn6ChTZGPUkc6QAaE3O1lYt7a2G2A/XGEPWueHKkyKLWUpQp4B+3NDC4hV93YrnaKJB dDZY8oITRCeRhID5cCn8ZGgsrD1yRgi8xaVlp24qfI44gxTCPLxbO7n3q76jOoewoJQY zASdbVojcgh8ZIpedonOHOtwuRBkLsQwHKh/cnHfyb+qXI6gPNofKQ/cmOaHDR4yOYDm TUE6ZX+0eUWhMyzngrVycIOtzxQvCpy6K8W9l8jVtYoP9cxEzdjJ6vajkXx+EpvPpnz2 geFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KtCnfAra; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id v18si623588oic.188.2020.02.21.04.07.34; Fri, 21 Feb 2020 04:07:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KtCnfAra; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727096AbgBUMFZ (ORCPT + 99 others); Fri, 21 Feb 2020 07:05:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:50672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726410AbgBUMFZ (ORCPT ); Fri, 21 Feb 2020 07:05:25 -0500 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 80F4B24656; Fri, 21 Feb 2020 12:05:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582286724; bh=WIk1USnqAYkVxVYxm8jkcz/+F+dnJUCoVZThI8VfNkg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=KtCnfAra6d8zyENZqf6RSr+3ZUy4jJnz9Yaz0D7BcMlgtGksKzAbq0l4pFEU86z2x f4y550bi4rYlZk7WqL7Pg0yNOULb3Zlumegz4RCtIY+ZuKwjVYMU0V11WV68JBByrH wvRgl1HEziNnUgsB5cqI9CHcH4+x1SizLQeRiGo8= Date: Fri, 21 Feb 2020 12:05:19 +0000 From: Jonathan Cameron To: Guido =?UTF-8?B?R8O8bnRoZXI=?= Cc: Tomas Novotny , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , "Angus Ainslie (Purism)" , Marco Felsch , Thomas Gleixner , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] iio: vcnl4000: Export near level property for proximity sensor Message-ID: <20200221120519.43b72007@archlinux> In-Reply-To: <4a8075acde807225a2d9aeb4164fff881013bbe2.1581947007.git.agx@sigxcpu.org> References: <4a8075acde807225a2d9aeb4164fff881013bbe2.1581947007.git.agx@sigxcpu.org> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 17 Feb 2020 14:44:47 +0100 Guido G=C3=BCnther wrote: > When an object can be considered close to the sensor is hardware > dependent. Allowing to configure the property via device tree > allows to configure this device specific value. >=20 > This is useful for e.g. iio-sensor-proxy to indicate to userspace > if an object is close to the sensor. >=20 > Signed-off-by: Guido G=C3=BCnther I'd like this to sit for a while on the mailing list and hopefully get some input from others. However, it needs documentation and I think this should be in the generic docs, or at least proximity specific ones. Documentation/ABI/testing/sysfs-bus-iio-proximity would be the obvious place. Thanks, Jonathan > --- > drivers/iio/light/vcnl4000.c | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) >=20 > diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c > index 38fcd9a26046..7111118e0fda 100644 > --- a/drivers/iio/light/vcnl4000.c > +++ b/drivers/iio/light/vcnl4000.c > @@ -83,6 +83,7 @@ struct vcnl4000_data { > struct mutex vcnl4000_lock; > struct vcnl4200_channel vcnl4200_al; > struct vcnl4200_channel vcnl4200_ps; > + uint32_t near_level; > }; > =20 > struct vcnl4000_chip_spec { > @@ -342,6 +343,26 @@ static const struct vcnl4000_chip_spec vcnl4000_chip= _spec_cfg[] =3D { > }, > }; > =20 > + > +static ssize_t vcnl4000_read_near_level(struct iio_dev *indio_dev, > + uintptr_t priv, > + const struct iio_chan_spec *chan, > + char *buf) > +{ > + struct vcnl4000_data *data =3D iio_priv(indio_dev); > + > + return sprintf(buf, "%u\n", data->near_level); > +} > + > +static const struct iio_chan_spec_ext_info vcnl4000_ext_info[] =3D { > + { > + .name =3D "near_level", > + .shared =3D IIO_SEPARATE, > + .read =3D vcnl4000_read_near_level, > + }, > + { /* sentinel */ } > +}; > + > static const struct iio_chan_spec vcnl4000_channels[] =3D { > { > .type =3D IIO_LIGHT, > @@ -350,6 +371,7 @@ static const struct iio_chan_spec vcnl4000_channels[]= =3D { > }, { > .type =3D IIO_PROXIMITY, > .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW), > + .ext_info =3D vcnl4000_ext_info, > } > }; > =20 > @@ -439,6 +461,10 @@ static int vcnl4000_probe(struct i2c_client *client, > dev_dbg(&client->dev, "%s Ambient light/proximity sensor, Rev: %02x\n", > data->chip_spec->prod, data->rev); > =20 > + if (device_property_read_u32(&client->dev, "near-level", > + &data->near_level) < 0) > + data->near_level =3D 0; > + > indio_dev->dev.parent =3D &client->dev; > indio_dev->info =3D &vcnl4000_info; > indio_dev->channels =3D vcnl4000_channels;