Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp118558iof; Sun, 5 Jun 2022 22:56:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVGIU1BKZs40LQU9lIzKQDaby5fj0Q399xErXVrrY4Ov1W6CiNTZrm/4tZwNInLswAW+XT X-Received: by 2002:a17:902:6907:b0:167:7ae6:a20a with SMTP id j7-20020a170902690700b001677ae6a20amr4711312plk.65.1654494968410; Sun, 05 Jun 2022 22:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654494968; cv=none; d=google.com; s=arc-20160816; b=DUYKCoAlmTIcKnpikvHY7RjNIwlDHvOL8ZJw+ArNei74mVPQsTY4eKZg3Kv8ijauxs 1awXU+4Cr65Ejk5qLBrMtu9CuzBwzTVw4+Swn4gdKAJE2ljBy2aC3weDeZmUXsct8SJ8 NI2YsGKfyaPUkrNN9sdJO/D83N4Xi4DuED3KexTIc9VszwMgPfGOe4tE1sx7nlsNT4+O 8qJI8iSPRldt/mJdv9Fw3z4UIkJkPs+EAK2M9Nr4j/n/mqdC4PWTCogNf9hVmxKTreL6 VLjpkZ3TRKRV8r0PFpZ/2pHsh9roLJrsy/exT4rF8taogvdKkFW+bj2eTNqOYO6xFeUO tQmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=kGHgDC/U7IE5Of4hGVURnC5JgOhceFltw3XHFh5rfWk=; b=DXXvJa1A+xPX4pwexydpDfYMsuFV32piKomzx6/u0EOExEZX7xFf6bTDbG5WgWvW/1 soiXZP4YXdxEnB0ZqeR02zESpG99YjRWMgozUp4ugIHR+1ewFRk0e20ewLkKa75rbal4 QfgTJV0fxIlQiIpHHb9tFQs5Uo+/vncxGNhX5ahy8W4iv4M1+yefQjxuDqC/rfQ1mvsD vbD9Pg1HkAg0CfbSD6eQW1X9cPZjHWmt0gnkYuTWQEXxO7pgAR9XE/sFzKgsUGRdbSXK WognT9ME1EOCQScoqv8+q6ZkJljQGfcevqfWdYFUw4ia6Hk+EuPCx5KHDDpVWrna7sPP 6Gag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Wlep1SZv; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 8-20020a630408000000b003faa7f0e4bcsi19777519pge.221.2022.06.05.22.56.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:56:08 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Wlep1SZv; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 225CC2D514C; Sun, 5 Jun 2022 21:44:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344385AbiFCRXa (ORCPT + 99 others); Fri, 3 Jun 2022 13:23:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344392AbiFCRX2 (ORCPT ); Fri, 3 Jun 2022 13:23:28 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B212552B03; Fri, 3 Jun 2022 10:23:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id F2B87CE234C; Fri, 3 Jun 2022 17:23:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8D75C385A9; Fri, 3 Jun 2022 17:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654277004; bh=IC0b4j9tRA7J2kGa80DzPEvWME4w+UNjiMU0VqZZJJc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Wlep1SZv7MhpG4ewG6PDQwTxXox7R54NkMKwVTHUs9F/YpWxQSMrNcBhb5qR7fWKi tC/KpeNV2nL1DA91vvJra1NnfUUa0wTqIa6K1nfkChUrcsybLGFucsvmPt57rNNxTE l2j73b8UPWVfT1KJz6Npk7ZlnR2NhOE9qz56PzoGgWr77t+sKWNObUpHzK0piB1JpF ubYhfiNTfoSafXa3wU9dJWfYK40KR8iYrXMMOKOvaNrpC2bo5oj5zzll0isNkCzgqx 3T1t6C6Hyj8YipCj69a/hCr7TWaFxaXQE46FIBwKJ3VUBKLbWH1nB8nAGhq/jN961Z P06aZ/rk3o+Fw== Date: Fri, 3 Jun 2022 18:32:24 +0100 From: Jonathan Cameron To: Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Lars-Peter Clausen , Michal Simek Subject: Re: [PATCH v1 1/2] iio: adc: xilinx-xadc: Make use of device properties Message-ID: <20220603183224.540b3808@jic23-huawei> In-Reply-To: <20220531141118.64540-1-andriy.shevchenko@linux.intel.com> References: <20220531141118.64540-1-andriy.shevchenko@linux.intel.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 31 May 2022 17:11:17 +0300 Andy Shevchenko wrote: > Convert the module to be property provider agnostic and allow > it to be used on non-OF platforms. > > Add mod_devicetable.h include. > > Signed-off-by: Andy Shevchenko These both seem good to me, but as the driver is fairly actively maintained, I'll let this one sit on the list for a while so others can take a look. Whilst it 'seems' unlikely anyone will ever use this driver with other firmware I am keen to reduce the number of of-specific drivers in IIO just to avoid any chance of cut and paste. Who knows, I'm trying to run an aspeed-i2c driver with ACPI at the moment because it's handy for a emulated setup, so maybe the same will one day happen with this device :) Weirder things have happened. Jonathan > --- > drivers/iio/adc/xilinx-xadc-core.c | 39 ++++++++++++------------------ > 1 file changed, 16 insertions(+), 23 deletions(-) > > diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c > index 823c8e5f9809..e883f95f0cda 100644 > --- a/drivers/iio/adc/xilinx-xadc-core.c > +++ b/drivers/iio/adc/xilinx-xadc-core.c > @@ -17,10 +17,11 @@ > #include > #include > #include > +#include > #include > -#include > #include > #include > +#include > #include > #include > > @@ -1182,14 +1183,13 @@ static const struct of_device_id xadc_of_match_table[] = { > }; > MODULE_DEVICE_TABLE(of, xadc_of_match_table); > > -static int xadc_parse_dt(struct iio_dev *indio_dev, struct device_node *np, > - unsigned int *conf, int irq) > +static int xadc_parse_dt(struct iio_dev *indio_dev, unsigned int *conf, int irq) > { > struct device *dev = indio_dev->dev.parent; > struct xadc *xadc = iio_priv(indio_dev); > const struct iio_chan_spec *channel_templates; > struct iio_chan_spec *channels, *chan; > - struct device_node *chan_node, *child; > + struct fwnode_handle *chan_node, *child; > unsigned int max_channels; > unsigned int num_channels; > const char *external_mux; > @@ -1200,7 +1200,7 @@ static int xadc_parse_dt(struct iio_dev *indio_dev, struct device_node *np, > > *conf = 0; > > - ret = of_property_read_string(np, "xlnx,external-mux", &external_mux); > + ret = device_property_read_string(dev, "xlnx,external-mux", &external_mux); > if (ret < 0 || strcasecmp(external_mux, "none") == 0) > xadc->external_mux_mode = XADC_EXTERNAL_MUX_NONE; > else if (strcasecmp(external_mux, "single") == 0) > @@ -1211,8 +1211,7 @@ static int xadc_parse_dt(struct iio_dev *indio_dev, struct device_node *np, > return -EINVAL; > > if (xadc->external_mux_mode != XADC_EXTERNAL_MUX_NONE) { > - ret = of_property_read_u32(np, "xlnx,external-mux-channel", > - &ext_mux_chan); > + ret = device_property_read_u32(dev, "xlnx,external-mux-channel", &ext_mux_chan); > if (ret < 0) > return ret; > > @@ -1247,19 +1246,19 @@ static int xadc_parse_dt(struct iio_dev *indio_dev, struct device_node *np, > num_channels = 9; > chan = &channels[9]; > > - chan_node = of_get_child_by_name(np, "xlnx,channels"); > + chan_node = device_get_named_child_node(dev, "xlnx,channels"); > if (chan_node) { > - for_each_child_of_node(chan_node, child) { > + fwnode_for_each_child_node(chan_node, child) { > if (num_channels >= max_channels) { > - of_node_put(child); > + fwnode_handle_put(child); > break; > } > > - ret = of_property_read_u32(child, "reg", ®); > + ret = fwnode_property_read_u32(child, "reg", ®); > if (ret || reg > 16) > continue; > > - if (of_property_read_bool(child, "xlnx,bipolar")) > + if (fwnode_property_read_bool(child, "xlnx,bipolar")) > chan->scan_type.sign = 's'; > > if (reg == 0) { > @@ -1273,7 +1272,7 @@ static int xadc_parse_dt(struct iio_dev *indio_dev, struct device_node *np, > chan++; > } > } > - of_node_put(chan_node); > + fwnode_handle_put(chan_node); > > /* No IRQ => no events */ > if (irq <= 0) { > @@ -1316,7 +1315,6 @@ static void xadc_cancel_delayed_work(void *data) > static int xadc_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > - const struct of_device_id *id; > const struct xadc_ops *ops; > struct iio_dev *indio_dev; > unsigned int bipolar_mask; > @@ -1326,15 +1324,10 @@ static int xadc_probe(struct platform_device *pdev) > int irq; > int i; > > - if (!dev->of_node) > - return -ENODEV; > - > - id = of_match_node(xadc_of_match_table, dev->of_node); > - if (!id) > + ops = device_get_match_data(dev); > + if (!ops) > return -EINVAL; > > - ops = id->data; > - > irq = platform_get_irq_optional(pdev, 0); > if (irq < 0 && > (irq != -ENXIO || !(ops->flags & XADC_FLAGS_IRQ_OPTIONAL))) > @@ -1345,7 +1338,7 @@ static int xadc_probe(struct platform_device *pdev) > return -ENOMEM; > > xadc = iio_priv(indio_dev); > - xadc->ops = id->data; > + xadc->ops = ops; > init_completion(&xadc->completion); > mutex_init(&xadc->mutex); > spin_lock_init(&xadc->lock); > @@ -1359,7 +1352,7 @@ static int xadc_probe(struct platform_device *pdev) > indio_dev->modes = INDIO_DIRECT_MODE; > indio_dev->info = &xadc_info; > > - ret = xadc_parse_dt(indio_dev, dev->of_node, &conf0, irq); > + ret = xadc_parse_dt(indio_dev, &conf0, irq); > if (ret) > return ret; >