Writing Linux Device Drivers


Kernel Hacker's Guide


Naming



Functions Needed


For driver "lp":
int lp_reset(int minor)
static int lp_char_polled(char lpchar, int minor)
static int lp_char_interrupt(char lpchar, int minor)
static void lp_interrupt(int irq, struct pt_regs *regs)
static int lp_write_interrupt(struct inode * inode, struct file * file, char * b
uf, int count)
static int lp_write_polled(struct inode * inode, struct file * file,
                           char * buf, int count)
static int lp_write(struct inode * inode, struct file * file, char * buf, int co
unt)
static int lp_lseek(struct inode * inode, struct file * file,
                    off_t offset, int origin)
static int lp_open(struct inode * inode, struct file * file)
static void lp_release(struct inode * inode, struct file * file)
static int lp_ioctl(struct inode *inode, struct file *file,
                    unsigned int cmd, unsigned long arg)
static struct file_operations lp_fops = {
        lp_lseek,
        NULL,           /* lp_read */
        lp_write,
        NULL,           /* lp_readdir */
        NULL,           /* lp_select */
        lp_ioctl,
        NULL,           /* lp_mmap */
        lp_open,
        lp_release
};
#ifndef MODULE

long lp_init(long kmem_start)
#else

char kernel_version[]= UTS_RELEASE;

int init_module(void)
void cleanup_module(void)


For driver "mouse"
static int mouse_open(struct inode * inode, struct file * file)
static struct file_operations mouse_fops = {
        NULL,           /* seek */
        NULL,           /* read */
        NULL,           /* write */
        NULL,           /* readdir */
        NULL,           /* select */
        NULL,           /* ioctl */
        NULL,           /* mmap */
        mouse_open,
        NULL            /* release */
};
unsigned long mouse_init(unsigned long kmem_start)

For driver "serial"
static inline int serial_paranoia_check(struct async_struct *info,
                                        dev_t device, const char *routine)
static inline unsigned int serial_in(struct async_struct *info, int offset)
static inline unsigned int serial_inp(struct async_struct *info, int offset)
static inline void serial_out(struct async_struct *info, int offset, int value)
static inline void serial_outp(struct async_struct *info, int offset,
                               int value)
static void rs_stop(struct tty_struct *tty)
static void rs_start(struct tty_struct *tty)
static void rs_probe(int irq, struct pt_regs * regs)
static _INLINE_ void rs_sched_event(struct async_struct *info,
                                  int event)
static _INLINE_ void receive_chars(struct async_struct *info,
                                 int *status)
static _INLINE_ void transmit_chars(struct async_struct *info, int *intr_done)
static _INLINE_ void check_modem_status(struct async_struct *info)
static void rs_interrupt(int irq, struct pt_regs * regs)
static void rs_interrupt_single(int irq, struct pt_regs * regs)
static void rs_interrupt_multi(int irq, struct pt_regs * regs)
static void do_serial_bh(void *unused)
static void do_softint(void *private_)
static void do_serial_hangup(void *private_)
static void rs_timer(void)
static int grab_all_interrupts(int dontgrab)
static void free_all_interrupts(int irq_lines)
static void figure_IRQ_timeout(int irq)
static int startup(struct async_struct * info)
static void shutdown(struct async_struct * info)
static void change_speed(struct async_struct *info)
static void rs_put_char(struct tty_struct *tty, unsigned char ch)
static void rs_flush_chars(struct tty_struct *tty)
static int rs_write(struct tty_struct * tty, int from_user,
                    unsigned char *buf, int count)
static int rs_write_room(struct tty_struct *tty)
static int rs_chars_in_buffer(struct tty_struct *tty)
static void rs_flush_buffer(struct tty_struct *tty)
static void rs_throttle(struct tty_struct * tty)
static void rs_unthrottle(struct tty_struct * tty)
static int get_serial_info(struct async_struct * info,
static int set_serial_info(struct async_struct * info,
                           struct serial_struct * new_info)
static int get_lsr_info(struct async_struct * info, unsigned int *value)
static int get_modem_info(struct async_struct * info, unsigned int *value)
static int set_modem_info(struct async_struct * info, unsigned int cmd,
                          unsigned int *value)
static int do_autoconfig(struct async_struct * info)
static void send_break( struct async_struct * info, int duration)
static int check_wild_interrupts(int doprint)
static int get_multiport_struct(struct async_struct * info,
                                struct serial_multiport_struct *retinfo)
static int set_multiport_struct(struct async_struct * info,
                                struct serial_multiport_struct *in_multi)
static int rs_ioctl(struct tty_struct *tty, struct file * file,
                    unsigned int cmd, unsigned long arg)
static void rs_set_termios(struct tty_struct *tty, struct termios *old_termios)
static void rs_close(struct tty_struct *tty, struct file * filp)
void rs_hangup(struct tty_struct *tty)
static int block_til_ready(struct tty_struct *tty, struct file * filp,
                           struct async_struct *info)
int rs_open(struct tty_struct *tty, struct file * filp)
static void show_serial_version(void)
static int get_auto_irq(struct async_struct *info)
static int do_auto_irq(struct async_struct * info)
static void autoconfig(struct async_struct * info)
long rs_init(long kmem_start)
int register_serial(struct serial_struct *req)
void unregister_serial(int line)