LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-07-2008, 03:25 AM   #1
pintu_agarwal
LQ Newbie
 
Registered: Jul 2008
Posts: 1

Rep: Reputation: 0
Linux - 2.6 - Device Driver - using multiple C files


Hi,

I have written a simple char driver(mychar) for linux 2.6.22 kernel.
I have split my driver code into 2 C files.
- mychar.c (main file where __init is present)
- test1.c (some user defined function)

I am using Makefile for compilation.
My makefile looks like this -
------------------------------------------------------------
EXTRA_CFLAGS += -I. -ITEST

obj-m += mychar.o
mychar-objs += TEST/test1.o

KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

all:
$(MAKE) -C $(KDIR) M=$(PWD) modules

clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean
---------------------------------------------------------------

I am interested in building only mychar.ko and no the whole kernel.
I am doing my development on Ubuntu 7.10 with kernel version 2.6.22-14-generic

Although this Makefile works and I could able to generate "mychar.ko". Also when I do "insmod mychar.ko" the module installs successfully, and I could see "mychar" in "lsmod" output.
(But could not find it in - /proc/devices)
I have added some printk in my module_init function but after doing insmod I am not able to see any output in /var/log/messages

If I put everything in single C file(only mychar.c), I could able to see all the output in /var/log/messages.

Please let me know what am I doing wrong while including the 2 C files and how should the makefile be modified.
( I have referred Documentation/kbuild makefiles.txt for creating my makefile)


Thanks, Regards
Pintu
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Device driver from single device driver???? rickhg12hs Linux - Kernel 3 05-25-2008 01:11 AM
Linux Device Driver malacma Linux - Software 10 10-09-2007 07:14 AM
uclinux custom device driver not loading, possibly multiple problems godzilla Linux - Kernel 12 09-10-2007 07:39 PM
linux device driver faris10 Linux - Kernel 4 07-25-2007 10:51 AM
Kdoc2 unable to generate html doc files of e1000 device driver ahm_irf Linux - Software 0 02-13-2007 08:59 AM


All times are GMT -5. The time now is 06:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration