diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-06 14:36:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-06 14:36:30 -0400 |
commit | ab69bcd66fb4be64edfc767365cb9eb084961246 (patch) | |
tree | f7623585aee58978fc7814460fff517ec39138f2 /Documentation | |
parent | c513b67e68787eceafeede32bcd0edbee45c0006 (diff) | |
parent | 6937e8f8c0135f2325194c372ada6dc655499992 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: (28 commits)
driver core: device_rename's new_name can be const
sysfs: Remove owner field from sysfs struct attribute
powerpc/pci: Remove owner field from attribute initialization in PCI bridge init
regulator: Remove owner field from attribute initialization in regulator core driver
leds: Remove owner field from attribute initialization in bd2802 driver
scsi: Remove owner field from attribute initialization in ARCMSR driver
scsi: Remove owner field from attribute initialization in LPFC driver
cgroupfs: create /sys/fs/cgroup to mount cgroupfs on
Driver core: Add BUS_NOTIFY_BIND_DRIVER
driver core: fix memory leak on one error path in bus_register()
debugfs: no longer needs to depend on SYSFS
sysfs: Fix one more signature discrepancy between sysfs implementation and docs.
sysfs: fix discrepancies between implementation and documentation
dcdbas: remove a redundant smi_data_buf_free in dcdbas_exit
dmi-id: fix a memory leak in dmi_id_init error path
sysfs: sysfs_chmod_file's attr can be const
firmware: Update hotplug script
Driver core: move platform device creation helpers to .init.text (if MODULE=n)
Driver core: reduce duplicated code for platform_device creation
Driver core: use kmemdup in platform_device_add_resources
...
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/DocBook/device-drivers.tmpl | 1 | ||||
-rw-r--r-- | Documentation/filesystems/sysfs.txt | 46 | ||||
-rw-r--r-- | Documentation/firmware_class/hotplug-script | 17 |
3 files changed, 36 insertions, 28 deletions
diff --git a/Documentation/DocBook/device-drivers.tmpl b/Documentation/DocBook/device-drivers.tmpl index 1b2dd4fc3db2..ecd35e9d4410 100644 --- a/Documentation/DocBook/device-drivers.tmpl +++ b/Documentation/DocBook/device-drivers.tmpl | |||
@@ -111,6 +111,7 @@ X!Edrivers/base/attribute_container.c | |||
111 | <!-- | 111 | <!-- |
112 | X!Edrivers/base/interface.c | 112 | X!Edrivers/base/interface.c |
113 | --> | 113 | --> |
114 | !Iinclude/linux/platform_device.h | ||
114 | !Edrivers/base/platform.c | 115 | !Edrivers/base/platform.c |
115 | !Edrivers/base/bus.c | 116 | !Edrivers/base/bus.c |
116 | </sect1> | 117 | </sect1> |
diff --git a/Documentation/filesystems/sysfs.txt b/Documentation/filesystems/sysfs.txt index 931c806642c5..5d1335faec2d 100644 --- a/Documentation/filesystems/sysfs.txt +++ b/Documentation/filesystems/sysfs.txt | |||
@@ -4,7 +4,7 @@ sysfs - _The_ filesystem for exporting kernel objects. | |||
4 | Patrick Mochel <mochel@osdl.org> | 4 | Patrick Mochel <mochel@osdl.org> |
5 | Mike Murphy <mamurph@cs.clemson.edu> | 5 | Mike Murphy <mamurph@cs.clemson.edu> |
6 | 6 | ||
7 | Revised: 22 February 2009 | 7 | Revised: 15 July 2010 |
8 | Original: 10 January 2003 | 8 | Original: 10 January 2003 |
9 | 9 | ||
10 | 10 | ||
@@ -124,7 +124,7 @@ show and store methods of the attribute owners. | |||
124 | 124 | ||
125 | struct sysfs_ops { | 125 | struct sysfs_ops { |
126 | ssize_t (*show)(struct kobject *, struct attribute *, char *); | 126 | ssize_t (*show)(struct kobject *, struct attribute *, char *); |
127 | ssize_t (*store)(struct kobject *, struct attribute *, const char *); | 127 | ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t); |
128 | }; | 128 | }; |
129 | 129 | ||
130 | [ Subsystems should have already defined a struct kobj_type as a | 130 | [ Subsystems should have already defined a struct kobj_type as a |
@@ -139,18 +139,22 @@ calls the associated methods. | |||
139 | 139 | ||
140 | To illustrate: | 140 | To illustrate: |
141 | 141 | ||
142 | #define to_dev(obj) container_of(obj, struct device, kobj) | ||
142 | #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) | 143 | #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) |
143 | #define to_dev(d) container_of(d, struct device, kobj) | ||
144 | 144 | ||
145 | static ssize_t | 145 | static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr, |
146 | dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) | 146 | char *buf) |
147 | { | 147 | { |
148 | struct device_attribute * dev_attr = to_dev_attr(attr); | 148 | struct device_attribute *dev_attr = to_dev_attr(attr); |
149 | struct device * dev = to_dev(kobj); | 149 | struct device *dev = to_dev(kobj); |
150 | ssize_t ret = 0; | 150 | ssize_t ret = -EIO; |
151 | 151 | ||
152 | if (dev_attr->show) | 152 | if (dev_attr->show) |
153 | ret = dev_attr->show(dev, buf); | 153 | ret = dev_attr->show(dev, dev_attr, buf); |
154 | if (ret >= (ssize_t)PAGE_SIZE) { | ||
155 | print_symbol("dev_attr_show: %s returned bad count\n", | ||
156 | (unsigned long)dev_attr->show); | ||
157 | } | ||
154 | return ret; | 158 | return ret; |
155 | } | 159 | } |
156 | 160 | ||
@@ -163,10 +167,9 @@ To read or write attributes, show() or store() methods must be | |||
163 | specified when declaring the attribute. The method types should be as | 167 | specified when declaring the attribute. The method types should be as |
164 | simple as those defined for device attributes: | 168 | simple as those defined for device attributes: |
165 | 169 | ||
166 | ssize_t (*show)(struct device * dev, struct device_attribute * attr, | 170 | ssize_t (*show)(struct device *dev, struct device_attribute *attr, char *buf); |
167 | char * buf); | 171 | ssize_t (*store)(struct device *dev, struct device_attribute *attr, |
168 | ssize_t (*store)(struct device * dev, struct device_attribute * attr, | 172 | const char *buf, size_t count); |
169 | const char * buf); | ||
170 | 173 | ||
171 | IOW, they should take only an object, an attribute, and a buffer as parameters. | 174 | IOW, they should take only an object, an attribute, and a buffer as parameters. |
172 | 175 | ||
@@ -209,8 +212,8 @@ Other notes: | |||
209 | 212 | ||
210 | - show() should always use snprintf(). | 213 | - show() should always use snprintf(). |
211 | 214 | ||
212 | - store() should return the number of bytes used from the buffer. This | 215 | - store() should return the number of bytes used from the buffer. If the |
213 | can be done using strlen(). | 216 | entire buffer has been used, just return the count argument. |
214 | 217 | ||
215 | - show() or store() can always return errors. If a bad value comes | 218 | - show() or store() can always return errors. If a bad value comes |
216 | through, be sure to return an error. | 219 | through, be sure to return an error. |
@@ -223,15 +226,18 @@ Other notes: | |||
223 | 226 | ||
224 | A very simple (and naive) implementation of a device attribute is: | 227 | A very simple (and naive) implementation of a device attribute is: |
225 | 228 | ||
226 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) | 229 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, |
230 | char *buf) | ||
227 | { | 231 | { |
228 | return snprintf(buf, PAGE_SIZE, "%s\n", dev->name); | 232 | return snprintf(buf, PAGE_SIZE, "%s\n", dev->name); |
229 | } | 233 | } |
230 | 234 | ||
231 | static ssize_t store_name(struct device * dev, const char * buf) | 235 | static ssize_t store_name(struct device *dev, struct device_attribute *attr, |
236 | const char *buf, size_t count) | ||
232 | { | 237 | { |
233 | sscanf(buf, "%20s", dev->name); | 238 | snprintf(dev->name, sizeof(dev->name), "%.*s", |
234 | return strnlen(buf, PAGE_SIZE); | 239 | (int)min(count, sizeof(dev->name) - 1), buf); |
240 | return count; | ||
235 | } | 241 | } |
236 | 242 | ||
237 | static DEVICE_ATTR(name, S_IRUGO, show_name, store_name); | 243 | static DEVICE_ATTR(name, S_IRUGO, show_name, store_name); |
@@ -327,7 +333,7 @@ Structure: | |||
327 | struct bus_attribute { | 333 | struct bus_attribute { |
328 | struct attribute attr; | 334 | struct attribute attr; |
329 | ssize_t (*show)(struct bus_type *, char * buf); | 335 | ssize_t (*show)(struct bus_type *, char * buf); |
330 | ssize_t (*store)(struct bus_type *, const char * buf); | 336 | ssize_t (*store)(struct bus_type *, const char * buf, size_t count); |
331 | }; | 337 | }; |
332 | 338 | ||
333 | Declaring: | 339 | Declaring: |
diff --git a/Documentation/firmware_class/hotplug-script b/Documentation/firmware_class/hotplug-script index 1990130f2ab1..8143a950b607 100644 --- a/Documentation/firmware_class/hotplug-script +++ b/Documentation/firmware_class/hotplug-script | |||
@@ -6,11 +6,12 @@ | |||
6 | 6 | ||
7 | HOTPLUG_FW_DIR=/usr/lib/hotplug/firmware/ | 7 | HOTPLUG_FW_DIR=/usr/lib/hotplug/firmware/ |
8 | 8 | ||
9 | echo 1 > /sys/$DEVPATH/loading | 9 | if [ "$SUBSYSTEM" == "firmware" -a "$ACTION" == "add" ]; then |
10 | cat $HOTPLUG_FW_DIR/$FIRMWARE > /sys/$DEVPATH/data | 10 | if [ -f $HOTPLUG_FW_DIR/$FIRMWARE ]; then |
11 | echo 0 > /sys/$DEVPATH/loading | 11 | echo 1 > /sys/$DEVPATH/loading |
12 | 12 | cat $HOTPLUG_FW_DIR/$FIRMWARE > /sys/$DEVPATH/data | |
13 | # To cancel the load in case of error: | 13 | echo 0 > /sys/$DEVPATH/loading |
14 | # | 14 | else |
15 | # echo -1 > /sys/$DEVPATH/loading | 15 | echo -1 > /sys/$DEVPATH/loading |
16 | # | 16 | fi |
17 | fi | ||