Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1727315rdf; Sun, 5 Nov 2023 11:32:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IERYhU6Fq1jrLFvC7d5wHtt+IEghm00m+iC5h5NXgREhUsIY3FjLjQoljkpa9R0wgQ58mh4 X-Received: by 2002:a17:902:e5c5:b0:1cc:53d1:10b8 with SMTP id u5-20020a170902e5c500b001cc53d110b8mr23221063plf.50.1699212773918; Sun, 05 Nov 2023 11:32:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699212773; cv=none; d=google.com; s=arc-20160816; b=R/rPMnIPGn9n9fFuzMlfg7LU3e0ivQOHSBklXCdFA31xUbOHjMYU5CAvb5zyTlb+oV 35/aC6eu1BN+TOBUra0/B4C/Cogi8zDoUBe9A0I6vmRfOnBwW1FtqjxskoIG/0gHsM29 kaZ9o/FF1qz0LgkqtSlC6PqQl1+Auuk0ot5CGvsfpTGe0vMox9S2Y+nw9hYRfwitLcBz 8QxDKHqrDehuRPgPOxOmFOW+4z588I3i7sz3jPFTi0RjhDZbI8hpMUyOAb12HFuz/N4O lm3icIuVgBtUjnC6nXyxaEOodjwUqXF3BQ9vo66g6sBPKuLm8LSsKCrNw3okiCCivKk0 PSaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=fx4rbRfjJn26t0QwsBmlr0DRSHJPbATrjWqayUKhDAA=; fh=E5JIoNPAqU7DJB26XElMV2IemHlkUEn9pp7K5QWv1hQ=; b=azuq+wxMzUhXt+YuW8kp1djGMQM2VySuN6KOUxBt9BrfJmI0XpGRPxVaKauFQaYucF a/jzSULaufP/SsmyogAsGHpHLu/hc5kfzciABT0XpqM5I/BfZEcd24RxvOzVPCt/+Kcw a+QFwzFyw7OnfJMPnzBsX1uOGTR0MiTMLQZtK+2rGg8i24aFfy2BSUck9xWhumlMuyi+ 3GdV3TfFVw+PqHTpnl1YC0Su2zRVkrR7sz7O56UYyzgkQtYgxJ2zCw6VcA8bh+21KFWi pCCf1Mbe2g/EXOWSDd7nwEjCpI5PfT6imMpsXwJneVk0vjCHrYbkLHsuTzTQ9BrhdiwK XrCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20230601 header.b="WinK7U/4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id o10-20020a170902d4ca00b001b69ede5b79si6478596plg.470.2023.11.05.11.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 11:32:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20230601 header.b="WinK7U/4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 5A5E5805CCE1; Sun, 5 Nov 2023 11:32:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229594AbjKETc0 (ORCPT + 99 others); Sun, 5 Nov 2023 14:32:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229573AbjKETcY (ORCPT ); Sun, 5 Nov 2023 14:32:24 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC65BE1; Sun, 5 Nov 2023 11:32:21 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-9a6190af24aso565391966b.0; Sun, 05 Nov 2023 11:32:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699212740; x=1699817540; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fx4rbRfjJn26t0QwsBmlr0DRSHJPbATrjWqayUKhDAA=; b=WinK7U/4MP8E4x7FuXKrMgCw/K8t59guALdWCOTGj9Bqtae+VGseKWvQBjT1GC7ufS m/b8VGxc4D7QWiUqSe+uBgTD4GmEekA7MEFe9fX0DtYcJVxGZ/VqipbXJAUjGt3Cd9RX QajUdmRNXX8lz/Hjz9Jtkexf0j5KDn5tfdGiORipW8PFffbRsKMskI9JbJ0ioDvN0rqG EPP00ALXVdflz9VoZBzQG2KP5n+7Dz3r6rXWJkbIIMINQBDs8ee+jDfLwp7wtTVvIsjH YY72Ze5W4WoOh2hEkJ2sKkWzWGtI/aYGMxfLxozJCb+kNp+F7HAMB3E+qFhMe3Kipbad jXiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699212740; x=1699817540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fx4rbRfjJn26t0QwsBmlr0DRSHJPbATrjWqayUKhDAA=; b=StpXDEyYqAEBr4Ds+FUdgb/+6RlC6XytxAHQsefal6PQn2F+I/4rtP6RGb0j5QRRBx zLPxJWwaKSJ5u87BtnyqloBlTwKjiuAAks+y7Fz4IRoagSJ/jjjIa7K1iJmzSgjc8UZd C9tQRjS4nOhGz2I3lCWGkg1f9lZpQXkVMO59XvNFqj+oy2/m7O1g1SzXaIxUdcf1fVPu of/NCvY7Tf0Jezep8DuF6jguIw0J5lRkT+4B6nRJsmLqlRI8j8X4NooPFPNkKaWnKkCP nDxj9QUmfhggGSR7yEMHiVmFKKlObX1ELVvxqyDVeRzZ1dr4m94PpQBEaC3qFer+XvJ1 IGvA== X-Gm-Message-State: AOJu0YwbN9hoWzTgyHY8WZ9X2F9/r98TiHPLW6Vswj993bZln9RParMi ZRDGRQkXrEt1ZF8TvJr0XEc= X-Received: by 2002:a17:907:c24:b0:9bf:20e0:bfe9 with SMTP id ga36-20020a1709070c2400b009bf20e0bfe9mr14275382ejc.15.1699212739794; Sun, 05 Nov 2023 11:32:19 -0800 (PST) Received: from spiri.. ([5.14.137.80]) by smtp.gmail.com with ESMTPSA id d26-20020a1709064c5a00b009b947aacb4bsm3300259ejw.191.2023.11.05.11.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 11:32:19 -0800 (PST) From: alisadariana@gmail.com Cc: Alisa-Dariana Roman , Alexandru Tachici , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andy Shevchenko , Maksim Kiselev , Cosmin Tanislav , Arnd Bergmann , Liam Beguin , Marius Cristea , Ibrahim Tilki , ChiaEn Wu , Ivan Mikhaylov , Marcus Folkesson , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] iio: adc: ad7192: Use device api Date: Sun, 5 Nov 2023 21:31:29 +0200 Message-Id: <20231105193132.47009-2-alisadariana@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231105193132.47009-1-alisadariana@gmail.com> References: <20231105193132.47009-1-alisadariana@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.3 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,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 lipwig.vger.email To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 05 Nov 2023 11:32:46 -0800 (PST) From: Alisa-Dariana Roman Replace of.h and corresponding functions with preferred device specific functions. Also replace of_device_get_match_data function with spi_get_device_match_data. Signed-off-by: Alisa-Dariana Roman --- drivers/iio/adc/ad7192.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c index adc3cbe92d6e..48e0357564af 100644 --- a/drivers/iio/adc/ad7192.c +++ b/drivers/iio/adc/ad7192.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -364,19 +363,19 @@ static inline bool ad7192_valid_external_frequency(u32 freq) freq <= AD7192_EXT_FREQ_MHZ_MAX); } -static int ad7192_of_clock_select(struct ad7192_state *st) +static int ad7192_device_clock_select(struct ad7192_state *st) { - struct device_node *np = st->sd.spi->dev.of_node; + struct device *dev = &st->sd.spi->dev; unsigned int clock_sel; clock_sel = AD7192_CLK_INT; /* use internal clock */ if (!st->mclk) { - if (of_property_read_bool(np, "adi,int-clock-output-enable")) + if (device_property_read_bool(dev, "adi,int-clock-output-enable")) clock_sel = AD7192_CLK_INT_CO; } else { - if (of_property_read_bool(np, "adi,clock-xtal")) + if (device_property_read_bool(dev, "adi,clock-xtal")) clock_sel = AD7192_CLK_EXT_MCLK1_2; else clock_sel = AD7192_CLK_EXT_MCLK2; @@ -385,9 +384,10 @@ static int ad7192_of_clock_select(struct ad7192_state *st) return clock_sel; } -static int ad7192_setup(struct iio_dev *indio_dev, struct device_node *np) +static int ad7192_setup(struct iio_dev *indio_dev) { struct ad7192_state *st = iio_priv(indio_dev); + struct device *dev = &st->sd.spi->dev; bool rej60_en, refin2_en; bool buf_en, bipolar, burnout_curr_en; unsigned long long scale_uv; @@ -416,26 +416,26 @@ static int ad7192_setup(struct iio_dev *indio_dev, struct device_node *np) st->conf = FIELD_PREP(AD7192_CONF_GAIN_MASK, 0); - rej60_en = of_property_read_bool(np, "adi,rejection-60-Hz-enable"); + rej60_en = device_property_read_bool(dev, "adi,rejection-60-Hz-enable"); if (rej60_en) st->mode |= AD7192_MODE_REJ60; - refin2_en = of_property_read_bool(np, "adi,refin2-pins-enable"); + refin2_en = device_property_read_bool(dev, "adi,refin2-pins-enable"); if (refin2_en && st->chip_info->chip_id != CHIPID_AD7195) st->conf |= AD7192_CONF_REFSEL; st->conf &= ~AD7192_CONF_CHOP; - buf_en = of_property_read_bool(np, "adi,buffer-enable"); + buf_en = device_property_read_bool(dev, "adi,buffer-enable"); if (buf_en) st->conf |= AD7192_CONF_BUF; - bipolar = of_property_read_bool(np, "bipolar"); + bipolar = device_property_read_bool(dev, "bipolar"); if (!bipolar) st->conf |= AD7192_CONF_UNIPOLAR; - burnout_curr_en = of_property_read_bool(np, - "adi,burnout-currents-enable"); + burnout_curr_en = + device_property_read_bool(dev, "adi,burnout-currents-enable"); if (burnout_curr_en && buf_en) { st->conf |= AD7192_CONF_BURN; } else if (burnout_curr_en) { @@ -1117,9 +1117,7 @@ static int ad7192_probe(struct spi_device *spi) } st->int_vref_mv = ret / 1000; - st->chip_info = of_device_get_match_data(&spi->dev); - if (!st->chip_info) - st->chip_info = (void *)spi_get_device_id(spi)->driver_data; + st->chip_info = spi_get_device_match_data(spi); indio_dev->name = st->chip_info->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = st->chip_info->channels; @@ -1140,7 +1138,7 @@ static int ad7192_probe(struct spi_device *spi) if (IS_ERR(st->mclk)) return PTR_ERR(st->mclk); - st->clock_sel = ad7192_of_clock_select(st); + st->clock_sel = ad7192_device_clock_select(st); if (st->clock_sel == AD7192_CLK_EXT_MCLK1_2 || st->clock_sel == AD7192_CLK_EXT_MCLK2) { @@ -1152,7 +1150,7 @@ static int ad7192_probe(struct spi_device *spi) } } - ret = ad7192_setup(indio_dev, spi->dev.of_node); + ret = ad7192_setup(indio_dev); if (ret) return ret; -- 2.34.1