Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp973237pxf; Thu, 11 Mar 2021 21:33:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmdDkfQQlYW0H8PYJi9GTI7qrSRa0qaNcb6mtd0navCPEJMpy8RccUxdEepmPuBdudIzQ+ X-Received: by 2002:a17:906:fcb2:: with SMTP id qw18mr6473752ejb.434.1615527185071; Thu, 11 Mar 2021 21:33:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615527185; cv=none; d=google.com; s=arc-20160816; b=Sn12VGXNL6WmdP00XtKz5792nO3YdOnBYjIY6M3YKJrYlnQsim95SyAwtT2cr6KBH+ saKjz5cMvrbjLtlZ8qMFd/KAkOhbzIMqo7pMXZ91AQ7BladkOgs0e5mHlBFEUWt1uo8k Cd1IMotfUL4SORLG4+fEoieMJ4j4J2Nzsqyt9WK5FVeYmbICxIYZY+Y2Z5sf84B9htYx sxqflnvK5K6oorRS/D7npvI2fBWCeKxl+mzDN1MSbXEHCradVO8riDZoG351W3PsiEpg UesZJHtZHwliyTudf/cmqAgXjSx6GAq1OVZC6chnx1wu0wKUEBpC6/ksmntRtTOCcp9e Wb4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=cedzXH2mwsyrkSO9r0tC4BCdclkRwN6ijBwzgFvGgU0=; b=T+L2gk0C/AEt9M4d6CTK0JakDQxqqF2coq436caImitiETh36fp47jL/ozutEVia1h gnIXolWNM6uUfK7Esbm1b7NjLyke1cdg7TLZpplVDn1B5bnpK/3mltia5sxa9UCuPicR k61Tw5+BqSwMH0WWKl2RzRwhofaWWC8t81EQImdJzDZ7yuQYe+yqiR00bxBLVb1ku13e lSeTc8ec2Qoz28SkXgRAEXDWrJ9MEYLIn3hYuDl2V4dVippF9/8Bmmbb4ca996K30sNn lAWn6D3SK+i030TzFjWEWoUAB5qkpXNidnNywBxehftAmmX9NX1ayeFScfUUp40DBCO1 Q0TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="TBJd7C/N"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gz5si3278888ejb.19.2021.03.11.21.32.41; Thu, 11 Mar 2021 21:33:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="TBJd7C/N"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231391AbhCLF2F (ORCPT + 99 others); Fri, 12 Mar 2021 00:28:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230205AbhCLF1k (ORCPT ); Fri, 12 Mar 2021 00:27:40 -0500 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBA49C061574; Thu, 11 Mar 2021 21:27:39 -0800 (PST) Received: by mail-il1-x129.google.com with SMTP id b5so1493165ilq.10; Thu, 11 Mar 2021 21:27:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cedzXH2mwsyrkSO9r0tC4BCdclkRwN6ijBwzgFvGgU0=; b=TBJd7C/NApDyC+0/5wKLyKr+fzrC1bBtWFxlApGpVyZYTAMf7pMBGY8VGT5i+/J/0F UMCA16UtCB0WQK3L/IsMP0EAFn6zxNPGkQnIYDCljBIdnLgPbUSHRJhI9vt3NXmpbbc3 V4pQiFiINrAbHbvATj2zBbezRRPDl/+kJOglBy4/cSNRnIqv64w2zVclA5keFs/39eLG zKRl7UdUJ+fTHc8bFAHhjTJswQxlhYD6giVjVgDBs9dluN0WOLhScK/ewf009dIZUPEE Bg9fEPPZo/KAOiCkcDJx21B5dM1wF3CqnWo/FhMB6fbqa3gJ4Dtr5737Z9xjEd/32mkY dR9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cedzXH2mwsyrkSO9r0tC4BCdclkRwN6ijBwzgFvGgU0=; b=NTLaEi3ZBJSvUW2zstccAQd0wCc0umCs7G9++9L6IW7LKhaZMrupxvzHaa0zJOkvQz 6MtfHWQTADEnFCIInGnNeZP+C+77snxsCjz6TqwbdbtZBHywDy9yaX6S3iYsy2KrqO5H vcvYAooaUoNjv/86/AVm2X7xN/DqtcrP9OrG8lHHQfni/n0u0xb/N9vwpGHRqfCfe6tD GZz4eUjm4EQt/tlqfsi14cSN+bGIitg4BfOknEzsuuACJHmkAypKV9kl9DMTeIB8e8X/ DColPBb0cerVtEa2nRO5ufJ/lyySzEqaU9uNxfhNNZaQScP0eLWbxq7Uh/HoNSB2bS8Y qCjw== X-Gm-Message-State: AOAM5313WMxvCQTwbJFQIB7ODnLtHcrXRJQjL3Xep3V3mN+XHwBrBdTo XFjDEhlUnFEUcWf1D+OPAKcztirUYDRiYDmxazw= X-Received: by 2002:a92:3652:: with SMTP id d18mr1627864ilf.100.1615526859345; Thu, 11 Mar 2021 21:27:39 -0800 (PST) MIME-Version: 1.0 References: <20210311091042.22417-1-aardelean@deviqon.com> In-Reply-To: <20210311091042.22417-1-aardelean@deviqon.com> From: Alexandru Ardelean Date: Fri, 12 Mar 2021 07:27:28 +0200 Message-ID: Subject: Re: [PATCH] iio: kfifo: add devm_iio_triggered_buffer_setup_ext variant To: Alexandru Ardelean Cc: linux-iio , LKML , linux@deviqon.com, Jonathan Cameron , Gwendal Grignou , Guenter Roeck , Jonathan Cameron Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 11, 2021 at 11:14 AM Alexandru Ardelean wrote: > > This is similar to the {devm_}iio_triggered_buffer_setup_ext variants added > via commit 5164c7889857 ("iio: triggered-buffer: add > {devm_}iio_triggered_buffer_setup_ext variants"). > > These can be used to pass extra buffer attributes to the buffer object. > This is a bit of temporary mechanism (hopefully) so that drivers that want > to allocate a kfifo buffer with extra buffer attributes, don't need to > include 'buffer_impl.h' directly. This can also become an API function (in > it's own right, unfortunately), but it may be a little less bad vs drivers > having to include 'buffer_impl.h'. > > So, far the drivers that want to pass buffer attributes, all have to do > with some HW FIFO attributes, so there may be a chance of unifying them > into IIO core somehow (as some standard API). But, until that happens, we > just need to let them register their HW FIFO attributes directly (without > having to let them include 'buffer_impl.h' directly). > This isn't required anymore. Please disregard. Apologies for the noise > Signed-off-by: Alexandru Ardelean > --- > > Related to the discussion here: > https://lore.kernel.org/linux-iio/CA+U=Dspk3cWjiiRmDrgfHAY6houjr-KtSD3u4BssUcb=c2ujpQ@mail.gmail.com/T/#mcfda9d6cb6426caefa4a5db6d634640bfdbe328e > > drivers/iio/buffer/kfifo_buf.c | 16 ++++++++++------ > include/linux/iio/kfifo_buf.h | 12 ++++++++---- > 2 files changed, 18 insertions(+), 10 deletions(-) > > diff --git a/drivers/iio/buffer/kfifo_buf.c b/drivers/iio/buffer/kfifo_buf.c > index 4ecfa0ec3016..13eea2e11cbc 100644 > --- a/drivers/iio/buffer/kfifo_buf.c > +++ b/drivers/iio/buffer/kfifo_buf.c > @@ -206,22 +206,24 @@ static struct iio_buffer *devm_iio_kfifo_allocate(struct device *dev) > } > > /** > - * devm_iio_kfifo_buffer_setup - Allocate a kfifo buffer & attach it to an IIO device > + * devm_iio_kfifo_buffer_setup_ext - Allocate a kfifo buffer & attach it to an IIO device > * @dev: Device object to which to attach the life-time of this kfifo buffer > * @indio_dev: The device the buffer should be attached to > * @mode_flags: The mode flags for this buffer (INDIO_BUFFER_SOFTWARE and/or > * INDIO_BUFFER_TRIGGERED). > * @setup_ops: The setup_ops required to configure the HW part of the buffer (optional) > + * @buffer_attrs: Extra sysfs buffer attributes for this IIO buffer > * > * This function allocates a kfifo buffer via devm_iio_kfifo_allocate() and > * attaches it to the IIO device via iio_device_attach_buffer(). > * This is meant to be a bit of a short-hand/helper function as there are a few > * drivers that seem to do this. > */ > -int devm_iio_kfifo_buffer_setup(struct device *dev, > - struct iio_dev *indio_dev, > - int mode_flags, > - const struct iio_buffer_setup_ops *setup_ops) > +int devm_iio_kfifo_buffer_setup_ext(struct device *dev, > + struct iio_dev *indio_dev, > + int mode_flags, > + const struct iio_buffer_setup_ops *setup_ops, > + const struct attribute **buffer_attrs) > { > struct iio_buffer *buffer; > > @@ -237,8 +239,10 @@ int devm_iio_kfifo_buffer_setup(struct device *dev, > indio_dev->modes |= mode_flags; > indio_dev->setup_ops = setup_ops; > > + buffer->attrs = buffer_attrs; > + > return iio_device_attach_buffer(indio_dev, buffer); > } > -EXPORT_SYMBOL_GPL(devm_iio_kfifo_buffer_setup); > +EXPORT_SYMBOL_GPL(devm_iio_kfifo_buffer_setup_ext); > > MODULE_LICENSE("GPL"); > diff --git a/include/linux/iio/kfifo_buf.h b/include/linux/iio/kfifo_buf.h > index 1522896e1daf..ccd2ceae7b25 100644 > --- a/include/linux/iio/kfifo_buf.h > +++ b/include/linux/iio/kfifo_buf.h > @@ -10,9 +10,13 @@ struct device; > struct iio_buffer *iio_kfifo_allocate(void); > void iio_kfifo_free(struct iio_buffer *r); > > -int devm_iio_kfifo_buffer_setup(struct device *dev, > - struct iio_dev *indio_dev, > - int mode_flags, > - const struct iio_buffer_setup_ops *setup_ops); > +int devm_iio_kfifo_buffer_setup_ext(struct device *dev, > + struct iio_dev *indio_dev, > + int mode_flags, > + const struct iio_buffer_setup_ops *setup_ops, > + const struct attribute **buffer_attrs); > + > +#define devm_iio_kfifo_buffer_setup(dev, indio_dev, mode_flags, setup_ops) \ > + devm_iio_kfifo_buffer_setup_ext((dev), (indio_dev), (mode_flags), (setup_ops), NULL) > > #endif > -- > 2.29.2 >