Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp645069ybh; Wed, 18 Mar 2020 06:38:06 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu8ZTLA1UZzElppu1P2RlKq+2hz34ro/I+A3LkmmLuoGc+ui+OFAGNoT8XyTYAXH0Qz+m88 X-Received: by 2002:aca:d50f:: with SMTP id m15mr3337531oig.19.1584538686077; Wed, 18 Mar 2020 06:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584538686; cv=none; d=google.com; s=arc-20160816; b=BqjAvORWHx6Y6OebCCwgniJKZVP+j/4pI4tl/hKQYxdzRx2Ohzco2CLk1ckT8DWNg6 Rb5Dz+wInXIM1qW5pJSTHBo7obHCuW8IZ6lM9qtUgjb8SenVntY9VrXq/HnQqyIdqCQL wUAAXu//eSgDwuNDqbiaFjAoU4VumAzaHC6XgS3EHjGic7yKULSKjRCsgkGU4+JbQW84 4OyDUKziu6Icao8IkZIprUXCb4c97vdNjcpCzfGs17fYa9S94njjkG2lSuOTx+BeUUw8 ZOHMaC4U/5UKpTFELjRS+8H1/5OpoGk9f5kjtBdIDGIw8+jmAxnkU3WQUpk1MH68CmnQ RsKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PR2Dx4JJczYBzXPLCpd2saEeBdJWRyPIAxRYGmlSBHk=; b=yH+/r1ZXWtSf7aIvqJPJd4OfDUzSTFKb8zbFILzYmek9V7ilz3gVx4iq5WfPMDb4fO z9eRjQxtzNAfwA5iTB+AfOzgE94JacUP37wZxFgNtjkrqqJDNMOprLuDdnhWAqhhKIZ+ cHDTvBqpEkzrziu2R+L04u55hS0wt7XuFVfzp5ciqJwhLpKS18sSIsozIZghGOmaWZBm 8bIHPNPySL5gZ07Cg/Lt46jW5Cxl2of2g3yrBg6SJ4Z6vYnITHrRdqWz5DdzNzYJX4BY PKdr12kzRr6hXj+uqpidv7tnZ38CE5qJ1gmyveCTg6fPBXz5UxgYTjTdNJ6KIHoe/07o erHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OpWAwC08; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si3334962otf.88.2020.03.18.06.37.53; Wed, 18 Mar 2020 06:38:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OpWAwC08; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727036AbgCRNhi (ORCPT + 99 others); Wed, 18 Mar 2020 09:37:38 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:54512 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726796AbgCRNhh (ORCPT ); Wed, 18 Mar 2020 09:37:37 -0400 Received: by mail-wm1-f65.google.com with SMTP id n8so3401291wmc.4; Wed, 18 Mar 2020 06:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PR2Dx4JJczYBzXPLCpd2saEeBdJWRyPIAxRYGmlSBHk=; b=OpWAwC08VQH5fnuStY7Wf973ZBfDQd8hcSkwZVh6PwZXr9sk5c/ozGEo5duxIM+0XV 1AwPdOTXahyyrNeW1NcaIgguG/RrRe88rnirEDSaZAngZlxr5i5+YYtoG1hfLGlOntm5 2WgsXQv9mPwnTwfCGJIPw5+Had37iUsfNQLkS0sthUyGYgsCf3YzdvR0WcJyIqOnrQxz v378FCm7elVEDd2ebaUR5rYspqddq0XOQ/BTjbyDPPtCUSJNR78ey9PABBe5Wt2tvFP5 Yzwr9dXpjVkgXvMzH5evNj84dH6ooniI/DrBHc0d+Yl7TM2AavFt3EBKIWh2eMdhGEt2 kV2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PR2Dx4JJczYBzXPLCpd2saEeBdJWRyPIAxRYGmlSBHk=; b=uVjjTjollIJ7EbHS7OApluIbubopWVx8CoCnob9uq/0t2tww4OrIg0zYYMlcABhuTY dqgrN7hBxzxLV9yZcppGSCctGC54VjhOzJsa0soZZlML5iuAIKERpdN+i3aXa/PLMoz+ Jw8fO/PlS+WakZhDOANSgCHl+x+H+yiTKCwLU8H4acjuP+0C8/sDPZkd5fQgTjvB/XxW zVTbzQoSHRRnxnmzT7xRYVElff1PU+HBbgS3ATvG75ansUTAnArMob4fAtYAnzctJK7S 7VCvi2vcegeIkZmp6nZbI66VjgeZZC1FOUp+fo+5+LGLcMR04LtezO+s1uKv2sY0jzNC 1tfA== X-Gm-Message-State: ANhLgQ31LiEMvRWaXFyQDMwFo3OLhBG+gfF0KJ4/T2G2FOg1UC8Il7R8 yVGnVwOMto4DE5KGsnorSR+DMKql X-Received: by 2002:a05:600c:290f:: with SMTP id i15mr5071254wmd.113.1584538655129; Wed, 18 Mar 2020 06:37:35 -0700 (PDT) Received: from saturn.lan ([188.26.73.247]) by smtp.gmail.com with ESMTPSA id f15sm9444002wru.83.2020.03.18.06.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2020 06:37:34 -0700 (PDT) From: Alexandru Ardelean X-Google-Original-From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael.Hennerich@analog.com, renatogeh@gmail.com, lars@metafoo.de, jic23@kernel.org, mircea.caprioru@analog.com, Alexandru Ardelean Subject: [PATCH 1/5] iio: adc: ad7780: define/use own IIO channel macros Date: Wed, 18 Mar 2020 15:40:38 +0200 Message-Id: <20200318134042.30133-2-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200318134042.30133-1-alexandru.ardelean@analog.com> References: <20200318134042.30133-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change gets rid of the AD_SD_*_CHANNEL macros in favor of defining it's own. The ad7780 is quite simpler than it's other Sigma-Delta brothers. It turned out that centralizing the AD_SD_*_CHANNEL macros doesn't scale too well, especially with some more complicated drivers. Some of the variations in the more complicated drivers require new macros, and that way things can become harder to maintain. Signed-off-by: Alexandru Ardelean --- drivers/iio/adc/ad7780.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ad7780.c b/drivers/iio/adc/ad7780.c index 291c1a898129..f47606ebbbbe 100644 --- a/drivers/iio/adc/ad7780.c +++ b/drivers/iio/adc/ad7780.c @@ -206,10 +206,29 @@ static const struct ad_sigma_delta_info ad7780_sigma_delta_info = { .irq_flags = IRQF_TRIGGER_LOW, }; -#define AD7780_CHANNEL(bits, wordsize) \ - AD_SD_CHANNEL(1, 0, 0, bits, 32, (wordsize) - (bits)) -#define AD7170_CHANNEL(bits, wordsize) \ - AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, bits, 32, (wordsize) - (bits)) +#define _AD7780_CHANNEL(_bits, _wordsize, _mask_all) \ +{ \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .channel = 0, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_OFFSET), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_all = _mask_all, \ + .scan_index = 1, \ + .scan_type = { \ + .sign = 'u', \ + .realbits = (_bits), \ + .storagebits = 32, \ + .shift = (_wordsize) - (_bits), \ + .endianness = IIO_BE, \ + }, \ +} + +#define AD7780_CHANNEL(_bits, _wordsize) \ + _AD7780_CHANNEL(_bits, _wordsize, BIT(IIO_CHAN_INFO_SAMP_FREQ)) +#define AD7170_CHANNEL(_bits, _wordsize) \ + _AD7780_CHANNEL(_bits, _wordsize, 0) static const struct ad7780_chip_info ad7780_chip_info_tbl[] = { [ID_AD7170] = { -- 2.20.1