Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1261609lfc; Wed, 1 Jun 2022 13:26:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJT1qISZ0/kdrkc7mIhqXxxymb0BQLjTLfabVdRqnsGTOwEDQuvT3hxWmsK7L8YtcCLjhA X-Received: by 2002:a17:903:18a:b0:164:eb9:ed21 with SMTP id z10-20020a170903018a00b001640eb9ed21mr1216323plg.87.1654115180426; Wed, 01 Jun 2022 13:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654115180; cv=none; d=google.com; s=arc-20160816; b=u0Cmcon1xOYWFxmmceGnuO87GXJ4AyWvhNpCt8vN3TFNYSQGDq0C2UAlEDwPbbqncC i6VL500YUDKAMG7yrsQK8jFzZFGyTdHkXeQOKYaZLPxu67KB9CcnEwGP7Uw0UwOyGFBP zOGLr4kKkDd9CQ04Hj3Arfmafujv4zNtQda0XDoL1hRS6a1D0CKAWqx4As1B9PS9ST45 r892SCZxbqhRktZ4FViHSQ2elszqY2XfcRsFpi5IEaRHVpic2br4h00oaRNPewqWVx/X y8BnWqJCKE5Yebx6E2xtzxouJU/OOz4NDztLt+kNNaOz10Lmb+urUT7g9ouyneu5BSZJ kfNg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=yP+m2IlfR8NY4IOgWPPK60VSM5tGdUuD34IO3ygYHCY=; b=qmUrGK+uQydHjh+3yf5ioIQHNUQg5Eh7RB1JKofEfJpxstA1zmvQyprdddPHXZXdRN NpLtHFhQ8J55+B1i+nWzGp4eZmkebukEP4EISvv4uP6b1aCXYga3/x6NpG0ZWsGlijPi KWZ+1yal2f6UwZl4DPkvYBVpVXSpJKjSz6ytn9iPws+Licoj7EUMghA9bApcsbkKmO8R dGzTOu5YxSyVc+m7nuQRkOp7K+Ijp/0Rf+9y9dKrXobG0olyGCh9KerG/p7N3h/tEHgC 5do+E6L9rZDVNJb1TPKpFWoqcjdOp/B0pazuFjlg95QhcP0PgDgUzgJpBe7kaeU/Ytis gTAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bpiYKeI1; 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=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l184-20020a6391c1000000b003fc2d55e661si2977112pge.484.2022.06.01.13.26.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:26:20 -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=@intel.com header.s=Intel header.b=bpiYKeI1; 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=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EB6CD1B9F9B; Wed, 1 Jun 2022 12:38:04 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345159AbiEaOLY (ORCPT + 99 others); Tue, 31 May 2022 10:11:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243973AbiEaOLW (ORCPT ); Tue, 31 May 2022 10:11:22 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24A4E64D14; Tue, 31 May 2022 07:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654006281; x=1685542281; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Yzu5FPYImu2WBpuvDEFFP5ixeektvOVGiblDrxZebqE=; b=bpiYKeI1o1a7ioMtIrASADagACAyp0yWbyOrGJYda66POPtDnAhKyTbq KbAVhfjQL+HAqLrx4y3w97EjOofRP2jy665JA1QvEBwkC0lOoCkxmEStr D8RPJNvjHGxKfKQDunSSGNzzOYo8tmHkcvz2BIB3UoCRGVa6Gz2ua+TLl YaN2f6pH4oX+IEkGJsgmHedyfmlfOp01VIO/PbgYMLgEQNqjRZMmlhD2D Isn4d8ufMFnQBIMBvILD613xMX/TlmVlBZmdzwA6RiId42ZIxiCgs2nRO eVNxIbOTjMomoRB6r9rdcLOdH2I5/DaSKh3jilEtdNOF/CXhizfza2gS0 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10364"; a="257330307" X-IronPort-AV: E=Sophos;i="5.91,265,1647327600"; d="scan'208";a="257330307" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, 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 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