Commit b25f8641 authored by Patrick Mochel's avatar Patrick Mochel

sysfs: fix up device attribute read/write methods.

Remove @off and @count from the sysfs_ops, and the core attribute methods.
parent 0f902ed5
...@@ -35,28 +35,26 @@ DECLARE_MUTEX(device_sem); ...@@ -35,28 +35,26 @@ DECLARE_MUTEX(device_sem);
extern struct attribute * dev_default_attrs[]; extern struct attribute * dev_default_attrs[];
static ssize_t static ssize_t
dev_attr_show(struct kobject * kobj, struct attribute * attr, dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
char * buf, size_t count, loff_t off)
{ {
struct device_attribute * dev_attr = to_dev_attr(attr); struct device_attribute * dev_attr = to_dev_attr(attr);
struct device * dev = to_dev(kobj); struct device * dev = to_dev(kobj);
ssize_t ret = 0; ssize_t ret = 0;
if (dev_attr->show) if (dev_attr->show)
ret = dev_attr->show(dev,buf,count,off); ret = dev_attr->show(dev,buf);
return ret; return ret;
} }
static ssize_t static ssize_t
dev_attr_store(struct kobject * kobj, struct attribute * attr, dev_attr_store(struct kobject * kobj, struct attribute * attr, const char * buf)
const char * buf, size_t count, loff_t off)
{ {
struct device_attribute * dev_attr = to_dev_attr(attr); struct device_attribute * dev_attr = to_dev_attr(attr);
struct device * dev = to_dev(kobj); struct device * dev = to_dev(kobj);
ssize_t ret = 0; ssize_t ret = 0;
if (dev_attr->store) if (dev_attr->store)
ret = dev_attr->store(dev,buf,count,off); ret = dev_attr->store(dev,buf);
return ret; return ret;
} }
......
...@@ -10,21 +10,21 @@ ...@@ -10,21 +10,21 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/string.h> #include <linux/string.h>
static ssize_t device_read_name(struct device * dev, char * buf, size_t count, loff_t off) static ssize_t device_read_name(struct device * dev, char * buf)
{ {
return off ? 0 : sprintf(buf,"%s\n",dev->name); return sprintf(buf,"%s\n",dev->name);
} }
static DEVICE_ATTR(name,S_IRUGO,device_read_name,NULL); static DEVICE_ATTR(name,S_IRUGO,device_read_name,NULL);
static ssize_t static ssize_t
device_read_power(struct device * dev, char * page, size_t count, loff_t off) device_read_power(struct device * dev, char * page)
{ {
return off ? 0 : sprintf(page,"%d\n",dev->power_state); return sprintf(page,"%d\n",dev->power_state);
} }
static ssize_t static ssize_t
device_write_power(struct device * dev, const char * buf, size_t count, loff_t off) device_write_power(struct device * dev, const char * buf)
{ {
char str_command[20]; char str_command[20];
char str_level[20]; char str_level[20];
...@@ -33,9 +33,6 @@ device_write_power(struct device * dev, const char * buf, size_t count, loff_t o ...@@ -33,9 +33,6 @@ device_write_power(struct device * dev, const char * buf, size_t count, loff_t o
u32 int_level; u32 int_level;
int error = 0; int error = 0;
if (off)
return 0;
if (!dev->driver) if (!dev->driver)
goto done; goto done;
...@@ -83,7 +80,7 @@ device_write_power(struct device * dev, const char * buf, size_t count, loff_t o ...@@ -83,7 +80,7 @@ device_write_power(struct device * dev, const char * buf, size_t count, loff_t o
error = 0; error = 0;
} }
done: done:
return error < 0 ? error : count; return error < 0 ? error : strlen(buf);
} }
static DEVICE_ATTR(power,S_IWUSR | S_IRUGO, static DEVICE_ATTR(power,S_IWUSR | S_IRUGO,
......
...@@ -319,8 +319,8 @@ extern void device_release_driver(struct device * dev); ...@@ -319,8 +319,8 @@ extern void device_release_driver(struct device * dev);
struct device_attribute { struct device_attribute {
struct attribute attr; struct attribute attr;
ssize_t (*show)(struct device * dev, char * buf, size_t count, loff_t off); ssize_t (*show)(struct device * dev, char * buf);
ssize_t (*store)(struct device * dev, const char * buf, size_t count, loff_t off); ssize_t (*store)(struct device * dev, const char * buf);
}; };
#define DEVICE_ATTR(_name,_mode,_show,_store) \ #define DEVICE_ATTR(_name,_mode,_show,_store) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment