Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2606724imd; Sun, 28 Oct 2018 13:58:53 -0700 (PDT) X-Google-Smtp-Source: AJdET5cgpUJxXtX2ChWlHOkQtODB6CnHlcstWhWzws7Wa+bo9vbzAteU9MImnxp0cObqoQAq1Wbm X-Received: by 2002:a63:955a:: with SMTP id t26mr9187547pgn.449.1540760333616; Sun, 28 Oct 2018 13:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540760333; cv=none; d=google.com; s=arc-20160816; b=HOLgbO8X4kCNvEejP4Gjcy208VXXBzIIgRJajV0aCRlHTsgV2gaiQxu2Wu/QD5mRE3 zZOjFV3jwMn23EBx32EDbOFGuf30ajeCYzSLacUEOz/rs2WVu66T+jtzwA1ycFwTXf3L jz9Qqi05p/7QQTWLKxvlu6jlixBLF25e7egqh14uUgHXeO6+jxQYA5PTNP629S5szDJk jtZfIzCoi+L/BuQ5dJKyEAJ/M3G8jp4Lecg1jC15MEt7NxxmeUjZO20KJTeehRMep9LY vLKvUR1W8B7ag7ywVBQ2ByuyzAbm1V9Poh+ylH27cUv7uT32JTtHTeYg4u+EdVYyKX1v EHyQ== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=IdIVM9hysnX97hObu18s1bHs1pSm+N/OszU8FKBvCsw=; b=sMM9ghEfaa5QHjAuaxOw55Kwaxf7mNplNBYjU3SSp3zUhx3EfN4HuWk24CcPxpsjP/ Rp+uQ6ETSTeyfeUMEY0K05XdAhuCzmuDXBxVR+PKLCgJyQWkMvCsAB0aBllvRGvi5vie nPRas4qCHEqXFf2oEghEoVdRVkuE+bbAmfszRdfN5k1ChsCgCZPizF/k5rZmKHf1666m R/XUTLoJgwY00kiC2xhShVw65Jj0ZIs6Fj90EykNaYmJzfEf3cHYmpc2FeXv+Fc8/cqV 5EquEtcvpW0YLd/HDUXP3IAfu6QEO9LBRQI8QyxUgln1udM6XHCvm4vjvd+pmLshlJVs XcgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ektcp63m; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e93-v6si18701558plk.208.2018.10.28.13.58.35; Sun, 28 Oct 2018 13:58:53 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ektcp63m; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727633AbeJ2FkC (ORCPT + 99 others); Mon, 29 Oct 2018 01:40:02 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:38915 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725841AbeJ2FkC (ORCPT ); Mon, 29 Oct 2018 01:40:02 -0400 Received: by mail-pl1-f194.google.com with SMTP id b5-v6so2172411pla.6; Sun, 28 Oct 2018 13:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=IdIVM9hysnX97hObu18s1bHs1pSm+N/OszU8FKBvCsw=; b=Ektcp63mxrajj+zePK80E8BoM63YtlXmmlcZmZZR4PSsQnl+O8jD+OHE/RNxTIwtB0 iEHHuZzWNqNBJNQJHgidp2oW1pNeZTEfD0VgV3I5mSGWAMNKB3Y1tphZ6qcThpuaXxhr SMBYCZU6s3OstnBMm3UDVcNVnKgQriQ1C48EHuSQWVXkQxiqsjwTJ3NCTuSHE4wyJbc1 s+mpy46fgFPczR7m991sey75Vx47QFhfiUp24jg1y/dnzOHMJhcGL9JwL/H/JMpd9CNK Ons+ylNEB1Cnu+RXAIXtzS84jKcC9stB0TeMScHetmVUQ24wbsRWK8jGgf0pBO+L0c6K 9FTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=IdIVM9hysnX97hObu18s1bHs1pSm+N/OszU8FKBvCsw=; b=CtKLy5v7gp/5P/zO0QW+YpmMYwmTaQjatPmrKGgzCIfrAQkIl37cIKXsKX+hiiL3kJ 0vf/347yR3fzgnpbRg2LA9FOHaqjPAwzfcvSg2SG/mnoDVbqWrStY0LVLWtUJRK5R5mm mMeSq1WOFLMfsqQUbM7JpLM8s+VuRQPbzivJT4MOy5QGHcR8XNCvUsz5+lpc1ZpLgZTI +SHj8teKaeL7ve8Q34trBJJvBAOyK4a5E3BnkzMHyFwlFJoUbtJZeCBMMvRW8zS7f6T4 Q8JCeyjwwgc+qgqP8QwggGZKH83pDUOdJfS3IW1eGVtDUVmEJq7+rjALR2wBH4fujC5q lmkw== X-Gm-Message-State: AGRZ1gKt0qL6NLYAtfNp27bx1+ze2BTNVRtswp5ikNICZBfwXLojDjTK UzZaVddtu0geYtQ+DxAcbj8= X-Received: by 2002:a17:902:6f16:: with SMTP id w22-v6mr11920886plk.309.1540760054730; Sun, 28 Oct 2018 13:54:14 -0700 (PDT) Received: from nishad ([106.51.27.228]) by smtp.gmail.com with ESMTPSA id f5-v6sm15192761pfb.123.2018.10.28.13.54.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Oct 2018 13:54:14 -0700 (PDT) Date: Mon, 29 Oct 2018 02:24:07 +0530 From: Nishad Kamdar To: Jonathan Cameron Cc: Slawomir Stepien , Lars-Peter Clausen , Michael Hennerich , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 3/3] staging: iio: ad2s1210: Add device tree support. Message-ID: <20181028205406.GA31715@nishad> References: <473e6abfe959e1ac78fe65bf8dc53ad25ad3b358.1540712249.git.nishadkamdar@gmail.com> <20181028145108.1079227f@archlinux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181028145108.1079227f@archlinux> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 28, 2018 at 02:51:08PM +0000, Jonathan Cameron wrote: > On Sun, 28 Oct 2018 13:23:23 +0530 > Nishad Kamdar wrote: > > > Replace platform data with device tree support. > > > > Signed-off-by: Nishad Kamdar > The whole gpio in or out thing makes less and less sense to > me and seems to contradict the datasheet. > > If I'm not missing something I would just get rid of the option. > If I am missing something (not hard in the datasheet which, whilst > fairly clear, is a rather long ;) > > Jonathan > Ok, I'll drop it. > > --- > > drivers/staging/iio/resolver/Kconfig | 1 + > > drivers/staging/iio/resolver/ad2s1210.c | 17 ++++++++--------- > > drivers/staging/iio/resolver/ad2s1210.h | 17 ----------------- > > 3 files changed, 9 insertions(+), 26 deletions(-) > > > > diff --git a/drivers/staging/iio/resolver/Kconfig b/drivers/staging/iio/resolver/Kconfig > > index 6a469ee6101f..cc1202ff813d 100644 > > --- a/drivers/staging/iio/resolver/Kconfig > > +++ b/drivers/staging/iio/resolver/Kconfig > > @@ -15,6 +15,7 @@ config AD2S90 > > > > config AD2S1210 > > tristate "Analog Devices ad2s1210 driver" > > + depends on OF > > depends on SPI > > depends on GPIOLIB || COMPILE_TEST > > help > > diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c > > index 0234869e9d74..5ecdb5785132 100644 > > --- a/drivers/staging/iio/resolver/ad2s1210.c > > +++ b/drivers/staging/iio/resolver/ad2s1210.c > > @@ -17,6 +17,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > #include > > @@ -76,7 +77,6 @@ struct ad2s1210_gpio { > > }; > > > > struct ad2s1210_state { > > - const struct ad2s1210_platform_data *pdata; > > struct mutex lock; > > struct spi_device *sdev; > > struct gpio_desc *sample; > > @@ -84,6 +84,7 @@ struct ad2s1210_state { > > struct gpio_desc *a1; > > struct gpio_desc *res0; > > struct gpio_desc *res1; > > + bool gpioin; > > unsigned int fclkin; > > unsigned int fexcit; > > bool hysteresis; > > @@ -314,7 +315,7 @@ static ssize_t ad2s1210_store_control(struct device *dev, > > } > > st->resolution > > = ad2s1210_resolution_value[data & AD2S1210_SET_RESOLUTION]; > > - if (st->pdata->gpioin) { > > + if (st->gpioin) { > > data = ad2s1210_read_resolution_pin(st); > > if (data != st->resolution) > > dev_warn(dev, "ad2s1210: resolution settings not match\n"); > > @@ -376,7 +377,7 @@ static ssize_t ad2s1210_store_resolution(struct device *dev, > > } > > st->resolution > > = ad2s1210_resolution_value[data & AD2S1210_SET_RESOLUTION]; > > - if (st->pdata->gpioin) { > > + if (st->gpioin) { > > data = ad2s1210_read_resolution_pin(st); > > if (data != st->resolution) > > dev_warn(dev, "ad2s1210: resolution settings not match\n"); > > @@ -603,7 +604,7 @@ static int ad2s1210_initial(struct ad2s1210_state *st) > > int ret; > > > > mutex_lock(&st->lock); > > - if (st->pdata->gpioin) > > + if (st->gpioin) > > st->resolution = ad2s1210_read_resolution_pin(st); > > else > > ad2s1210_set_resolution_pin(st); > > @@ -644,7 +645,7 @@ static int ad2s1210_setup_gpios(struct ad2s1210_state *st) > > int ret, i; > > struct spi_device *spi = st->sdev; > > struct ad2s1210_gpio *pin; > > - unsigned long flags = st->pdata->gpioin ? GPIOD_IN : GPIOD_OUT_LOW; > > + unsigned long flags = st->gpioin ? GPIOD_IN : GPIOD_OUT_LOW; > > > > struct ad2s1210_gpio gpios[] = { > > { .ptr = &st->sample, .name = "sample", .flags = GPIOD_IN }, > > @@ -673,16 +674,14 @@ static int ad2s1210_probe(struct spi_device *spi) > > { > > struct iio_dev *indio_dev; > > struct ad2s1210_state *st; > > + struct device_node *np = spi->dev.of_node; > > int ret; > > > > - if (!spi->dev.platform_data) > > - return -EINVAL; > > - > > indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); > > if (!indio_dev) > > return -ENOMEM; > > st = iio_priv(indio_dev); > > - st->pdata = spi->dev.platform_data; > > + st->gpioin = of_property_read_bool(np, "gpioin"); > > Hmm. This bothered me in the earlier patch. How are we meant to configure > these pins... (and this time I actually loaded the datasheet) > > A0 and A1 always seem to be control signals written to the device so > I don't really understand why we would ever want them to be 'inputs' > on our host. > > RES0 and RES1 are also control signals. Clearly marked as logic inputs. > > The only thing I can think here is there is an evaluation board out there > were we are not in control of these, some other controller is. > That is a pretty weird board if so, hence I would only support the version > where we use GPIO outputs from the host. > > This will further simplify patch 1 and get rid fo the need for this > non standard bit of devicetree binding. > > > > ret = ad2s1210_setup_gpios(st); > > if (ret < 0) > > return ret; > > diff --git a/drivers/staging/iio/resolver/ad2s1210.h b/drivers/staging/iio/resolver/ad2s1210.h > > index 63d479b20a6c..e69de29bb2d1 100644 > > --- a/drivers/staging/iio/resolver/ad2s1210.h > > +++ b/drivers/staging/iio/resolver/ad2s1210.h > > @@ -1,17 +0,0 @@ > > -/* > > - * ad2s1210.h plaform data for the ADI Resolver to Digital Converters: > > - * AD2S1210 > > - * > > - * Copyright (c) 2010-2010 Analog Devices Inc. > > - * > > - * This program is free software; you can redistribute it and/or modify > > - * it under the terms of the GNU General Public License version 2 as > > - * published by the Free Software Foundation. > > - */ > > -#ifndef _AD2S1210_H > > -#define _AD2S1210_H > > - > > -struct ad2s1210_platform_data { > > - bool gpioin; > > -}; > > -#endif /* _AD2S1210_H */ > Ok, I'll make the changes. Thanks for the review. regards, Nishad