platform_driver_register를 통해 등록한 driver중 probe 함수는 언제 호출이 되나요?

lmk378의 이미지

watchdog 관련 driver를 보던중 궁금하여 질문드립니다.
platform_driver_register를 통해 driver 등록 후 등록된 probe함수는 언제 호출되는 건가요?

ihavnoth의 이미지

커널 소스의 init/main.c에서

asmlinkage void __init start_kernel(void)
static noinline void __init_refok rest_init(void)
static int __init kernel_init(void * unused)
static void __init do_basic_setup(void)
static void __init do_initcalls(void)

static void __init do_initcalls(void) 펑션을 보시면

initcall 펑션들을 차례대로 수행하고 있습니다.

여기서 initcall 펑션들은 System.map파일에서 __initcall_로 시작되는 펑션들입니다.

보통 빌트인 코드의 경우 module_init(x), __initcall(x), device_initcall(x)로 등록됩니다.

printk로 확인해보실려면

해당 probe 펑션이 어떤 initcall에 등록돼있는지 불확실하시면

do_initcalls(void)에서 펑션 주소 출력하신 후 해당 probe 펑션전에 호출된 initcall 펑션 주소를

System.map에서 찾아보시면 됩니다.

779 static void __init do_initcalls(void)
- 780 {
| 781 initcall_t *fn;
| 782
|- 783 for (fn = __early_initcall_end; fn < __initcall_end; fn++) {
|| 784 printk(KERN_INFO "%s: %08x\n", __func__, fn);
|| 785 do_one_initcall(*fn);
|| 786 }
| 787
| 788 /* Make sure there is no pending stuff from the initcall sequence */
| 789 flush_scheduled_work();
| 790 }

없음

lmk378의 이미지

답변 감사합니다
일단 모듈이기 때문에 do_initcals에서 실행되지는 않습니다.
제가 그냥 insmod시키는 거구요^^;;
제가 궁금한건 probe를 어디서 등록해주느냐가 아니구 probe를 언제 실행하느냐 입니다.

추가할게요^^;;
지금 구현하려 하는것은 watchdog을 통해 시스템을 강제종료할 수 있는 driver를 만들고 싶습니다.
kernel에 built in하면 안되구요 모듈로 작성해야 합니다.
일단 base system은 ARM cortex a9계열이구요
참고를 하기 위해 s3c2410_wdt.c driver를 보던중 module_init을 통해 등록한 드라이버중
probe 함수를 언제 호출하는지가 궁금하여 질문드립니다.

ihavnoth의 이미지

최종적으로 device_initcall(x)에서 등록하고
do_one_initcall(*fn)에서 실행한다고 글을 쓴다고 썼는데 소통이 잘 안된거 같네요

builtin하실거 아니고 kernel module일 경우는

insmod 유틸 -> 시스템콜 init_module -> do_one_initcall(mod->init) 순서로 실행됩니다.

없음

furmuwon의 이미지

probe 가 있는 file 내에 register_driver 함수가 있을텐데요

register_driver 함수 호출 한 뒤 이 함수 루틴중에 호출 됩니다.

register_driver 의 내부적으로는 register_driver 를 호출 하면

같은 이름 혹은 비슷한 이름으로 된 등록된 device 를 찾고
( s3c244x_watch_dog:device name, s3c244x_watch_dog:driver name )

device 가 있다면 driver 의 probe 를 호출 합니다.

그 뒤에 sysfs 구성 하던가.. 그렇습니다.

lmk378의 이미지

답변 감사합니다.
driver_register 말씀하신거죠?^^;;
근데 device를 찾으면 probe를 하는 부분이 어디인가요?
제가 못찾은건가요?흠;;

익명 사용자의 이미지

이름도 헷갈렸네요 ㅎㅎ
분석하고자 하신다면 함수를 따라서
쭈욱 찾아 가시면 나옵니다
제가 현재는 소스를 볼수 있는 상황이 아니라
정확히 어디 인지는 모르겠네요

lmk378의 이미지

우왕..ㅠㅠ도저히 못찾겠습니다.
근데 probe가 수행되는것 같지 않아요~ probe에 DBG 찍어놨는데
출력이 안되는데요? platform_driver_register 함수도 0을 리턴하는걸로 봐서
정상적으로 등록된거 같은데~

pastime의 이미지

bus의 drivers_autoprobe 속성이 1이면
register 시 driver_attach() 함수가 호출됩니다.

3.2-rc4 커널 기준으로 다음과 같은 과정이 수행됩니다.

platform_driver_register
  driver_register
    bus_add_driver
      driver_attach (__driver_attach)
        driver_probe_device
          really_probe
lmk378의 이미지

감사합니다. 잘 찾았어요^^
근데 왜 probe는 수행되지 않을까요?ㅠ

익명 사용자의 이미지

위에 말씀들 중에 답이 있는것 같습니다
드라이버 가 등록 될때 같은 이름의 디바이스가 있어야
합니다 디바이스는 등록을 하셨나요?

제가 추측컨데 같은 이름의 디바이스가 없을 것으로
생각됩니다

이것과 반대로 디바이스를 추가할때도
같은 이름의 드라이버가 있으면
드라이버의 probe를 호출 할 것입니다(추측)

지나가의 이미지

같은 이름의 디바이스 없어도 됩니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.