~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to Documentation/filesystems/sysfs.txt

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
ancestors of object hierarchies; i.e. the subsystems the objects
40
40
belong to. 
41
41
 
42
 
Sysfs internally stores the kobject that owns the directory in the
43
 
->d_fsdata pointer of the directory's dentry. This allows sysfs to do
44
 
reference counting directly on the kobject when the file is opened and
45
 
closed. 
 
42
Sysfs internally stores a pointer to the kobject that implements a
 
43
directory in the sysfs_dirent object associated with the directory. In
 
44
the past this kobject pointer has been used by sysfs to do reference
 
45
counting directly on the kobject whenever the file is opened or closed.
 
46
With the current sysfs implementation the kobject reference count is
 
47
only modified directly by the function sysfs_schedule_callback().
46
48
 
47
49
 
48
50
Attributes
60
62
 
61
63
Mixing types, expressing multiple lines of data, and doing fancy
62
64
formatting of data is heavily frowned upon. Doing these things may get
63
 
you publically humiliated and your code rewritten without notice. 
 
65
you publicly humiliated and your code rewritten without notice. 
64
66
 
65
67
 
66
68
An attribute definition is simply:
208
210
  is 4096. 
209
211
 
210
212
- show() methods should return the number of bytes printed into the
211
 
  buffer. This is the return value of snprintf().
 
213
  buffer. This is the return value of scnprintf().
212
214
 
213
 
- show() should always use snprintf(). 
 
215
- show() should always use scnprintf().
214
216
 
215
217
- store() should return the number of bytes used from the buffer. If the
216
218
  entire buffer has been used, just return the count argument.
229
231
static ssize_t show_name(struct device *dev, struct device_attribute *attr,
230
232
                         char *buf)
231
233
{
232
 
        return snprintf(buf, PAGE_SIZE, "%s\n", dev->name);
 
234
        return scnprintf(buf, PAGE_SIZE, "%s\n", dev->name);
233
235
}
234
236
 
235
237
static ssize_t store_name(struct device *dev, struct device_attribute *attr,