All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Matti Vaittinen <mazziesaccount@gmail.com>,
	Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3 05/10] iio: Add IIO_STATIC_CONST_DEVICE_ATTR
Date: Mon, 3 Oct 2022 11:12:04 +0300	[thread overview]
Message-ID: <8dd853dd0ef8eb40cb980cc6f6e7a43166de3afb.1664782676.git.mazziesaccount@gmail.com> (raw)
In-Reply-To: <cover.1664782676.git.mazziesaccount@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1556 bytes --]

Add IIO_STATIC_CONST_DEVICE_ATTR macro for creating an read-only
iio_dev_attr which returns constant value. This macro is intended to be
used when replacing the IIO_CONST_ATTR - attributes for triggered
buffers because the triggered buffer attributes must be of type
iio_dev_attr.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
---
 include/linux/iio/sysfs.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/iio/sysfs.h b/include/linux/iio/sysfs.h
index e51fba66de4b..de5bb125815c 100644
--- a/include/linux/iio/sysfs.h
+++ b/include/linux/iio/sysfs.h
@@ -97,6 +97,17 @@ struct iio_const_attr {
 	= { .string = _string,						\
 	    .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
 
+#define IIO_STATIC_CONST_DEVICE_ATTR(_name, _string)				\
+	static ssize_t iio_const_dev_attr_show_##_name(			\
+					struct device *dev,		\
+					struct device_attribute *attr,	\
+					char *buf)			\
+	{								\
+		return sysfs_emit(buf, "%s\n", _string);		\
+	}								\
+	static IIO_DEVICE_ATTR(_name, 0444,				\
+			       iio_const_dev_attr_show_##_name, NULL, 0)
+
 /* Generic attributes of onetype or another */
 
 /**
-- 
2.37.3


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =] 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2022-10-03  8:39 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-03  8:09 [PATCH v3 00/10] iio: Fix unsafe buffer attributes Matti Vaittinen
2022-10-03  8:09 ` Matti Vaittinen
2022-10-03  8:10 ` [PATCH v3 01/10] iio: adxl367: " Matti Vaittinen
2022-10-16 11:12   ` Jonathan Cameron
2022-10-03  8:10 ` [PATCH v3 02/10] iio: adxl372: " Matti Vaittinen
2022-10-16 11:12   ` Jonathan Cameron
2022-10-03  8:11 ` [PATCH v3 03/10] iio: bmc150-accel-core: " Matti Vaittinen
2022-10-16 11:13   ` Jonathan Cameron
2022-10-03  8:11 ` [PATCH v3 04/10] iio: at91-sama5d2_adc: " Matti Vaittinen
2022-10-03  8:11   ` Matti Vaittinen
2022-10-06  8:34   ` Claudiu.Beznea
2022-10-06  8:34     ` Claudiu.Beznea
2022-10-16 11:14     ` Jonathan Cameron
2022-10-16 11:14       ` Jonathan Cameron
2022-10-03  8:12 ` Matti Vaittinen [this message]
2022-10-03  8:12 ` [PATCH v3 06/10] iio: adxl367: Use IIO_STATIC_CONST_DEVICE_ATTR() Matti Vaittinen
2022-10-03  8:12 ` [PATCH v3 07/10] iio: adxl372: " Matti Vaittinen
2022-10-03  8:13 ` [PATCH v3 08/10] iio: bmc150-accel-core: " Matti Vaittinen
2022-10-03  8:13 ` [PATCH v3 09/10] iio: at91-sama5d2_adc: " Matti Vaittinen
2022-10-03  8:13   ` Matti Vaittinen
2022-10-06  8:35   ` Claudiu.Beznea
2022-10-06  8:35     ` Claudiu.Beznea
2022-10-03  8:13 ` [RFT PATCH v3 10/10] iio: Don't silently expect attribute types Matti Vaittinen
2022-10-03  8:13   ` Matti Vaittinen
2022-10-03  8:43   ` Andy Shevchenko
2022-10-03  8:43     ` Andy Shevchenko
2022-10-03  8:58     ` Matti Vaittinen
2022-10-03  8:58       ` Matti Vaittinen
2022-10-03  9:02       ` Matti Vaittinen
2022-10-03  9:02         ` Matti Vaittinen
2022-10-03  9:39         ` Andy Shevchenko
2022-10-03  9:39           ` Andy Shevchenko
2022-10-03  9:42       ` Andy Shevchenko
2022-10-03  9:42         ` Andy Shevchenko
2022-10-06  8:35   ` Claudiu.Beznea
2022-10-06  8:35     ` Claudiu.Beznea
2022-10-06 12:53     ` Matti Vaittinen
2022-10-06 12:53       ` Matti Vaittinen
2022-10-09 17:38       ` Jonathan Cameron
2022-10-09 17:38         ` Jonathan Cameron
2022-10-10  9:36         ` Matti Vaittinen
2022-10-10  9:36           ` Matti Vaittinen
2022-11-05 14:45           ` Jonathan Cameron
2022-11-05 14:45             ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8dd853dd0ef8eb40cb980cc6f6e7a43166de3afb.1664782676.git.mazziesaccount@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matti.vaittinen@fi.rohmeurope.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.