From patchwork Wed Aug 17 10:56:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Rojek X-Patchwork-Id: 12945724 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8A82C3F6B0 for ; Wed, 17 Aug 2022 10:57:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239079AbiHQK5Z (ORCPT ); Wed, 17 Aug 2022 06:57:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239072AbiHQK5X (ORCPT ); Wed, 17 Aug 2022 06:57:23 -0400 Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [IPv6:2001:4b98:dc4:8::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5CE563F10; Wed, 17 Aug 2022 03:57:21 -0700 (PDT) Received: (Authenticated sender: contact@artur-rojek.eu) by mail.gandi.net (Postfix) with ESMTPSA id E8D9920000C; Wed, 17 Aug 2022 10:57:18 +0000 (UTC) From: Artur Rojek To: Paul Cercueil , Jonathan Cameron , Dmitry Torokhov , Chris Morgan Cc: linux-mips@vger.kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, Artur Rojek Subject: [PATCH 2/4] iio: add iio_channel_cb_get_iio_buffer helper Date: Wed, 17 Aug 2022 12:56:41 +0200 Message-Id: <20220817105643.95710-3-contact@artur-rojek.eu> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220817105643.95710-1-contact@artur-rojek.eu> References: <20220817105643.95710-1-contact@artur-rojek.eu> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Introduce a helper function to retrieve an iio_buffer from iio_cb_buffer. This is useful for consumers that need to extract metadata about the buffer, e.g. get the channel offsets. Tested-by: Paul Cercueil Signed-off-by: Artur Rojek --- drivers/iio/buffer/industrialio-buffer-cb.c | 7 +++++++ include/linux/iio/consumer.h | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/iio/buffer/industrialio-buffer-cb.c b/drivers/iio/buffer/industrialio-buffer-cb.c index 4c12b7a94af5..47d6e28b4d36 100644 --- a/drivers/iio/buffer/industrialio-buffer-cb.c +++ b/drivers/iio/buffer/industrialio-buffer-cb.c @@ -151,6 +151,13 @@ struct iio_dev } EXPORT_SYMBOL_GPL(iio_channel_cb_get_iio_dev); +struct iio_buffer +*iio_channel_cb_get_iio_buffer(struct iio_cb_buffer *cb_buffer) +{ + return &cb_buffer->buffer; +} +EXPORT_SYMBOL_GPL(iio_channel_cb_get_iio_buffer); + MODULE_AUTHOR("Jonathan Cameron "); MODULE_DESCRIPTION("Industrial I/O callback buffer"); MODULE_LICENSE("GPL"); diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h index 6802596b017c..c28925d5b69c 100644 --- a/include/linux/iio/consumer.h +++ b/include/linux/iio/consumer.h @@ -196,6 +196,18 @@ struct iio_channel struct iio_dev *iio_channel_cb_get_iio_dev(const struct iio_cb_buffer *cb_buffer); +/** + * iio_channel_cb_get_iio_buffer() - get access to the underlying buffer. + * @cb_buffer: The callback buffer from whom we want the buffer + * information. + * + * This function allows one to obtain information about the buffer. + * The primary aim is to allow drivers that are consuming a buffer to query + * things like channel offsets in the buffer. + */ +struct iio_buffer +*iio_channel_cb_get_iio_buffer(struct iio_cb_buffer *cb_buffer); + /** * iio_read_channel_raw() - read from a given channel * @chan: The channel being queried.