Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp72239rbe; Wed, 28 Feb 2024 12:30:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWn9kouuG2pEkICZCgRmqm77bueCBLZD4QpbdpFTgyZrBoklT5sAyyQHeqv/4wvzkRHns3IQJ1xOj7Y7iLLfxPfNXc5RCnH+J0JF7XgpA== X-Google-Smtp-Source: AGHT+IHepRg6/Q4YL/kDbQhbX0gZNbvre+wjLdn6BhUAHFgGy7xfoh2wF29dOkJrwlcjwXVi6w8H X-Received: by 2002:a17:902:8d8c:b0:1db:d586:b2d with SMTP id v12-20020a1709028d8c00b001dbd5860b2dmr81689plo.18.1709152237334; Wed, 28 Feb 2024 12:30:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709152237; cv=pass; d=google.com; s=arc-20160816; b=Oc9aAW7BLLXlzlVsc69oIwvi4QV/RPsgiWDyg+GbTjBqLmNepFcd+23qwMkWSUm52D f5v3ECH8v2hER8atFFjebN8IGbA4zDycktiABDofVr3M28OczIIjUt8s5HdMAHIDTCm9 3VabYX8gNBL9h5t3pb8uUI+jBs1rTt5n5CO52EaelwPpuJchY4ehBqJEC0LWiigrSseA 8wIBwh0YDHkNWrQx1FWeltSfTL0Hh0nSFHGbJHpurNEoBAp4lM4+CYp3eCjUnxbGGp6w xytUnc7cjn16ZX7iyW0oN1XQPN+1xhcFs+FiBXH2pj9Q0h1/bqnJCpm7HHs3V9hS8MOH 2Xeg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=/JeBn3bia62a6kKszM3/zHcQEmdTs24HaWD1frIh7GU=; fh=7iQvi5I81evY9m4vL3aMcKYQ0tic25NVaydrWj0J0Eg=; b=rhFoU7zaJd8perEVhBxAHuiw6ioj7XVJLMVcXC43GSPhvqWpP3sNiC874ygjM1X9PO ZEKkEILyfPNj3TuDeYfUYI5J5SCd3rniyZPzHZpywEjDiH4rglYb5eBphtCsnjUpqRKZ Rjw9Kap2nIVYNls6p5e8Ja0OKN5po2BiU6v4N9ltzNW0jRaMmxM0m1oT2OmYRV2SvXTk VTy8OoYM77/SokkMCnh8RTkbIp2xuDKein8JmRZKENsuC6b3sMoFUpuuGz+LliIgCemz py4u2o1ZJZcLu+gdPaypW+LPUTl5ByvY+7rnKf4UbO8u/8d6rrKaGeyD/rTemkDH7/WP y4qA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="AjyD/Uqi"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85677-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q12-20020a170902dacc00b001db4210203asi4132600plx.351.2024.02.28.12.30.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 12:30:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="AjyD/Uqi"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85677-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EB0EE28A3E2 for ; Wed, 28 Feb 2024 20:30:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80CE479B7A; Wed, 28 Feb 2024 20:30:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AjyD/Uqi" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB63B1DDF4; Wed, 28 Feb 2024 20:30:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709152231; cv=none; b=oR7PgUrhdkw+KRKbqMFm51dBLA28KD8w6dKz2f4Be1wspwXwCG8DrfJ42sZjOJxLZVfz4NP4YRZvOjm7MXImxxVK2D7B10lvaI0rVaOCF1Qj0Bd7Zn8NGYJGkCtKfMiB1T+4cT1Y9iyO5F5jS4PospD880Uynnv6FuMxiD7a26Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709152231; c=relaxed/simple; bh=WdFugmdSwuXnw/qKz9yLmhGuWa9vJjJ2n+gkaBqe/8Q=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dGkj+QNOj+lKhSPZd15Cy6DTXB4cPCABL39+vjWu1rTsjcG5L8GInl5T7vsFOHBatCBumzntSsKL1y4HaNiEihZ28+PBUMlMOiy1sfd+8kvA2O0k71J0OSks+H1JZPqjM43cEblafB1kyUZ17gQYhucbqN3jGH+dtn2q0Iqst0c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AjyD/Uqi; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709152230; x=1740688230; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=WdFugmdSwuXnw/qKz9yLmhGuWa9vJjJ2n+gkaBqe/8Q=; b=AjyD/UqiZOhgkgdcDiNVEK4BjCbAptorlv1NkCeDnkoYKiBCLz65IUBS QnNxw+wYKFzBsQSSlaH7greCtaJDy2Grti85J+b8skZr7fisLVz7ArBOw ykmtjMCGmeKRB3+TaZPfhqPxrYkjybZ1j1GJgrpy16uYDhrH1bsXFqi6/ cif5x4cW7f1D4z/6Xz5YquLZ4u0H1GiuyZfKmBc2iwGKEFQFymF1z9iHK /suNvojQ61kSyKv61wzSuoYG7aW1ebbjfhgvhwcRCVHrHjDQa3Dx24uiy DYqOMNjAcc4hrddQhGoDh+CwEtg20RKG5akP8jCC7txiT9qIuUQrbeTJX A==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="3426795" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="3426795" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 12:30:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="937034655" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="937034655" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 28 Feb 2024 12:30:27 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id ED4661C5; Wed, 28 Feb 2024 22:30:25 +0200 (EET) From: Andy Shevchenko To: Jinjie Ruan , Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko Subject: [PATCH v1 1/1] iio: adc: spear_adc: Make use of device properties Date: Wed, 28 Feb 2024 22:30:23 +0200 Message-ID: <20240228203023.3609181-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Convert the module to be property provider agnostic and allow it to be used on non-OF platforms. Include mod_devicetable.h explicitly to replace the dropped of.h which included mod_devicetable.h indirectly. Signed-off-by: Andy Shevchenko --- drivers/iio/adc/spear_adc.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/iio/adc/spear_adc.c b/drivers/iio/adc/spear_adc.c index 71362c2ddf89..b6dd096391c1 100644 --- a/drivers/iio/adc/spear_adc.c +++ b/drivers/iio/adc/spear_adc.c @@ -5,8 +5,10 @@ * Copyright 2012 Stefan Roese */ +#include #include #include +#include #include #include #include @@ -15,8 +17,6 @@ #include #include #include -#include -#include #include #include @@ -70,7 +70,7 @@ struct adc_regs_spear6xx { }; struct spear_adc_state { - struct device_node *np; + struct device *dev; struct adc_regs_spear3xx __iomem *adc_base_spear3xx; struct adc_regs_spear6xx __iomem *adc_base_spear6xx; struct clk *clk; @@ -123,7 +123,7 @@ static void spear_adc_set_ctrl(struct spear_adc_state *st, int n, static u32 spear_adc_get_average(struct spear_adc_state *st) { - if (of_device_is_compatible(st->np, "st,spear600-adc")) { + if (device_is_compatible(st->dev, "st,spear600-adc")) { return __raw_readl(&st->adc_base_spear6xx->average.msb) & SPEAR_ADC_DATA_MASK; } else { @@ -134,7 +134,7 @@ static u32 spear_adc_get_average(struct spear_adc_state *st) static void spear_adc_set_scanrate(struct spear_adc_state *st, u32 rate) { - if (of_device_is_compatible(st->np, "st,spear600-adc")) { + if (device_is_compatible(st->dev, "st,spear600-adc")) { __raw_writel(SPEAR600_ADC_SCAN_RATE_LO(rate), &st->adc_base_spear6xx->scan_rate_lo); __raw_writel(SPEAR600_ADC_SCAN_RATE_HI(rate), @@ -266,7 +266,6 @@ static const struct iio_info spear_adc_info = { static int spear_adc_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; struct device *dev = &pdev->dev; struct spear_adc_state *st; struct iio_dev *indio_dev = NULL; @@ -279,11 +278,10 @@ static int spear_adc_probe(struct platform_device *pdev) "failed allocating iio device\n"); st = iio_priv(indio_dev); + st->dev = dev; mutex_init(&st->lock); - st->np = np; - /* * SPEAr600 has a different register layout than other SPEAr SoC's * (e.g. SPEAr3xx). Let's provide two register base addresses @@ -310,8 +308,7 @@ static int spear_adc_probe(struct platform_device *pdev) if (ret < 0) return dev_err_probe(dev, ret, "failed requesting interrupt\n"); - if (of_property_read_u32(np, "sampling-frequency", - &st->sampling_freq)) + if (device_property_read_u32(dev, "sampling-frequency", &st->sampling_freq)) return dev_err_probe(dev, -EINVAL, "sampling-frequency missing in DT\n"); @@ -319,13 +316,13 @@ static int spear_adc_probe(struct platform_device *pdev) * Optional avg_samples defaults to 0, resulting in single data * conversion */ - of_property_read_u32(np, "average-samples", &st->avg_samples); + device_property_read_u32(dev, "average-samples", &st->avg_samples); /* * Optional vref_external defaults to 0, resulting in internal vref * selection */ - of_property_read_u32(np, "vref-external", &st->vref_external); + device_property_read_u32(dev, "vref-external", &st->vref_external); spear_adc_configure(st); @@ -346,19 +343,17 @@ static int spear_adc_probe(struct platform_device *pdev) return 0; } -#ifdef CONFIG_OF static const struct of_device_id spear_adc_dt_ids[] = { { .compatible = "st,spear600-adc", }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, spear_adc_dt_ids); -#endif static struct platform_driver spear_adc_driver = { .probe = spear_adc_probe, .driver = { .name = SPEAR_ADC_MOD_NAME, - .of_match_table = of_match_ptr(spear_adc_dt_ids), + .of_match_table = spear_adc_dt_ids, }, }; -- 2.43.0.rc1.1.gbec44491f096