From 82cd7fff8d7411756775909f089d8b44f54018b9 Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Thu, 9 Jan 2003 04:41:35 -0600 Subject: sysfs: remove count and off parameters from sysfs_ops methods. The previous sysfs change implies that the show() and store() methods in struct sysfs_ops are called only once, during the first read() or write(). This means that off is always 0, and count should always be PAGE_SIZE, to fill or clear the entire buffer in one shot. Therefore, those parameters can be removed from all attribute read/write methods. This changeset removes them from the definition and fixes sysfs to deal with that appropriately. --- include/linux/sysfs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/linux') diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index 29c3eb8d2c9e..b3cc047255b8 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -17,8 +17,8 @@ struct attribute { }; struct sysfs_ops { - ssize_t (*show)(struct kobject *, struct attribute *,char *, size_t, loff_t); - ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t, loff_t); + ssize_t (*show)(struct kobject *, struct attribute *,char *); + ssize_t (*store)(struct kobject *,struct attribute *,const char *); }; extern int -- cgit v1.2.3 From 0f902ed5f03360a9a0a32c5aa742262c55f61c40 Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Thu, 9 Jan 2003 05:04:45 -0600 Subject: sysfs: fixup bus, class, and driver attribute methods. Remove @count and @off parameters from show() and store() methods. --- drivers/base/bus.c | 20 ++++++++------------ drivers/base/class.c | 10 ++++------ include/linux/device.h | 12 ++++++------ 3 files changed, 18 insertions(+), 24 deletions(-) (limited to 'include/linux') diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 782ff309b887..a3e1eaeafadb 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -31,28 +31,26 @@ static ssize_t -drv_attr_show(struct kobject * kobj, struct attribute * attr, - char * buf, size_t count, loff_t off) +drv_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) { struct driver_attribute * drv_attr = to_drv_attr(attr); struct device_driver * drv = to_driver(kobj); ssize_t ret = 0; if (drv_attr->show) - ret = drv_attr->show(drv,buf,count,off); + ret = drv_attr->show(drv,buf); return ret; } static ssize_t -drv_attr_store(struct kobject * kobj, struct attribute * attr, - const char * buf, size_t count, loff_t off) +drv_attr_store(struct kobject * kobj, struct attribute * attr, const char * buf) { struct driver_attribute * drv_attr = to_drv_attr(attr); struct device_driver * drv = to_driver(kobj); ssize_t ret = 0; if (drv_attr->store) - ret = drv_attr->store(drv,buf,count,off); + ret = drv_attr->store(drv,buf); return ret; } @@ -80,28 +78,26 @@ static struct kobj_type ktype_driver = { static ssize_t -bus_attr_show(struct kobject * kobj, struct attribute * attr, - char * buf, size_t count, loff_t off) +bus_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) { struct bus_attribute * bus_attr = to_bus_attr(attr); struct bus_type * bus = to_bus(kobj); ssize_t ret = 0; if (bus_attr->show) - ret = bus_attr->show(bus,buf,count,off); + ret = bus_attr->show(bus,buf); return ret; } static ssize_t -bus_attr_store(struct kobject * kobj, struct attribute * attr, - const char * buf, size_t count, loff_t off) +bus_attr_store(struct kobject * kobj, struct attribute * attr, const char * buf) { struct bus_attribute * bus_attr = to_bus_attr(attr); struct bus_type * bus = to_bus(kobj); ssize_t ret = 0; if (bus_attr->store) - ret = bus_attr->store(bus,buf,count,off); + ret = bus_attr->store(bus,buf); return ret; } diff --git a/drivers/base/class.c b/drivers/base/class.c index 01e82cb997a5..3eac3a612957 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -14,28 +14,26 @@ #define to_class(obj) container_of(obj,struct device_class,subsys.kset.kobj) static ssize_t -devclass_attr_show(struct kobject * kobj, struct attribute * attr, - char * buf, size_t count, loff_t off) +devclass_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) { struct devclass_attribute * class_attr = to_class_attr(attr); struct device_class * dc = to_class(kobj); ssize_t ret = 0; if (class_attr->show) - ret = class_attr->show(dc,buf,count,off); + ret = class_attr->show(dc,buf); return ret; } static ssize_t -devclass_attr_store(struct kobject * kobj, struct attribute * attr, - const char * buf, size_t count, loff_t off) +devclass_attr_store(struct kobject * kobj, struct attribute * attr, const char * buf) { struct devclass_attribute * class_attr = to_class_attr(attr); struct device_class * dc = to_class(kobj); ssize_t ret = 0; if (class_attr->store) - ret = class_attr->store(dc,buf,count,off); + ret = class_attr->store(dc,buf); return ret; } diff --git a/include/linux/device.h b/include/linux/device.h index 2076d9c6ae4b..2e370a0eb3f5 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -97,8 +97,8 @@ int bus_for_each_drv(struct bus_type * bus, struct device_driver * start, struct bus_attribute { struct attribute attr; - ssize_t (*show)(struct bus_type *, char * buf, size_t count, loff_t off); - ssize_t (*store)(struct bus_type *, const char * buf, size_t count, loff_t off); + ssize_t (*show)(struct bus_type *, char * buf); + ssize_t (*store)(struct bus_type *, const char * buf); }; #define BUS_ATTR(_name,_mode,_show,_store) \ @@ -140,8 +140,8 @@ extern void put_driver(struct device_driver * drv); struct driver_attribute { struct attribute attr; - ssize_t (*show)(struct device_driver *, char * buf, size_t count, loff_t off); - ssize_t (*store)(struct device_driver *, const char * buf, size_t count, loff_t off); + ssize_t (*show)(struct device_driver *, char * buf); + ssize_t (*store)(struct device_driver *, const char * buf); }; #define DRIVER_ATTR(_name,_mode,_show,_store) \ @@ -181,8 +181,8 @@ extern void put_devclass(struct device_class *); struct devclass_attribute { struct attribute attr; - ssize_t (*show)(struct device_class *, char * buf, size_t count, loff_t off); - ssize_t (*store)(struct device_class *, const char * buf, size_t count, loff_t off); + ssize_t (*show)(struct device_class *, char * buf); + ssize_t (*store)(struct device_class *, const char * buf); }; #define DEVCLASS_ATTR(_name,_str,_mode,_show,_store) \ -- cgit v1.2.3 From b25f8641dd5d9f1cae312cc681ed26118d83db83 Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Thu, 9 Jan 2003 05:30:43 -0600 Subject: sysfs: fix up device attribute read/write methods. Remove @off and @count from the sysfs_ops, and the core attribute methods. --- drivers/base/core.c | 10 ++++------ drivers/base/interface.c | 15 ++++++--------- include/linux/device.h | 4 ++-- 3 files changed, 12 insertions(+), 17 deletions(-) (limited to 'include/linux') diff --git a/drivers/base/core.c b/drivers/base/core.c index 234337528d15..8e66d54a1c27 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -35,28 +35,26 @@ DECLARE_MUTEX(device_sem); extern struct attribute * dev_default_attrs[]; static ssize_t -dev_attr_show(struct kobject * kobj, struct attribute * attr, - char * buf, size_t count, loff_t off) +dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) { struct device_attribute * dev_attr = to_dev_attr(attr); struct device * dev = to_dev(kobj); ssize_t ret = 0; if (dev_attr->show) - ret = dev_attr->show(dev,buf,count,off); + ret = dev_attr->show(dev,buf); return ret; } static ssize_t -dev_attr_store(struct kobject * kobj, struct attribute * attr, - const char * buf, size_t count, loff_t off) +dev_attr_store(struct kobject * kobj, struct attribute * attr, const char * buf) { struct device_attribute * dev_attr = to_dev_attr(attr); struct device * dev = to_dev(kobj); ssize_t ret = 0; if (dev_attr->store) - ret = dev_attr->store(dev,buf,count,off); + ret = dev_attr->store(dev,buf); return ret; } diff --git a/drivers/base/interface.c b/drivers/base/interface.c index 7d06c1e44c34..ebf359fbca74 100644 --- a/drivers/base/interface.c +++ b/drivers/base/interface.c @@ -10,21 +10,21 @@ #include #include -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 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 -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_level[20]; @@ -33,9 +33,6 @@ device_write_power(struct device * dev, const char * buf, size_t count, loff_t o u32 int_level; int error = 0; - if (off) - return 0; - if (!dev->driver) goto done; @@ -83,7 +80,7 @@ device_write_power(struct device * dev, const char * buf, size_t count, loff_t o error = 0; } done: - return error < 0 ? error : count; + return error < 0 ? error : strlen(buf); } static DEVICE_ATTR(power,S_IWUSR | S_IRUGO, diff --git a/include/linux/device.h b/include/linux/device.h index 2e370a0eb3f5..ecba162850bc 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -319,8 +319,8 @@ extern void device_release_driver(struct device * dev); 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); + ssize_t (*show)(struct device * dev, char * buf); + ssize_t (*store)(struct device * dev, const char * buf); }; #define DEVICE_ATTR(_name,_mode,_show,_store) \ -- cgit v1.2.3 From fa72b61fbae5678655f3f9e05abc292b4d5ecd64 Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Thu, 9 Jan 2003 06:10:39 -0600 Subject: sysfs: fixup subsystem attributes. - Remove @count and @off from the show() and store() methods. --- fs/sysfs/inode.c | 4 ++-- include/linux/kobject.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'include/linux') diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c index 69fe8ccfda3e..3bbc05bfcb96 100644 --- a/fs/sysfs/inode.c +++ b/fs/sysfs/inode.c @@ -162,7 +162,7 @@ subsys_attr_show(struct kobject * kobj, struct attribute * attr, char * page) ssize_t ret = 0; if (sattr->show) - ret = sattr->show(s,page,PAGE_SIZE,0); + ret = sattr->show(s,page); return ret; } @@ -174,7 +174,7 @@ subsys_attr_store(struct kobject * kobj, struct attribute * attr, const char * p ssize_t ret = 0; if (sattr->store) - ret = sattr->store(s,page,PAGE_SIZE,0); + ret = sattr->store(s,page); return ret; } diff --git a/include/linux/kobject.h b/include/linux/kobject.h index ff15fe1bc8fd..0cc01658044d 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -165,8 +165,8 @@ static inline void subsys_put(struct subsystem * s) struct subsys_attribute { struct attribute attr; - ssize_t (*show)(struct subsystem *, char *, size_t, loff_t); - ssize_t (*store)(struct subsystem *, const char *, size_t, loff_t); + ssize_t (*show)(struct subsystem *, char *); + ssize_t (*store)(struct subsystem *, const char *); }; extern int subsys_create_file(struct subsystem * , struct subsys_attribute *); -- cgit v1.2.3