timer interrupt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
   I am writing a module that prints a message when ever a timer issues
an interrupt.Any way system timer issues an interrupt after 'tick rate'
and then kernel handles the interrupt handler.But it is not working in
my module.
Will you please tell me wht is wrong with it?
My code is as follows







#ifndef __KERNEL__
	#define __KERNEL__
#endif

#ifndef MODULE
	#define MODULE
#endif

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/interrupt.h>

MODULE_AUTHOR("RAJA");
MODULE_DESCRIPTION("TIMER INTERRUPT");
MODULE_LICENSE("GPL");

#define DEVICE_NAME "timer_interrupt"
#define TIMER_INTERRUPT 8
static int __init init_timer_interrupt(void);
static void __exit exit_timer_interrupt(void);

static irqreturn_t timer_interrupt_handler(unsigned int,void *, struct pt_regs *);

int devNo;
struct file_operations fops = {};

static irqreturn_t timer_interrupt_handler(unsigned int irq,void *data, struct pt_regs *regs)
{
	printk("Timer Interrup Occured\n");
	return 0;
}

static int __init init_timer_interrupt()
{
	printk("Entered Into init_timer\n");
	devNo = register_chrdev(0,DEVICE_NAME,&fops);
	request_irq(TIMER_INTERRUPT,timer_interrupt_handler,SA_SHIRQ,DEVICE_NAME,&devNo);
	printk("Exited From init_timer\n");	
	return 0;
}

static void __exit exit_timer_interrupt()
{
	printk("Entered Into exit_timer\n");
	unregister_chrdev(devNo,DEVICE_NAME);
	free_irq(TIMER_INTERRUPT,&devNo);
	printk("Exited From exit_timer\n");
}

module_init(init_timer_interrupt);
module_exit(exit_timer_interrupt);


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux