summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/device.h22
-rw-r--r--include/linux/driverfs_fs.h20
2 files changed, 31 insertions, 11 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index a6d10931ae7f..5dfa05c2dd3a 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -160,8 +160,6 @@ struct device {
void (*release)(struct device * dev);
};
-#define to_device(d) container_of(d, struct device, dir)
-
static inline struct device *
list_to_dev(struct list_head *node)
{
@@ -179,8 +177,24 @@ g_list_to_dev(struct list_head *g_list)
*/
extern int device_register(struct device * dev);
-extern int device_create_file(struct device *device, struct driver_file_entry * entry);
-extern void device_remove_file(struct device * dev, const char * name);
+
+/* driverfs interface for exporting device attributes */
+
+struct device_attribute {
+ struct attribute attr;
+ ssize_t (*show)(struct device * dev, char * buf, size_t count, loff_t off);
+ ssize_t (*store)(struct device * dev, const char * buf, size_t count, loff_t off);
+};
+
+#define DEVICE_ATTR(_name,_str,_mode,_show,_store) \
+struct device_attribute dev_attr_##_name = { \
+ .attr = {.name = _str, .mode = _mode }, \
+ .show = _show, \
+ .store = _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);
/*
* Platform "fixup" functions - allow the platform to have their say
diff --git a/include/linux/driverfs_fs.h b/include/linux/driverfs_fs.h
index 758dc23f09f6..d859f8c2e041 100644
--- a/include/linux/driverfs_fs.h
+++ b/include/linux/driverfs_fs.h
@@ -26,20 +26,26 @@
#ifndef _DRIVER_FS_H_
#define _DRIVER_FS_H_
+struct driver_dir_entry;
+struct attribute;
+
+struct driverfs_ops {
+ int (*open)(struct driver_dir_entry *);
+ int (*close)(struct driver_dir_entry *);
+ ssize_t (*show)(struct driver_dir_entry *, struct attribute *,char *, size_t, loff_t);
+ ssize_t (*store)(struct driver_dir_entry *,struct attribute *,const char *, size_t, loff_t);
+};
+
struct driver_dir_entry {
char * name;
struct dentry * dentry;
mode_t mode;
+ struct driverfs_ops * ops;
};
-struct device;
-
-struct driver_file_entry {
+struct attribute {
char * name;
mode_t mode;
-
- ssize_t (*show)(struct device * dev, char * buf, size_t count, loff_t off);
- ssize_t (*store)(struct device * dev, const char * buf, size_t count, loff_t off);
};
extern int
@@ -49,7 +55,7 @@ extern void
driverfs_remove_dir(struct driver_dir_entry * entry);
extern int
-driverfs_create_file(struct driver_file_entry * entry,
+driverfs_create_file(struct attribute * attr,
struct driver_dir_entry * parent);
extern int