From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D2EB3C433F5 for ; Tue, 31 May 2022 14:12:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=syDgt7py4q/eYbKtbLbep9SU8tsyDtYFvNOlFhNApq4=; b=14Z6qErMcs6dgz 9WNdu2rMT2+ys43ueLQ0OAJ/8oK4nSC15LKSAFQLZvQ6OTdJl6xnShJEgyRl38DGD5vNRKjcyopqu eYaTcha9PDr8nHsrpTzrFpHvChD+Wu+eQGtPAXTaBPzYWUdxv/iCrejxOLhm2piHutDnkm8zqZ9hS 7Mc5jNTiqnrqCuENHvbWs/Vh4ZDGT/go03cwholMFD/5tfnk5fQK29Hj9pG0EXf1yOY4uJbqw2lBl SWiq0ewmO2MQWlFYrox4E7ay81KzrgewzGf8L3bmReL5fs7hQj6fF0ocu5BeASxMX82rO2rLV4VYQ omw8UV2WyUr0L7nr/wSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nw2ak-00BEAQ-DH; Tue, 31 May 2022 14:11:26 +0000 Received: from mga01.intel.com ([192.55.52.88]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nw2ah-00BE9R-5M for linux-arm-kernel@lists.infradead.org; Tue, 31 May 2022 14:11:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654006283; x=1685542283; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Yzu5FPYImu2WBpuvDEFFP5ixeektvOVGiblDrxZebqE=; b=IpcqUDXJOmaq7vn7MjH58C0JHbxxEw4e22MCVMonq8EjQSJq9GosYm1L AHZB0Sd/Gs97Hb4chg28g6ZJQk7FYCiquaKXRUOmvAhspGtZ1z8OMoI1H dLcpbb3J34muUJs2cCm6eZVDWl68un8eYiH3rDRwI69S7g8/DTnpQMQZN 0NbmhosgyDGa7FkfBQF9+pfQSovgqD0RDg6PFY26z0xHb3fEphB/w7mJG mAvmU2NzCFhT+KwsMMqzIT/9YKfMn5jUoMXNed+oRPpR6OR2m+YJJ/GdO xY+3bL5Ci53yYv7LQf+0OIVZhgxtLb9zFWzghr90/NY92ktkOKQ1wB0D0 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10364"; a="300611372" X-IronPort-AV: E=Sophos;i="5.91,265,1647327600"; d="scan'208";a="300611372" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2022 07:11:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,265,1647327600"; d="scan'208";a="679593529" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 31 May 2022 07:11:18 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A853D14F; Tue, 31 May 2022 17:11:20 +0300 (EEST) From: Andy Shevchenko To: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen , Michal Simek , Andy Shevchenko Subject: [PATCH v1 1/2] iio: adc: xilinx-xadc: Make use of device properties Date: Tue, 31 May 2022 17:11:17 +0300 Message-Id: <20220531141118.64540-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220531_071123_266321_68E6C69A X-CRM114-Status: GOOD ( 22.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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; -- 2.35.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel