]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Driver core: add ability for devices to create and remove bin files
authorGreg Kroah-Hartman <gregkh@suse.de>
Tue, 19 Sep 2006 16:39:19 +0000 (09:39 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 26 Sep 2006 04:08:39 +0000 (21:08 -0700)
Makes it easier for devices to create and remove binary attribute files
so they don't have to call directly into sysfs.  This is needed to help
with the conversion from struct class_device to struct device.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/core.c
include/linux/device.h

index 1d3d3582fcca2764204ba40813e44ff541dfdfcb..bc9f35c816918b5ed9c4accc0af20c89186f27c4 100644 (file)
@@ -319,6 +319,32 @@ void device_remove_file(struct device * dev, struct device_attribute * attr)
        }
 }
 
+/**
+ * device_create_bin_file - create sysfs binary attribute file for device.
+ * @dev: device.
+ * @attr: device binary attribute descriptor.
+ */
+int device_create_bin_file(struct device *dev, struct bin_attribute *attr)
+{
+       int error = -EINVAL;
+       if (dev)
+               error = sysfs_create_bin_file(&dev->kobj, attr);
+       return error;
+}
+EXPORT_SYMBOL_GPL(device_create_bin_file);
+
+/**
+ * device_remove_bin_file - remove sysfs binary attribute file
+ * @dev: device.
+ * @attr: device binary attribute descriptor.
+ */
+void device_remove_bin_file(struct device *dev, struct bin_attribute *attr)
+{
+       if (dev)
+               sysfs_remove_bin_file(&dev->kobj, attr);
+}
+EXPORT_SYMBOL_GPL(device_remove_bin_file);
+
 static void klist_children_get(struct klist_node *n)
 {
        struct device *dev = container_of(n, struct device, knode_parent);
index e0fae0e76fa99ac53325bdac014152862cb347f5..7d447d7271c5bc87da5a5c61c9bee6ab0e30b510 100644 (file)
@@ -309,6 +309,10 @@ struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store)
 
 extern int device_create_file(struct device *device, struct device_attribute * entry);
 extern void device_remove_file(struct device * dev, struct device_attribute * attr);
+extern int __must_check device_create_bin_file(struct device *dev,
+                                              struct bin_attribute *attr);
+extern void device_remove_bin_file(struct device *dev,
+                                  struct bin_attribute *attr);
 struct device {
        struct klist            klist_children;
        struct klist_node       knode_parent;           /* node in sibling list */