Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: diva_didd.c,v 1.13.6.4 2005/02/11 19:40:25 armin Exp $ |
| 2 | * |
| 3 | * DIDD Interface module for Eicon active cards. |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame^] | 4 | * |
| 5 | * Functions are in dadapter.c |
| 6 | * |
| 7 | * Copyright 2002-2003 by Armin Schindler (mac@melware.de) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * Copyright 2002-2003 Cytronics & Melware (info@melware.de) |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame^] | 9 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * This software may be used and distributed according to the terms |
| 11 | * of the GNU General Public License, incorporated herein by reference. |
| 12 | */ |
| 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/module.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/kernel.h> |
| 17 | #include <linux/proc_fs.h> |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 18 | #include <linux/seq_file.h> |
Eric W. Biederman | 457c4cb | 2007-09-12 12:01:34 +0200 | [diff] [blame] | 19 | #include <net/net_namespace.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
| 21 | #include "platform.h" |
| 22 | #include "di_defs.h" |
| 23 | #include "dadapter.h" |
| 24 | #include "divasync.h" |
| 25 | #include "did_vers.h" |
| 26 | |
| 27 | static char *main_revision = "$Revision: 1.13.6.4 $"; |
| 28 | |
| 29 | static char *DRIVERNAME = |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame^] | 30 | "Eicon DIVA - DIDD table (http://www.melware.net)"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | static char *DRIVERLNAME = "divadidd"; |
| 32 | char *DRIVERRELEASE_DIDD = "2.0"; |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | MODULE_DESCRIPTION("DIDD table driver for diva drivers"); |
| 35 | MODULE_AUTHOR("Cytronics & Melware, Eicon Networks"); |
| 36 | MODULE_SUPPORTED_DEVICE("Eicon diva drivers"); |
| 37 | MODULE_LICENSE("GPL"); |
| 38 | |
| 39 | #define DBG_MINIMUM (DL_LOG + DL_FTL + DL_ERR) |
| 40 | #define DBG_DEFAULT (DBG_MINIMUM + DL_XLOG + DL_REG) |
| 41 | |
| 42 | extern int diddfunc_init(void); |
| 43 | extern void diddfunc_finit(void); |
| 44 | |
| 45 | extern void DIVA_DIDD_Read(void *, int); |
| 46 | |
| 47 | static struct proc_dir_entry *proc_didd; |
| 48 | struct proc_dir_entry *proc_net_eicon = NULL; |
| 49 | |
| 50 | EXPORT_SYMBOL(DIVA_DIDD_Read); |
| 51 | EXPORT_SYMBOL(proc_net_eicon); |
| 52 | |
| 53 | static char *getrev(const char *revision) |
| 54 | { |
| 55 | char *rev; |
| 56 | char *p; |
| 57 | if ((p = strchr(revision, ':'))) { |
| 58 | rev = p + 2; |
| 59 | p = strchr(rev, '$'); |
| 60 | *--p = 0; |
| 61 | } else |
| 62 | rev = "1.0"; |
| 63 | return rev; |
| 64 | } |
| 65 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 66 | static int divadidd_proc_show(struct seq_file *m, void *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | char tmprev[32]; |
| 69 | |
| 70 | strcpy(tmprev, main_revision); |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 71 | seq_printf(m, "%s\n", DRIVERNAME); |
| 72 | seq_printf(m, "name : %s\n", DRIVERLNAME); |
| 73 | seq_printf(m, "release : %s\n", DRIVERRELEASE_DIDD); |
| 74 | seq_printf(m, "build : %s(%s)\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame^] | 75 | diva_didd_common_code_build, DIVA_BUILD); |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 76 | seq_printf(m, "revision : %s\n", getrev(tmprev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 78 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | } |
| 80 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 81 | static int divadidd_proc_open(struct inode *inode, struct file *file) |
| 82 | { |
| 83 | return single_open(file, divadidd_proc_show, NULL); |
| 84 | } |
| 85 | |
| 86 | static const struct file_operations divadidd_proc_fops = { |
| 87 | .owner = THIS_MODULE, |
| 88 | .open = divadidd_proc_open, |
| 89 | .read = seq_read, |
| 90 | .llseek = seq_lseek, |
| 91 | .release = single_release, |
| 92 | }; |
| 93 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | static int DIVA_INIT_FUNCTION create_proc(void) |
| 95 | { |
Eric W. Biederman | 457c4cb | 2007-09-12 12:01:34 +0200 | [diff] [blame] | 96 | proc_net_eicon = proc_mkdir("eicon", init_net.proc_net); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
| 98 | if (proc_net_eicon) { |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 99 | proc_didd = proc_create(DRIVERLNAME, S_IRUGO, proc_net_eicon, |
| 100 | &divadidd_proc_fops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | return (1); |
| 102 | } |
| 103 | return (0); |
| 104 | } |
| 105 | |
Sam Ravnborg | 162dd3b | 2007-06-01 00:47:11 -0700 | [diff] [blame] | 106 | static void remove_proc(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | { |
| 108 | remove_proc_entry(DRIVERLNAME, proc_net_eicon); |
Eric W. Biederman | 457c4cb | 2007-09-12 12:01:34 +0200 | [diff] [blame] | 109 | remove_proc_entry("eicon", init_net.proc_net); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | static int DIVA_INIT_FUNCTION divadidd_init(void) |
| 113 | { |
| 114 | char tmprev[32]; |
| 115 | int ret = 0; |
| 116 | |
| 117 | printk(KERN_INFO "%s\n", DRIVERNAME); |
| 118 | printk(KERN_INFO "%s: Rel:%s Rev:", DRIVERLNAME, DRIVERRELEASE_DIDD); |
| 119 | strcpy(tmprev, main_revision); |
| 120 | printk("%s Build:%s(%s)\n", getrev(tmprev), |
| 121 | diva_didd_common_code_build, DIVA_BUILD); |
| 122 | |
| 123 | if (!create_proc()) { |
| 124 | printk(KERN_ERR "%s: could not create proc entry\n", |
| 125 | DRIVERLNAME); |
| 126 | ret = -EIO; |
| 127 | goto out; |
| 128 | } |
| 129 | |
| 130 | if (!diddfunc_init()) { |
| 131 | printk(KERN_ERR "%s: failed to connect to DIDD.\n", |
| 132 | DRIVERLNAME); |
| 133 | #ifdef MODULE |
| 134 | remove_proc(); |
| 135 | #endif |
| 136 | ret = -EIO; |
| 137 | goto out; |
| 138 | } |
| 139 | |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame^] | 140 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | return (ret); |
| 142 | } |
| 143 | |
| 144 | static void DIVA_EXIT_FUNCTION divadidd_exit(void) |
| 145 | { |
| 146 | diddfunc_finit(); |
| 147 | remove_proc(); |
| 148 | printk(KERN_INFO "%s: module unloaded.\n", DRIVERLNAME); |
| 149 | } |
| 150 | |
| 151 | module_init(divadidd_init); |
| 152 | module_exit(divadidd_exit); |