Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp604000rwn; Thu, 15 Sep 2022 03:54:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6XFhfXKYRvlxCRFy3HnLbDcV5fIwuKn5+BnnIhxq5Xi/3AqQa7HOBZQ1d8FtxVTkic/zBq X-Received: by 2002:a17:90a:cc7:b0:200:3b3e:4e00 with SMTP id 7-20020a17090a0cc700b002003b3e4e00mr9689036pjt.201.1663239287542; Thu, 15 Sep 2022 03:54:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663239287; cv=none; d=google.com; s=arc-20160816; b=jQugmPblmn0E7EkuXhZk5e9l0cg6Zcav3KPJlQyDkb2ezw4eJ5k+7U7kwiEFXgDQf/ lH+OQj8nFv5EqzZFMQioGusAFbn47Q9HjGxBpJAwNwcX+QF3OOjJdMZWGEJtoybWKKNE 4gmgBzL/Yx0MD4Q/39rgrVYbgOYaUj4y1i6/gamYkSrCRwimO7KHv3r+NZtLASslVp9d 5kMwnm4Ok2t9aI9nt7Tri6CM6hu+o+NXq1kLIM8WogNPtnw121593QlE0Loiggp1hbZH fTXxoZ+oFAvncxSrK7MvCsbcGUZCgmdsPxQsQm6ffphqaZ72yLAgsvVZeealhWvEYvha m/qw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BLldUmawu01GzUZglxj6MBSK7Wi8J1495Ow2vHiQCbA=; b=yHH8KHsz4+QmjsBcbIiw3Sq22AWSkuiTD6nE02DnBfvWP1JMgRtBjMYVYVCAwqJI1P ADyHk3AeuR1YEot7s0I0H2SLac3Q33bKXQE3t96C6yTtX0RBUtpFtr81dGJIUnuPrgbl cc0oRWvqVnc3CwBypfYG8REzgjAw2+VDz/T1uer3D3uyQCvcMny93wWf1Cg754+YT5nA K2RpBadLwIBkfgkJVAOp6WMhJxsQOA3/fc3d26E71tuxAfpBpvcl2hQAltpbBtFdyshS j/ORNeq0cj/G1mRDm7ZFp0K1j5CkVlBBqYAruG6SODrMGdfd+oL95SaqBTiKTiRXN8At cyjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mWs3Joq2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z11-20020a63c04b000000b0043961faced1si6061393pgi.318.2022.09.15.03.54.36; Thu, 15 Sep 2022 03:54:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mWs3Joq2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230182AbiIOJwT (ORCPT + 99 others); Thu, 15 Sep 2022 05:52:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230015AbiIOJvd (ORCPT ); Thu, 15 Sep 2022 05:51:33 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA9C1DEA; Thu, 15 Sep 2022 02:49:31 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id w13so2171291plp.1; Thu, 15 Sep 2022 02:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=BLldUmawu01GzUZglxj6MBSK7Wi8J1495Ow2vHiQCbA=; b=mWs3Joq2+U9sk0TTku4uVfHfyJi54bqPrLJdN+GMWioKOLnEkyRHTv5xRQa+u2QYdw dV95RVVDRAFNhd4CPJ8CDqlym//oYKusNe9pE+0UGlurC7GX9j8A0Jv5IGrQxD/r4B/t X13xnw9hl7TkRq7NoOqQaN5jnWFHhwLI7Auvg/P63ImdtomryUyEtHnnuVHpewnd0ZoO LCFMNAIQACzoLpPObHtHKsS0aYUS7SoFHipgKt6I9xIK+3iAKZeC3j0BoBAU2najHWr6 Ss9mWYWzKs3SgdP2noEt8mTzKzK7+QiBVL63MfrogRCkmxX0O33J6DOrFKmGE2fz5bDu YZOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=BLldUmawu01GzUZglxj6MBSK7Wi8J1495Ow2vHiQCbA=; b=xeUkZfJZl4iab4Jn4PwF7VJ6xC4YlXYCutT02DRfI2PzSEu6+xs4I+gwPkaEDj5Q6K iGmZ4qtQbIRXbUXPhPlHMQuzE5KvNg7mO33B8OyibqQiqi4YzBMHBcVX2MEh+URYIK1y /q+/JZzFmxCG8MgwsdiOPguxH7mIN0S9sSWRODGVFdpOZ4ssfXh5mmtkysCznEcoJLiM lpOwOr98i2kZiCb5A4swgf/Vb58TXH62AbHfWwKk83eBfI4QD6zFA2CFQPnG2VjnfBvt bCHidlMm3A8Rw05+TmQ6AxaNZlVYJW7R2ccGfYK5wliRsbpEjpV623DM64aT1CvqzgB2 WjRg== X-Gm-Message-State: ACrzQf1drRg31aqY/6NZHZmaV35QW2F1fsJGXLVPt3KNT/BChg6VcnOR 9uW1mpxkcWDdg2pW7qFkAGY= X-Received: by 2002:a17:90b:4d12:b0:202:e772:fa09 with SMTP id mw18-20020a17090b4d1200b00202e772fa09mr10042498pjb.30.1663235366651; Thu, 15 Sep 2022 02:49:26 -0700 (PDT) Received: from RD-3580-24288.rt.l (114-137-177-189.emome-ip.hinet.net. [114.137.177.189]) by smtp.gmail.com with ESMTPSA id n4-20020a170903110400b00176675adbe1sm12669010plh.208.2022.09.15.02.49.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 02:49:26 -0700 (PDT) From: ChiaEn Wu To: pavel@ucw.cz, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, matthias.bgg@gmail.com, sre@kernel.org, jic23@kernel.org, lars@metafoo.de, broonie@kernel.org, mazziesaccount@gmail.com, andriy.shevchenko@linux.intel.com Cc: chiaen_wu@richtek.com, alice_chen@richtek.com, cy_huang@richtek.com, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-iio@vger.kernel.org, szunichen@gmail.com Subject: [PATCH v11 4/8] lib: add linear range index macro Date: Thu, 15 Sep 2022 17:47:32 +0800 Message-Id: <0418eade65d434a25d304eaa804b34f92318be87.1663254344.git.chiaen_wu@richtek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 From: ChiaEn Wu Add linear_range_idx macro for declaring the linear_range struct simply. Reviewed-by: Matti Vaittinen Signed-off-by: ChiaEn Wu --- include/linux/linear_range.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/linear_range.h b/include/linux/linear_range.h index fd3d0b3..2e4f4c3 100644 --- a/include/linux/linear_range.h +++ b/include/linux/linear_range.h @@ -26,6 +26,17 @@ struct linear_range { unsigned int step; }; +#define LINEAR_RANGE(_min, _min_sel, _max_sel, _step) \ + { \ + .min = _min, \ + .min_sel = _min_sel, \ + .max_sel = _max_sel, \ + .step = _step, \ + } + +#define LINEAR_RANGE_IDX(_idx, _min, _min_sel, _max_sel, _step) \ + [_idx] = LINEAR_RANGE(_min, _min_sel, _max_sel, _step) + unsigned int linear_range_values_in_range(const struct linear_range *r); unsigned int linear_range_values_in_range_array(const struct linear_range *r, int ranges); -- 2.7.4