diff options
| author | Linus Torvalds <torvalds@evo.osdl.org> | 2005-09-06 03:32:12 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@evo.osdl.org> | 2005-09-06 03:32:12 -0400 |
| commit | f65e77693aa5a1cf688fc378bc6913a56f9ff7b7 (patch) | |
| tree | 5d5b6ee3e3f9da241a583bf49ab648637ac4c1a9 | |
| parent | 8566cfc9fe0934f52ddedc12b083176116c13978 (diff) | |
| parent | d856f1e337782326c638c70c0b4df2b909350dec (diff) | |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
| -rw-r--r-- | Documentation/filesystems/sysfs.txt | 28 | ||||
| -rw-r--r-- | drivers/base/bus.c | 8 | ||||
| -rw-r--r-- | drivers/base/class.c | 39 | ||||
| -rw-r--r-- | drivers/base/core.c | 2 | ||||
| -rw-r--r-- | drivers/base/dd.c | 2 | ||||
| -rw-r--r-- | drivers/base/sys.c | 110 | ||||
| -rw-r--r-- | drivers/block/floppy.c | 41 | ||||
| -rw-r--r-- | drivers/usb/core/hcd.c | 2 | ||||
| -rw-r--r-- | include/linux/klist.h | 8 | ||||
| -rw-r--r-- | lib/klist.c | 8 |
10 files changed, 178 insertions, 70 deletions
diff --git a/Documentation/filesystems/sysfs.txt b/Documentation/filesystems/sysfs.txt index dc276598a65a..c8bce82ddcac 100644 --- a/Documentation/filesystems/sysfs.txt +++ b/Documentation/filesystems/sysfs.txt | |||
| @@ -90,7 +90,7 @@ void device_remove_file(struct device *, struct device_attribute *); | |||
| 90 | 90 | ||
| 91 | It also defines this helper for defining device attributes: | 91 | It also defines this helper for defining device attributes: |
| 92 | 92 | ||
| 93 | #define DEVICE_ATTR(_name,_mode,_show,_store) \ | 93 | #define DEVICE_ATTR(_name, _mode, _show, _store) \ |
| 94 | struct device_attribute dev_attr_##_name = { \ | 94 | struct device_attribute dev_attr_##_name = { \ |
| 95 | .attr = {.name = __stringify(_name) , .mode = _mode }, \ | 95 | .attr = {.name = __stringify(_name) , .mode = _mode }, \ |
| 96 | .show = _show, \ | 96 | .show = _show, \ |
| @@ -99,14 +99,14 @@ struct device_attribute dev_attr_##_name = { \ | |||
| 99 | 99 | ||
| 100 | For example, declaring | 100 | For example, declaring |
| 101 | 101 | ||
| 102 | static DEVICE_ATTR(foo,0644,show_foo,store_foo); | 102 | static DEVICE_ATTR(foo, S_IWUSR | S_IRUGO, show_foo, store_foo); |
| 103 | 103 | ||
| 104 | is equivalent to doing: | 104 | is equivalent to doing: |
| 105 | 105 | ||
| 106 | static struct device_attribute dev_attr_foo = { | 106 | static struct device_attribute dev_attr_foo = { |
| 107 | .attr = { | 107 | .attr = { |
| 108 | .name = "foo", | 108 | .name = "foo", |
| 109 | .mode = 0644, | 109 | .mode = S_IWUSR | S_IRUGO, |
| 110 | }, | 110 | }, |
| 111 | .show = show_foo, | 111 | .show = show_foo, |
| 112 | .store = store_foo, | 112 | .store = store_foo, |
| @@ -121,8 +121,8 @@ set of sysfs operations for forwarding read and write calls to the | |||
| 121 | show and store methods of the attribute owners. | 121 | show and store methods of the attribute owners. |
| 122 | 122 | ||
| 123 | struct sysfs_ops { | 123 | struct sysfs_ops { |
| 124 | ssize_t (*show)(struct kobject *, struct attribute *,char *); | 124 | ssize_t (*show)(struct kobject *, struct attribute *, char *); |
| 125 | ssize_t (*store)(struct kobject *,struct attribute *,const char *); | 125 | ssize_t (*store)(struct kobject *, struct attribute *, const char *); |
| 126 | }; | 126 | }; |
| 127 | 127 | ||
| 128 | [ Subsystems should have already defined a struct kobj_type as a | 128 | [ Subsystems should have already defined a struct kobj_type as a |
| @@ -137,7 +137,7 @@ calls the associated methods. | |||
| 137 | 137 | ||
| 138 | To illustrate: | 138 | To illustrate: |
| 139 | 139 | ||
| 140 | #define to_dev_attr(_attr) container_of(_attr,struct device_attribute,attr) | 140 | #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) |
| 141 | #define to_dev(d) container_of(d, struct device, kobj) | 141 | #define to_dev(d) container_of(d, struct device, kobj) |
| 142 | 142 | ||
| 143 | static ssize_t | 143 | static ssize_t |
| @@ -148,7 +148,7 @@ dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) | |||
| 148 | ssize_t ret = 0; | 148 | ssize_t ret = 0; |
| 149 | 149 | ||
| 150 | if (dev_attr->show) | 150 | if (dev_attr->show) |
| 151 | ret = dev_attr->show(dev,buf); | 151 | ret = dev_attr->show(dev, buf); |
| 152 | return ret; | 152 | return ret; |
| 153 | } | 153 | } |
| 154 | 154 | ||
| @@ -216,16 +216,16 @@ A very simple (and naive) implementation of a device attribute is: | |||
| 216 | 216 | ||
| 217 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) | 217 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) |
| 218 | { | 218 | { |
| 219 | return sprintf(buf,"%s\n",dev->name); | 219 | return snprintf(buf, PAGE_SIZE, "%s\n", dev->name); |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | static ssize_t store_name(struct device * dev, const char * buf) | 222 | static ssize_t store_name(struct device * dev, const char * buf) |
| 223 | { | 223 | { |
| 224 | sscanf(buf,"%20s",dev->name); | 224 | sscanf(buf, "%20s", dev->name); |
| 225 | return strlen(buf); | 225 | return strnlen(buf, PAGE_SIZE); |
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | static DEVICE_ATTR(name,S_IRUGO,show_name,store_name); | 228 | static DEVICE_ATTR(name, S_IRUGO, show_name, store_name); |
| 229 | 229 | ||
| 230 | 230 | ||
| 231 | (Note that the real implementation doesn't allow userspace to set the | 231 | (Note that the real implementation doesn't allow userspace to set the |
| @@ -290,7 +290,7 @@ struct device_attribute { | |||
| 290 | 290 | ||
| 291 | Declaring: | 291 | Declaring: |
| 292 | 292 | ||
| 293 | DEVICE_ATTR(_name,_str,_mode,_show,_store); | 293 | DEVICE_ATTR(_name, _str, _mode, _show, _store); |
| 294 | 294 | ||
| 295 | Creation/Removal: | 295 | Creation/Removal: |
| 296 | 296 | ||
| @@ -310,7 +310,7 @@ struct bus_attribute { | |||
| 310 | 310 | ||
| 311 | Declaring: | 311 | Declaring: |
| 312 | 312 | ||
| 313 | BUS_ATTR(_name,_mode,_show,_store) | 313 | BUS_ATTR(_name, _mode, _show, _store) |
| 314 | 314 | ||
| 315 | Creation/Removal: | 315 | Creation/Removal: |
| 316 | 316 | ||
| @@ -331,7 +331,7 @@ struct driver_attribute { | |||
| 331 | 331 | ||
| 332 | Declaring: | 332 | Declaring: |
| 333 | 333 | ||
| 334 | DRIVER_ATTR(_name,_mode,_show,_store) | 334 | DRIVER_ATTR(_name, _mode, _show, _store) |
| 335 | 335 | ||
| 336 | Creation/Removal: | 336 | Creation/Removal: |
| 337 | 337 | ||
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index ab53832d57e5..17e96698410e 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
| @@ -156,7 +156,9 @@ static ssize_t driver_unbind(struct device_driver *drv, | |||
| 156 | device_release_driver(dev); | 156 | device_release_driver(dev); |
| 157 | err = count; | 157 | err = count; |
| 158 | } | 158 | } |
| 159 | return err; | 159 | if (err) |
| 160 | return err; | ||
| 161 | return count; | ||
| 160 | } | 162 | } |
| 161 | static DRIVER_ATTR(unbind, S_IWUSR, NULL, driver_unbind); | 163 | static DRIVER_ATTR(unbind, S_IWUSR, NULL, driver_unbind); |
| 162 | 164 | ||
| @@ -358,7 +360,7 @@ int bus_add_device(struct device * dev) | |||
| 358 | if (bus) { | 360 | if (bus) { |
| 359 | pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id); | 361 | pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id); |
| 360 | device_attach(dev); | 362 | device_attach(dev); |
| 361 | klist_add_tail(&bus->klist_devices, &dev->knode_bus); | 363 | klist_add_tail(&dev->knode_bus, &bus->klist_devices); |
| 362 | error = device_add_attrs(bus, dev); | 364 | error = device_add_attrs(bus, dev); |
| 363 | if (!error) { | 365 | if (!error) { |
| 364 | sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id); | 366 | sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id); |
| @@ -446,7 +448,7 @@ int bus_add_driver(struct device_driver * drv) | |||
| 446 | } | 448 | } |
| 447 | 449 | ||
| 448 | driver_attach(drv); | 450 | driver_attach(drv); |
| 449 | klist_add_tail(&bus->klist_drivers, &drv->knode_bus); | 451 | klist_add_tail(&drv->knode_bus, &bus->klist_drivers); |
| 450 | module_add_driver(drv->owner, drv); | 452 | module_add_driver(drv->owner, drv); |
| 451 | 453 | ||
| 452 | driver_add_attrs(bus, drv); | 454 | driver_add_attrs(bus, drv); |
diff --git a/drivers/base/class.c b/drivers/base/class.c index 0154a1623b21..d164c32a97ad 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
| @@ -299,10 +299,8 @@ static void class_dev_release(struct kobject * kobj) | |||
| 299 | 299 | ||
| 300 | pr_debug("device class '%s': release.\n", cd->class_id); | 300 | pr_debug("device class '%s': release.\n", cd->class_id); |
| 301 | 301 | ||
| 302 | if (cd->devt_attr) { | 302 | kfree(cd->devt_attr); |
| 303 | kfree(cd->devt_attr); | 303 | cd->devt_attr = NULL; |
| 304 | cd->devt_attr = NULL; | ||
