Received: by 10.213.65.68 with SMTP id h4csp335153imn; Fri, 23 Mar 2018 05:48:48 -0700 (PDT) X-Google-Smtp-Source: AG47ELtU9fP7+RZEXsSZbryumGn4LqxF99dUqD+kcbJqkfg+H2DQswsUP5uGgMXcbtd8YCTrXWHs X-Received: by 10.98.229.21 with SMTP id n21mr23856655pff.158.1521809328471; Fri, 23 Mar 2018 05:48:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521809328; cv=none; d=google.com; s=arc-20160816; b=R38BpfhSlSNPgzqqub+IiKhjz0ZNbAUEvfkRMi3NmBZWIfspOqrohfNaj1CU+BA5XL EHc+h4t43/DyRUne3ZyRp7O6GER8Ic/V8hMbuCOHA7lyc71uiEV7iCJtTNUCGtyZDV0a 5Y+3r8VoHsVBoCUWiGsInW75UHc6mLQpC3pes6EQuWhOFNlxSygjiewOZEIm8LObosms c4MaTEOW4vB+tYibAg5e2hFe8O9QijkXPPMq6Uqtft13pn+CLC54ybawzuxuUNgDw5wO pbbGBZU9QrzX4jYuY3XerYmVmH98XvxBB9HHXkOVhyv2OhlI2+NVs3HmFztOVq+QolHC WgCQ== 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 :arc-authentication-results; bh=0AWfP2+3kowaTXXoozlUm36C2Q6FWXCKABHv3bSpWN4=; b=kKkdS/sTYuU0ymY8ttKKJhDcqIuAg+Nm5/Xt2TVYo4ZpCfo17VHXib/43uMLXn/YIu jN/+4HTo9GHmPsUBToiTTOLkfvPQPemR9yMay+0znhLGwtrSwrStbmpsSGOtPjGITTgB OfUewfw10NBLKnk8QMd3AMd8dJ458msfsX9xrHesEeLzZ4j0XKPwIddiI6f8xQMNx52l GQ5qJt/uopN61PgKxaGiORQYEr+f1yrC3z3BgtBeFniizl4Z0GFxpif6taKelmmgmrmX ladjiqOO6lLvmlSSVZH7BirRzsuUgH6lLqYg7l3L34ggvUz06a/oavNR2IlOpqdsa7Yy qr7w== 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 a78si1834488pfc.279.2018.03.23.05.48.33; Fri, 23 Mar 2018 05:48:48 -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 S1752673AbeCWMrB convert rfc822-to-8bit (ORCPT + 99 others); Fri, 23 Mar 2018 08:47:01 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:38748 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752087AbeCWMq7 (ORCPT ); Fri, 23 Mar 2018 08:46:59 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 1E36FB214ABDD; Fri, 23 Mar 2018 20:46:56 +0800 (CST) Received: from localhost (10.202.226.45) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 23 Mar 2018 20:46:55 +0800 Date: Fri, 23 Mar 2018 12:46:47 +0000 From: Jonathan Cameron To: =?ISO-8859-1?Q?Hern=E1n?= Gonzalez CC: , , , , , , Subject: Re: [PATCH 06/11] staging: iio: ad7746: Add dt-bindings Message-ID: <20180323134647.0000654d@huawei.com> In-Reply-To: <1521642539-4845-7-git-send-email-hernan@vanguardiasur.com.ar> References: <1521642539-4845-1-git-send-email-hernan@vanguardiasur.com.ar> <1521642539-4845-7-git-send-email-hernan@vanguardiasur.com.ar> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.202.226.45] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 21 Mar 2018 11:28:54 -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 > --- > drivers/staging/iio/cdc/ad7746.c | 55 +++++++++++++++++++++++++++++++++++++++- > 1 file changed, 54 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c > index cba8cd1..815573c 100644 > --- a/drivers/staging/iio/cdc/ad7746.c > +++ b/drivers/staging/iio/cdc/ad7746.c > @@ -658,6 +658,44 @@ 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 > + * in the dt if needed. > + */ > + > + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); > + if (!pdata) > + return NULL; > + > + tmp = 0; > + ret = of_property_read_u32(np, "adi,exclvl", &tmp); It's not an optional read so why would temp be unset in any paths where it is used? > + if (ret || tmp > 3) { > + dev_warn(dev, "Wrong exclvl value, using default\n"); > + pdata->exclvl = 3; /* default value */ > + } else { > + pdata->exclvl = tmp; > + } > + > + pdata->exca_inv_en = of_property_read_bool(np, "adi,nexca_en"); > + pdata->excb_inv_en = of_property_read_bool(np, "adi,nexcb_en"); > + pdata->exca_en = !pdata->exca_inv_en; > + pdata->excb_en = !pdata->excb_inv_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) > @@ -668,6 +706,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; > @@ -731,12 +774,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,