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