LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-24-2008, 10:05 AM   #1
ben85
LQ Newbie
 
Registered: Jan 2008
Posts: 1

Rep: Reputation: 0
Newbie to device driver programming


Hello,

I am fairly new to linux and new to device driver programming. I have a fresh install of ubuntu 6.0.6 and decided to start off with a small program that dosent do nothing, but i cant even get that to work

I havent done anything to the system yet besides install GNU make. When i call make, i get the following error.

make: Nothing to be done for `default'.

Could someone please head me onto the right track? I added the source code and the makefile after the message. And please try make it dummy proof :/ , I know the basics of linux but nothing really advanced.

Thanks in advances

My source code is.
=========================================================================
#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/cdev.h>

MODULE_AUTHOR("none");
MODULE_DESCRIPTION("driver_lab1");
MODULE_SUPPORTED_DEVICE("none");
MODULE_LICENSE("none");
MODULE_PARM_DESC(major, "major number");

static int major = 240;

module_param(major, int, 0);

static ssize_t my_read_function(struct file *file, char *buf, size_t count, loff_t *ppos)
{
printk(KERN_DEBUG "read()\n");
return 0;
}

static ssize_t my_write_function(struct file *file, const char *buf, size_t count, loff_t *ppos)
{
printk(KERN_DEBUG "write()\n");
return 0;
}

static int my_open_function(struct inode *inode, struct file *file)
{
printk(KERN_DEBUG "open()\n");
return 0;
}

static int my_release_function(struct inode *inode, struct file *file)
{
printk(KERN_DEBUG "close()\n");
return 0;
}

static struct file_operations fops =
{
.owner = THIS_MODULE,
.read = my_read_function,
.write = my_write_function,
.open = my_open_function,
.release = my_release_function /* correspond a close */
};

static struct cdev ccdev;

static void cdevinit (struct cdev *dev, struct file_operations *fops)
{
int err, devno = MKDEV(major,0);
cdev_init(dev, fops);
dev->owner = THIS_MODULE;
dev->ops = fops;
err = cdev_add(dev, devno, 1);
if (err)
printk (KERN_DEBUG "erreur dans cdevinit");
}

static int __init mon_module_init(void)
{
int result = register_chrdev_region(major ,1,"driver_lab1");
if(result)
printk(KERN_DEBUG "driver_lab1 non chargé\n");
else
printk(KERN_DEBUG "driver_lab1 chargé avec succès\n");

cdevinit(&ccdev, &fops);

return 0;
}

static void __exit mon_module_cleanup(void)
{
unregister_chrdev_region(major, 1);
printk(KERN_DEBUG "driver_lab1 déchargé avec succès\n");
}

module_init(mon_module_init);
module_exit(mon_module_cleanup);
========================================================================

My makefile is
========================================================================

ifneq ($(KERNELRELEASE),)
obj-m := lab1.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
========================================================================
 
Old 01-24-2008, 04:48 PM   #2
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Try this line instead

default:
$(MAKE) -C $(KDIR) SUBDIR
 
  


Reply



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
device driver programming rebel_angel Linux - Hardware 5 11-30-2006 04:48 AM
simple test circuit to learn kernel device driver programming slzckboy Programming 3 01-30-2006 02:12 AM
Linux device driver programming iammisc Programming 1 11-26-2005 10:46 AM
linux device driver programming chandansingh Programming 1 03-26-2005 07:30 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:15 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
Open Source Consulting | Domain Registration