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:
pnp: fix "add acpi:* modalias entries"
UIO: generic irq handling for some uio platform devices
UIO: uio_pdrv: fix license specification
UIO: uio_pdrv: fix memory leak
block: drop references taken by class_find_device()
block: fix partial read() of /proc/{partitions,diskstats}
PM: Remove WARN_ON from device_pm_add
driver core: add init_name to struct device
PM: don't skip device PM init when CONFIG_PM_SLEEP isn't set and CONFIG_PM is set
driver model: anti-oopsing medicine
dev_printk(): constify the `dev' argument
drivers/base/driver.c: remove unused to_dev() macro
Documentation: HOWTO-ja_JP-sync patch
Japanese translation of Documentation/SubmitChecklist
kobject: Replace ALL occurrences of '/' with '!' instead of only the first one.

+445 -72
+47 -20
Documentation/ja_JP/HOWTO
··· 11 11 fork. So if you have any comments or updates for this file, please try 12 12 to update the original English file first. 13 13 14 - Last Updated: 2007/11/16 14 + Last Updated: 2008/08/21 15 15 ================================== 16 16 これは、 17 - linux-2.6.24/Documentation/HOWTO 17 + linux-2.6.27/Documentation/HOWTO 18 18 の和訳です。 19 19 20 20 翻訳団体: JF プロジェクト < http://www.linux.or.jp/JF/ > 21 - 翻訳日: 2007/11/10 21 + 翻訳日: 2008/8/5 22 22 翻訳者: Tsugikazu Shibata <tshibata at ab dot jp dot nec dot com> 23 23 校正者: 松倉さん <nbh--mats at nifty dot com> 24 24 小林 雅典さん (Masanori Kobayasi) <zap03216 at nifty dot ne dot jp> ··· 287 287 に安定した状態にあると判断したときにリリースされます。目標は毎週新 288 288 しい -rc カーネルをリリースすることです。 289 289 290 - - 以下の URL で各 -rc リリースに存在する既知の後戻り問題のリスト 291 - が追跡されます- 292 - http://kernelnewbies.org/known_regressions 293 - 294 290 - このプロセスはカーネルが 「準備ができた」と考えられるまで継続しま 295 291 す。このプロセスはだいたい 6週間継続します。 292 + 293 + - 各リリースでの既知の後戻り問題(regression: このリリースの中で新規 294 + に作り込まれた問題を指す) はその都度 Linux-kernel メーリングリスト 295 + に投稿されます。ゴールとしては、カーネルが 「準備ができた」と宣言 296 + する前にこのリストの長さをゼロに減らすことですが、現実には、数個の 297 + 後戻り問題がリリース時にたびたび残ってしまいます。 296 298 297 299 Andrew Morton が Linux-kernel メーリングリストにカーネルリリースについ 298 300 て書いたことをここで言っておくことは価値があります- ··· 305 303 2.6.x.y -stable カーネルツリー 306 304 --------------------------- 307 305 308 - バージョンに4つ目の数字がついたカーネルは -stable カーネルです。これに 309 - は、2.6.x カーネルで見つかったセキュリティ問題や重大な後戻りに対する比 310 - 較的小さい重要な修正が含まれます。 306 + バージョン番号が4つの数字に分かれているカーネルは -stable カーネルです。 307 + これには、2.6.x カーネルで見つかったセキュリティ問題や重大な後戻りに対 308 + する比較的小さい重要な修正が含まれます。 311 309 312 310 これは、開発/実験的バージョンのテストに協力することに興味が無く、 313 311 最新の安定したカーネルを使いたいユーザに推奨するブランチです。 314 312 315 - もし、2.6.x.y カーネルが存在しない場合には、番号が一番大きい 2.6.x 316 - が最新の安定版カーネルです。 313 + もし、2.6.x.y カーネルが存在しない場合には、番号が一番大きい 2.6.x が 314 + 最新の安定版カーネルです。 317 315 318 - 2.6.x.y は "stable" チーム <stable@kernel.org> でメンテされており、だ 319 - いたい隔週でリリースされています。 316 + 2.6.x.y は "stable" チーム <stable@kernel.org> でメンテされており、必 317 + 要に応じてリリースされます。通常のリリース期間は 2週間毎ですが、差し迫っ 318 + た問題がなければもう少し長くなることもあります。セキュリティ関連の問題 319 + の場合はこれに対してだいたいの場合、すぐにリリースがされます。 320 320 321 321 カーネルツリーに入っている、Documentation/stable_kernel_rules.txt ファ 322 322 イルにはどのような種類の変更が -stable ツリーに受け入れ可能か、またリ ··· 345 341 メインラインへ入れるように Linus にプッシュします。 346 342 347 343 メインカーネルツリーに含めるために Linus に送る前に、すべての新しいパッ 348 - チが -mm ツリーでテストされることが強く推奨されます。 344 + チが -mm ツリーでテストされることが強く推奨されています。マージウィン 345 + ドウが開く前に -mm ツリーに現れなかったパッチはメインラインにマージさ 346 + れることは困難になります。 349 347 350 348 これらのカーネルは安定して動作すべきシステムとして使うのには適切ではあ 351 349 りませんし、カーネルブランチの中でももっとも動作にリスクが高いものです。 ··· 401 395 - pcmcia, Dominik Brodowski <linux@dominikbrodowski.net> 402 396 git.kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6.git 403 397 404 - - SCSI, James Bottomley <James.Bottomley@SteelEye.com> 398 + - SCSI, James Bottomley <James.Bottomley@hansenpartnership.com> 405 399 git.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6.git 406 400 401 + - x86, Ingo Molnar <mingo@elte.hu> 402 + git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86.git 403 + 407 404 quilt ツリー- 408 - - USB, PCI ドライバコアと I2C, Greg Kroah-Hartman <gregkh@suse.de> 405 + - USB, ドライバコアと I2C, Greg Kroah-Hartman <gregkh@suse.de> 409 406 kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/ 410 - - x86-64 と i386 の仲間 Andi Kleen <ak@suse.de> 411 407 412 408 その他のカーネルツリーは http://git.kernel.org/ と MAINTAINERS ファ 413 409 イルに一覧表があります。 ··· 420 412 bugzilla.kernel.org は Linux カーネル開発者がカーネルのバグを追跡する 421 413 場所です。ユーザは見つけたバグの全てをこのツールで報告すべきです。 422 414 どう kernel bugzilla を使うかの詳細は、以下を参照してください- 423 - http://test.kernel.org/bugzilla/faq.html 424 - 415 + http://bugzilla.kernel.org/page.cgi?id=faq.html 425 416 メインカーネルソースディレクトリにあるファイル REPORTING-BUGS はカーネ 426 417 ルバグらしいものについてどうレポートするかの良いテンプレートであり、問 427 418 題の追跡を助けるためにカーネル開発者にとってどんな情報が必要なのかの詳 428 419 細が書かれています。 420 + 421 + バグレポートの管理 422 + ------------------- 423 + 424 + あなたのハッキングのスキルを訓練する最高の方法のひとつに、他人がレポー 425 + トしたバグを修正することがあります。あなたがカーネルをより安定化させる 426 + こに寄与するということだけでなく、あなたは 現実の問題を修正することを 427 + 学び、自分のスキルも強化でき、また他の開発者があなたの存在に気がつき 428 + ます。バグを修正することは、多くの開発者の中から自分が功績をあげる最善 429 + の道です、なぜなら多くの人は他人のバグの修正に時間を浪費することを好ま 430 + ないからです。 431 + 432 + すでにレポートされたバグのために仕事をするためには、 433 + http://bugzilla.kernel.org に行ってください。もし今後のバグレポートに 434 + ついてアドバイスを受けたいのであれば、bugme-new メーリングリスト(新し 435 + いバグレポートだけがここにメールされる) または bugme-janitor メーリン 436 + グリスト(bugzilla の変更毎にここにメールされる)を購読できます。 437 + 438 + http://lists.linux-foundation.org/mailman/listinfo/bugme-new 439 + http://lists.linux-foundation.org/mailman/listinfo/bugme-janitors 429 440 430 441 メーリングリスト 431 442 -------------
+111
Documentation/ja_JP/SubmitChecklist
··· 1 + NOTE: 2 + This is a version of Documentation/SubmitChecklist into Japanese. 3 + This document is maintained by Takenori Nagano <t-nagano@ah.jp.nec.com> 4 + and the JF Project team <http://www.linux.or.jp/JF/>. 5 + If you find any difference between this document and the original file 6 + or a problem with the translation, 7 + please contact the maintainer of this file or JF project. 8 + 9 + Please also note that the purpose of this file is to be easier to read 10 + for non English (read: Japanese) speakers and is not intended as a 11 + fork. So if you have any comments or updates of this file, please try 12 + to update the original English file first. 13 + 14 + Last Updated: 2008/07/14 15 + ================================== 16 + これは、 17 + linux-2.6.26/Documentation/SubmitChecklist の和訳です。 18 + 19 + 翻訳団体: JF プロジェクト < http://www.linux.or.jp/JF/ > 20 + 翻訳日: 2008/07/14 21 + 翻訳者: Takenori Nagano <t-nagano at ah dot jp dot nec dot com> 22 + 校正者: Masanori Kobayashi さん <zap03216 at nifty dot ne dot jp> 23 + ================================== 24 + 25 + 26 + Linux カーネルパッチ投稿者向けチェックリスト 27 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 28 + 29 + 本書では、パッチをより素早く取り込んでもらいたい開発者が実践すべき基本的な事柄 30 + をいくつか紹介します。ここにある全ての事柄は、Documentation/SubmittingPatches 31 + などのLinuxカーネルパッチ投稿に際しての心得を補足するものです。 32 + 33 + 1: 妥当なCONFIGオプションや変更されたCONFIGオプション、つまり =y, =m, =n 34 + 全てで正しくビルドできることを確認してください。その際、gcc及びリンカが 35 + warningやerrorを出していないことも確認してください。 36 + 37 + 2: allnoconfig, allmodconfig オプションを用いて正しくビルドできることを 38 + 確認してください。 39 + 40 + 3: 手許のクロスコンパイルツールやOSDLのPLMのようなものを用いて、複数の 41 + アーキテクチャにおいても正しくビルドできることを確認してください。 42 + 43 + 4: 64bit長の'unsigned long'を使用しているppc64は、クロスコンパイルでの 44 + チェックに適当なアーキテクチャです。 45 + 46 + 5: カーネルコーディングスタイルに準拠しているかどうか確認してください(!) 47 + 48 + 6: CONFIGオプションの追加・変更をした場合には、CONFIGメニューが壊れていない 49 + ことを確認してください。 50 + 51 + 7: 新しくKconfigのオプションを追加する際には、必ずそのhelpも記述してください。 52 + 53 + 8: 適切なKconfigの依存関係を考えながら慎重にチェックしてください。 54 + ただし、この作業はマシンを使ったテストできちんと行うのがとても困難です。 55 + うまくやるには、自分の頭で考えることです。 56 + 57 + 9: sparseを利用してちゃんとしたコードチェックをしてください。 58 + 59 + 10: 'make checkstack' と 'make namespacecheck' を利用し、問題が発見されたら 60 + 修正してください。'make checkstack' は明示的に問題を示しませんが、どれか 61 + 1つの関数が512バイトより大きいスタックを使っていれば、修正すべき候補と 62 + なります。 63 + 64 + 11: グローバルなkernel API を説明する kernel-doc をソースの中に含めてください。 65 + ( staticな関数においては必須ではありませんが、含めてもらっても結構です ) 66 + そして、'make htmldocs' もしくは 'make mandocs' を利用して追記した 67 + ドキュメントのチェックを行い、問題が見つかった場合には修正を行ってください。 68 + 69 + 12: CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, CONFIG_DEBUG_SLAB, 70 + CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, CONFIG_DEBUG_SPINLOCK, 71 + CONFIG_DEBUG_SPINLOCK_SLEEP これら全てを同時に有効にして動作確認を 72 + 行ってください。 73 + 74 + 13: CONFIG_SMP, CONFIG_PREEMPT を有効にした場合と無効にした場合の両方で 75 + ビルドした上、動作確認を行ってください。 76 + 77 + 14: もしパッチがディスクのI/O性能などに影響を与えるようであれば、 78 + 'CONFIG_LBD'オプションを有効にした場合と無効にした場合の両方で 79 + テストを実施してみてください。 80 + 81 + 15: lockdepの機能を全て有効にした上で、全てのコードパスを評価してください。 82 + 83 + 16: /proc に新しいエントリを追加した場合には、Documentation/ 配下に 84 + 必ずドキュメントを追加してください。 85 + 86 + 17: 新しいブートパラメータを追加した場合には、 87 + 必ずDocumentation/kernel-parameters.txt に説明を追加してください。 88 + 89 + 18: 新しくmoduleにパラメータを追加した場合には、MODULE_PARM_DESC()を 90 + 利用して必ずその説明を記述してください。 91 + 92 + 19: 新しいuserspaceインタフェースを作成した場合には、Documentation/ABI/ に 93 + Documentation/ABI/README を参考にして必ずドキュメントを追加してください。 94 + 95 + 20: 'make headers_check'を実行して全く問題がないことを確認してください。 96 + 97 + 21: 少なくともslabアロケーションとpageアロケーションに失敗した場合の 98 + 挙動について、fault-injectionを利用して確認してください。 99 + Documentation/fault-injection/ を参照してください。 100 + 101 + 追加したコードがかなりの量であったならば、サブシステム特有の 102 + fault-injectionを追加したほうが良いかもしれません。 103 + 104 + 22: 新たに追加したコードは、`gcc -W'でコンパイルしてください。 105 + このオプションは大量の不要なメッセージを出力しますが、 106 + "warning: comparison between signed and unsigned" のようなメッセージは、 107 + バグを見つけるのに役に立ちます。 108 + 109 + 23: 投稿したパッチが -mm パッチセットにマージされた後、全ての既存のパッチや 110 + VM, VFS およびその他のサブシステムに関する様々な変更と、現時点でも共存 111 + できることを確認するテストを行ってください。
+24 -12
block/genhd.c
··· 293 293 /* iterator */ 294 294 static int find_start(struct device *dev, void *data) 295 295 { 296 - loff_t k = *(loff_t *)data; 296 + loff_t *k = data; 297 297 298 298 if (dev->type != &disk_type) 299 299 return 0; 300 - if (!k--) 300 + if (!*k) 301 301 return 1; 302 + (*k)--; 302 303 return 0; 303 304 } 304 305 305 306 static void *part_start(struct seq_file *part, loff_t *pos) 306 307 { 307 308 struct device *dev; 308 - loff_t n = *pos; 309 + loff_t k = *pos; 309 310 310 - if (!n) 311 + if (!k) 311 312 seq_puts(part, "major minor #blocks name\n\n"); 312 313 313 314 mutex_lock(&block_class_lock); 314 - dev = class_find_device(&block_class, NULL, (void *)pos, find_start); 315 - if (dev) 315 + dev = class_find_device(&block_class, NULL, &k, find_start); 316 + if (dev) { 317 + put_device(dev); 316 318 return dev_to_disk(dev); 319 + } 317 320 return NULL; 318 321 } 319 322 ··· 333 330 struct device *dev; 334 331 ++*pos; 335 332 dev = class_find_device(&block_class, &gp->dev, NULL, find_next); 336 - if (dev) 333 + if (dev) { 334 + put_device(dev); 337 335 return dev_to_disk(dev); 336 + } 338 337 return NULL; 339 338 } 340 339 ··· 573 568 static void *diskstats_start(struct seq_file *part, loff_t *pos) 574 569 { 575 570 struct device *dev; 571 + loff_t k = *pos; 576 572 577 573 mutex_lock(&block_class_lock); 578 - dev = class_find_device(&block_class, NULL, (void *)pos, find_start); 579 - if (dev) 574 + dev = class_find_device(&block_class, NULL, &k, find_start); 575 + if (dev) { 576 + put_device(dev); 580 577 return dev_to_disk(dev); 578 + } 581 579 return NULL; 582 580 } 583 581 ··· 591 583 592 584 ++*pos; 593 585 dev = class_find_device(&block_class, &gp->dev, NULL, find_next); 594 - if (dev) 586 + if (dev) { 587 + put_device(dev); 595 588 return dev_to_disk(dev); 589 + } 596 590 return NULL; 597 591 } 598 592 ··· 722 712 mutex_lock(&block_class_lock); 723 713 find.name = name; 724 714 find.part = part; 725 - dev = class_find_device(&block_class, NULL, (void *)&find, match_id); 726 - if (dev) 715 + dev = class_find_device(&block_class, NULL, &find, match_id); 716 + if (dev) { 717 + put_device(dev); 727 718 devt = MKDEV(MAJOR(dev->devt), 728 719 MINOR(dev->devt) + part); 720 + } 729 721 mutex_unlock(&block_class_lock); 730 722 731 723 return devt;
+11
drivers/base/class.c
··· 295 295 296 296 if (!class) 297 297 return -EINVAL; 298 + if (!class->p) { 299 + WARN(1, "%s called for class '%s' before it was initialized", 300 + __func__, class->name); 301 + return -EINVAL; 302 + } 303 + 298 304 mutex_lock(&class->p->class_mutex); 299 305 list_for_each_entry(dev, &class->p->class_devices, node) { 300 306 if (start) { ··· 350 344 351 345 if (!class) 352 346 return NULL; 347 + if (!class->p) { 348 + WARN(1, "%s called for class '%s' before it was initialized", 349 + __func__, class->name); 350 + return NULL; 351 + } 353 352 354 353 mutex_lock(&class->p->class_mutex); 355 354 list_for_each_entry(dev, &class->p->class_devices, node) {
+20 -11
drivers/base/core.c
··· 53 53 * it is attached to. If it is not attached to a bus either, an empty 54 54 * string will be returned. 55 55 */ 56 - const char *dev_driver_string(struct device *dev) 56 + const char *dev_driver_string(const struct device *dev) 57 57 { 58 58 return dev->driver ? dev->driver->name : 59 59 (dev->bus ? dev->bus->name : ··· 541 541 spin_lock_init(&dev->devres_lock); 542 542 INIT_LIST_HEAD(&dev->devres_head); 543 543 device_init_wakeup(dev, 0); 544 + device_pm_init(dev); 544 545 set_dev_node(dev, -1); 545 546 } 546 547 ··· 844 843 { 845 844 struct device *parent = NULL; 846 845 struct class_interface *class_intf; 847 - int error; 846 + int error = -EINVAL; 848 847 849 848 dev = get_device(dev); 850 - if (!dev || !strlen(dev->bus_id)) { 851 - error = -EINVAL; 852 - goto Done; 853 - } 849 + if (!dev) 850 + goto done; 851 + 852 + /* Temporarily support init_name if it is set. 853 + * It will override bus_id for now */ 854 + if (dev->init_name) 855 + dev_set_name(dev, "%s", dev->init_name); 856 + 857 + if (!strlen(dev->bus_id)) 858 + goto done; 854 859 855 860 pr_debug("device: '%s': %s\n", dev->bus_id, __func__); 856 861 ··· 904 897 error = bus_add_device(dev); 905 898 if (error) 906 899 goto BusError; 907 - error = device_pm_add(dev); 900 + error = dpm_sysfs_add(dev); 908 901 if (error) 909 - goto PMError; 902 + goto DPMError; 903 + device_pm_add(dev); 910 904 kobject_uevent(&dev->kobj, KOBJ_ADD); 911 905 bus_attach_device(dev); 912 906 if (parent) ··· 925 917 class_intf->add_dev(dev, class_intf); 926 918 mutex_unlock(&dev->class->p->class_mutex); 927 919 } 928 - Done: 920 + done: 929 921 put_device(dev); 930 922 return error; 931 - PMError: 923 + DPMError: 932 924 bus_remove_device(dev); 933 925 BusError: 934 926 if (dev->bus) ··· 952 944 cleanup_device_parent(dev); 953 945 if (parent) 954 946 put_device(parent); 955 - goto Done; 947 + goto done; 956 948 } 957 949 958 950 /** ··· 1015 1007 struct class_interface *class_intf; 1016 1008 1017 1009 device_pm_remove(dev); 1010 + dpm_sysfs_remove(dev); 1018 1011 if (parent) 1019 1012 klist_del(&dev->knode_parent); 1020 1013 if (MAJOR(dev->devt)) {
-3
drivers/base/driver.c
··· 16 16 #include <linux/string.h> 17 17 #include "base.h" 18 18 19 - #define to_dev(node) container_of(node, struct device, driver_list) 20 - 21 - 22 19 static struct device *next_device(struct klist_iter *i) 23 20 { 24 21 struct klist_node *n = klist_next(i);
+5 -14
drivers/base/power/main.c
··· 67 67 * device_pm_add - add a device to the list of active devices 68 68 * @dev: Device to be added to the list 69 69 */ 70 - int device_pm_add(struct device *dev) 70 + void device_pm_add(struct device *dev) 71 71 { 72 - int error; 73 - 74 72 pr_debug("PM: Adding info for %s:%s\n", 75 73 dev->bus ? dev->bus->name : "No Bus", 76 74 kobject_name(&dev->kobj)); 77 75 mutex_lock(&dpm_list_mtx); 78 76 if (dev->parent) { 79 - if (dev->parent->power.status >= DPM_SUSPENDING) { 80 - dev_warn(dev, "parent %s is sleeping, will not add\n", 77 + if (dev->parent->power.status >= DPM_SUSPENDING) 78 + dev_warn(dev, "parent %s should not be sleeping\n", 81 79 dev->parent->bus_id); 82 - WARN_ON(true); 83 - } 84 80 } else if (transition_started) { 85 81 /* 86 82 * We refuse to register parentless devices while a PM ··· 85 89 */ 86 90 WARN_ON(true); 87 91 } 88 - error = dpm_sysfs_add(dev); 89 - if (!error) { 90 - dev->power.status = DPM_ON; 91 - list_add_tail(&dev->power.entry, &dpm_list); 92 - } 92 + 93 + list_add_tail(&dev->power.entry, &dpm_list); 93 94 mutex_unlock(&dpm_list_mtx); 94 - return error; 95 95 } 96 96 97 97 /** ··· 102 110 dev->bus ? dev->bus->name : "No Bus", 103 111 kobject_name(&dev->kobj)); 104 112 mutex_lock(&dpm_list_mtx); 105 - dpm_sysfs_remove(dev); 106 113 list_del_init(&dev->power.entry); 107 114 mutex_unlock(&dpm_list_mtx); 108 115 }
+7 -2
drivers/base/power/power.h
··· 1 + static inline void device_pm_init(struct device *dev) 2 + { 3 + dev->power.status = DPM_ON; 4 + } 5 + 1 6 #ifdef CONFIG_PM_SLEEP 2 7 3 8 /* ··· 16 11 return container_of(entry, struct device, power.entry); 17 12 } 18 13 19 - extern int device_pm_add(struct device *); 14 + extern void device_pm_add(struct device *); 20 15 extern void device_pm_remove(struct device *); 21 16 22 17 #else /* CONFIG_PM_SLEEP */ 23 18 24 - static inline int device_pm_add(struct device *dev) { return 0; } 19 + static inline void device_pm_add(struct device *dev) {} 25 20 static inline void device_pm_remove(struct device *dev) {} 26 21 27 22 #endif
+13
drivers/uio/Kconfig
··· 33 33 34 34 If you don't know what to do here, say N. 35 35 36 + config UIO_PDRV_GENIRQ 37 + tristate "Userspace I/O platform driver with generic IRQ handling" 38 + help 39 + Platform driver for Userspace I/O devices, including generic 40 + interrupt handling code. Shared interrupts are not supported. 41 + 42 + This kernel driver requires that the matching userspace driver 43 + handles interrupts in a special way. Userspace is responsible 44 + for acknowledging the hardware device if needed, and re-enabling 45 + interrupts in the interrupt controller using the write() syscall. 46 + 47 + If you don't know what to do here, say N. 48 + 36 49 config UIO_SMX 37 50 tristate "SMX cryptengine UIO interface" 38 51 default n
+1
drivers/uio/Makefile
··· 1 1 obj-$(CONFIG_UIO) += uio.o 2 2 obj-$(CONFIG_UIO_CIF) += uio_cif.o 3 3 obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o 4 + obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o 4 5 obj-$(CONFIG_UIO_SMX) += uio_smx.o
+3 -1
drivers/uio/uio_pdrv.c
··· 88 88 89 89 uio_unregister_device(pdata->uioinfo); 90 90 91 + kfree(pdata); 92 + 91 93 return 0; 92 94 } 93 95 ··· 116 114 117 115 MODULE_AUTHOR("Uwe Kleine-Koenig"); 118 116 MODULE_DESCRIPTION("Userspace I/O platform driver"); 119 - MODULE_LICENSE("GPL"); 117 + MODULE_LICENSE("GPL v2"); 120 118 MODULE_ALIAS("platform:" DRIVER_NAME);
+188
drivers/uio/uio_pdrv_genirq.c
··· 1 + /* 2 + * drivers/uio/uio_pdrv_genirq.c 3 + * 4 + * Userspace I/O platform driver with generic IRQ handling code. 5 + * 6 + * Copyright (C) 2008 Magnus Damm 7 + * 8 + * Based on uio_pdrv.c by Uwe Kleine-Koenig, 9 + * Copyright (C) 2008 by Digi International Inc. 10 + * All rights reserved. 11 + * 12 + * This program is free software; you can redistribute it and/or modify it 13 + * under the terms of the GNU General Public License version 2 as published by 14 + * the Free Software Foundation. 15 + */ 16 + 17 + #include <linux/platform_device.h> 18 + #include <linux/uio_driver.h> 19 + #include <linux/spinlock.h> 20 + #include <linux/bitops.h> 21 + #include <linux/interrupt.h> 22 + #include <linux/stringify.h> 23 + 24 + #define DRIVER_NAME "uio_pdrv_genirq" 25 + 26 + struct uio_pdrv_genirq_platdata { 27 + struct uio_info *uioinfo; 28 + spinlock_t lock; 29 + unsigned long flags; 30 + }; 31 + 32 + static irqreturn_t uio_pdrv_genirq_handler(int irq, struct uio_info *dev_info) 33 + { 34 + struct uio_pdrv_genirq_platdata *priv = dev_info->priv; 35 + 36 + /* Just disable the interrupt in the interrupt controller, and 37 + * remember the state so we can allow user space to enable it later. 38 + */ 39 + 40 + if (!test_and_set_bit(0, &priv->flags)) 41 + disable_irq_nosync(irq); 42 + 43 + return IRQ_HANDLED; 44 + } 45 + 46 + static int uio_pdrv_genirq_irqcontrol(struct uio_info *dev_info, s32 irq_on) 47 + { 48 + struct uio_pdrv_genirq_platdata *priv = dev_info->priv; 49 + unsigned long flags; 50 + 51 + /* Allow user space to enable and disable the interrupt 52 + * in the interrupt controller, but keep track of the 53 + * state to prevent per-irq depth damage. 54 + * 55 + * Serialize this operation to support multiple tasks. 56 + */ 57 + 58 + spin_lock_irqsave(&priv->lock, flags); 59 + if (irq_on) { 60 + if (test_and_clear_bit(0, &priv->flags)) 61 + enable_irq(dev_info->irq); 62 + } else { 63 + if (!test_and_set_bit(0, &priv->flags)) 64 + disable_irq(dev_info->irq); 65 + } 66 + spin_unlock_irqrestore(&priv->lock, flags); 67 + 68 + return 0; 69 + } 70 + 71 + static int uio_pdrv_genirq_probe(struct platform_device *pdev) 72 + { 73 + struct uio_info *uioinfo = pdev->dev.platform_data; 74 + struct uio_pdrv_genirq_platdata *priv; 75 + struct uio_mem *uiomem; 76 + int ret = -EINVAL; 77 + int i; 78 + 79 + if (!uioinfo || !uioinfo->name || !uioinfo->version) { 80 + dev_err(&pdev->dev, "missing platform_data\n"); 81 + goto bad0; 82 + } 83 + 84 + if (uioinfo->handler || uioinfo->irqcontrol || uioinfo->irq_flags) { 85 + dev_err(&pdev->dev, "interrupt configuration error\n"); 86 + goto bad0; 87 + } 88 + 89 + priv = kzalloc(sizeof(*priv), GFP_KERNEL); 90 + if (!priv) { 91 + ret = -ENOMEM; 92 + dev_err(&pdev->dev, "unable to kmalloc\n"); 93 + goto bad0; 94 + } 95 + 96 + priv->uioinfo = uioinfo; 97 + spin_lock_init(&priv->lock); 98 + priv->flags = 0; /* interrupt is enabled to begin with */ 99 + 100 + uiomem = &uioinfo->mem[0]; 101 + 102 + for (i = 0; i < pdev->num_resources; ++i) { 103 + struct resource *r = &pdev->resource[i]; 104 + 105 + if (r->flags != IORESOURCE_MEM) 106 + continue; 107 + 108 + if (uiomem >= &uioinfo->mem[MAX_UIO_MAPS]) { 109 + dev_warn(&pdev->dev, "device has more than " 110 + __stringify(MAX_UIO_MAPS) 111 + " I/O memory resources.\n"); 112 + break; 113 + } 114 + 115 + uiomem->memtype = UIO_MEM_PHYS; 116 + uiomem->addr = r->start; 117 + uiomem->size = r->end - r->start + 1; 118 + ++uiomem; 119 + } 120 + 121 + while (uiomem < &uioinfo->mem[MAX_UIO_MAPS]) { 122 + uiomem->size = 0; 123 + ++uiomem; 124 + } 125 + 126 + /* This driver requires no hardware specific kernel code to handle 127 + * interrupts. Instead, the interrupt handler simply disables the 128 + * interrupt in the interrupt controller. User space is responsible 129 + * for performing hardware specific acknowledge and re-enabling of 130 + * the interrupt in the interrupt controller. 131 + * 132 + * Interrupt sharing is not supported. 133 + */ 134 + 135 + uioinfo->irq_flags = IRQF_DISABLED; 136 + uioinfo->handler = uio_pdrv_genirq_handler; 137 + uioinfo->irqcontrol = uio_pdrv_genirq_irqcontrol; 138 + uioinfo->priv = priv; 139 + 140 + ret = uio_register_device(&pdev->dev, priv->uioinfo); 141 + if (ret) { 142 + dev_err(&pdev->dev, "unable to register uio device\n"); 143 + goto bad1; 144 + } 145 + 146 + platform_set_drvdata(pdev, priv); 147 + return 0; 148 + bad1: 149 + kfree(priv); 150 + bad0: 151 + return ret; 152 + } 153 + 154 + static int uio_pdrv_genirq_remove(struct platform_device *pdev) 155 + { 156 + struct uio_pdrv_genirq_platdata *priv = platform_get_drvdata(pdev); 157 + 158 + uio_unregister_device(priv->uioinfo); 159 + kfree(priv); 160 + return 0; 161 + } 162 + 163 + static struct platform_driver uio_pdrv_genirq = { 164 + .probe = uio_pdrv_genirq_probe, 165 + .remove = uio_pdrv_genirq_remove, 166 + .driver = { 167 + .name = DRIVER_NAME, 168 + .owner = THIS_MODULE, 169 + }, 170 + }; 171 + 172 + static int __init uio_pdrv_genirq_init(void) 173 + { 174 + return platform_driver_register(&uio_pdrv_genirq); 175 + } 176 + 177 + static void __exit uio_pdrv_genirq_exit(void) 178 + { 179 + platform_driver_unregister(&uio_pdrv_genirq); 180 + } 181 + 182 + module_init(uio_pdrv_genirq_init); 183 + module_exit(uio_pdrv_genirq_exit); 184 + 185 + MODULE_AUTHOR("Magnus Damm"); 186 + MODULE_DESCRIPTION("Userspace I/O platform driver with generic IRQ handling"); 187 + MODULE_LICENSE("GPL v2"); 188 + MODULE_ALIAS("platform:" DRIVER_NAME);
+3 -2
include/linux/device.h
··· 358 358 359 359 struct kobject kobj; 360 360 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 361 + const char *init_name; /* initial name of the device */ 361 362 struct device_type *type; 362 363 unsigned uevent_suppress:1; 363 364 ··· 407 406 /* Get the wakeup routines, which depend on struct device */ 408 407 #include <linux/pm_wakeup.h> 409 408 410 - static inline const char *dev_name(struct device *dev) 409 + static inline const char *dev_name(const struct device *dev) 411 410 { 412 411 /* will be changed into kobject_name(&dev->kobj) in the near future */ 413 412 return dev->bus_id; ··· 519 518 extern void sysdev_shutdown(void); 520 519 521 520 /* debugging and troubleshooting/diagnostic helpers. */ 522 - extern const char *dev_driver_string(struct device *dev); 521 + extern const char *dev_driver_string(const struct device *dev); 523 522 #define dev_printk(level, dev, format, arg...) \ 524 523 printk(level "%s %s: " format , dev_driver_string(dev) , \ 525 524 dev_name(dev) , ## arg)
+1 -2
lib/kobject.c
··· 223 223 return -ENOMEM; 224 224 225 225 /* ewww... some of these buggers have '/' in the name ... */ 226 - s = strchr(kobj->name, '/'); 227 - if (s) 226 + while ((s = strchr(kobj->name, '/'))) 228 227 s[0] = '!'; 229 228 230 229 kfree(old_name);
+11 -5
scripts/mod/file2alias.c
··· 344 344 struct module *mod) 345 345 { 346 346 const unsigned long id_size = sizeof(struct pnp_device_id); 347 - const struct pnp_device_id *id = symval; 347 + const unsigned int count = (size / id_size)-1; 348 + const struct pnp_device_id *devs = symval; 349 + unsigned int i; 348 350 349 351 device_id_check(mod->name, "pnp", size, id_size, symval); 350 352 351 - buf_printf(&mod->dev_table_buf, 352 - "MODULE_ALIAS(\"pnp:d%s*\");\n", id->id); 353 - buf_printf(&mod->dev_table_buf, 354 - "MODULE_ALIAS(\"acpi*:%s:*\");\n", id->id); 353 + for (i = 0; i < count; i++) { 354 + const char *id = (char *)devs[i].id; 355 + 356 + buf_printf(&mod->dev_table_buf, 357 + "MODULE_ALIAS(\"pnp:d%s*\");\n", id); 358 + buf_printf(&mod->dev_table_buf, 359 + "MODULE_ALIAS(\"acpi*:%s:*\");\n", id); 360 + } 355 361 } 356 362 357 363 /* looks like: "pnp:dD" for every device of the card */