diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-28 18:59:50 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-28 18:59:50 -0500 |
commit | cae2f9c46d69edb1aee565917735d79aba3a3267 (patch) | |
tree | 203ab78f46b6362859d53717eae7c60a437f07cc | |
parent | 09f345da758fca1222b0971b65b2fddbdf78bb83 (diff) | |
parent | 8118a859dc7abd873193986c77a8d9bdb877adc8 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6:
sysfs: fix off-by-one error in fill_read_buffer()
kobject: two typo fixes
UIO: add UIO documentation target to DocBook Makefile
UIO: fix up the UIO documentation
create /sys/.../power when CONFIG_PM is set
allow LEGACY_PTYS to be set to 0
-rw-r--r-- | Documentation/DocBook/Makefile | 2 | ||||
-rw-r--r-- | Documentation/DocBook/uio-howto.tmpl | 90 | ||||
-rw-r--r-- | drivers/base/core.c | 4 | ||||
-rw-r--r-- | drivers/base/power/Makefile | 3 | ||||
-rw-r--r-- | drivers/base/power/main.c | 8 | ||||
-rw-r--r-- | drivers/base/power/power.h | 28 | ||||
-rw-r--r-- | drivers/char/Kconfig | 2 | ||||
-rw-r--r-- | fs/sysfs/file.c | 6 | ||||
-rw-r--r-- | lib/kobject.c | 4 |
9 files changed, 68 insertions, 79 deletions
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile index 054a7ecf64c6..4953bc258729 100644 --- a/Documentation/DocBook/Makefile +++ b/Documentation/DocBook/Makefile | |||
@@ -11,7 +11,7 @@ DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \ | |||
11 | procfs-guide.xml writing_usb_driver.xml \ | 11 | procfs-guide.xml writing_usb_driver.xml \ |
12 | kernel-api.xml filesystems.xml lsm.xml usb.xml \ | 12 | kernel-api.xml filesystems.xml lsm.xml usb.xml \ |
13 | gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \ | 13 | gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \ |
14 | genericirq.xml s390-drivers.xml | 14 | genericirq.xml s390-drivers.xml uio-howto.xml |
15 | 15 | ||
16 | ### | 16 | ### |
17 | # The build process is as follows (targets): | 17 | # The build process is as follows (targets): |
diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl index c119484258b8..fdd7f4f887b7 100644 --- a/Documentation/DocBook/uio-howto.tmpl +++ b/Documentation/DocBook/uio-howto.tmpl | |||
@@ -30,6 +30,12 @@ | |||
30 | 30 | ||
31 | <revhistory> | 31 | <revhistory> |
32 | <revision> | 32 | <revision> |
33 | <revnumber>0.4</revnumber> | ||
34 | <date>2007-11-26</date> | ||
35 | <authorinitials>hjk</authorinitials> | ||
36 | <revremark>Removed section about uio_dummy.</revremark> | ||
37 | </revision> | ||
38 | <revision> | ||
33 | <revnumber>0.3</revnumber> | 39 | <revnumber>0.3</revnumber> |
34 | <date>2007-04-29</date> | 40 | <date>2007-04-29</date> |
35 | <authorinitials>hjk</authorinitials> | 41 | <authorinitials>hjk</authorinitials> |
@@ -94,6 +100,26 @@ interested in translating it, please email me | |||
94 | user space. This simplifies development and reduces the risk of | 100 | user space. This simplifies development and reduces the risk of |
95 | serious bugs within a kernel module. | 101 | serious bugs within a kernel module. |
96 | </para> | 102 | </para> |
103 | <para> | ||
104 | Please note that UIO is not an universal driver interface. Devices | ||
105 | that are already handled well by other kernel subsystems (like | ||
106 | networking or serial or USB) are no candidates for an UIO driver. | ||
107 | Hardware that is ideally suited for an UIO driver fulfills all of | ||
108 | the following: | ||
109 | </para> | ||
110 | <itemizedlist> | ||
111 | <listitem> | ||
112 | <para>The device has memory that can be mapped. The device can be | ||
113 | controlled completely by writing to this memory.</para> | ||
114 | </listitem> | ||
115 | <listitem> | ||
116 | <para>The device usually generates interrupts.</para> | ||
117 | </listitem> | ||
118 | <listitem> | ||
119 | <para>The device does not fit into one of the standard kernel | ||
120 | subsystems.</para> | ||
121 | </listitem> | ||
122 | </itemizedlist> | ||
97 | </sect1> | 123 | </sect1> |
98 | 124 | ||
99 | <sect1 id="thanks"> | 125 | <sect1 id="thanks"> |
@@ -174,8 +200,9 @@ interested in translating it, please email me | |||
174 | For cards that don't generate interrupts but need to be | 200 | For cards that don't generate interrupts but need to be |
175 | polled, there is the possibility to set up a timer that | 201 | polled, there is the possibility to set up a timer that |
176 | triggers the interrupt handler at configurable time intervals. | 202 | triggers the interrupt handler at configurable time intervals. |
177 | See <filename>drivers/uio/uio_dummy.c</filename> for an | 203 | This interrupt simulation is done by calling |
178 | example of this technique. | 204 | <function>uio_event_notify()</function> |
205 | from the timer's event handler. | ||
179 | </para> | 206 | </para> |
180 | 207 | ||
181 | <para> | 208 | <para> |
@@ -263,63 +290,11 @@ offset = N * getpagesize(); | |||
263 | </sect1> | 290 | </sect1> |
264 | </chapter> | 291 | </chapter> |
265 | 292 | ||
266 | <chapter id="using-uio_dummy" xreflabel="Using uio_dummy"> | ||
267 | <?dbhtml filename="using-uio_dummy.html"?> | ||
268 | <title>Using uio_dummy</title> | ||
269 | <para> | ||
270 | Well, there is no real use for uio_dummy. Its only purpose is | ||
271 | to test most parts of the UIO system (everything except | ||
272 | hardware interrupts), and to serve as an example for the | ||
273 | kernel module that you will have to write yourself. | ||
274 | </para> | ||
275 | |||
276 | <sect1 id="what_uio_dummy_does"> | ||
277 | <title>What uio_dummy does</title> | ||
278 | <para> | ||
279 | The kernel module <filename>uio_dummy.ko</filename> creates a | ||
280 | device that uses a timer to generate periodic interrupts. The | ||
281 | interrupt handler does nothing but increment a counter. The | ||
282 | driver adds two custom attributes, <varname>count</varname> | ||
283 | and <varname>freq</varname>, that appear under | ||
284 | <filename>/sys/devices/platform/uio_dummy/</filename>. | ||
285 | </para> | ||
286 | |||
287 | <para> | ||
288 | The attribute <varname>count</varname> can be read and | ||
289 | written. The associated file | ||
290 | <filename>/sys/devices/platform/uio_dummy/count</filename> | ||
291 | appears as a normal text file and contains the total number of | ||
292 | timer interrupts. If you look at it (e.g. using | ||
293 | <function>cat</function>), you'll notice it is slowly counting | ||
294 | up. | ||
295 | </para> | ||
296 | |||
297 | <para> | ||
298 | The attribute <varname>freq</varname> can be read and written. | ||
299 | The content of | ||
300 | <filename>/sys/devices/platform/uio_dummy/freq</filename> | ||
301 | represents the number of system timer ticks between two timer | ||
302 | interrupts. The default value of <varname>freq</varname> is | ||
303 | the value of the kernel variable <varname>HZ</varname>, which | ||
304 | gives you an interval of one second. Lower values will | ||
305 | increase the frequency. Try the following: | ||
306 | </para> | ||
307 | <programlisting format="linespecific"> | ||
308 | cd /sys/devices/platform/uio_dummy/ | ||
309 | echo 100 > freq | ||
310 | </programlisting> | ||
311 | <para> | ||
312 | Use <function>cat count</function> to see how the interrupt | ||
313 | frequency changes. | ||
314 | </para> | ||
315 | </sect1> | ||
316 | </chapter> | ||
317 | |||
318 | <chapter id="custom_kernel_module" xreflabel="Writing your own kernel module"> | 293 | <chapter id="custom_kernel_module" xreflabel="Writing your own kernel module"> |
319 | <?dbhtml filename="custom_kernel_module.html"?> | 294 | <?dbhtml filename="custom_kernel_module.html"?> |
320 | <title>Writing your own kernel module</title> | 295 | <title>Writing your own kernel module</title> |
321 | <para> | 296 | <para> |
322 | Please have a look at <filename>uio_dummy.c</filename> as an | 297 | Please have a look at <filename>uio_cif.c</filename> as an |
323 | example. The following paragraphs explain the different | 298 | example. The following paragraphs explain the different |
324 | sections of this file. | 299 | sections of this file. |
325 | </para> | 300 | </para> |
@@ -354,9 +329,8 @@ See the description below for details. | |||
354 | interrupt, it's your modules task to determine the irq number during | 329 | interrupt, it's your modules task to determine the irq number during |
355 | initialization. If you don't have a hardware generated interrupt but | 330 | initialization. If you don't have a hardware generated interrupt but |
356 | want to trigger the interrupt handler in some other way, set | 331 | want to trigger the interrupt handler in some other way, set |
357 | <varname>irq</varname> to <varname>UIO_IRQ_CUSTOM</varname>. The | 332 | <varname>irq</varname> to <varname>UIO_IRQ_CUSTOM</varname>. |
358 | uio_dummy module does this as it triggers the event mechanism in a timer | 333 | If you had no interrupt at all, you could set |
359 | routine. If you had no interrupt at all, you could set | ||
360 | <varname>irq</varname> to <varname>UIO_IRQ_NONE</varname>, though this | 334 | <varname>irq</varname> to <varname>UIO_IRQ_NONE</varname>, though this |
361 | rarely makes sense. | 335 | rarely makes sense. |
362 | </para></listitem> | 336 | </para></listitem> |
diff --git a/drivers/base/core.c b/drivers/base/core.c index 3f4d6aa13990..2683eac30c68 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -770,9 +770,10 @@ int device_add(struct device *dev) | |||
770 | error = device_add_attrs(dev); | 770 | error = device_add_attrs(dev); |
771 | if (error) | 771 | if (error) |
772 | goto AttrsError; | 772 | goto AttrsError; |
773 | error = device_pm_add(dev); | 773 | error = dpm_sysfs_add(dev); |
774 | if (error) | 774 | if (error) |
775 | goto PMError; | 775 | goto PMError; |
776 | device_pm_add(dev); | ||
776 | error = bus_add_device(dev); | 777 | error = bus_add_device(dev); |
777 | if (error) | 778 | if (error) |
778 | goto BusError; | 779 | goto BusError; |
@@ -797,6 +798,7 @@ int device_add(struct device *dev) | |||
797 | return error; | 798 | return error; |
798 | BusError: | 799 | BusError: |
799 | device_pm_remove(dev); | 800 | device_pm_remove(dev); |
801 | dpm_sysfs_remove(dev); | ||
800 | PMError: | 802 | PMError: |
801 | if (dev->bus) | 803 | if (dev->bus) |
802 | blocking_notifier_call_chain(&dev->bus->bus_notifier, | 804 | blocking_notifier_call_chain(&dev->bus->bus_notifier, |
diff --git a/drivers/base/power/Makefile b/drivers/base/power/Makefile index a803733c839e..44504e6618fb 100644 --- a/drivers/base/power/Makefile +++ b/drivers/base/power/Makefile | |||
@@ -1,5 +1,6 @@ | |||
1 | obj-y := shutdown.o | 1 | obj-y := shutdown.o |
2 | obj-$(CONFIG_PM_SLEEP) += main.o sysfs.o | 2 | obj-$(CONFIG_PM) += sysfs.o |
3 | obj-$(CONFIG_PM_SLEEP) += main.o | ||
3 | obj-$(CONFIG_PM_TRACE) += trace.o | 4 | obj-$(CONFIG_PM_TRACE) += trace.o |
4 | 5 | ||
5 | ifeq ($(CONFIG_DEBUG_DRIVER),y) | 6 | ifeq ($(CONFIG_DEBUG_DRIVER),y) |
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 0ab4ab21f564..691ffb64cc37 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c | |||
@@ -38,20 +38,14 @@ static DEFINE_MUTEX(dpm_list_mtx); | |||
38 | int (*platform_enable_wakeup)(struct device *dev, int is_on); | 38 | int (*platform_enable_wakeup)(struct device *dev, int is_on); |
39 | 39 | ||
40 | 40 | ||
41 | int device_pm_add(struct device *dev) | 41 | void device_pm_add(struct device *dev) |
42 | { | 42 | { |
43 | int error; | ||
44 | |||
45 | pr_debug("PM: Adding info for %s:%s\n", | 43 | pr_debug("PM: Adding info for %s:%s\n", |
46 | dev->bus ? dev->bus->name : "No Bus", | 44 | dev->bus ? dev->bus->name : "No Bus", |
47 | kobject_name(&dev->kobj)); | 45 | kobject_name(&dev->kobj)); |
48 | mutex_lock(&dpm_list_mtx); | 46 | mutex_lock(&dpm_list_mtx); |
49 | list_add_tail(&dev->power.entry, &dpm_active); | 47 | list_add_tail(&dev->power.entry, &dpm_active); |
50 | error = dpm_sysfs_add(dev); | ||
51 | if (error) | ||
52 | list_del(&dev->power.entry); | ||
53 | mutex_unlock(&dpm_list_mtx); | 48 | mutex_unlock(&dpm_list_mtx); |
54 | return error; | ||
55 | } | 49 | } |
56 | 50 | ||
57 | void device_pm_remove(struct device *dev) | 51 | void device_pm_remove(struct device *dev) |
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h index 5c4efd493fa5..379da4e958e0 100644 --- a/drivers/base/power/power.h +++ b/drivers/base/power/power.h | |||
@@ -13,14 +13,29 @@ extern void device_shutdown(void); | |||
13 | 13 | ||
14 | extern struct list_head dpm_active; /* The active device list */ | 14 | extern struct list_head dpm_active; /* The active device list */ |
15 | 15 | ||
16 | static inline struct device * to_device(struct list_head * entry) | 16 | static inline struct device *to_device(struct list_head *entry) |
17 | { | 17 | { |
18 | return container_of(entry, struct device, power.entry); | 18 | return container_of(entry, struct device, power.entry); |
19 | } | 19 | } |
20 | 20 | ||
21 | extern int device_pm_add(struct device *); | 21 | extern void device_pm_add(struct device *); |
22 | extern void device_pm_remove(struct device *); | 22 | extern void device_pm_remove(struct device *); |
23 | 23 | ||
24 | #else /* CONFIG_PM_SLEEP */ | ||
25 | |||
26 | |||
27 | static inline void device_pm_add(struct device *dev) | ||
28 | { | ||
29 | } | ||
30 | |||
31 | static inline void device_pm_remove(struct device *dev) | ||
32 | { | ||
33 | } | ||
34 | |||
35 | #endif | ||
36 | |||
37 | #ifdef CONFIG_PM | ||
38 | |||
24 | /* | 39 | /* |
25 | * sysfs.c | 40 | * sysfs.c |
26 | */ | 41 | */ |
@@ -28,16 +43,15 @@ extern void device_pm_remove(struct device *); | |||
28 | extern int dpm_sysfs_add(struct device *); | 43 | extern int dpm_sysfs_add(struct device *); |
29 | extern void dpm_sysfs_remove(struct device *); | 44 | extern void dpm_sysfs_remove(struct device *); |
30 | 45 | ||
31 | #else /* CONFIG_PM_SLEEP */ | 46 | #else /* CONFIG_PM */ |
32 | |||
33 | 47 | ||
34 | static inline int device_pm_add(struct device * dev) | 48 | static inline int dpm_sysfs_add(struct device *dev) |
35 | { | 49 | { |
36 | return 0; | 50 | return 0; |
37 | } | 51 | } |
38 | static inline void device_pm_remove(struct device * dev) | ||
39 | { | ||
40 | 52 | ||
53 | static inline void dpm_sysfs_remove(struct device *dev) | ||
54 | { | ||
41 | } | 55 | } |
42 | 56 | ||
43 | #endif | 57 | #endif |
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index bf18d757b876..a509b8d79781 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -457,7 +457,7 @@ config LEGACY_PTYS | |||
457 | config LEGACY_PTY_COUNT | 457 | config LEGACY_PTY_COUNT |
458 | int "Maximum number of legacy PTY in use" | 458 | int "Maximum number of legacy PTY in use" |
459 | depends on LEGACY_PTYS | 459 | depends on LEGACY_PTYS |
460 | range 1 256 | 460 | range 0 256 |
461 | default "256" | 461 | default "256" |
462 | ---help--- | 462 | ---help--- |
463 | The maximum number of legacy PTYs that can be used at any one time. | 463 | The maximum number of legacy PTYs that can be used at any one time. |
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 27d1785b7644..4045bdcc4b33 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -119,7 +119,11 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer | |||
119 | 119 | ||
120 | sysfs_put_active_two(attr_sd); | 120 | sysfs_put_active_two(attr_sd); |
121 | 121 | ||
122 | BUG_ON(count > (ssize_t)PAGE_SIZE); | 122 | /* |
123 | * The code works fine with PAGE_SIZE return but it's likely to | ||
124 | * indicate truncated result or overflow in normal use cases. | ||
125 | */ | ||
126 | BUG_ON(count >= (ssize_t)PAGE_SIZE); | ||
123 | if (count >= 0) { | 127 | if (count >= 0) { |
124 | buffer->needs_read_fill = 0; | 128 | buffer->needs_read_fill = 0; |
125 | buffer->count = count; | 129 | buffer->count = count; |
diff --git a/lib/kobject.c b/lib/kobject.c index a7e3bf4d3c70..b52e9f4ef371 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -313,8 +313,8 @@ int kobject_rename(struct kobject * kobj, const char *new_name) | |||
313 | struct kobject *temp_kobj; | 313 | struct kobject *temp_kobj; |
314 | temp_kobj = kset_find_obj(kobj->kset, new_name); | 314 | temp_kobj = kset_find_obj(kobj->kset, new_name); |
315 | if (temp_kobj) { | 315 | if (temp_kobj) { |
316 | printk(KERN_WARNING "kobject '%s' can not be renamed " | 316 | printk(KERN_WARNING "kobject '%s' cannot be renamed " |
317 | "to '%s' as '%s' is already in existance.\n", | 317 | "to '%s' as '%s' is already in existence.\n", |
318 | kobject_name(kobj), new_name, new_name); | 318 | kobject_name(kobj), new_name, new_name); |
319 | kobject_put(temp_kobj); | 319 | kobject_put(temp_kobj); |
320 | return -EINVAL; | 320 | return -EINVAL; |