diff mbox series

[v8,1/2] drivers: export to_ext_attr()

Message ID 20240613092830.15761-2-brgl@bgdev.pl
State New
Headers show
Series misc: add a virtual driver for testing the GPIO API | expand

Commit Message

Bartosz Golaszewski June 13, 2024, 9:28 a.m. UTC
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Make to_ext_attr() available to code that wants to reuse struct
dev_ext_attribute. While at it: make it into a static inline function.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/base/core.c    | 2 --
 include/linux/device.h | 6 ++++++
 2 files changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 131d96c6090b..d51e7f05d15a 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -2459,8 +2459,6 @@  static const struct sysfs_ops dev_sysfs_ops = {
 	.store	= dev_attr_store,
 };
 
-#define to_ext_attr(x) container_of(x, struct dev_ext_attribute, attr)
-
 ssize_t device_store_ulong(struct device *dev,
 			   struct device_attribute *attr,
 			   const char *buf, size_t size)
diff --git a/include/linux/device.h b/include/linux/device.h
index fc3bd7116ab9..f7957ec918a3 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -120,6 +120,12 @@  struct dev_ext_attribute {
 	void *var;
 };
 
+static inline struct dev_ext_attribute *
+to_ext_attr(struct device_attribute *attr)
+{
+	return container_of(attr, struct dev_ext_attribute, attr);
+}
+
 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
 			  char *buf);
 ssize_t device_store_ulong(struct device *dev, struct device_attribute *attr,