aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-30 19:35:35 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-30 19:35:35 -0400
commitaf9473118979f3b09ee5d92fdbd8014cf085f7c5 (patch)
tree922f5623f1861dcf00a33aca5d7f2ae6b7782cb1
parent9f8e35fc0c1d96e5383eca5f0c7c963a9fadef57 (diff)
parent74c5b597e9c2fc728c61582afdea4971a5c8ed8f (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6: modules: better error messages when modules fail to load due to a sysfs problem. kobject: update documentation kset: kernel-doc cleanups driver core: revert "device" link creation check stable_api_nonsense.txt: Disambiguate the use of "this" by using "that" to refer to the syscall interface Fix Doc/sysfs-rules typos kernel-doc fixes for PCI and drivers/base/ kobject: put kobject_actions in kobject.h kobject: fix link error when CONFIG_HOTPLUG is disabled HOWTO: sync Japanese HOWTO HOWTO: adjust translation header of Japanese stable_api_nonsense.txt
-rw-r--r--Documentation/ja_JP/HOWTO66
-rw-r--r--Documentation/ja_JP/stable_api_nonsense.txt20
-rw-r--r--Documentation/kobject.txt178
-rw-r--r--Documentation/stable_api_nonsense.txt2
-rw-r--r--Documentation/sysfs-rules.txt72
-rw-r--r--drivers/base/core.c5
-rw-r--r--drivers/base/firmware_class.c1
-rw-r--r--drivers/pci/pci.c2
-rw-r--r--include/linux/kobject.h26
-rw-r--r--kernel/params.c7
-rw-r--r--lib/kobject_uevent.c16
11 files changed, 171 insertions, 224 deletions
diff --git a/Documentation/ja_JP/HOWTO b/Documentation/ja_JP/HOWTO
index b2446a090870..9f08dab1e75b 100644
--- a/Documentation/ja_JP/HOWTO
+++ b/Documentation/ja_JP/HOWTO
@@ -1,23 +1,24 @@
1NOTE: 1NOTE:
2This is Japanese translated version of "Documentation/HOWTO". 2This is a version of Documentation/HOWTO translated into Japanese.
3This one is maintained by Tsugikazu Shibata <tshibata@ab.jp.nec.com> 3This document is maintained by Tsugikazu Shibata <tshibata@ab.jp.nec.com>
4and JF Project team <www.linux.or.jp/JF>. 4and the JF Project team <www.linux.or.jp/JF>.
5If you find difference with original file or problem in translation, 5If you find any difference between this document and the original file
6please contact maintainer of this file or JF project. 6or a problem with the translation,
7 7please contact the maintainer of this file or JF project.
8Please also note that purpose of this file is easier to read for non 8
9English natives and not to be intended to fork. So, if you have any 9Please also note that the purpose of this file is to be easier to read
10comments or updates of this file, please try to update Original(English) 10for non English (read: Japanese) speakers and is not intended as a
11file at first. 11fork. So if you have any comments or updates for this file, please try
12 12to update the original English file first.
13Last Updated: 2007/06/04 13
14Last Updated: 2007/07/18
14================================== 15==================================
15これは、 16これは、
16linux-2.6.21/Documentation/HOWTO 17linux-2.6.22/Documentation/HOWTO
17の和訳です。 18の和訳です。
18 19
19翻訳団体: JF プロジェクト < http://www.linux.or.jp/JF/ > 20翻訳団体: JF プロジェクト < http://www.linux.or.jp/JF/ >
20翻訳日: 2007/06/04 21翻訳日: 2007/07/16
21翻訳者: Tsugikazu Shibata <tshibata at ab dot jp dot nec dot com> 22翻訳者: Tsugikazu Shibata <tshibata at ab dot jp dot nec dot com>
22校正者: 松倉さん <nbh--mats at nifty dot com> 23校正者: 松倉さん <nbh--mats at nifty dot com>
23 小林 雅典さん (Masanori Kobayasi) <zap03216 at nifty dot ne dot jp> 24 小林 雅典さん (Masanori Kobayasi) <zap03216 at nifty dot ne dot jp>
@@ -52,6 +53,7 @@ Linux カーネル開発コミュニティと共に活動するやり方を学
52また、このコミュニティがなぜ今うまくまわっているのかという理由の一部も 53また、このコミュニティがなぜ今うまくまわっているのかという理由の一部も
53説明しようと試みています。 54説明しようと試みています。
54 55
56
55カーネルは 少量のアーキテクチャ依存部分がアセンブリ言語で書かれている 57カーネルは 少量のアーキテクチャ依存部分がアセンブリ言語で書かれている
56以外は大部分は C 言語で書かれています。C言語をよく理解していることはカー 58以外は大部分は C 言語で書かれています。C言語をよく理解していることはカー
57ネル開発者には必要です。アーキテクチャ向けの低レベル部分の開発をするの 59ネル開発者には必要です。アーキテクチャ向けの低レベル部分の開発をするの
@@ -141,6 +143,7 @@ Linux カーネルソースツリーは幅広い範囲のドキュメントを
141 これらのルールに従えばうまくいくことを保証することではありません 143 これらのルールに従えばうまくいくことを保証することではありません
142 が (すべてのパッチは内容とスタイルについて精査を受けるので)、 144 が (すべてのパッチは内容とスタイルについて精査を受けるので)、
143 ルールに従わなければ間違いなくうまくいかないでしょう。 145 ルールに従わなければ間違いなくうまくいかないでしょう。
146
144 この他にパッチを作る方法についてのよくできた記述は- 147 この他にパッチを作る方法についてのよくできた記述は-
145 148
146 "The Perfect Patch" 149 "The Perfect Patch"
@@ -360,44 +363,42 @@ linux-kernel メーリングリストで収集された多数のパッチと同
360 363
361 git ツリー- 364 git ツリー-
362 - Kbuild の開発ツリー、Sam Ravnborg <sam@ravnborg.org> 365 - Kbuild の開発ツリー、Sam Ravnborg <sam@ravnborg.org>
363 kernel.org:/pub/scm/linux/kernel/git/sam/kbuild.git 366 git.kernel.org:/pub/scm/linux/kernel/git/sam/kbuild.git
364 367
365 - ACPI の開発ツリー、 Len Brown <len.brown@intel.com> 368 - ACPI の開発ツリー、 Len Brown <len.brown@intel.com>
366 kernel.org:/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6.git 369 git.kernel.org:/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6.git
367 370
368 - Block の開発ツリー、Jens Axboe <axboe@suse.de> 371 - Block の開発ツリー、Jens Axboe <axboe@suse.de>
369 kernel.org:/pub/scm/linux/kernel/git/axboe/linux-2.6-block.git 372 git.kernel.org:/pub/scm/linux/kernel/git/axboe/linux-2.6-block.git
370 373
371 - DRM の開発ツリー、Dave Airlie <airlied@linux.ie> 374 - DRM の開発ツリー、Dave Airlie <airlied@linux.ie>
372 kernel.org:/pub/scm/linux/kernel/git/airlied/drm-2.6.git 375 git.kernel.org:/pub/scm/linux/kernel/git/airlied/drm-2.6.git
373 376
374 - ia64 の開発ツリー、Tony Luck <tony.luck@intel.com> 377 - ia64 の開発ツリー、Tony Luck <tony.luck@intel.com>
375 kernel.org:/pub/scm/linux/kernel/git/aegl/linux-2.6.git 378 git.kernel.org:/pub/scm/linux/kernel/git/aegl/linux-2.6.git
376
377 - ieee1394 の開発ツリー、Jody McIntyre <scjody@modernduck.com>
378 kernel.org:/pub/scm/linux/kernel/git/scjody/ieee1394.git
379 379
380 - infiniband, Roland Dreier <rolandd@cisco.com> 380 - infiniband, Roland Dreier <rolandd@cisco.com>
381 kernel.org:/pub/scm/linux/kernel/git/roland/infiniband.git 381 git.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband.git
382 382
383 - libata, Jeff Garzik <jgarzik@pobox.com> 383 - libata, Jeff Garzik <jgarzik@pobox.com>
384 kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev.git 384 git.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev.git
385 385
386 - ネットワークドライバ, Jeff Garzik <jgarzik@pobox.com> 386 - ネットワークドライバ, Jeff Garzik <jgarzik@pobox.com>
387 kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6.git 387 git.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6.git
388 388
389 - pcmcia, Dominik Brodowski <linux@dominikbrodowski.net> 389 - pcmcia, Dominik Brodowski <linux@dominikbrodowski.net>
390 kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6.git 390 git.kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6.git
391 391
392 - SCSI, James Bottomley <James.Bottomley@SteelEye.com> 392 - SCSI, James Bottomley <James.Bottomley@SteelEye.com>
393 kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6.git 393 git.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6.git
394
395 その他の git カーネルツリーは http://kernel.org/git に一覧表がありま
396 す。
397 394
398 quilt ツリー- 395 quilt ツリー-
399 - USB, PCI ドライバコアと I2C, Greg Kroah-Hartman <gregkh@suse.de> 396 - USB, PCI ドライバコアと I2C, Greg Kroah-Hartman <gregkh@suse.de>
400 kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/ 397 kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/
398 - x86-64 と i386 の仲間 Andi Kleen <ak@suse.de>
399
400 その他のカーネルツリーは http://git.kernel.org/ と MAINTAINERS ファ
401 イルに一覧表があります。
401 402
402バグレポート 403バグレポート
403------------- 404-------------
@@ -508,6 +509,7 @@ MAINTAINERS ファイルにリストがありますので参照してくださ
508せん*。単に自分のパッチに対して指摘された問題を全て修正して再送すれば 509せん*。単に自分のパッチに対して指摘された問題を全て修正して再送すれば
509いいのです。 510いいのです。
510 511
512
511カーネルコミュニティと企業組織のちがい 513カーネルコミュニティと企業組織のちがい
512----------------------------------------------------------------- 514-----------------------------------------------------------------
513 515
@@ -577,6 +579,7 @@ Linux カーネルコミュニティは、一度に大量のコードの塊を
577 かし、500行のパッチは、正しいことをレビューするのに数時間かかるかも 579 かし、500行のパッチは、正しいことをレビューするのに数時間かかるかも
578 しれません(時間はパッチのサイズなどにより指数関数に比例してかかりま 580 しれません(時間はパッチのサイズなどにより指数関数に比例してかかりま
579 す) 581 す)
582
580 小さいパッチは何かあったときにデバッグもとても簡単になります。パッ 583 小さいパッチは何かあったときにデバッグもとても簡単になります。パッ
581 チを1個1個取り除くのは、とても大きなパッチを当てた後に(かつ、何かお 584 チを1個1個取り除くのは、とても大きなパッチを当てた後に(かつ、何かお
582 かしくなった後で)解剖するのに比べればとても簡単です。 585 かしくなった後で)解剖するのに比べればとても簡単です。
@@ -591,6 +594,7 @@ Linux カーネルコミュニティは、一度に大量のコードの塊を
591 う。先生は簡潔な最高の解をみたいのです。良い生徒はこれを知って 594 う。先生は簡潔な最高の解をみたいのです。良い生徒はこれを知って
592 おり、そして最終解の前の中間作業を提出することは決してないので 595 おり、そして最終解の前の中間作業を提出することは決してないので
593 す" 596 す"
597
594 カーネル開発でもこれは同じです。メンテナー達とレビューア達は、 598 カーネル開発でもこれは同じです。メンテナー達とレビューア達は、
595 問題を解決する解の背後になる思考プロセスをみたいとは思いません。 599 問題を解決する解の背後になる思考プロセスをみたいとは思いません。
596 彼らは単純であざやかな解決方法をみたいのです。 600 彼らは単純であざやかな解決方法をみたいのです。
diff --git a/Documentation/ja_JP/stable_api_nonsense.txt b/Documentation/ja_JP/stable_api_nonsense.txt
index b3f2b27f0881..7653b5cbfed2 100644
--- a/Documentation/ja_JP/stable_api_nonsense.txt
+++ b/Documentation/ja_JP/stable_api_nonsense.txt
@@ -1,17 +1,17 @@
1NOTE: 1NOTE:
2This is a Japanese translated version of 2This is a version of Documentation/stable_api_nonsense.txt into Japanese.
3"Documentation/stable_api_nonsense.txt". 3This document is maintained by IKEDA, Munehiro <m-ikeda@ds.jp.nec.com>
4This one is maintained by 4and the JF Project team <http://www.linux.or.jp/JF/>.
5IKEDA, Munehiro <m-ikeda@ds.jp.nec.com> 5If you find any difference between this document and the original file
6and JF Project team <http://www.linux.or.jp/JF/>. 6or a problem with the translation,
7If you find difference with original file or problem in translation,
8please contact the maintainer of this file or JF project. 7please contact the maintainer of this file or JF project.
9 8
10Please also note that purpose of this file is easier to read for non 9Please also note that the purpose of this file is to be easier to read
11English natives and not to be intended to fork. So, if you have any 10for non English (read: Japanese) speakers and is not intended as a
12comments or updates of this file, please try to update 11fork. So if you have any comments or updates of this file, please try
13Original(English) file at first. 12to update the original English file first.
14 13
14Last Updated: 2007/07/18
15================================== 15==================================
16これは、 16これは、
17linux-2.6.22-rc4/Documentation/stable_api_nonsense.txt の和訳 17linux-2.6.22-rc4/Documentation/stable_api_nonsense.txt の和訳
diff --git a/Documentation/kobject.txt b/Documentation/kobject.txt
index e44855513b3d..8ee49ee7c963 100644
--- a/Documentation/kobject.txt
+++ b/Documentation/kobject.txt
@@ -27,7 +27,6 @@ in detail, and briefly here:
27- kobjects a simple object. 27- kobjects a simple object.
28- kset a set of objects of a certain type. 28- kset a set of objects of a certain type.
29- ktype a set of helpers for objects of a common type. 29- ktype a set of helpers for objects of a common type.
30- subsystem a controlling object for a number of ksets.
31 30
32 31
33The kobject infrastructure maintains a close relationship with the 32The kobject infrastructure maintains a close relationship with the
@@ -54,13 +53,15 @@ embedded in larger data structures and replace fields they duplicate.
541.2 Definition 531.2 Definition
55 54
56struct kobject { 55struct kobject {
56 const char * k_name;
57 char name[KOBJ_NAME_LEN]; 57 char name[KOBJ_NAME_LEN];
58 atomic_t refcount; 58 struct kref kref;
59 struct list_head entry; 59 struct list_head entry;
60 struct kobject * parent; 60 struct kobject * parent;
61 struct kset * kset; 61 struct kset * kset;
62 struct kobj_type * ktype; 62 struct kobj_type * ktype;
63 struct dentry * dentry; 63 struct sysfs_dirent * sd;
64 wait_queue_head_t poll;
64}; 65};
65 66
66void kobject_init(struct kobject *); 67void kobject_init(struct kobject *);
@@ -137,8 +138,7 @@ If a kobject does not have a parent when it is registered, its parent
137becomes its dominant kset. 138becomes its dominant kset.
138 139
139If a kobject does not have a parent nor a dominant kset, its directory 140If a kobject does not have a parent nor a dominant kset, its directory
140is created at the top-level of the sysfs partition. This should only 141is created at the top-level of the sysfs partition.
141happen for kobjects that are embedded in a struct subsystem.
142 142
143 143
144 144
@@ -150,10 +150,10 @@ A kset is a set of kobjects that are embedded in the same type.
150 150
151 151
152struct kset { 152struct kset {
153 struct subsystem * subsys;
154 struct kobj_type * ktype; 153 struct kobj_type * ktype;
155 struct list_head list; 154 struct list_head list;
156 struct kobject kobj; 155 struct kobject kobj;
156 struct kset_uevent_ops * uevent_ops;
157}; 157};
158 158
159 159
@@ -169,8 +169,7 @@ struct kobject * kset_find_obj(struct kset *, char *);
169 169
170 170
171The type that the kobjects are embedded in is described by the ktype 171The type that the kobjects are embedded in is described by the ktype
172pointer. The subsystem that the kobject belongs to is pointed to by the 172pointer.
173subsys pointer.
174 173
175A kset contains a kobject itself, meaning that it may be registered in 174A kset contains a kobject itself, meaning that it may be registered in
176the kobject hierarchy and exported via sysfs. More importantly, the 175the kobject hierarchy and exported via sysfs. More importantly, the
@@ -209,6 +208,58 @@ the hierarchy.
209kset_find_obj() may be used to locate a kobject with a particular 208kset_find_obj() may be used to locate a kobject with a particular
210name. The kobject, if found, is returned. 209name. The kobject, if found, is returned.
211 210
211There are also some helper functions which names point to the formerly
212existing "struct subsystem", whose functions have been taken over by
213ksets.
214
215
216decl_subsys(name,type,uevent_ops)
217
218Declares a kset named '<name>_subsys' of type <type> with
219uevent_ops <uevent_ops>. For example,
220
221decl_subsys(devices, &ktype_device, &device_uevent_ops);
222
223is equivalent to doing:
224
225struct kset devices_subsys = {
226 .kobj = {
227 .name = "devices",
228 },
229 .ktype = &ktype_devices,
230 .uevent_ops = &device_uevent_ops,
231};
232
233
234The objects that are registered with a subsystem that use the
235subsystem's default list must have their kset ptr set properly. These
236objects may have embedded kobjects or ksets. The
237following helpers make setting the kset easier:
238
239
240kobj_set_kset_s(obj,subsys)
241
242- Assumes that obj->kobj exists, and is a struct kobject.
243- Sets the kset of that kobject to the kset <subsys>.
244
245
246kset_set_kset_s(obj,subsys)
247
248- Assumes that obj->kset exists, and is a struct kset.
249- Sets the kset of the embedded kobject to the kset <subsys>.
250
251subsys_set_kset(obj,subsys)
252
253- Assumes obj->subsys exists, and is a struct subsystem.
254- Sets obj->subsys.kset.kobj.kset to the subsystem's embedded kset.
255
256void subsystem_init(struct kset *s);
257int subsystem_register(struct kset *s);
258void subsystem_unregister(struct kset *s);
259struct kset *subsys_get(struct kset *s);
260void kset_put(struct kset *s);
261
262These are just wrappers around the respective kset_* functions.
212 263
2132.3 sysfs 2642.3 sysfs
214 265
@@ -254,114 +305,3 @@ Instances of struct kobj_type are not registered; only referenced by
254the kset. A kobj_type may be referenced by an arbitrary number of 305the kset. A kobj_type may be referenced by an arbitrary number of
255ksets, as there may be disparate sets of identical objects. 306ksets, as there may be disparate sets of identical objects.
256 307
257
258
2594. subsystems
260
2614.1 Description
262
263A subsystem represents a significant entity of code that maintains an
264arbitrary number of sets of objects of various types. Since the number
265of ksets and the type of objects they contain are variable, a
266generic representation of a subsystem is minimal.
267
268
269struct subsystem {
270 struct kset kset;
271 struct rw_semaphore rwsem;
272};
273
274int subsystem_register(struct subsystem *);
275void subsystem_unregister(struct subsystem *);
276
277struct subsystem * subsys_get(struct subsystem * s);
278void subsys_put(struct subsystem * s);
279
280
281A subsystem contains an embedded kset so:
282
283- It can be represented in the object hierarchy via the kset's
284 embedded kobject.
285
286- It can maintain a default list of objects of one type.
287
288Additional ksets may attach to the subsystem simply by referencing the
289subsystem before they are registered. (This one-way reference means
290that there is no way to determine the ksets that are attached to the
291subsystem.)
292
293All ksets that are attached to a subsystem share the subsystem's R/W
294semaphore.
295
296
2974.2 subsystem Programming Interface.
298
299The subsystem programming interface is simple and does not offer the
300flexibility that the kset and kobject programming interfaces do. They
301may be registered and unregistered, as well as reference counted. Each
302call forwards the calls to their embedded ksets (which forward the
303calls to their embedded kobjects).
304
305
3064.3 Helpers
307
308A number of macros are available to make dealing with subsystems and
309their embedded objects easier.
310
311
312decl_subsys(name,type)
313
314Declares a subsystem named '<name>_subsys', with an embedded kset of
315type <type>. For example,
316
317decl_subsys(devices,&ktype_devices);
318
319is equivalent to doing:
320
321struct subsystem device_subsys = {
322 .kset = {
323 .kobj = {
324 .name = "devices",
325 },
326 .ktype = &ktype_devices,
327 }
328};
329
330
331The objects that are registered with a subsystem that use the
332subsystem's default list must have their kset ptr set properly. These
333objects may have embedded kobjects, ksets, or other subsystems. The
334following helpers make setting the kset easier:
335
336
337kobj_set_kset_s(obj,subsys)
338
339- Assumes that obj->kobj exists, and is a struct kobject.
340- Sets the kset of that kobject to the subsystem's embedded kset.
341
342
343kset_set_kset_s(obj,subsys)
344
345- Assumes that obj->kset exists, and is a struct kset.
346- Sets the kset of the embedded kobject to the subsystem's
347 embedded kset.
348
349subsys_set_kset(obj,subsys)
350
351- Assumes obj->subsys exists, and is a struct subsystem.
352- Sets obj->subsys.kset.kobj.kset to the subsystem's embedded kset.
353
354
3554.4 sysfs
356
357subsystems are represented in sysfs via their embedded kobjects. They
358follow the same rules as previously mentioned with no exceptions. They
359typically receive a top-level directory in sysfs, except when their
360embedded kobject is part of another kset, or the parent of the
361embedded kobject is explicitly set.
362
363Note that the subsystem's embedded kset must be 'attached' to the
364subsystem itself in order to use its rwsem. This is done after
365kset_add() has been called. (Not before, because kset_add() uses its
366subsystem for a default parent if it doesn't already have one).
367
diff --git a/Documentation/stable_api_nonsense.txt b/Documentation/stable_api_nonsense.txt
index a2afca3b2bab..847b342b7b20 100644
--- a/Documentation/stable_api_nonsense.txt
+++ b/Documentation/stable_api_nonsense.txt
@@ -10,7 +10,7 @@ kernel to userspace interfaces. The kernel to userspace interface is
10the one that application programs use, the syscall interface. That 10the one that application programs use, the syscall interface. That
11interface is _very_ stable over time, and will not break. I have old 11interface is _very_ stable over time, and will not break. I have old
12programs that were built on a pre 0.9something kernel that still work 12programs that were built on a pre 0.9something kernel that still work
13just fine on the latest 2.6 kernel release. This interface is the one 13just fine on the latest 2.6 kernel release. That interface is the one
14that users and application programmers can count on being stable. 14that users and application programmers can count on being stable.
15 15
16 16
diff --git a/Documentation/sysfs-rules.txt b/Documentation/sysfs-rules.txt
index 42861bb0bc9b..80ef562160bb 100644
--- a/Documentation/sysfs-rules.txt
+++ b/Documentation/sysfs-rules.txt
@@ -1,19 +1,18 @@
1Rules on how to access information in the Linux kernel sysfs 1Rules on how to access information in the Linux kernel sysfs
2 2
3The kernel exported sysfs exports internal kernel implementation-details 3The kernel-exported sysfs exports internal kernel implementation details
4and depends on internal kernel structures and layout. It is agreed upon 4and depends on internal kernel structures and layout. It is agreed upon
5by the kernel developers that the Linux kernel does not provide a stable 5by the kernel developers that the Linux kernel does not provide a stable
6internal API. As sysfs is a direct export of kernel internal 6internal API. As sysfs is a direct export of kernel internal
7structures, the sysfs interface can not provide a stable interface eighter, 7structures, the sysfs interface cannot provide a stable interface either;
8it may always change along with internal kernel changes. 8it may always change along with internal kernel changes.
9 9
10To minimize the risk of breaking users of sysfs, which are in most cases 10To minimize the risk of breaking users of sysfs, which are in most cases
11low-level userspace applications, with a new kernel release, the users 11low-level userspace applications, with a new kernel release, the users
12of sysfs must follow some rules to use an as abstract-as-possible way to 12of sysfs must follow some rules to use an as-abstract-as-possible way to
13access this filesystem. The current udev and HAL programs already 13access this filesystem. The current udev and HAL programs already
14implement this and users are encouraged to plug, if possible, into the 14implement this and users are encouraged to plug, if possible, into the
15abstractions these programs provide instead of accessing sysfs 15abstractions these programs provide instead of accessing sysfs directly.
16directly.
17 16
18But if you really do want or need to access sysfs directly, please follow 17But if you really do want or need to access sysfs directly, please follow
19the following rules and then your programs should work with future 18the following rules and then your programs should work with future
@@ -25,22 +24,22 @@ versions of the sysfs interface.
25 implementation details in its own API. Therefore it is not better than 24 implementation details in its own API. Therefore it is not better than
26 reading directories and opening the files yourself. 25 reading directories and opening the files yourself.
27 Also, it is not actively maintained, in the sense of reflecting the 26 Also, it is not actively maintained, in the sense of reflecting the
28 current kernel-development. The goal of providing a stable interface 27 current kernel development. The goal of providing a stable interface
29 to sysfs has failed, it causes more problems, than it solves. It 28 to sysfs has failed; it causes more problems than it solves. It
30 violates many of the rules in this document. 29 violates many of the rules in this document.
31 30
32- sysfs is always at /sys 31- sysfs is always at /sys
33 Parsing /proc/mounts is a waste of time. Other mount points are a 32 Parsing /proc/mounts is a waste of time. Other mount points are a
34 system configuration bug you should not try to solve. For test cases, 33 system configuration bug you should not try to solve. For test cases,
35 possibly support a SYSFS_PATH environment variable to overwrite the 34 possibly support a SYSFS_PATH environment variable to overwrite the
36 applications behavior, but never try to search for sysfs. Never try 35 application's behavior, but never try to search for sysfs. Never try
37 to mount it, if you are not an early boot script. 36 to mount it, if you are not an early boot script.
38 37
39- devices are only "devices" 38- devices are only "devices"
40 There is no such thing like class-, bus-, physical devices, 39 There is no such thing like class-, bus-, physical devices,
41 interfaces, and such that you can rely on in userspace. Everything is 40 interfaces, and such that you can rely on in userspace. Everything is
42 just simply a "device". Class-, bus-, physical, ... types are just 41 just simply a "device". Class-, bus-, physical, ... types are just
43 kernel implementation details, which should not be expected by 42 kernel implementation details which should not be expected by
44 applications that look for devices in sysfs. 43 applications that look for devices in sysfs.
45 44
46 The properties of a device are: 45 The properties of a device are:
@@ -48,11 +47,11 @@ versions of the sysfs interface.
48 - identical to the DEVPATH value in the event sent from the kernel 47 - identical to the DEVPATH value in the event sent from the kernel
49 at device creation and removal 48 at device creation and removal
50 - the unique key to the device at that point in time 49 - the unique key to the device at that point in time
51 - the kernels path to the device-directory without the leading 50 - the kernel's path to the device directory without the leading
52 /sys, and always starting with with a slash 51 /sys, and always starting with with a slash
53 - all elements of a devpath must be real directories. Symlinks 52 - all elements of a devpath must be real directories. Symlinks
54 pointing to /sys/devices must always be resolved to their real 53 pointing to /sys/devices must always be resolved to their real
55 target, and the target path must be used to access the device. 54 target and the target path must be used to access the device.
56 That way the devpath to the device matches the devpath of the 55 That way the devpath to the device matches the devpath of the
57 kernel used at event time. 56 kernel used at event time.
58 - using or exposing symlink values as elements in a devpath string 57 - using or exposing symlink values as elements in a devpath string
@@ -73,17 +72,17 @@ versions of the sysfs interface.
73 link 72 link
74 - it is retrieved by reading the "driver"-link and using only the 73 - it is retrieved by reading the "driver"-link and using only the
75 last element of the target path 74 last element of the target path
76 - devices which do not have "driver"-link, just do not have a 75 - devices which do not have "driver"-link just do not have a
77 driver; copying the driver value in a child device context, is a 76 driver; copying the driver value in a child device context is a
78 bug in the application 77 bug in the application
79 78
80 o attributes 79 o attributes
81 - the files in the device directory or files below a subdirectories 80 - the files in the device directory or files below subdirectories
82 of the same device directory 81 of the same device directory
83 - accessing attributes reached by a symlink pointing to another device, 82 - accessing attributes reached by a symlink pointing to another device,
84 like the "device"-link, is a bug in the application 83 like the "device"-link, is a bug in the application
85 84
86 Everything else is just a kernel driver-core implementation detail, 85 Everything else is just a kernel driver-core implementation detail
87 that should not be assumed to be stable across kernel releases. 86 that should not be assumed to be stable across kernel releases.
88 87
89- Properties of parent devices never belong into a child device. 88- Properties of parent devices never belong into a child device.
@@ -91,25 +90,25 @@ versions of the sysfs interface.
91 context properties. If the device 'eth0' or 'sda' does not have a 90 context properties. If the device 'eth0' or 'sda' does not have a
92 "driver"-link, then this device does not have a driver. Its value is empty. 91 "driver"-link, then this device does not have a driver. Its value is empty.
93 Never copy any property of the parent-device into a child-device. Parent 92 Never copy any property of the parent-device into a child-device. Parent
94 device-properties may change dynamically without any notice to the 93 device properties may change dynamically without any notice to the
95 child device. 94 child device.
96 95
97- Hierarchy in a single device-tree 96- Hierarchy in a single device tree
98 There is only one valid place in sysfs where hierarchy can be examined 97 There is only one valid place in sysfs where hierarchy can be examined
99 and this is below: /sys/devices. 98 and this is below: /sys/devices.
100 It is planned, that all device directories will end up in the tree 99 It is planned that all device directories will end up in the tree
101 below this directory. 100 below this directory.
102 101
103- Classification by subsystem 102- Classification by subsystem
104 There are currently three places for classification of devices: 103 There are currently three places for classification of devices:
105 /sys/block, /sys/class and /sys/bus. It is planned that these will 104 /sys/block, /sys/class and /sys/bus. It is planned that these will
106 not contain any device-directories themselves, but only flat lists of 105 not contain any device directories themselves, but only flat lists of
107 symlinks pointing to the unified /sys/devices tree. 106 symlinks pointing to the unified /sys/devices tree.
108 All three places have completely different rules on how to access 107 All three places have completely different rules on how to access
109 device information. It is planned to merge all three 108 device information. It is planned to merge all three
110 classification-directories into one place at /sys/subsystem, 109 classification directories into one place at /sys/subsystem,
111 following the layout of the bus-directories. All buses and 110 following the layout of the bus directories. All buses and
112 classes, including the converted block-subsystem, will show up 111 classes, including the converted block subsystem, will show up
113 there. 112 there.
114 The devices belonging to a subsystem will create a symlink in the 113 The devices belonging to a subsystem will create a symlink in the
115 "devices" directory at /sys/subsystem/<name>/devices. 114 "devices" directory at /sys/subsystem/<name>/devices.
@@ -121,38 +120,38 @@ versions of the sysfs interface.
121 subsystem name. 120 subsystem name.
122 121
123 Assuming /sys/class/<subsystem> and /sys/bus/<subsystem>, or 122 Assuming /sys/class/<subsystem> and /sys/bus/<subsystem>, or
124 /sys/block and /sys/class/block are not interchangeable, is a bug in 123 /sys/block and /sys/class/block are not interchangeable is a bug in
125 the application. 124 the application.
126 125
127- Block 126- Block
128 The converted block-subsystem at /sys/class/block, or 127 The converted block subsystem at /sys/class/block or
129 /sys/subsystem/block will contain the links for disks and partitions 128 /sys/subsystem/block will contain the links for disks and partitions
130 at the same level, never in a hierarchy. Assuming the block-subsytem to 129 at the same level, never in a hierarchy. Assuming the block subsytem to
131 contain only disks and not partition-devices in the same flat list is 130 contain only disks and not partition devices in the same flat list is
132 a bug in the application. 131 a bug in the application.
133 132
134- "device"-link and <subsystem>:<kernel name>-links 133- "device"-link and <subsystem>:<kernel name>-links
135 Never depend on the "device"-link. The "device"-link is a workaround 134 Never depend on the "device"-link. The "device"-link is a workaround
136 for the old layout, where class-devices are not created in 135 for the old layout, where class devices are not created in
137 /sys/devices/ like the bus-devices. If the link-resolving of a 136 /sys/devices/ like the bus devices. If the link-resolving of a
138 device-directory does not end in /sys/devices/, you can use the 137 device directory does not end in /sys/devices/, you can use the
139 "device"-link to find the parent devices in /sys/devices/. That is the 138 "device"-link to find the parent devices in /sys/devices/. That is the
140 single valid use of the "device"-link, it must never appear in any 139 single valid use of the "device"-link; it must never appear in any
141 path as an element. Assuming the existence of the "device"-link for 140 path as an element. Assuming the existence of the "device"-link for
142 a device in /sys/devices/ is a bug in the application. 141 a device in /sys/devices/ is a bug in the application.
143 Accessing /sys/class/net/eth0/device is a bug in the application. 142 Accessing /sys/class/net/eth0/device is a bug in the application.
144 143
145 Never depend on the class-specific links back to the /sys/class 144 Never depend on the class-specific links back to the /sys/class
146 directory. These links are also a workaround for the design mistake 145 directory. These links are also a workaround for the design mistake
147 that class-devices are not created in /sys/devices. If a device 146 that class devices are not created in /sys/devices. If a device
148 directory does not contain directories for child devices, these links 147 directory does not contain directories for child devices, these links
149 may be used to find the child devices in /sys/class. That is the single 148 may be used to find the child devices in /sys/class. That is the single
150 valid use of these links, they must never appear in any path as an 149 valid use of these links; they must never appear in any path as an
151 element. Assuming the existence of these links for devices which are 150 element. Assuming the existence of these links for devices which are
152 real child device directories in the /sys/devices tree, is a bug in 151 real child device directories in the /sys/devices tree is a bug in
153 the application. 152 the application.
154 153
155 It is planned to remove all these links when when all class-device 154 It is planned to remove all these links when all class device
156 directories live in /sys/devices. 155 directories live in /sys/devices.
157 156
158- Position of devices along device chain can change. 157- Position of devices along device chain can change.
@@ -161,6 +160,5 @@ versions of the sysfs interface.
161 the chain. You must always request the parent device you are looking for 160 the chain. You must always request the parent device you are looking for
162 by its subsystem value. You need to walk up the chain until you find 161 by its subsystem value. You need to walk up the chain until you find
163 the device that matches the expected subsystem. Depending on a specific 162 the device that matches the expected subsystem. Depending on a specific
164 position of a parent device, or exposing relative paths, using "../" to 163 position of a parent device or exposing relative paths using "../" to
165 access the chain of parents, is a bug in the application. 164 access the chain of parents is a bug in the application.
166
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 3599ab2506d2..e6738bcbe5a9 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -24,8 +24,6 @@
24#include "base.h" 24#include "base.h"
25#include "power/power.h" 25#include "power/power.h"
26 26
27extern const char *kobject_actions[];
28
29int (*platform_notify)(struct device * dev) = NULL; 27int (*platform_notify)(struct device * dev) = NULL;
30int (*platform_notify_remove)(struct device * dev) = NULL; 28int (*platform_notify_remove)(struct device * dev) = NULL;
31 29
@@ -680,8 +678,7 @@ static int device_add_class_symlinks(struct device *dev)
680 if (error) 678 if (error)
681 goto out_subsys; 679 goto out_subsys;
682 } 680 }
683 /* only bus-device parents get a "device"-link */ 681 if (dev->parent) {
684 if (dev->parent && dev->parent->bus) {
685 error = sysfs_create_link(&dev->kobj, &dev->parent->kobj, 682 error = sysfs_create_link(&dev->kobj, &dev->parent->kobj,
686 "device"); 683 "device");
687 if (error) 684 if (error)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 53f0ee6f3016..b24efd4e3e3d 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -232,6 +232,7 @@ fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size)
232/** 232/**
233 * firmware_data_write - write method for firmware 233 * firmware_data_write - write method for firmware
234 * @kobj: kobject for the device 234 * @kobj: kobject for the device
235 * @bin_attr: bin_attr structure
235 * @buffer: buffer being written 236 * @buffer: buffer being written
236 * @offset: buffer offset for write in total data store area 237 * @offset: buffer offset for write in total data store area
237 * @count: buffer size 238 * @count: buffer size
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index fba319d6fcc8..1ee9cd9c86e2 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1517,7 +1517,7 @@ EXPORT_SYMBOL(pcie_get_readrq);
1517/** 1517/**
1518 * pcie_set_readrq - set PCI Express maximum memory read request 1518 * pcie_set_readrq - set PCI Express maximum memory read request
1519 * @dev: PCI device to query 1519 * @dev: PCI device to query
1520 * @count: maximum memory read count in bytes 1520 * @rq: maximum memory read count in bytes
1521 * valid values are 128, 256, 512, 1024, 2048, 4096 1521 * valid values are 128, 256, 512, 1024, 2048, 4096
1522 * 1522 *
1523 * If possible sets maximum read byte count 1523 * If possible sets maximum read byte count
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index aa2fe22b1baa..949706c33622 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -56,6 +56,9 @@ enum kobject_action {
56 KOBJ_MAX 56 KOBJ_MAX
57}; 57};
58 58
59/* The list of strings defining the valid kobject actions as specified above */
60extern const char *kobject_actions[];
61
59struct kobject { 62struct kobject {
60 const char * k_name; 63 const char * k_name;
61 char name[KOBJ_NAME_LEN]; 64 char name[KOBJ_NAME_LEN];
@@ -108,9 +111,15 @@ struct kobj_type {
108 struct attribute ** default_attrs; 111 struct attribute ** default_attrs;
109}; 112};
110 113
114struct kset_uevent_ops {
115 int (*filter)(struct kset *kset, struct kobject *kobj);
116 const char *(*name)(struct kset *kset, struct kobject *kobj);
117 int (*uevent)(struct kset *kset, struct kobject *kobj, char **envp,
118 int num_envp, char *buffer, int buffer_size);
119};
111 120
112/** 121/*
113 * kset - a set of kobjects of a specific type, belonging 122 * struct kset - a set of kobjects of a specific type, belonging
114 * to a specific subsystem. 123 * to a specific subsystem.
115 * 124 *
116 * All kobjects of a kset should be embedded in an identical 125 * All kobjects of a kset should be embedded in an identical
@@ -126,13 +135,6 @@ struct kobj_type {
126 * supress the event generation or add subsystem specific 135 * supress the event generation or add subsystem specific
127 * variables carried with the event. 136 * variables carried with the event.
128 */ 137 */
129struct kset_uevent_ops {
130 int (*filter)(struct kset *kset, struct kobject *kobj);
131 const char *(*name)(struct kset *kset, struct kobject *kobj);
132 int (*uevent)(struct kset *kset, struct kobject *kobj, char **envp,
133 int num_envp, char *buffer, int buffer_size);
134};
135
136struct kset { 138struct kset {
137 struct kobj_type * ktype; 139 struct kobj_type * ktype;
138 struct list_head list; 140 struct list_head list;
@@ -173,7 +175,7 @@ static inline struct kobj_type * get_ktype(struct kobject * k)
173extern struct kobject * kset_find_obj(struct kset *, const char *); 175extern struct kobject * kset_find_obj(struct kset *, const char *);
174 176
175 177
176/** 178/*
177 * Use this when initializing an embedded kset with no other 179 * Use this when initializing an embedded kset with no other
178 * fields to initialize. 180 * fields to initialize.
179 */ 181 */
@@ -198,7 +200,7 @@ extern struct kset kernel_subsys;
198/* The global /sys/hypervisor/ subsystem */ 200/* The global /sys/hypervisor/ subsystem */
199extern struct kset hypervisor_subsys; 201extern struct kset hypervisor_subsys;
200 202
201/** 203/*
202 * Helpers for setting the kset of registered objects. 204 * Helpers for setting the kset of registered objects.
203 * Often, a registered object belongs to a kset embedded in a 205 * Often, a registered object belongs to a kset embedded in a
204 * subsystem. These do no magic, just make the resulting code 206 * subsystem. These do no magic, just make the resulting code
@@ -233,7 +235,7 @@ extern struct kset hypervisor_subsys;
233/** 235/**
234 * subsys_set_kset(obj,subsys) - set kset for subsystem 236 * subsys_set_kset(obj,subsys) - set kset for subsystem
235 * @obj: ptr to some object type. 237 * @obj: ptr to some object type.
236 * @subsys: a subsystem object (not a ptr). 238 * @_subsys: a subsystem object (not a ptr).
237 * 239 *
238 * Can be used for any object type with an embedded ->subsys. 240 * Can be used for any object type with an embedded ->subsys.
239 * Sets the kset of @obj's kobject to @subsys.kset. This makes 241 * Sets the kset of @obj's kobject to @subsys.kset. This makes
diff --git a/kernel/params.c b/kernel/params.c
index effbaaedd7f3..4e57732fcfb4 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -567,7 +567,12 @@ static void __init kernel_param_sysfs_setup(const char *name,
567 kobject_set_name(&mk->kobj, name); 567 kobject_set_name(&mk->kobj, name);
568 kobject_init(&mk->kobj); 568 kobject_init(&mk->kobj);
569 ret = kobject_add(&mk->kobj); 569 ret = kobject_add(&mk->kobj);
570 BUG_ON(ret < 0); 570 if (ret) {
571 printk(KERN_ERR "Module '%s' failed to be added to sysfs, "
572 "error number %d\n", name, ret);
573 printk(KERN_ERR "The system will be unstable now.\n");
574 return;
575 }
571 param_sysfs_setup(mk, kparam, num_params, name_skip); 576 param_sysfs_setup(mk, kparam, num_params, name_skip);
572 kobject_uevent(&mk->kobj, KOBJ_ADD); 577 kobject_uevent(&mk->kobj, KOBJ_ADD);
573} 578}
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 6a80c784a8fb..df02814699d7 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -25,14 +25,6 @@
25#define BUFFER_SIZE 2048 /* buffer for the variables */ 25#define BUFFER_SIZE 2048 /* buffer for the variables */
26#define NUM_ENVP 32 /* number of env pointers */ 26#define NUM_ENVP 32 /* number of env pointers */
27 27
28#if defined(CONFIG_HOTPLUG)
29u64 uevent_seqnum;
30char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug";
31static DEFINE_SPINLOCK(sequence_lock);
32#if defined(CONFIG_NET)
33static struct sock *uevent_sock;
34#endif
35
36/* the strings here must match the enum in include/linux/kobject.h */ 28/* the strings here must match the enum in include/linux/kobject.h */
37const char *kobject_actions[] = { 29const char *kobject_actions[] = {
38 "add", 30 "add",
@@ -43,6 +35,14 @@ const char *kobject_actions[] = {
43 "offline", 35 "offline",
44}; 36};
45 37
38#if defined(CONFIG_HOTPLUG)
39u64 uevent_seqnum;
40char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug";
41static DEFINE_SPINLOCK(sequence_lock);
42#if defined(CONFIG_NET)
43static struct sock *uevent_sock;
44#endif
45
46/** 46/**
47 * kobject_uevent_env - send an uevent with environmental data 47 * kobject_uevent_env - send an uevent with environmental data
48 * 48 *