It may seem gratuitous, but it's what we really want.
driverfs files are meant to expose attributes of various kernel objects, so in that sense,
the change adds more accurate meaning to the object.
Plus, we will soon gain the ability to expose attributes of drivers (both device and bus)
themselves, and we want to be able to have each mean something reasonable.
This changes driverfs and the device model core (but none of the other users)
#include <linux/stat.h>
#include <linux/limits.h>
-extern struct driver_file_entry * device_default_files[];
+extern struct device_attribute * device_default_files[];
/**
* device_create_file - create a driverfs file for a device
*
* Allocate space for file entry, copy descriptor, and create.
*/
-int device_create_file(struct device * dev, struct driver_file_entry * entry)
+int device_create_file(struct device * dev, struct device_attribute * entry)
{
int error = -EINVAL;
int device_make_dir(struct device * dev)
{
struct driver_dir_entry * parent = NULL;
- struct driver_file_entry * entry;
+ struct device_attribute * entry;
int error;
int i;
return off ? 0 : sprintf(buf,"%s\n",dev->name);
}
-static struct driver_file_entry device_name_entry = {
+static struct device_attribute device_name_entry = {
name: "name",
mode: S_IRUGO,
show: device_read_name,
return error < 0 ? error : count;
}
-static struct driver_file_entry device_power_entry = {
+static struct device_attribute device_power_entry = {
name: "power",
mode: S_IWUSR | S_IRUGO,
show: device_read_power,
store: device_write_power,
};
-struct driver_file_entry * device_default_files[] = {
+struct device_attribute * device_default_files[] = {
&device_name_entry,
&device_power_entry,
NULL,
*
* Userspace wants data from a file. It is up to the creator of the file to
* provide that data.
- * There is a struct driver_file_entry embedded in file->private_data. We
+ * There is a struct device_attribute embedded in file->private_data. We
* obtain that and check if the read callback is implemented. If so, we call
* it, passing the data field of the file entry.
* Said callback is responsible for filling the buffer and returning the number
static ssize_t
driverfs_read_file(struct file *file, char *buf, size_t count, loff_t *ppos)
{
- struct driver_file_entry * entry;
+ struct device_attribute * entry;
struct driver_dir_entry * dir;
unsigned char *page;
ssize_t retval = 0;
struct device * dev;
dir = file->f_dentry->d_parent->d_fsdata;
- entry = (struct driver_file_entry *)file->f_dentry->d_fsdata;
+ entry = (struct device_attribute *)file->f_dentry->d_fsdata;
if (!entry) {
DBG("%s: file entry is NULL\n",__FUNCTION__);
return -ENOENT;
static ssize_t
driverfs_write_file(struct file *file, const char *buf, size_t count, loff_t *ppos)
{
- struct driver_file_entry * entry;
+ struct device_attribute * entry;
struct driver_dir_entry * dir;
struct device * dev;
ssize_t retval = 0;
dir = file->f_dentry->d_parent->d_fsdata;
- entry = (struct driver_file_entry *)file->f_dentry->d_fsdata;
+ entry = (struct device_attribute *)file->f_dentry->d_fsdata;
if (!entry) {
DBG("%s: file entry is NULL\n",__FUNCTION__);
return -ENOENT;
* @parent: directory to create it in
*/
int
-driverfs_create_file(struct driver_file_entry * entry,
+driverfs_create_file(struct device_attribute * entry,
struct driver_dir_entry * parent)
{
struct dentry * dentry;
*/
extern int device_register(struct device * dev);
-extern int device_create_file(struct device *device, struct driver_file_entry * entry);
+extern int device_create_file(struct device *device, struct device_attribute * entry);
extern void device_remove_file(struct device * dev, const char * name);
/*
struct device;
-struct driver_file_entry {
+struct device_attribute {
char * name;
mode_t mode;
driverfs_remove_dir(struct driver_dir_entry * entry);
extern int
-driverfs_create_file(struct driver_file_entry * entry,
+driverfs_create_file(struct device_attribute * entry,
struct driver_dir_entry * parent);
extern int