0

So, I am trying to modify evdev.c, which is an event handler driver for input devices like mouse on linux.

The problem I am having is that when I try to compile the module, I get a ton of errors saying the members of evdev cannot be found.

/home/mousedev_dbl.c:215: error: ‘struct evdev’ has no member named ‘client_lock’
/home/mousedev_dbl.c:216: error: ‘struct evdev’ has no member named ‘client_list’
/hom/mousedev_dbl.c:217: error: ‘struct evdev’ has no member named ‘client_lock’
/home/mousedev_dbl.c: In function ‘evdev_detach_client’:
/home/mousedev_dbl.c:224: error: ‘struct evdev’ has no member named ‘client_lock’
/home/mousedev_dbl.c:226: error: ‘struct evdev’ has no member named ‘client_lock’
/home/mousedev_dbl.c: In function ‘evdev_open_device’:
/home/mousedev_dbl.c:234: error: ‘struct evdev’ has no member named ‘mutex’
/home/mousedev_dbl.c:238: error: ‘struct evdev’ has no member named ‘exist’

This is only a small portion of the errors.

The struct for evdev is clearly present in the mousedev_dbl.c files I am compiling.

struct evdev {
      int open;
      int minor;
      struct input_handle handle;
      wait_queue_head_t wait;
      struct evdev_client __rcu *grab;
      struct list_head client_list;
      spinlock_t client_lock; /* protects client_list */
      struct mutex mutex;
      struct device dev;
      bool exist;
};

As an example, here is how it is used on line 215.

spin_lock(&evdev->client_lock);
list_add_tail_rcu(&client->node, &evdev->client_list);
spin_unlock(&evdev->client_lock);
synchronize_rcu();

What would cause these errors?? The entire file can be found here: http://lxr.free-electrons.com/source/drivers/input/evdev.c

Claudio
  • 10,614
  • 4
  • 31
  • 71
user623879
  • 4,066
  • 9
  • 38
  • 53
  • Which is your OS? If it is Ubuntu you might try 'apt-get build-dep ' and then 'apt-get source -b ', they will take care of everything necessary for a package to compile – sashoalm Apr 01 '11 at 06:34
  • Using ubuntu, but were not talking about packages. I have everything I need to compile under /usr/include/linux. The problem is that the compiler doesn't seem to find the members of the struct that is located in the file I wish to compile. – user623879 Apr 01 '11 at 06:42
  • It seems that you don't have appropriate headers in path. It may depend on your distribution but you'll need to have package like kernel-dev or kernel-headers installed. – Maciej Apr 01 '11 at 08:51
  • /usr/include is for userspace - not kernel modules. – user611775 Apr 03 '11 at 00:23

3 Answers3

0

__rcu is defined in include/linux/compiler.h as

# define __rcu          __attribute__((noderef, address_space(4)))
LeoChu
  • 726
  • 6
  • 6
0
struct evdev_client __rcu *grab;

Is this declaration valid? (Doesn't look like to me, unless __rcu is for the preprocessor).

Seems this declaration is rendering the rest of your struct evdev garbled. Which could explain the compiler not identifying the client_list, client_lock etc.

s_b
  • 501
  • 5
  • 16
0

The problem was that I was using the kernel source from the wrong version. 2.6.38 rather than 2.6.35 so the headers and the source were not mixing well.

user623879
  • 4,066
  • 9
  • 38
  • 53