2005-04-16 22:20:36 +00:00
|
|
|
/* $Id: hysdn_procconf.c,v 1.8.6.4 2001/09/23 22:24:54 kai Exp $
|
|
|
|
*
|
|
|
|
* Linux driver for HYSDN cards, /proc/net filesystem dir and conf functions.
|
|
|
|
*
|
|
|
|
* written by Werner Cornelius (werner@titro.de) for Hypercope GmbH
|
|
|
|
*
|
|
|
|
* Copyright 1999 by Werner Cornelius (werner@titro.de)
|
|
|
|
*
|
|
|
|
* This software may be used and distributed according to the terms
|
|
|
|
* of the GNU General Public License, incorporated herein by reference.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-10-07 13:09:06 +00:00
|
|
|
#include <linux/cred.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/poll.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/pci.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2010-07-11 11:18:53 +00:00
|
|
|
#include <linux/mutex.h>
|
2007-09-12 10:01:34 +00:00
|
|
|
#include <net/net_namespace.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include "hysdn_defs.h"
|
|
|
|
|
2010-07-11 11:18:53 +00:00
|
|
|
static DEFINE_MUTEX(hysdn_conf_mutex);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#define INFO_OUT_LEN 80 /* length of info line including lf */
|
|
|
|
|
|
|
|
/********************************************************/
|
|
|
|
/* defines and data structure for conf write operations */
|
|
|
|
/********************************************************/
|
|
|
|
#define CONF_STATE_DETECT 0 /* waiting for detect */
|
|
|
|
#define CONF_STATE_CONF 1 /* writing config data */
|
|
|
|
#define CONF_STATE_POF 2 /* writing pof data */
|
|
|
|
#define CONF_LINE_LEN 255 /* 255 chars max */
|
|
|
|
|
|
|
|
struct conf_writedata {
|
|
|
|
hysdn_card *card; /* card the device is connected to */
|
|
|
|
int buf_size; /* actual number of bytes in the buffer */
|
|
|
|
int needed_size; /* needed size when reading pof */
|
|
|
|
int state; /* actual interface states from above constants */
|
2006-03-25 11:07:04 +00:00
|
|
|
unsigned char conf_line[CONF_LINE_LEN]; /* buffered conf line */
|
|
|
|
unsigned short channel; /* active channel number */
|
|
|
|
unsigned char *pof_buffer; /* buffer when writing pof */
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/***********************************************************************/
|
|
|
|
/* process_line parses one config line and transfers it to the card if */
|
|
|
|
/* necessary. */
|
|
|
|
/* if the return value is negative an error occurred. */
|
|
|
|
/***********************************************************************/
|
|
|
|
static int
|
|
|
|
process_line(struct conf_writedata *cnf)
|
|
|
|
{
|
2006-03-25 11:07:04 +00:00
|
|
|
unsigned char *cp = cnf->conf_line;
|
2005-04-16 22:20:36 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (cnf->card->debug_flags & LOG_CNF_LINE)
|
|
|
|
hysdn_addlog(cnf->card, "conf line: %s", cp);
|
|
|
|
|
|
|
|
if (*cp == '-') { /* option */
|
|
|
|
cp++; /* point to option char */
|
|
|
|
|
|
|
|
if (*cp++ != 'c')
|
|
|
|
return (0); /* option unknown or used */
|
|
|
|
i = 0; /* start value for channel */
|
|
|
|
while ((*cp <= '9') && (*cp >= '0'))
|
|
|
|
i = i * 10 + *cp++ - '0'; /* get decimal number */
|
|
|
|
if (i > 65535) {
|
|
|
|
if (cnf->card->debug_flags & LOG_CNF_MISC)
|
|
|
|
hysdn_addlog(cnf->card, "conf channel invalid %d", i);
|
|
|
|
return (-ERR_INV_CHAN); /* invalid channel */
|
|
|
|
}
|
|
|
|
cnf->channel = i & 0xFFFF; /* set new channel number */
|
|
|
|
return (0); /* success */
|
|
|
|
} /* option */
|
|
|
|
if (*cp == '*') { /* line to send */
|
|
|
|
if (cnf->card->debug_flags & LOG_CNF_DATA)
|
|
|
|
hysdn_addlog(cnf->card, "conf chan=%d %s", cnf->channel, cp);
|
|
|
|
return (hysdn_tx_cfgline(cnf->card, cnf->conf_line + 1,
|
|
|
|
cnf->channel)); /* send the line without * */
|
|
|
|
} /* line to send */
|
|
|
|
return (0);
|
|
|
|
} /* process_line */
|
|
|
|
|
|
|
|
/***********************************/
|
|
|
|
/* conf file operations and tables */
|
|
|
|
/***********************************/
|
|
|
|
|
|
|
|
/****************************************************/
|
|
|
|
/* write conf file -> boot or send cfg line to card */
|
|
|
|
/****************************************************/
|
|
|
|
static ssize_t
|
2012-02-20 03:52:38 +00:00
|
|
|
hysdn_conf_write(struct file *file, const char __user *buf, size_t count, loff_t *off)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct conf_writedata *cnf;
|
|
|
|
int i;
|
2006-03-25 11:07:04 +00:00
|
|
|
unsigned char ch, *cp;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (!count)
|
|
|
|
return (0); /* nothing to handle */
|
|
|
|
|
|
|
|
if (!(cnf = file->private_data))
|
|
|
|
return (-EFAULT); /* should never happen */
|
|
|
|
|
|
|
|
if (cnf->state == CONF_STATE_DETECT) { /* auto detect cnf or pof data */
|
|
|
|
if (copy_from_user(&ch, buf, 1)) /* get first char for detect */
|
|
|
|
return (-EFAULT);
|
|
|
|
|
|
|
|
if (ch == 0x1A) {
|
|
|
|
/* we detected a pof file */
|
|
|
|
if ((cnf->needed_size = pof_write_open(cnf->card, &cnf->pof_buffer)) <= 0)
|
|
|
|
return (cnf->needed_size); /* an error occurred -> exit */
|
|
|
|
cnf->buf_size = 0; /* buffer is empty */
|
|
|
|
cnf->state = CONF_STATE_POF; /* new state */
|
|
|
|
} else {
|
|
|
|
/* conf data has been detected */
|
|
|
|
cnf->buf_size = 0; /* buffer is empty */
|
|
|
|
cnf->state = CONF_STATE_CONF; /* requested conf data write */
|
|
|
|
if (cnf->card->state != CARD_STATE_RUN)
|
|
|
|
return (-ERR_NOT_BOOTED);
|
|
|
|
cnf->conf_line[CONF_LINE_LEN - 1] = 0; /* limit string length */
|
|
|
|
cnf->channel = 4098; /* default channel for output */
|
|
|
|
}
|
|
|
|
} /* state was auto detect */
|
|
|
|
if (cnf->state == CONF_STATE_POF) { /* pof write active */
|
|
|
|
i = cnf->needed_size - cnf->buf_size; /* bytes still missing for write */
|
|
|
|
if (i <= 0)
|
|
|
|
return (-EINVAL); /* size error handling pof */
|
|
|
|
|
|
|
|
if (i < count)
|
|
|
|
count = i; /* limit requested number of bytes */
|
|
|
|
if (copy_from_user(cnf->pof_buffer + cnf->buf_size, buf, count))
|
|
|
|
return (-EFAULT); /* error while copying */
|
|
|
|
cnf->buf_size += count;
|
|
|
|
|
|
|
|
if (cnf->needed_size == cnf->buf_size) {
|
|
|
|
cnf->needed_size = pof_write_buffer(cnf->card, cnf->buf_size); /* write data */
|
|
|
|
if (cnf->needed_size <= 0) {
|
|
|
|
cnf->card->state = CARD_STATE_BOOTERR; /* show boot error */
|
|
|
|
return (cnf->needed_size); /* an error occurred */
|
|
|
|
}
|
|
|
|
cnf->buf_size = 0; /* buffer is empty again */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* pof write active */
|
|
|
|
else { /* conf write active */
|
|
|
|
|
|
|
|
if (cnf->card->state != CARD_STATE_RUN) {
|
|
|
|
if (cnf->card->debug_flags & LOG_CNF_MISC)
|
|
|
|
hysdn_addlog(cnf->card, "cnf write denied -> not booted");
|
|
|
|
return (-ERR_NOT_BOOTED);
|
|
|
|
}
|
|
|
|
i = (CONF_LINE_LEN - 1) - cnf->buf_size; /* bytes available in buffer */
|
|
|
|
if (i > 0) {
|
|
|
|
/* copy remaining bytes into buffer */
|
|
|
|
|
|
|
|
if (count > i)
|
|
|
|
count = i; /* limit transfer */
|
|
|
|
if (copy_from_user(cnf->conf_line + cnf->buf_size, buf, count))
|
|
|
|
return (-EFAULT); /* error while copying */
|
|
|
|
|
|
|
|
i = count; /* number of chars in buffer */
|
|
|
|
cp = cnf->conf_line + cnf->buf_size;
|
|
|
|
while (i) {
|
|
|
|
/* search for end of line */
|
|
|
|
if ((*cp < ' ') && (*cp != 9))
|
|
|
|
break; /* end of line found */
|
|
|
|
cp++;
|
|
|
|
i--;
|
|
|
|
} /* search for end of line */
|
|
|
|
|
|
|
|
if (i) {
|
|
|
|
/* delimiter found */
|
|
|
|
*cp++ = 0; /* string termination */
|
|
|
|
count -= (i - 1); /* subtract remaining bytes from count */
|
|
|
|
while ((i) && (*cp < ' ') && (*cp != 9)) {
|
|
|
|
i--; /* discard next char */
|
|
|
|
count++; /* mark as read */
|
|
|
|
cp++; /* next char */
|
|
|
|
}
|
|
|
|
cnf->buf_size = 0; /* buffer is empty after transfer */
|
|
|
|
if ((i = process_line(cnf)) < 0) /* handle the line */
|
|
|
|
count = i; /* return the error */
|
|
|
|
}
|
|
|
|
/* delimiter found */
|
|
|
|
else {
|
|
|
|
cnf->buf_size += count; /* add chars to string */
|
|
|
|
if (cnf->buf_size >= CONF_LINE_LEN - 1) {
|
|
|
|
if (cnf->card->debug_flags & LOG_CNF_MISC)
|
|
|
|
hysdn_addlog(cnf->card, "cnf line too long %d chars pos %d", cnf->buf_size, count);
|
|
|
|
return (-ERR_CONF_LONG);
|
|
|
|
}
|
|
|
|
} /* not delimited */
|
|
|
|
|
|
|
|
}
|
|
|
|
/* copy remaining bytes into buffer */
|
|
|
|
else {
|
|
|
|
if (cnf->card->debug_flags & LOG_CNF_MISC)
|
|
|
|
hysdn_addlog(cnf->card, "cnf line too long");
|
|
|
|
return (-ERR_CONF_LONG);
|
|
|
|
}
|
|
|
|
} /* conf write active */
|
|
|
|
|
|
|
|
return (count);
|
|
|
|
} /* hysdn_conf_write */
|
|
|
|
|
|
|
|
/*******************************************/
|
|
|
|
/* read conf file -> output card info data */
|
|
|
|
/*******************************************/
|
|
|
|
static ssize_t
|
2008-06-10 19:50:14 +00:00
|
|
|
hysdn_conf_read(struct file *file, char __user *buf, size_t count, loff_t *off)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
char *cp;
|
|
|
|
|
2008-06-10 19:50:14 +00:00
|
|
|
if (!(file->f_mode & FMODE_READ))
|
|
|
|
return -EPERM; /* no permission to read */
|
|
|
|
|
|
|
|
if (!(cp = file->private_data))
|
|
|
|
return -EFAULT; /* should never happen */
|
|
|
|
|
|
|
|
return simple_read_from_buffer(buf, count, off, cp, strlen(cp));
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* hysdn_conf_read */
|
|
|
|
|
|
|
|
/******************/
|
|
|
|
/* open conf file */
|
|
|
|
/******************/
|
|
|
|
static int
|
|
|
|
hysdn_conf_open(struct inode *ino, struct file *filep)
|
|
|
|
{
|
|
|
|
hysdn_card *card;
|
|
|
|
struct conf_writedata *cnf;
|
|
|
|
char *cp, *tmp;
|
|
|
|
|
|
|
|
/* now search the addressed card */
|
2010-07-11 11:18:53 +00:00
|
|
|
mutex_lock(&hysdn_conf_mutex);
|
2013-03-31 22:16:14 +00:00
|
|
|
card = PDE_DATA(ino);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL))
|
|
|
|
hysdn_addlog(card, "config open for uid=%d gid=%d mode=0x%x",
|
2008-11-13 23:39:25 +00:00
|
|
|
filep->f_cred->fsuid, filep->f_cred->fsgid,
|
|
|
|
filep->f_mode);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
|
|
|
|
/* write only access -> write boot file or conf line */
|
|
|
|
|
|
|
|
if (!(cnf = kmalloc(sizeof(struct conf_writedata), GFP_KERNEL))) {
|
2010-07-11 11:18:53 +00:00
|
|
|
mutex_unlock(&hysdn_conf_mutex);
|
2005-04-16 22:20:36 +00:00
|
|
|
return (-EFAULT);
|
|
|
|
}
|
|
|
|
cnf->card = card;
|
|
|
|
cnf->buf_size = 0; /* nothing buffered */
|
|
|
|
cnf->state = CONF_STATE_DETECT; /* start auto detect */
|
|
|
|
filep->private_data = cnf;
|
|
|
|
|
|
|
|
} else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
|
|
|
|
/* read access -> output card info data */
|
|
|
|
|
2006-12-13 08:35:56 +00:00
|
|
|
if (!(tmp = kmalloc(INFO_OUT_LEN * 2 + 2, GFP_KERNEL))) {
|
2010-07-11 11:18:53 +00:00
|
|
|
mutex_unlock(&hysdn_conf_mutex);
|
2005-04-16 22:20:36 +00:00
|
|
|
return (-EFAULT); /* out of memory */
|
|
|
|
}
|
|
|
|
filep->private_data = tmp; /* start of string */
|
|
|
|
|
|
|
|
/* first output a headline */
|
|
|
|
sprintf(tmp, "id bus slot type irq iobase dp-mem b-chans fax-chans state device");
|
|
|
|
cp = tmp; /* start of string */
|
|
|
|
while (*cp)
|
|
|
|
cp++;
|
|
|
|
while (((cp - tmp) % (INFO_OUT_LEN + 1)) != INFO_OUT_LEN)
|
|
|
|
*cp++ = ' ';
|
|
|
|
*cp++ = '\n';
|
|
|
|
|
|
|
|
/* and now the data */
|
|
|
|
sprintf(cp, "%d %3d %4d %4d %3d 0x%04x 0x%08lx %7d %9d %3d %s",
|
|
|
|
card->myid,
|
|
|
|
card->bus,
|
|
|
|
PCI_SLOT(card->devfn),
|
|
|
|
card->brdtype,
|
|
|
|
card->irq,
|
|
|
|
card->iobase,
|
|
|
|
card->membase,
|
|
|
|
card->bchans,
|
|
|
|
card->faxchans,
|
|
|
|
card->state,
|
|
|
|
hysdn_net_getname(card));
|
|
|
|
while (*cp)
|
|
|
|
cp++;
|
|
|
|
while (((cp - tmp) % (INFO_OUT_LEN + 1)) != INFO_OUT_LEN)
|
|
|
|
*cp++ = ' ';
|
|
|
|
*cp++ = '\n';
|
|
|
|
*cp = 0; /* end of string */
|
|
|
|
} else { /* simultaneous read/write access forbidden ! */
|
2010-07-11 11:18:53 +00:00
|
|
|
mutex_unlock(&hysdn_conf_mutex);
|
2005-04-16 22:20:36 +00:00
|
|
|
return (-EPERM); /* no permission this time */
|
|
|
|
}
|
2010-07-11 11:18:53 +00:00
|
|
|
mutex_unlock(&hysdn_conf_mutex);
|
2005-04-16 22:20:36 +00:00
|
|
|
return nonseekable_open(ino, filep);
|
|
|
|
} /* hysdn_conf_open */
|
|
|
|
|
|
|
|
/***************************/
|
|
|
|
/* close a config file. */
|
|
|
|
/***************************/
|
|
|
|
static int
|
|
|
|
hysdn_conf_close(struct inode *ino, struct file *filep)
|
|
|
|
{
|
|
|
|
hysdn_card *card;
|
|
|
|
struct conf_writedata *cnf;
|
|
|
|
int retval = 0;
|
|
|
|
|
2010-07-11 11:18:53 +00:00
|
|
|
mutex_lock(&hysdn_conf_mutex);
|
2013-03-31 22:16:14 +00:00
|
|
|
card = PDE_DATA(ino);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL))
|
|
|
|
hysdn_addlog(card, "config close for uid=%d gid=%d mode=0x%x",
|
2008-11-13 23:39:25 +00:00
|
|
|
filep->f_cred->fsuid, filep->f_cred->fsgid,
|
|
|
|
filep->f_mode);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
|
|
|
|
/* write only access -> write boot file or conf line */
|
|
|
|
if (filep->private_data) {
|
|
|
|
cnf = filep->private_data;
|
|
|
|
|
|
|
|
if (cnf->state == CONF_STATE_POF)
|
|
|
|
retval = pof_write_close(cnf->card); /* close the pof write */
|
|
|
|
kfree(filep->private_data); /* free allocated memory for buffer */
|
|
|
|
|
|
|
|
} /* handle write private data */
|
|
|
|
} else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
|
|
|
|
/* read access -> output card info data */
|
|
|
|
|
2005-11-07 09:01:29 +00:00
|
|
|
kfree(filep->private_data); /* release memory */
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2010-07-11 11:18:53 +00:00
|
|
|
mutex_unlock(&hysdn_conf_mutex);
|
2005-04-16 22:20:36 +00:00
|
|
|
return (retval);
|
|
|
|
} /* hysdn_conf_close */
|
|
|
|
|
|
|
|
/******************************************************/
|
|
|
|
/* table for conf filesystem functions defined above. */
|
|
|
|
/******************************************************/
|
2007-02-12 08:55:32 +00:00
|
|
|
static const struct file_operations conf_fops =
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-04-29 08:02:30 +00:00
|
|
|
.owner = THIS_MODULE,
|
2005-04-16 22:20:36 +00:00
|
|
|
.llseek = no_llseek,
|
|
|
|
.read = hysdn_conf_read,
|
|
|
|
.write = hysdn_conf_write,
|
|
|
|
.open = hysdn_conf_open,
|
2012-02-20 03:52:38 +00:00
|
|
|
.release = hysdn_conf_close,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*****************************/
|
|
|
|
/* hysdn subdir in /proc/net */
|
|
|
|
/*****************************/
|
|
|
|
struct proc_dir_entry *hysdn_proc_entry = NULL;
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
/* hysdn_procconf_init is called when the module is loaded and after the cards */
|
|
|
|
/* have been detected. The needed proc dir and card config files are created. */
|
|
|
|
/* The log init is called at last. */
|
|
|
|
/*******************************************************************************/
|
|
|
|
int
|
|
|
|
hysdn_procconf_init(void)
|
|
|
|
{
|
|
|
|
hysdn_card *card;
|
2006-03-25 11:07:04 +00:00
|
|
|
unsigned char conf_name[20];
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-09-12 10:01:34 +00:00
|
|
|
hysdn_proc_entry = proc_mkdir(PROC_SUBDIR_NAME, init_net.proc_net);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!hysdn_proc_entry) {
|
|
|
|
printk(KERN_ERR "HYSDN: unable to create hysdn subdir\n");
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
card = card_root; /* point to first card */
|
|
|
|
while (card) {
|
|
|
|
|
|
|
|
sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid);
|
2013-03-28 22:56:21 +00:00
|
|
|
if ((card->procconf = (void *) proc_create_data(conf_name,
|
2012-02-20 03:52:38 +00:00
|
|
|
S_IFREG | S_IRUGO | S_IWUSR,
|
|
|
|
hysdn_proc_entry,
|
2013-03-28 22:56:21 +00:00
|
|
|
&conf_fops,
|
|
|
|
card)) != NULL) {
|
2005-04-16 22:20:36 +00:00
|
|
|
hysdn_proclog_init(card); /* init the log file entry */
|
|
|
|
}
|
|
|
|
card = card->next; /* next entry */
|
|
|
|
}
|
|
|
|
|
2011-02-09 21:54:26 +00:00
|
|
|
printk(KERN_NOTICE "HYSDN: procfs initialised\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return (0);
|
|
|
|
} /* hysdn_procconf_init */
|
|
|
|
|
|
|
|
/*************************************************************************************/
|
|
|
|
/* hysdn_procconf_release is called when the module is unloaded and before the cards */
|
|
|
|
/* resources are released. The module counter is assumed to be 0 ! */
|
|
|
|
/*************************************************************************************/
|
|
|
|
void
|
|
|
|
hysdn_procconf_release(void)
|
|
|
|
{
|
|
|
|
hysdn_card *card;
|
2006-03-25 11:07:04 +00:00
|
|
|
unsigned char conf_name[20];
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
card = card_root; /* start with first card */
|
|
|
|
while (card) {
|
|
|
|
|
|
|
|
sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid);
|
|
|
|
if (card->procconf)
|
|
|
|
remove_proc_entry(conf_name, hysdn_proc_entry);
|
|
|
|
|
|
|
|
hysdn_proclog_release(card); /* init the log file entry */
|
|
|
|
|
|
|
|
card = card->next; /* point to next card */
|
|
|
|
}
|
|
|
|
|
2007-09-12 10:01:34 +00:00
|
|
|
remove_proc_entry(PROC_SUBDIR_NAME, init_net.proc_net);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|