[Intel-gfx] [PATCH v4 05/13] drivers: create binary sysfs for class

Ramalingam C ramalingam.c at intel.com
Fri Apr 5 08:42:54 UTC 2019


Functions to create and remove the binary sysfs for class are added.

These are getting introduced as DRM wants to create the common binary
sysfs across the drm subsystem to handle hdcp srm.

Signed-off-by: Ramalingam C <ramalingam.c at intel.com>
cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
cc: Daniel Vetter <daniel at ffwll.ch>
---
 drivers/base/class.c   | 19 +++++++++++++++++++
 include/linux/device.h |  4 ++++
 2 files changed, 23 insertions(+)

diff --git a/drivers/base/class.c b/drivers/base/class.c
index d8a6a5864c2e..b0f37de16a14 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -83,6 +83,23 @@ static struct kobj_type class_ktype = {
 /* Hotplug events for classes go to the class subsys */
 static struct kset *class_kset;
 
+int class_create_bin_file(struct class *cls, const struct bin_attribute *attr)
+{
+	int error;
+
+	if (cls)
+		error = sysfs_create_bin_file(&cls->p->subsys.kobj, attr);
+	else
+		error = -EINVAL;
+	return error;
+}
+
+void class_remove_bin_file(struct class *cls, const struct bin_attribute *attr)
+{
+	if (cls)
+		sysfs_remove_bin_file(&cls->p->subsys.kobj, attr);
+}
+
 
 int class_create_file_ns(struct class *cls, const struct class_attribute *attr,
 			 const void *ns)
@@ -577,6 +594,8 @@ int __init classes_init(void)
 	return 0;
 }
 
+EXPORT_SYMBOL_GPL(class_create_bin_file);
+EXPORT_SYMBOL_GPL(class_remove_bin_file);
 EXPORT_SYMBOL_GPL(class_create_file_ns);
 EXPORT_SYMBOL_GPL(class_remove_file_ns);
 EXPORT_SYMBOL_GPL(class_unregister);
diff --git a/include/linux/device.h b/include/linux/device.h
index b6c6a4634801..004c8064a78a 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -485,6 +485,10 @@ struct class_attribute {
 #define CLASS_ATTR_WO(_name) \
 	struct class_attribute class_attr_##_name = __ATTR_WO(_name)
 
+extern int __must_check class_create_bin_file(struct class *class,
+					      const struct bin_attribute *attr);
+extern void class_remove_bin_file(struct class *class,
+				  const struct bin_attribute *attr);
 extern int __must_check class_create_file_ns(struct class *class,
 					     const struct class_attribute *attr,
 					     const void *ns);
-- 
2.19.1



More information about the Intel-gfx mailing list