Received: by 10.192.165.156 with SMTP id m28csp2755962imm; Sun, 15 Apr 2018 08:20:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+up8F1z8uRHOfph6l1oK5givFeJ5f3sn3Tkd0bnaOr23ANAPCOG3W3b0mlzi+vY0uGHup1 X-Received: by 10.99.173.67 with SMTP id y3mr10375706pgo.109.1523805634206; Sun, 15 Apr 2018 08:20:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523805634; cv=none; d=google.com; s=arc-20160816; b=u3f1v4nPAv8T3uGv+aRAXaQGqNgg368q2ookHolrO/R2m5WulD0Z8IdZhSettQb0xl VWAx5g4kyo51seQWbGQaAE8YjLYpXdGqCcwj2YAk6nqa+LMa+jxE/7q2Vtc9nFjUvts8 X95cnqhDipPe7vHMEH9wjWV27NOCJVtB9y56jGA8nF47ri5/XbmqhzO8CjsXUcglamjm 236E3hK/ypyRfP8rfgVOKn9T4sfHBU1cJWLIVqnlxnymcPoGyySdvbendz3ByFDDiew/ 8c7xGAVj9hEOIS8N4uxCUOyH30XBJ2hcOvtFqveRKZcliN3xaNjuhQYlPL1Huq8NIKxJ bEUw== 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 :dmarc-filter:arc-authentication-results; bh=Gbzl0D7DLQZbKhm+JzZgI+iWty6lsWTtcANBS99Cfd4=; b=W4xlvHp4GL6icPdKg8nfWAb/q75kC1QzEE4fXjM8kZzZoamFyQ5XrX1qppRo5LLTRQ Ax5c0e6HuXmSI4aj107/Flq+Qi1YzVNWdJucJ/USuxQt3VZqmQstPhVMWRHjs0WLO1t8 SJwwZoVy8Yxb2ix36Cp4jCPFUjs1r6qedaZOT2ymLqyTZMIlRz9+SNxB67qr7XyL/8uq Y6NDru/73aWQR/r8bWA8cGfeWR/HKuOU5tMz+lS2i3NHvvMWookav4kNeR6ZF3AqdlGn qKKehwNIrxqZEEN0qxnh4kbInHI1WOVhIVbcDTPVmNDqOoeVx0IpDwPWiNby68pghrxL zWJg== 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 f34-v6si10261793plf.362.2018.04.15.08.20.20; Sun, 15 Apr 2018 08:20:34 -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 S1752557AbeDOPTQ convert rfc822-to-8bit (ORCPT + 99 others); Sun, 15 Apr 2018 11:19:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:39120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751890AbeDOPTO (ORCPT ); Sun, 15 Apr 2018 11:19:14 -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 73B63206B2; Sun, 15 Apr 2018 15:19:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73B63206B2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=jic23@kernel.org Date: Sun, 15 Apr 2018 16:19:09 +0100 From: Jonathan Cameron To: =?UTF-8?B?SGVybsOhbg==?= Gonzalez Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, Michael.Hennerich@analog.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 08/14] staging: iio: ad7746: Add dt-bindings Message-ID: <20180415161909.34877620@archlinux> In-Reply-To: <1523637411-8531-9-git-send-email-hernan@vanguardiasur.com.ar> References: <1523637411-8531-1-git-send-email-hernan@vanguardiasur.com.ar> <1523637411-8531-9-git-send-email-hernan@vanguardiasur.com.ar> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 13 Apr 2018 13:36:45 -0300 Hernán Gonzalez wrote: > This patch adds dt bindings by populating a pdata struct in order to > modify as little as possible the existing code. It supports both > platform_data and dt-bindings but uses only one depending on > CONFIG_OF's value. > > Signed-off-by: Hernán Gonzalez Please reorder the patches in the next version to put the bindings patch next to this one (before preferably, but after is fine as well.) Hmm. I can see why you want to minimize the effect of the older code, but given that we will probably (eventually) drop the platform data option, I wonder if it wouldn't be better to move the data to a sensible location rather than faking platform_data. The pdata is only used in probe and only two bits of it at that so it would be fine to use some local variables and fill them from platform data or device tree as appropriate. Jonathan > --- > drivers/staging/iio/cdc/ad7746.c | 54 +++++++++++++++++++++++++++++++++++++++- > 1 file changed, 53 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c > index d39ab34..c29a221 100644 > --- a/drivers/staging/iio/cdc/ad7746.c > +++ b/drivers/staging/iio/cdc/ad7746.c > @@ -666,6 +666,43 @@ static const struct iio_info ad7746_info = { > /* > * device probe and remove > */ > +#ifdef CONFIG_OF > +static struct ad7746_platform_data *ad7746_parse_dt(struct device *dev) > +{ > + struct device_node *np = dev->of_node; > + struct ad7746_platform_data *pdata; > + unsigned int tmp; > + int ret; > + > + /* The default excitation outputs are not inverted, it should be stated Please use standard multiline comment syntax. /* * The... */ > + * in the dt if needed. > + */ > + > + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); > + if (!pdata) > + return NULL; > + > + ret = of_property_read_u32(np, "adi,exclvl", &tmp); > + if (ret || tmp > 3) { > + dev_warn(dev, "Wrong exclvl value, using default\n"); Seems a little odd to have the check in here rather than generic. > + pdata->exclvl = 3; /* default value */ > + } else { > + pdata->exclvl = tmp; > + } > + > + pdata->exca_en = true; > + pdata->excb_en = true; > + pdata->exca_inv_en = of_property_read_bool(np, "adi,nexca_en"); > + pdata->excb_inv_en = of_property_read_bool(np, "adi,nexcb_en"); > + > + return pdata; > +} > +#else > +static struct ad7746_platform_data *ad7746_parse_dt(struct device *dev) > +{ > + return NULL; > +} > +#endif > > static int ad7746_probe(struct i2c_client *client, > const struct i2c_device_id *id) > @@ -676,6 +713,11 @@ static int ad7746_probe(struct i2c_client *client, > unsigned char regval = 0; > int ret = 0; > > + if (client->dev.of_node) > + pdata = ad7746_parse_dt(&client->dev); > + else > + pdata = client->dev.platform_data; > + > indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); > if (!indio_dev) > return -ENOMEM; > @@ -739,12 +781,22 @@ static const struct i2c_device_id ad7746_id[] = { > { "ad7747", 7747 }, > {} > }; > - > MODULE_DEVICE_TABLE(i2c, ad7746_id); > > +#ifdef CONFIG_OF > +static const struct of_device_id ad7746_of_match[] = { > + { .compatible = "adi,ad7745" }, > + { .compatible = "adi,ad7746" }, > + { .compatible = "adi,ad7747" }, > + { } > +}; > +MODULE_DEVICE_TABLE(of, ad7746_of_match); > +#endif > + > static struct i2c_driver ad7746_driver = { > .driver = { > .name = KBUILD_MODNAME, > + .of_match_table = of_match_ptr(ad7746_of_match), > }, > .probe = ad7746_probe, > .id_table = ad7746_id,