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. |
| 4 | * |
| 5 | * Functions are in dadapter.c |
| 6 | * |
| 7 | * Copyright 2002-2003 by Armin Schindler (mac@melware.de) |
| 8 | * Copyright 2002-2003 Cytronics & Melware (info@melware.de) |
| 9 | * |
| 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> |
| 18 | |
| 19 | #include "platform.h" |
| 20 | #include "di_defs.h" |
| 21 | #include "dadapter.h" |
| 22 | #include "divasync.h" |
| 23 | #include "did_vers.h" |
| 24 | |
| 25 | static char *main_revision = "$Revision: 1.13.6.4 $"; |
| 26 | |
| 27 | static char *DRIVERNAME = |
| 28 | "Eicon DIVA - DIDD table (http://www.melware.net)"; |
| 29 | static char *DRIVERLNAME = "divadidd"; |
| 30 | char *DRIVERRELEASE_DIDD = "2.0"; |
| 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | MODULE_DESCRIPTION("DIDD table driver for diva drivers"); |
| 33 | MODULE_AUTHOR("Cytronics & Melware, Eicon Networks"); |
| 34 | MODULE_SUPPORTED_DEVICE("Eicon diva drivers"); |
| 35 | MODULE_LICENSE("GPL"); |
| 36 | |
| 37 | #define DBG_MINIMUM (DL_LOG + DL_FTL + DL_ERR) |
| 38 | #define DBG_DEFAULT (DBG_MINIMUM + DL_XLOG + DL_REG) |
| 39 | |
| 40 | extern int diddfunc_init(void); |
| 41 | extern void diddfunc_finit(void); |
| 42 | |
| 43 | extern void DIVA_DIDD_Read(void *, int); |
| 44 | |
| 45 | static struct proc_dir_entry *proc_didd; |
| 46 | struct proc_dir_entry *proc_net_eicon = NULL; |
| 47 | |
| 48 | EXPORT_SYMBOL(DIVA_DIDD_Read); |
| 49 | EXPORT_SYMBOL(proc_net_eicon); |
| 50 | |
| 51 | static char *getrev(const char *revision) |
| 52 | { |
| 53 | char *rev; |
| 54 | char *p; |
| 55 | if ((p = strchr(revision, ':'))) { |
| 56 | rev = p + 2; |
| 57 | p = strchr(rev, '$'); |
| 58 | *--p = 0; |
| 59 | } else |
| 60 | rev = "1.0"; |
| 61 | return rev; |
| 62 | } |
| 63 | |
| 64 | static int |
| 65 | proc_read(char *page, char **start, off_t off, int count, int *eof, |
| 66 | void *data) |
| 67 | { |
| 68 | int len = 0; |
| 69 | char tmprev[32]; |
| 70 | |
| 71 | strcpy(tmprev, main_revision); |
| 72 | len += sprintf(page + len, "%s\n", DRIVERNAME); |
| 73 | len += sprintf(page + len, "name : %s\n", DRIVERLNAME); |
| 74 | len += sprintf(page + len, "release : %s\n", DRIVERRELEASE_DIDD); |
| 75 | len += sprintf(page + len, "build : %s(%s)\n", |
| 76 | diva_didd_common_code_build, DIVA_BUILD); |
| 77 | len += sprintf(page + len, "revision : %s\n", getrev(tmprev)); |
| 78 | |
| 79 | if (off + count >= len) |
| 80 | *eof = 1; |
| 81 | if (len < off) |
| 82 | return 0; |
| 83 | *start = page + off; |
| 84 | return ((count < len - off) ? count : len - off); |
| 85 | } |
| 86 | |
| 87 | static int DIVA_INIT_FUNCTION create_proc(void) |
| 88 | { |
Al Viro | 6660022 | 2005-09-28 22:32:57 +0100 | [diff] [blame] | 89 | proc_net_eicon = proc_mkdir("net/eicon", NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | |
| 91 | if (proc_net_eicon) { |
| 92 | if ((proc_didd = |
| 93 | create_proc_entry(DRIVERLNAME, S_IFREG | S_IRUGO, |
| 94 | proc_net_eicon))) { |
| 95 | proc_didd->read_proc = proc_read; |
| 96 | } |
| 97 | return (1); |
| 98 | } |
| 99 | return (0); |
| 100 | } |
| 101 | |
Sam Ravnborg | 162dd3b | 2007-06-01 00:47:11 -0700 | [diff] [blame^] | 102 | static void remove_proc(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | { |
| 104 | remove_proc_entry(DRIVERLNAME, proc_net_eicon); |
Al Viro | 6660022 | 2005-09-28 22:32:57 +0100 | [diff] [blame] | 105 | remove_proc_entry("net/eicon", NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | static int DIVA_INIT_FUNCTION divadidd_init(void) |
| 109 | { |
| 110 | char tmprev[32]; |
| 111 | int ret = 0; |
| 112 | |
| 113 | printk(KERN_INFO "%s\n", DRIVERNAME); |
| 114 | printk(KERN_INFO "%s: Rel:%s Rev:", DRIVERLNAME, DRIVERRELEASE_DIDD); |
| 115 | strcpy(tmprev, main_revision); |
| 116 | printk("%s Build:%s(%s)\n", getrev(tmprev), |
| 117 | diva_didd_common_code_build, DIVA_BUILD); |
| 118 | |
| 119 | if (!create_proc()) { |
| 120 | printk(KERN_ERR "%s: could not create proc entry\n", |
| 121 | DRIVERLNAME); |
| 122 | ret = -EIO; |
| 123 | goto out; |
| 124 | } |
| 125 | |
| 126 | if (!diddfunc_init()) { |
| 127 | printk(KERN_ERR "%s: failed to connect to DIDD.\n", |
| 128 | DRIVERLNAME); |
| 129 | #ifdef MODULE |
| 130 | remove_proc(); |
| 131 | #endif |
| 132 | ret = -EIO; |
| 133 | goto out; |
| 134 | } |
| 135 | |
| 136 | out: |
| 137 | return (ret); |
| 138 | } |
| 139 | |
| 140 | static void DIVA_EXIT_FUNCTION divadidd_exit(void) |
| 141 | { |
| 142 | diddfunc_finit(); |
| 143 | remove_proc(); |
| 144 | printk(KERN_INFO "%s: module unloaded.\n", DRIVERLNAME); |
| 145 | } |
| 146 | |
| 147 | module_init(divadidd_init); |
| 148 | module_exit(divadidd_exit); |