linux/drivers/isdn/hardware/eicon/diva_didd.c
<<
>>
Prefs
   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/module.h>
  15#include <linux/init.h>
  16#include <linux/kernel.h>
  17#include <linux/proc_fs.h>
  18#include <linux/seq_file.h>
  19#include <net/net_namespace.h>
  20
  21#include "platform.h"
  22#include "di_defs.h"
  23#include "dadapter.h"
  24#include "divasync.h"
  25#include "did_vers.h"
  26
  27static char *main_revision = "$Revision: 1.13.6.4 $";
  28
  29static char *DRIVERNAME =
  30        "Eicon DIVA - DIDD table (http://www.melware.net)";
  31static char *DRIVERLNAME = "divadidd";
  32char *DRIVERRELEASE_DIDD = "2.0";
  33
  34MODULE_DESCRIPTION("DIDD table driver for diva drivers");
  35MODULE_AUTHOR("Cytronics & Melware, Eicon Networks");
  36MODULE_SUPPORTED_DEVICE("Eicon diva drivers");
  37MODULE_LICENSE("GPL");
  38
  39#define DBG_MINIMUM  (DL_LOG + DL_FTL + DL_ERR)
  40#define DBG_DEFAULT  (DBG_MINIMUM + DL_XLOG + DL_REG)
  41
  42extern int diddfunc_init(void);
  43extern void diddfunc_finit(void);
  44
  45extern void DIVA_DIDD_Read(void *, int);
  46
  47static struct proc_dir_entry *proc_didd;
  48struct proc_dir_entry *proc_net_eicon = NULL;
  49
  50EXPORT_SYMBOL(DIVA_DIDD_Read);
  51EXPORT_SYMBOL(proc_net_eicon);
  52
  53static 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
  66static int divadidd_proc_show(struct seq_file *m, void *v)
  67{
  68        char tmprev[32];
  69
  70        strcpy(tmprev, main_revision);
  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",
  75                   diva_didd_common_code_build, DIVA_BUILD);
  76        seq_printf(m, "revision : %s\n", getrev(tmprev));
  77
  78        return 0;
  79}
  80
  81static int __init create_proc(void)
  82{
  83        proc_net_eicon = proc_mkdir("eicon", init_net.proc_net);
  84
  85        if (proc_net_eicon) {
  86                proc_didd = proc_create_single(DRIVERLNAME, S_IRUGO,
  87                                proc_net_eicon, divadidd_proc_show);
  88                return (1);
  89        }
  90        return (0);
  91}
  92
  93static void remove_proc(void)
  94{
  95        remove_proc_entry(DRIVERLNAME, proc_net_eicon);
  96        remove_proc_entry("eicon", init_net.proc_net);
  97}
  98
  99static int __init divadidd_init(void)
 100{
 101        char tmprev[32];
 102        int ret = 0;
 103
 104        printk(KERN_INFO "%s\n", DRIVERNAME);
 105        printk(KERN_INFO "%s: Rel:%s  Rev:", DRIVERLNAME, DRIVERRELEASE_DIDD);
 106        strcpy(tmprev, main_revision);
 107        printk("%s  Build:%s(%s)\n", getrev(tmprev),
 108               diva_didd_common_code_build, DIVA_BUILD);
 109
 110        if (!create_proc()) {
 111                printk(KERN_ERR "%s: could not create proc entry\n",
 112                       DRIVERLNAME);
 113                ret = -EIO;
 114                goto out;
 115        }
 116
 117        if (!diddfunc_init()) {
 118                printk(KERN_ERR "%s: failed to connect to DIDD.\n",
 119                       DRIVERLNAME);
 120#ifdef MODULE
 121                remove_proc();
 122#endif
 123                ret = -EIO;
 124                goto out;
 125        }
 126
 127out:
 128        return (ret);
 129}
 130
 131static void __exit divadidd_exit(void)
 132{
 133        diddfunc_finit();
 134        remove_proc();
 135        printk(KERN_INFO "%s: module unloaded.\n", DRIVERLNAME);
 136}
 137
 138module_init(divadidd_init);
 139module_exit(divadidd_exit);
 140