Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5987955pxb; Mon, 14 Feb 2022 12:27:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWO5LNHrNRDar83n4lsNORvVPd8sKtVJ2LJ7jMvskX9JBKTWpEs78AsFeECNfDte5PSwgQ X-Received: by 2002:a05:6a00:114a:: with SMTP id b10mr412796pfm.86.1644870473256; Mon, 14 Feb 2022 12:27:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644870473; cv=none; d=google.com; s=arc-20160816; b=yACXmGBEP5yQ3nXlCXyuW6fz8H1DMdfDisz0WvToQ/VVZk+CTuRVH2QU1vwiWX7zRj geLlAQHKaxHOl3h1UU/2wuDmGqdR3+UaY5gQlQol91AbSk0hnBfkl8oG6Yqqi8G0ePqN YTfv2COBx0g8+W+8o1dPnTzxMZqqDisCgz4RiMmYP5kmdTqKlVArqjSiu0OaPNnwy41Q 7UML4E6BRcO9n5eam4gwplP4IS6ZZrWjGcAzV93lJB8jgTor5aKq0n2zrN4eM6ts+HMW gm8XJKKtXaDkj7hTevLxmmL4b5K8NriadSTqwhWLut7SO5bN0u2L6PRubJFamENiBlYF baxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=G7KqLxqPXt/++zKfasndyL6p23tdrDEEEjd2RPr4XZo=; b=EqxU6Dwfr/yaVdY27VwjAcQpq/f/REmhYXEbQUJXQeWaSKvI/O0dz5vc7A9N9rvIp/ lZFTa69V3u++YGAgZCOqasIefmBY1b6dpnZWJaz7BlcVY+gmzaS8HQ3xksYm5vxkNGxM KMp/vN22vbabXjxRzKdFAQNnfdmJYdtH0c4MIZls/fne2jT6ZyVDN3iTgFBbFRj4DS5r Ti5W4ljvCGbVSI/zV/Rl960S6pUPGeTmu5zTqhLufGvhoJJZGy232c2fR8s2uK/T4bKa 4w9RiiMUfUwHZm6Ia64dZDeyKaGFvfzBNJUp5hZlOVVPArjbd1z8czC0GqOhjo9KR5lD PDQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Pc7IxxDb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y3si689700pgs.461.2022.02.14.12.27.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 12:27:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Pc7IxxDb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9821518D9FE; Mon, 14 Feb 2022 12:00:16 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240032AbiBNDgl (ORCPT + 99 others); Sun, 13 Feb 2022 22:36:41 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:58864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231682AbiBNDgj (ORCPT ); Sun, 13 Feb 2022 22:36:39 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 172B855BEB; Sun, 13 Feb 2022 19:36:31 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id z17so9496403plb.9; Sun, 13 Feb 2022 19:36:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G7KqLxqPXt/++zKfasndyL6p23tdrDEEEjd2RPr4XZo=; b=Pc7IxxDbPMy2UhDaeNT6VbKrKdAb8RyVUEzmuNZ+LoKtxXGF5Quz9RWZm8uv3JqQ/o xuK7wnKECOSpAO/KIt+8UPJjpXsc8FMHa11rkrhHl+ZWQhbDntA99DmKBtT+TWpxYV8o WLrwupk7DSZaCgltu+WtqclK5cogCElvYJ0n+tNR0ON7gpwmNnuhQS25TYlSz2CoPpku uDUE7cY7h0qGQxhq6nVWUI6lxJPPCSwG6F+pHDDRT5LscxJf6igszJrM/ynVL2pYeJNU ZCKSDe3e91iS/0Wdd5Ix004ap+ggZ4FRfNMDJfMXcSn5kkWqJRIhupn+Eh4Db5EZLgbi A59Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G7KqLxqPXt/++zKfasndyL6p23tdrDEEEjd2RPr4XZo=; b=WcZsgoCWQV8RNbENufSZjZH3whljPdN5RbbCciD5KeEPvGsh3Cb7EIKQdwBGNrfEia xUkTBwssXxcoOpxlCZIaGHpaFTVWuSqsCojV7UEBb+xXKd/7nU/Q/CTiWRl9HPo6XW7G CcTLxslIYY/l5j/5U7F34TF975xbg/c9DQCvA5hY4iQy2gxSxjlwV+4dcxgLXJiIyK+r wypNsN9hEAlOd/Qsc/xjTAmSkbHcMbaAdxk/PLWodEPsCZM3K31oecEHnTpwRuJF8ZKA M8W0bi6kqRvRQDkdjRWp2f3skWa7g5mcmj3gyHWhkxxe4Td99N5zA5GbWIHuWZkJ34+G jFLw== X-Gm-Message-State: AOAM531s8+ZKhIDTjVutlNEYvkN3MK5/RmZH2gd5kX3zsI+SEFAJnF9c ZxomXS/h+pht29TYAJ6TaKQ= X-Received: by 2002:a17:902:778b:: with SMTP id o11mr4796423pll.87.1644809790406; Sun, 13 Feb 2022 19:36:30 -0800 (PST) Received: from localhost.localdomain ([27.7.103.158]) by smtp.gmail.com with ESMTPSA id me14sm36012pjb.41.2022.02.13.19.36.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Feb 2022 19:36:30 -0800 (PST) From: Jagath Jog J To: jic23@kernel.org, lars@metafoo.de, andy.shevchenko@gmail.com, sst@poczta.fm, robh+dt@kernel.org Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] iio: potentiometer: Add available functionality Date: Mon, 14 Feb 2022 09:06:18 +0530 Message-Id: <20220214033620.4059-3-jagathjog1996@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220214033620.4059-1-jagathjog1996@gmail.com> References: <20220214033620.4059-1-jagathjog1996@gmail.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Adding available functionality for ds1803 driver which will show the minimum, step and maximum values it can accepts through sysfs entry. Signed-off-by: Jagath Jog J --- drivers/iio/potentiometer/ds1803.c | 38 ++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/drivers/iio/potentiometer/ds1803.c b/drivers/iio/potentiometer/ds1803.c index 3481dd460525..bccb9ccac931 100644 --- a/drivers/iio/potentiometer/ds1803.c +++ b/drivers/iio/potentiometer/ds1803.c @@ -27,12 +27,13 @@ enum ds1803_type { struct ds1803_cfg { int kohms; + int avail[3]; }; static const struct ds1803_cfg ds1803_cfg[] = { - [DS1803_010] = { .kohms = 10, }, - [DS1803_050] = { .kohms = 50, }, - [DS1803_100] = { .kohms = 100, }, + [DS1803_010] = { .avail = { 0, 1, 255 }, .kohms = 10, }, + [DS1803_050] = { .avail = { 0, 1, 255 }, .kohms = 50, }, + [DS1803_100] = { .avail = { 0, 1, 255 }, .kohms = 100, }, }; struct ds1803_data { @@ -40,13 +41,14 @@ struct ds1803_data { const struct ds1803_cfg *cfg; }; -#define DS1803_CHANNEL(ch) { \ - .type = IIO_RESISTANCE, \ - .indexed = 1, \ - .output = 1, \ - .channel = (ch), \ - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ +#define DS1803_CHANNEL(ch) { \ + .type = IIO_RESISTANCE, \ + .indexed = 1, \ + .output = 1, \ + .channel = (ch), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_RAW), \ } static const struct iio_chan_spec ds1803_channels[] = { @@ -104,9 +106,25 @@ static int ds1803_write_raw(struct iio_dev *indio_dev, return i2c_smbus_write_byte_data(data->client, DS1803_WRITE(pot), val); } +static int ds1803_read_avail(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, long mask) +{ + struct ds1803_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_RAW: + *vals = data->cfg->avail; + *length = ARRAY_SIZE(data->cfg->avail); + *type = IIO_VAL_INT; + return IIO_AVAIL_RANGE; + } + return -EINVAL; +} + static const struct iio_info ds1803_info = { .read_raw = ds1803_read_raw, .write_raw = ds1803_write_raw, + .read_avail = ds1803_read_avail, }; static int ds1803_probe(struct i2c_client *client, -- 2.17.1