Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2845845ybh; Mon, 16 Mar 2020 10:48:41 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtFv7K0LvtxMnmNuWjfHdG+ahGU7LEUf3Sk6nGRcrtg548V1BFftk16SAPqShpiFm2O7kt4 X-Received: by 2002:a9d:c61:: with SMTP id 88mr385877otr.144.1584380920868; Mon, 16 Mar 2020 10:48:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584380920; cv=none; d=google.com; s=arc-20160816; b=gKo7cS79jNBcemUWI3PVz/6rRCtadNp3NQNE/v8RW+9GdsraZOOQxeSiDhEnYK9vpU 1SvJAyuVtZtYalkoF8QJTerH8OhEwi3J3kJSAxXdalJVT5emmaegstL34CZQY3Uy1oM5 t3ZMRLi+yO8PeNA5calgmMnj99LqZB9aeMZz+9fHxgl3XilpCs/F/v8mME+h+iIpeZ8C /oDN26eCZLIZ54G85HKWJgHDFUDhPBfhJqRcrdirrCToNPZ8lSw384PIVspEuunOalsd C4hH4Jmkjk7eXx80e1atBalGf8SPb4rzA7pXXXK7kgpjuPRM7WnlGSL+oQ7AmxHcPKXT u/hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=maoScrP2Cc7oi4hbHaKNxc/0Jy2hGY2eoTTUtCjN8lQ=; b=BFquaPpfNlB72Pl4bg7gUpAx3ryZhI1kvEbJOfZkGUUCwDd2xlnoGTono7GPl8cauB zhv/sioVth7/dYzQwOok8yzFqblAjvmiNEKf5K+Sm5xcgPUWiWg/ePiDAXowm7rT/x7/ 3lBKKGESdkxxT6aymZACrtOBoC6IHukoBZeq9kpJHUSh7egGxO4Rcsrm0akiJaoLkvU3 Il67MgAxo17YMujGpUiaKPZsl+9DQ2S2g21o4R/96vPna4whbuvrNYgrpFJutUJ2BFEV BVfNq45ne8rr04G7Yr6KI6R0gLKyECzqSUo8o//qocb4AjG3t6GOEx58pbhhZli6QnTw /ldw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7si298129oij.97.2020.03.16.10.48.28; Mon, 16 Mar 2020 10:48:40 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732285AbgCPRrZ (ORCPT + 99 others); Mon, 16 Mar 2020 13:47:25 -0400 Received: from honk.sigxcpu.org ([24.134.29.49]:54170 "EHLO honk.sigxcpu.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731843AbgCPRrY (ORCPT ); Mon, 16 Mar 2020 13:47:24 -0400 Received: from localhost (localhost [127.0.0.1]) by honk.sigxcpu.org (Postfix) with ESMTP id 7F511FB03; Mon, 16 Mar 2020 18:47:22 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at honk.sigxcpu.org Received: from honk.sigxcpu.org ([127.0.0.1]) by localhost (honk.sigxcpu.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GMMW-5x6GCXX; Mon, 16 Mar 2020 18:47:21 +0100 (CET) Received: by bogon.sigxcpu.org (Postfix, from userid 1000) id D498B40D82; Mon, 16 Mar 2020 18:47:20 +0100 (CET) Date: Mon, 16 Mar 2020 18:47:20 +0100 From: Guido =?iso-8859-1?Q?G=FCnther?= To: Jonathan Cameron 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: <20200316174720.GA188762@bogon.m.sigxcpu.org> References: <4a8075acde807225a2d9aeb4164fff881013bbe2.1581947007.git.agx@sigxcpu.org> <20200221120519.43b72007@archlinux> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200221120519.43b72007@archlinux> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, Feb 21, 2020 at 12:05:19PM +0000, Jonathan Cameron wrote: > On Mon, 17 Feb 2020 14:44:47 +0100 > Guido G?nther 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. > > > > This is useful for e.g. iio-sensor-proxy to indicate to userspace > > if an object is close to the sensor. > > > > Signed-off-by: Guido G?nther > > 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. Makes sense, i left that out to gather initial feedback but added the docs and converted the bindings to yaml for v2. Cheers, -- Guido > > Thanks, > > Jonathan > > > --- > > drivers/iio/light/vcnl4000.c | 26 ++++++++++++++++++++++++++ > > 1 file changed, 26 insertions(+) > > > > 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; > > }; > > > > struct vcnl4000_chip_spec { > > @@ -342,6 +343,26 @@ static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] = { > > }, > > }; > > > > + > > +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 = iio_priv(indio_dev); > > + > > + return sprintf(buf, "%u\n", data->near_level); > > +} > > + > > +static const struct iio_chan_spec_ext_info vcnl4000_ext_info[] = { > > + { > > + .name = "near_level", > > + .shared = IIO_SEPARATE, > > + .read = vcnl4000_read_near_level, > > + }, > > + { /* sentinel */ } > > +}; > > + > > static const struct iio_chan_spec vcnl4000_channels[] = { > > { > > .type = IIO_LIGHT, > > @@ -350,6 +371,7 @@ static const struct iio_chan_spec vcnl4000_channels[] = { > > }, { > > .type = IIO_PROXIMITY, > > .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > > + .ext_info = vcnl4000_ext_info, > > } > > }; > > > > @@ -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); > > > > + if (device_property_read_u32(&client->dev, "near-level", > > + &data->near_level) < 0) > > + data->near_level = 0; > > + > > indio_dev->dev.parent = &client->dev; > > indio_dev->info = &vcnl4000_info; > > indio_dev->channels = vcnl4000_channels; >