Find the answer to your Linux question:
Results 1 to 3 of 3
Good Day, A very simple hello world kind of module. It does print message from init and exit routine but from with in probe() function it won't print ant thing. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2008
    Posts
    2

    Printk won't "print" from probe() ::::A hello world module-pci device


    Good Day,

    A very simple hello world kind of module.
    It does print message from init and exit routine but from with in probe() function it won't print ant thing.

    I suspect probe wont get executed.

    Code:
    #include <linux/module.h>       /* Needed by all modules */
    #include <linux/kernel.h>       /* Needed for KERN_INFO */
    #include<linux/pci.h>
    
    #define MY_VENDOR_ID  0x109e
    #define MY_DEVICE_ID  0x036e
    
    struct pci_device_id my_driver_pci_table[] __devinitdata = {
      {
       MY_VENDOR_ID,
       PCI_ANY_ID,
       MY_DEVICE_ID,
        0,0
      }, {0},
    };
    
    static int __devinit  my_driver_probe(struct pci_dev *pdev, const struct pci_device_id *id)
         {
            pci_enable_device(pdev);
            printk("--------------------------------\n");
            printk("message from inside of probe function \n\n");
            printk("--------------------------------\n");
    
          }
    
    
    struct pci_driver  my_pci_driver = {
         .name = "mydrv",
         .probe = my_driver_probe,
    //   .remove = __devexit_p(my_driver_remove),
         .id_table = my_driver_pci_table,
         };
    
    static int __init my_driver_init(void)
         {
             pci_register_driver(&my_pci_driver);
             printk("--------------------------------\n");
             printk("Msg from init fonction\n\n");
             printk("--------------------------------\n");
             return 0;
         }
    
    static void __exit my_driver_exit(void)
        {
        pci_unregister_driver(&my_pci_driver);
        printk("un registering hello-1\n");
        }
    
    
    module_init(my_driver_init);
    module_exit(my_driver_exit);
    MODULE_DEVICE_TABLE(pci,my_driver_pci_table);
    output from /var/log/message

    Code:
    [root@ku backup]# tail -n 10 /var/log/messages 
    Aug 12 14:45:36 ku kernel: --------------------------------
    Aug 12 14:46:39 ku kernel: un registering hello-1--------------------------------
    Aug 12 14:46:39 ku kernel: Msg from init fonction
    Aug 12 14:46:39 ku kernel: 
    Aug 12 14:46:39 ku kernel: --------------------------------
    Aug 12 14:55:12 ku kernel: un registering hello-1
    Aug 12 14:56:49 ku kernel: --------------------------------
    Aug 12 14:56:49 ku kernel: Msg from init fonction
    Aug 12 14:56:49 ku kernel: 
    Aug 12 14:56:49 ku kernel: --------------------------------
    [root@ku backup]#
    Thanks.

  2. #2
    Just Joined!
    Join Date
    Aug 2008
    Posts
    9

    printk - not printing from probe()

    Hi,

    I am using Fedora 9 -> bought a cd version and installed and i could not find the module.h and kernel.h that contains the necessary interfaces,
    printk, init_module(), etc.,

    Should i download a new kernel from the kernel tree and recompile ?

  3. #3
    Just Joined!
    Join Date
    Aug 2008
    Posts
    2
    In the link below,
    Follow the instruction under "kernel source" + "kernel header" and installe kenel source and kernel header.
    :
    Personal Fedora 9 Installation Guide


    You need to have those 2 in order to build modules.
    Fedore doesn't ship kernel source.

    Thanks.

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •