diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /Documentation/driver-model | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'Documentation/driver-model')
-rw-r--r-- | Documentation/driver-model/binding.txt | 4 | ||||
-rw-r--r-- | Documentation/driver-model/device.txt | 65 | ||||
-rw-r--r-- | Documentation/driver-model/devres.txt | 22 |
3 files changed, 37 insertions, 54 deletions
diff --git a/Documentation/driver-model/binding.txt b/Documentation/driver-model/binding.txt index abfc8e290d5..f7ec9d625bf 100644 --- a/Documentation/driver-model/binding.txt +++ b/Documentation/driver-model/binding.txt | |||
@@ -48,6 +48,10 @@ devclass_add_device is called to enumerate the device within the class | |||
48 | and actually register it with the class, which happens with the | 48 | and actually register it with the class, which happens with the |
49 | class's register_dev callback. | 49 | class's register_dev callback. |
50 | 50 | ||
51 | NOTE: The device class structures and core routines to manipulate them | ||
52 | are not in the mainline kernel, so the discussion is still a bit | ||
53 | speculative. | ||
54 | |||
51 | 55 | ||
52 | Driver | 56 | Driver |
53 | ~~~~~~ | 57 | ~~~~~~ |
diff --git a/Documentation/driver-model/device.txt b/Documentation/driver-model/device.txt index 1e70220d20f..bdefe728a73 100644 --- a/Documentation/driver-model/device.txt +++ b/Documentation/driver-model/device.txt | |||
@@ -45,52 +45,33 @@ struct device_attribute { | |||
45 | const char *buf, size_t count); | 45 | const char *buf, size_t count); |
46 | }; | 46 | }; |
47 | 47 | ||
48 | Attributes of devices can be exported by a device driver through sysfs. | 48 | Attributes of devices can be exported via drivers using a simple |
49 | procfs-like interface. | ||
49 | 50 | ||
50 | Please see Documentation/filesystems/sysfs.txt for more information | 51 | Please see Documentation/filesystems/sysfs.txt for more information |
51 | on how sysfs works. | 52 | on how sysfs works. |
52 | 53 | ||
53 | As explained in Documentation/kobject.txt, device attributes must be be | ||
54 | created before the KOBJ_ADD uevent is generated. The only way to realize | ||
55 | that is by defining an attribute group. | ||
56 | |||
57 | Attributes are declared using a macro called DEVICE_ATTR: | 54 | Attributes are declared using a macro called DEVICE_ATTR: |
58 | 55 | ||
59 | #define DEVICE_ATTR(name,mode,show,store) | 56 | #define DEVICE_ATTR(name,mode,show,store) |
60 | 57 | ||
61 | Example: | 58 | Example: |
62 | 59 | ||
63 | static DEVICE_ATTR(type, 0444, show_type, NULL); | 60 | DEVICE_ATTR(power,0644,show_power,store_power); |
64 | static DEVICE_ATTR(power, 0644, show_power, store_power); | ||
65 | |||
66 | This declares two structures of type struct device_attribute with respective | ||
67 | names 'dev_attr_type' and 'dev_attr_power'. These two attributes can be | ||
68 | organized as follows into a group: | ||
69 | 61 | ||
70 | static struct attribute *dev_attrs[] = { | 62 | This declares a structure of type struct device_attribute named |
71 | &dev_attr_type.attr, | 63 | 'dev_attr_power'. This can then be added and removed to the device's |
72 | &dev_attr_power.attr, | 64 | directory using: |
73 | NULL, | ||
74 | }; | ||
75 | |||
76 | static struct attribute_group dev_attr_group = { | ||
77 | .attrs = dev_attrs, | ||
78 | }; | ||
79 | 65 | ||
80 | static const struct attribute_group *dev_attr_groups[] = { | 66 | int device_create_file(struct device *device, struct device_attribute * entry); |
81 | &dev_attr_group, | 67 | void device_remove_file(struct device * dev, struct device_attribute * attr); |
82 | NULL, | ||
83 | }; | ||
84 | 68 | ||
85 | This array of groups can then be associated with a device by setting the | 69 | Example: |
86 | group pointer in struct device before device_register() is invoked: | ||
87 | 70 | ||
88 | dev->groups = dev_attr_groups; | 71 | device_create_file(dev,&dev_attr_power); |
89 | device_register(dev); | 72 | device_remove_file(dev,&dev_attr_power); |
90 | 73 | ||
91 | The device_register() function will use the 'groups' pointer to create the | 74 | The file name will be 'power' with a mode of 0644 (-rw-r--r--). |
92 | device attributes and the device_unregister() function will use this pointer | ||
93 | to remove the device attributes. | ||
94 | 75 | ||
95 | Word of warning: While the kernel allows device_create_file() and | 76 | Word of warning: While the kernel allows device_create_file() and |
96 | device_remove_file() to be called on a device at any time, userspace has | 77 | device_remove_file() to be called on a device at any time, userspace has |
@@ -103,4 +84,24 @@ not know about the new attributes. | |||
103 | This is important for device driver that need to publish additional | 84 | This is important for device driver that need to publish additional |
104 | attributes for a device at driver probe time. If the device driver simply | 85 | attributes for a device at driver probe time. If the device driver simply |
105 | calls device_create_file() on the device structure passed to it, then | 86 | calls device_create_file() on the device structure passed to it, then |
106 | userspace will never be notified of the new attributes. | 87 | userspace will never be notified of the new attributes. Instead, it should |
88 | probably use class_create() and class->dev_attrs to set up a list of | ||
89 | desired attributes in the modules_init function, and then in the .probe() | ||
90 | hook, and then use device_create() to create a new device as a child | ||
91 | of the probed device. The new device will generate a new uevent and | ||
92 | properly advertise the new attributes to userspace. | ||
93 | |||
94 | For example, if a driver wanted to add the following attributes: | ||
95 | struct device_attribute mydriver_attribs[] = { | ||
96 | __ATTR(port_count, 0444, port_count_show), | ||
97 | __ATTR(serial_number, 0444, serial_number_show), | ||
98 | NULL | ||
99 | }; | ||
100 | |||
101 | Then in the module init function is would do: | ||
102 | mydriver_class = class_create(THIS_MODULE, "my_attrs"); | ||
103 | mydriver_class.dev_attr = mydriver_attribs; | ||
104 | |||
105 | And assuming 'dev' is the struct device passed into the probe hook, the driver | ||
106 | probe function would do something like: | ||
107 | device_create(&mydriver_class, dev, chrdev, &private_data, "my_name"); | ||
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index 43cff70465a..d79aead9418 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt | |||
@@ -233,10 +233,6 @@ certainly invest a bit more effort into libata core layer). | |||
233 | 6. List of managed interfaces | 233 | 6. List of managed interfaces |
234 | ----------------------------- | 234 | ----------------------------- |
235 | 235 | ||
236 | MEM | ||
237 | devm_kzalloc() | ||
238 | devm_kfree() | ||
239 | |||
240 | IO region | 236 | IO region |
241 | devm_request_region() | 237 | devm_request_region() |
242 | devm_request_mem_region() | 238 | devm_request_mem_region() |
@@ -266,25 +262,7 @@ IOMAP | |||
266 | devm_ioremap() | 262 | devm_ioremap() |
267 | devm_ioremap_nocache() | 263 | devm_ioremap_nocache() |
268 | devm_iounmap() | 264 | devm_iounmap() |
269 | devm_request_and_ioremap() : checks resource, requests region, ioremaps | ||
270 | pcim_iomap() | 265 | pcim_iomap() |
271 | pcim_iounmap() | 266 | pcim_iounmap() |
272 | pcim_iomap_table() : array of mapped addresses indexed by BAR | 267 | pcim_iomap_table() : array of mapped addresses indexed by BAR |
273 | pcim_iomap_regions() : do request_region() and iomap() on multiple BARs | 268 | pcim_iomap_regions() : do request_region() and iomap() on multiple BARs |
274 | |||
275 | REGULATOR | ||
276 | devm_regulator_get() | ||
277 | devm_regulator_put() | ||
278 | devm_regulator_bulk_get() | ||
279 | |||
280 | CLOCK | ||
281 | devm_clk_get() | ||
282 | devm_clk_put() | ||
283 | |||
284 | PINCTRL | ||
285 | devm_pinctrl_get() | ||
286 | devm_pinctrl_put() | ||
287 | |||
288 | PWM | ||
289 | devm_pwm_get() | ||
290 | devm_pwm_put() | ||