Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1726492img; Sat, 23 Mar 2019 10:29:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzY7nZxYfCOkpzNEy/m14emchUcJBWbVEVqUDgLm2ziVWCDM790e4e898dVxh6yPMMJ5TtX X-Received: by 2002:a63:f212:: with SMTP id v18mr15187110pgh.261.1553362160213; Sat, 23 Mar 2019 10:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553362160; cv=none; d=google.com; s=arc-20160816; b=ufcO/to8EIgtk3wsoO5X1N5LdhZxAmwvYo3SyaFsCzkRZNzfbxQfq888T0HqkTGBD4 cvDQA0vEbE7Fa/0P/XpOx27pstLjHyUJTRJII4jF09DQrRdv4HVgWgFIriXYA5LXeF33 kOCZI620Ebc5Q5t9QfZPRz2l59HfK7xiKvA0QqDLFDjUp9sAovDeUOG/H1yMOyfi1DuY FYCYJv2GE1NPd015p5OiH9U0hdeLf0hSIskatNbI7jb+nGDsM6CAK8sCOK8kpMYMjurG SCB4RGvLPubaLpSPvsLxVhGgVLoQbwtr9Tk1k/P54AuEACK3egCSsh5WCKGr44bYCH/k edpg== 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 :message-id:date:subject:cc:to:from; bh=uc2PBBhgW2iRy5crVQsQvb/ARPfVlWT5fCLKFCNy0so=; b=ZUmXBZlZGgEwXrH1NEj6gNISJ4kp8BPMHwRvgok+gvsKECCYRddt9oaxA7X57WeMxX K9uTsGzI1z4q8+ASDeJP74lUcxY2HnjRk5eGulP4nJ+1jDg4CvVgtqutlOHr45Khyph1 Vz7vtsvy2xevPNMBw62OE1lDrsje9514xyMiNAq2Wrl9tAz3equlcANMvky9C8xXIVq+ F+mSDuyC9JHuxu9UJq+caO/8cRpecVPn3ZoIjO4Hcvza9HcfTl95YhXUaJ4v41b3HJYj qpcHq2IcQrazhBmyN6aZK8ktCmlf0B75wqioUrYrDU4jYcxwQxLHIjj8mHC4a5tWHxVw unjw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n22si9871895plp.296.2019.03.23.10.29.04; Sat, 23 Mar 2019 10:29:20 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728027AbfCWR2T (ORCPT + 99 others); Sat, 23 Mar 2019 13:28:19 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:50937 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728009AbfCWR2S (ORCPT ); Sat, 23 Mar 2019 13:28:18 -0400 Received: from pc.localdomain (unknown [91.192.165.7]) (Authenticated sender: contact@artur-rojek.eu) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 10B4320000E; Sat, 23 Mar 2019 17:28:14 +0000 (UTC) From: Artur Rojek To: Sebastian Reichel , Jonathan Cameron , Rob Herring , Mark Rutland Cc: linux-pm@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Cercueil , Artur Rojek Subject: [PATCH v2 1/4] iio: inkern: API for reading available iio channel attribute values Date: Sat, 23 Mar 2019 18:28:06 +0100 Message-Id: <20190323172809.14407-1-contact@artur-rojek.eu> X-Mailer: git-send-email 2.21.0 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 Extend the inkern API with a function for reading available attribute values of iio channels. Signed-off-by: Artur Rojek --- Changes: v2: no change drivers/iio/inkern.c | 20 ++++++++++++++++++++ include/linux/iio/consumer.h | 14 ++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 06ca3f7fcc44..f19dbde3c945 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -733,6 +733,26 @@ static int iio_channel_read_avail(struct iio_channel *chan, vals, type, length, info); } +int iio_read_avail_channel_attribute(struct iio_channel *chan, + const int **vals, int *type, int *length, + enum iio_chan_info_enum attribute) +{ + int ret; + + mutex_lock(&chan->indio_dev->info_exist_lock); + if (!chan->indio_dev->info) { + ret = -ENODEV; + goto err_unlock; + } + + ret = iio_channel_read_avail(chan, vals, type, length, attribute); +err_unlock: + mutex_unlock(&chan->indio_dev->info_exist_lock); + + return ret; +} +EXPORT_SYMBOL_GPL(iio_read_avail_channel_attribute); + int iio_read_avail_channel_raw(struct iio_channel *chan, const int **vals, int *length) { diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h index 9887f4f8e2a8..b2d34831ed7c 100644 --- a/include/linux/iio/consumer.h +++ b/include/linux/iio/consumer.h @@ -290,6 +290,20 @@ int iio_read_max_channel_raw(struct iio_channel *chan, int *val); int iio_read_avail_channel_raw(struct iio_channel *chan, const int **vals, int *length); +/** + * iio_read_avail_channel_attribute() - read available channel attribute values + * @chan: The channel being queried. + * @vals: Available values read back. + * @type: Type of values read back. + * @length: Number of entries in vals. + * @attribute: info attribute to be read back. + * + * Returns an error code, IIO_AVAIL_RANGE or IIO_AVAIL_LIST. + */ +int iio_read_avail_channel_attribute(struct iio_channel *chan, + const int **vals, int *type, int *length, + enum iio_chan_info_enum attribute); + /** * iio_get_channel_type() - get the type of a channel * @channel: The channel being queried. -- 2.21.0