Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2334007imd; Sun, 28 Oct 2018 07:57:47 -0700 (PDT) X-Google-Smtp-Source: AJdET5fCvRTf8KsHJgc9gH+XViBOEYodzus0bEXuWk1OZsssG3wMfQ40OuCn0M7uQ37NnPS0JIEI X-Received: by 2002:a63:504d:: with SMTP id q13mr3063116pgl.319.1540738667284; Sun, 28 Oct 2018 07:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540738667; cv=none; d=google.com; s=arc-20160816; b=h6Itull61ApXAdkHj6ejFHZiHFrQWw2iRhN5RBfEsBO5b4NPAMaWGD/6vcW1B38b3Q 48jep9QC9DOKCFX+BTd5A/raljUIIlROFWL3f1szjgkQCQ0j43FMtrDgJohRgmb70Yz3 PLKZ24HfN0m0htuWN4lpJgsIqG4f+zpo1kPYGT6o/V5SWJduHRcopP6pWVPrBohLObqK qz2HIZNwoW06H7hXDer8aPdiciJK/jcfTJ8R4IAEl4ER9iky4XOhpfXY8eN0UquMCZK9 EwD5/xdtzyX4og4c70e07Fy96C4jumV4sBX0LeuZ6RlAUICRa4cR9GaXJ4PsAlM1/wqe Sqyw== 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=ZyxFQDKeccz4X07FgDnT+PKeK6BvVPSSBhceMviEsIc=; b=Ibg5dMnRUqQIJtve2kfsCkw9FqfXdTv1pENKY8rumLks81gl9i+tTl3+9dmn5iFtZF YxlHLGrrHmG7AaZ5Q1F0AoLBbliliTTA4B/pl6thVBmiR7dvKuOY0Ye65LZg0D/esXEU vYncltFzR26oZ9cpRIxRB31xp4pkgCKDF6XAi7sS21ZIS65XSk/4/vlgYdCte9cs06SQ Nhd2CTNb5TleSA02NpQsSrgwgD7J8xYsC0US9f2gUQOAvXRGQKf+ToxhxK9Nx2/dTeTT XTl5HG9FpFSbuls+E6gdLV2KyEljh6TI8J1mLD/uQfBfKUQ4zXIOA7CV6nMdab3kVojg cF2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e2b7iHMc; 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 d9-v6si18001025pgm.109.2018.10.28.07.57.09; Sun, 28 Oct 2018 07:57:47 -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=@kernel.org header.s=default header.b=e2b7iHMc; 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 S1727653AbeJ1XkK (ORCPT + 99 others); Sun, 28 Oct 2018 19:40:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:37184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726492AbeJ1XkK (ORCPT ); Sun, 28 Oct 2018 19:40:10 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (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 44F7520831; Sun, 28 Oct 2018 14:55:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540738520; bh=iozTR/dugiwiAktLlfR31FTBeCfgR9pHqCElDjUAK6M=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=e2b7iHMc0Y2/syY0Q14aia+UCnURsKShz3D6LgWj19PIngyOyJ6l/Af986t50AS1Z y4jusAO61a2NQSlQhqZGXFU20cmJH0T0sr04WbxrPXu9ARJ52JI8I0UBORwh01s/eP MFSPf4DLjWP4DbOacpAUHdUtYP42MuubIPnn5HAs= Date: Sun, 28 Oct 2018 14:55:15 +0000 From: Jonathan Cameron To: Slawomir Stepien Cc: Nishad Kamdar , 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 v5 2/2] staging: iio: ad2s1210: Add device tree support. Message-ID: <20181028145515.03c03d5b@archlinux> In-Reply-To: <20181027154903.GA1582@x220.localdomain> References: <1dc6fdf4626e7cf1ca4933fe3008cb3cd267149b.1540489369.git.nishadkamdar@gmail.com> <20181027154903.GA1582@x220.localdomain> X-Mailer: Claws Mail 3.17.1 (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 Sat, 27 Oct 2018 17:49:03 +0200 Slawomir Stepien wrote: > Hi >=20 > On pa=C5=BA 26, 2018 18:55, Nishad Kamdar wrote: > > Add device tree table for matching vendor ID > > and support for retrieving platform data > > from device tree. =20 >=20 > So maybe you should make 2 commits? >=20 > > Signed-off-by: Nishad Kamdar > > --- > > drivers/staging/iio/resolver/ad2s1210.c | 43 ++++++++++++++++++++++++- > > 1 file changed, 42 insertions(+), 1 deletion(-) > >=20 > > diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/= iio/resolver/ad2s1210.c > > index 93c3c70ce62e..9fd5461c4ed0 100644 > > --- a/drivers/staging/iio/resolver/ad2s1210.c > > +++ b/drivers/staging/iio/resolver/ad2s1210.c > > @@ -17,6 +17,7 @@ > > #include > > #include > > #include > > +#include > > =20 > > #include > > #include > > @@ -669,6 +670,27 @@ static int ad2s1210_setup_gpios(struct ad2s1210_st= ate *st) > > return 0; > > } > > =20 > > +#ifdef CONFIG_OF > > +static struct ad2s1210_platform_data *ad2s1210_parse_dt(struct device = *dev) > > +{ > > + struct device_node *np =3D dev->of_node; > > + struct ad2s1210_platform_data *pdata; > > + > > + pdata =3D devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); > > + if (!pdata) > > + return NULL; > > + > > + pdata->gpioin =3D of_property_read_bool(np, "adi,gpioin"); =20 >=20 > Why here you are adding "adi", but you are not adding it to the gpios in = prev > commit? >=20 > I've also seen this: https://patchwork.kernel.org/patch/10355839/. Howeve= r I do > not understand why adding vendor id to props is needed... This is not standard ABI, hence we define it as being under the scope of a particular manufacturer (and hope they use it consistently ;) So this should have a the prefix, as should the gpios now you mention it. We have gotten that bit wrong a lot in the past in IIO. If the gpio is standard, i.e. reset or similar it doesn't need it, but for very much device specific gpios like these it should have the prefix (similar reasons to any other property - different manufacturers might use the same name for different things). Jonathan >=20 > > + > > + return pdata; > > +} > > +#else > > +static struct ad2s1210_platform_data *ad2s1210_parse_dt(struct device = *dev) > > +{ > > + return NULL; > > +} > > +#endif > > + > > static int ad2s1210_probe(struct spi_device *spi) > > { > > struct iio_dev *indio_dev; > > @@ -682,7 +704,19 @@ static int ad2s1210_probe(struct spi_device *spi) > > if (!indio_dev) > > return -ENOMEM; > > st =3D iio_priv(indio_dev); > > - st->pdata =3D spi->dev.platform_data; > > + if (spi->dev.of_node) { > > + st->pdata =3D ad2s1210_parse_dt(&spi->dev); > > + if (!st->pdata) > > + return -EINVAL; > > + } else { > > + st->pdata =3D spi->dev.platform_data; > > + } > > + > > + if (!st->pdata) { > > + dev_err(&spi->dev, "ad2s1210: no platform data supplied\n"); > > + return -EINVAL; > > + } > > + =20 >=20 > Why not just use only device-tree here? The ad2s1210_platform_data has no= w only > one entry... In that case remember to add "depends on OF" in Kconfig. >=20 > > ret =3D ad2s1210_setup_gpios(st); > > if (ret < 0) > > return ret; > > @@ -724,6 +758,12 @@ static int ad2s1210_remove(struct spi_device *spi) > > return 0; > > } > > =20 > > +static const struct of_device_id ad2s1210_of_match[] =3D { > > + { .compatible =3D "adi,ad2s1210", }, > > + { } > > +}; > > +MODULE_DEVICE_TABLE(of, ad2s1210_of_match); > > + > > static const struct spi_device_id ad2s1210_id[] =3D { > > { "ad2s1210" }, > > {} > > @@ -733,6 +773,7 @@ MODULE_DEVICE_TABLE(spi, ad2s1210_id); > > static struct spi_driver ad2s1210_driver =3D { > > .driver =3D { > > .name =3D DRV_NAME, > > + .of_match_table =3D of_match_ptr(ad2s1210_of_match), > > }, > > .probe =3D ad2s1210_probe, > > .remove =3D ad2s1210_remove, =20 >=20