Search code examples
device-driverkernel-modulekernel

Error during creation of Proc entry


I want to create a Proc entry in an USB driver code , but I'm getting the error as implicit function declaration of function 'create_proc_read_entry' and 'remove_proc_entry' .

I have followed similar steps in the scull driver code in order to create the proc entry as specified in the Linux device drivers text, but I'm getting the two errors above while compiling through makefile .

I'm compiling the code on ubuntu 12.04 kernel version is 3.2.0-23-generic-pae. I have made small edits to the existing driver code and below is the code snippet. Please let me know if any other details are needed .

   #include <linux/module.h>
   #include <linux/kernel.h>
   #include <linux/version.h>
   #include <linux/usb.h>
   #include <linux/mutex.h>
   #include <linux/errno.h>
   #include <linux/slab.h>
   #include <linux/cdev.h>
   #include <asm/uaccess.h>
   #ifdef ENABLE_FILE_OPS
   #include <asm/atomic.h>
   #include <linux/proc_fs.h> 
   #endif
   #include "ddk_mem.h"
   #include "usb_proc.h"
   #define PROC_DEBUG

   #ifdef PROC_DEBUG 
   int read_proc(char *buf, char **start, off_t offset,
               int count, int *eof, void *data)

    {
       int len=0;

       len  += sprintf(buf+len, "Hello world");

       *eof=1;
       return len;
    }

    static void usb_mem_create_proc(void )
    {
       create_proc_read_entry("hello",0,NULL,read_proc,NULL);

    }

   static void usb_mem_remove_proc(void)
   {
      remove_proc_entry("hello",NULL);
   }

   #endif

Solution

  • The ifdef block when removed will allow you to create proc entry.