2005-04-16 22:20:36 +00:00
|
|
|
/* $Id: hysdn_proclog.c,v 1.9.6.3 2001/09/23 22:24:54 kai Exp $
|
|
|
|
*
|
|
|
|
* Linux driver for HYSDN cards, /proc/net filesystem log functions.
|
|
|
|
*
|
|
|
|
* Author 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/poll.h>
|
|
|
|
#include <linux/proc_fs.h>
|
2009-10-07 13:09:06 +00:00
|
|
|
#include <linux/sched.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>
|
2010-07-15 02:37:19 +00:00
|
|
|
#include <linux/kernel.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include "hysdn_defs.h"
|
|
|
|
|
|
|
|
/* the proc subdir for the interface is defined in the procconf module */
|
|
|
|
extern struct proc_dir_entry *hysdn_proc_entry;
|
|
|
|
|
2010-07-11 11:18:53 +00:00
|
|
|
static DEFINE_MUTEX(hysdn_log_mutex);
|
2012-02-20 03:52:38 +00:00
|
|
|
static void put_log_buffer(hysdn_card *card, char *cp);
|
2005-06-29 03:44:56 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*************************************************/
|
|
|
|
/* structure keeping ascii log for device output */
|
|
|
|
/*************************************************/
|
|
|
|
struct log_data {
|
|
|
|
struct log_data *next;
|
2006-03-25 11:07:04 +00:00
|
|
|
unsigned long usage_cnt;/* number of files still to work */
|
2005-04-16 22:20:36 +00:00
|
|
|
void *proc_ctrl; /* pointer to own control procdata structure */
|
|
|
|
char log_start[2]; /* log string start (final len aligned by size) */
|
|
|
|
};
|
|
|
|
|
|
|
|
/**********************************************/
|
|
|
|
/* structure holding proc entrys for one card */
|
|
|
|
/**********************************************/
|
|
|
|
struct procdata {
|
|
|
|
struct proc_dir_entry *log; /* log entry */
|
|
|
|
char log_name[15]; /* log filename */
|
|
|
|
struct log_data *log_head, *log_tail; /* head and tail for queue */
|
|
|
|
int if_used; /* open count for interface */
|
|
|
|
int volatile del_lock; /* lock for delete operations */
|
2006-03-25 11:07:04 +00:00
|
|
|
unsigned char logtmp[LOG_MAX_LINELEN];
|
2005-04-16 22:20:36 +00:00
|
|
|
wait_queue_head_t rd_queue;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************/
|
|
|
|
/* log function for cards error log interface */
|
|
|
|
/**********************************************/
|
|
|
|
void
|
2012-02-20 03:52:38 +00:00
|
|
|
hysdn_card_errlog(hysdn_card *card, tErrLogEntry *logp, int maxsize)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
char buf[ERRLOG_TEXT_SIZE + 40];
|
|
|
|
|
|
|
|
sprintf(buf, "LOG 0x%08lX 0x%08lX : %s\n", logp->ulErrType, logp->ulErrSubtype, logp->ucText);
|
|
|
|
put_log_buffer(card, buf); /* output the string */
|
|
|
|
} /* hysdn_card_errlog */
|
|
|
|
|
|
|
|
/***************************************************/
|
|
|
|
/* Log function using format specifiers for output */
|
|
|
|
/***************************************************/
|
|
|
|
void
|
2012-02-20 03:52:38 +00:00
|
|
|
hysdn_addlog(hysdn_card *card, char *fmt, ...)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct procdata *pd = card->proclog;
|
|
|
|
char *cp;
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
if (!pd)
|
|
|
|
return; /* log structure non existent */
|
|
|
|
|
|
|
|
cp = pd->logtmp;
|
|
|
|
cp += sprintf(cp, "HYSDN: card %d ", card->myid);
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
cp += vsprintf(cp, fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
*cp++ = '\n';
|
|
|
|
*cp = 0;
|
|
|
|
|
|
|
|
if (card->debug_flags & DEB_OUT_SYSLOG)
|
|
|
|
printk(KERN_INFO "%s", pd->logtmp);
|
|
|
|
else
|
|
|
|
put_log_buffer(card, pd->logtmp);
|
|
|
|
|
|
|
|
} /* hysdn_addlog */
|
|
|
|
|
|
|
|
/********************************************/
|
|
|
|
/* put an log buffer into the log queue. */
|
|
|
|
/* This buffer will be kept until all files */
|
|
|
|
/* opened for read got the contents. */
|
|
|
|
/* Flushes buffers not longer in use. */
|
|
|
|
/********************************************/
|
2005-06-29 03:44:56 +00:00
|
|
|
static void
|
2012-02-20 03:52:38 +00:00
|
|
|
put_log_buffer(hysdn_card *card, char *cp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct log_data *ib;
|
|
|
|
struct procdata *pd = card->proclog;
|
|
|
|
int i;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (!pd)
|
|
|
|
return;
|
|
|
|
if (!cp)
|
|
|
|
return;
|
|
|
|
if (!*cp)
|
|
|
|
return;
|
|
|
|
if (pd->if_used <= 0)
|
|
|
|
return; /* no open file for read */
|
|
|
|
|
2006-12-13 08:35:56 +00:00
|
|
|
if (!(ib = kmalloc(sizeof(struct log_data) + strlen(cp), GFP_ATOMIC)))
|
2012-02-20 03:52:38 +00:00
|
|
|
return; /* no memory */
|
2005-04-16 22:20:36 +00:00
|
|
|
strcpy(ib->log_start, cp); /* set output string */
|
|
|
|
ib->next = NULL;
|
|
|
|
ib->proc_ctrl = pd; /* point to own control structure */
|
2006-10-17 07:10:36 +00:00
|
|
|
spin_lock_irqsave(&card->hysdn_lock, flags);
|
2005-04-16 22:20:36 +00:00
|
|
|
ib->usage_cnt = pd->if_used;
|
|
|
|
if (!pd->log_head)
|
|
|
|
pd->log_head = ib; /* new head */
|
|
|
|
else
|
|
|
|
pd->log_tail->next = ib; /* follows existing messages */
|
|
|
|
pd->log_tail = ib; /* new tail */
|
|
|
|
i = pd->del_lock++; /* get lock state */
|
2006-10-17 07:10:36 +00:00
|
|
|
spin_unlock_irqrestore(&card->hysdn_lock, flags);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* delete old entrys */
|
|
|
|
if (!i)
|
|
|
|
while (pd->log_head->next) {
|
|
|
|
if ((pd->log_head->usage_cnt <= 0) &&
|
|
|
|
(pd->log_head->next->usage_cnt <= 0)) {
|
|
|
|
ib = pd->log_head;
|
|
|
|
pd->log_head = pd->log_head->next;
|
|
|
|
kfree(ib);
|
|
|
|
} else
|
|
|
|
break;
|
|
|
|
} /* pd->log_head->next */
|
|
|
|
pd->del_lock--; /* release lock level */
|
|
|
|
wake_up_interruptible(&(pd->rd_queue)); /* announce new entry */
|
|
|
|
} /* put_log_buffer */
|
|
|
|
|
|
|
|
|
|
|
|
/******************************/
|
|
|
|
/* file operations and tables */
|
|
|
|
/******************************/
|
|
|
|
|
|
|
|
/****************************************/
|
|
|
|
/* write log file -> set log level bits */
|
|
|
|
/****************************************/
|
|
|
|
static ssize_t
|
2012-02-20 03:52:38 +00:00
|
|
|
hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t *off)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-07-15 02:37:19 +00:00
|
|
|
int rc;
|
|
|
|
unsigned char valbuf[128];
|
2010-07-12 10:50:02 +00:00
|
|
|
hysdn_card *card = file->private_data;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (count > (sizeof(valbuf) - 1))
|
|
|
|
count = sizeof(valbuf) - 1; /* limit length */
|
|
|
|
if (copy_from_user(valbuf, buf, count))
|
|
|
|
return (-EFAULT); /* copy failed */
|
|
|
|
|
|
|
|
valbuf[count] = 0; /* terminating 0 */
|
2010-07-15 02:37:19 +00:00
|
|
|
|
2011-03-27 02:58:35 +00:00
|
|
|
rc = kstrtoul(valbuf, 0, &card->debug_flags);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
hysdn_addlog(card, "debug set to 0x%lx", card->debug_flags);
|
2005-04-16 22:20:36 +00:00
|
|
|
return (count);
|
|
|
|
} /* hysdn_log_write */
|
|
|
|
|
|
|
|
/******************/
|
|
|
|
/* read log file */
|
|
|
|
/******************/
|
|
|
|
static ssize_t
|
2012-02-20 03:52:38 +00:00
|
|
|
hysdn_log_read(struct file *file, char __user *buf, size_t count, loff_t *off)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct log_data *inf;
|
|
|
|
int len;
|
2006-12-08 10:37:13 +00:00
|
|
|
struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
|
2005-04-16 22:20:36 +00:00
|
|
|
struct procdata *pd = NULL;
|
|
|
|
hysdn_card *card;
|
|
|
|
|
|
|
|
if (!*((struct log_data **) file->private_data)) {
|
|
|
|
if (file->f_flags & O_NONBLOCK)
|
|
|
|
return (-EAGAIN);
|
|
|
|
|
|
|
|
/* sorry, but we need to search the card */
|
|
|
|
card = card_root;
|
|
|
|
while (card) {
|
|
|
|
pd = card->proclog;
|
|
|
|
if (pd->log == pde)
|
|
|
|
break;
|
|
|
|
card = card->next; /* search next entry */
|
|
|
|
}
|
|
|
|
if (card)
|
|
|
|
interruptible_sleep_on(&(pd->rd_queue));
|
|
|
|
else
|
|
|
|
return (-EAGAIN);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (!(inf = *((struct log_data **) file->private_data)))
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
inf->usage_cnt--; /* new usage count */
|
|
|
|
file->private_data = &inf->next; /* next structure */
|
|
|
|
if ((len = strlen(inf->log_start)) <= count) {
|
|
|
|
if (copy_to_user(buf, inf->log_start, len))
|
|
|
|
return -EFAULT;
|
|
|
|
*off += len;
|
|
|
|
return (len);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
} /* hysdn_log_read */
|
|
|
|
|
|
|
|
/******************/
|
|
|
|
/* open log file */
|
|
|
|
/******************/
|
|
|
|
static int
|
|
|
|
hysdn_log_open(struct inode *ino, struct file *filep)
|
|
|
|
{
|
|
|
|
hysdn_card *card;
|
|
|
|
struct procdata *pd = NULL;
|
2006-03-25 11:07:04 +00:00
|
|
|
unsigned long flags;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-07-11 11:18:53 +00:00
|
|
|
mutex_lock(&hysdn_log_mutex);
|
2005-04-16 22:20:36 +00:00
|
|
|
card = card_root;
|
|
|
|
while (card) {
|
|
|
|
pd = card->proclog;
|
|
|
|
if (pd->log == PDE(ino))
|
|
|
|
break;
|
|
|
|
card = card->next; /* search next entry */
|
|
|
|
}
|
|
|
|
if (!card) {
|
2010-07-11 11:18:53 +00:00
|
|
|
mutex_unlock(&hysdn_log_mutex);
|
2005-04-16 22:20:36 +00:00
|
|
|
return (-ENODEV); /* device is unknown/invalid */
|
|
|
|
}
|
|
|
|
filep->private_data = card; /* remember our own card */
|
|
|
|
|
|
|
|
if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
|
|
|
|
/* write only access -> write log level only */
|
|
|
|
} else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
|
|
|
|
|
|
|
|
/* read access -> log/debug read */
|
2006-10-17 07:10:36 +00:00
|
|
|
spin_lock_irqsave(&card->hysdn_lock, flags);
|
2005-04-16 22:20:36 +00:00
|
|
|
pd->if_used++;
|
|
|
|
if (pd->log_head)
|
|
|
|
filep->private_data = &pd->log_tail->next;
|
|
|
|
else
|
|
|
|
filep->private_data = &pd->log_head;
|
2006-10-17 07:10:36 +00:00
|
|
|
spin_unlock_irqrestore(&card->hysdn_lock, flags);
|
2005-04-16 22:20:36 +00:00
|
|
|
} else { /* simultaneous read/write access forbidden ! */
|
2010-07-11 11:18:53 +00:00
|
|
|
mutex_unlock(&hysdn_log_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_log_mutex);
|
2005-04-16 22:20:36 +00:00
|
|
|
return nonseekable_open(ino, filep);
|
|
|
|
} /* hysdn_log_open */
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
/* close a cardlog file. If the file has been opened for exclusive write it is */
|
|
|
|
/* assumed as pof data input and the pof loader is noticed about. */
|
|
|
|
/* Otherwise file is handled as log output. In this case the interface usage */
|
|
|
|
/* count is decremented and all buffers are noticed of closing. If this file */
|
|
|
|
/* was the last one to be closed, all buffers are freed. */
|
|
|
|
/*******************************************************************************/
|
|
|
|
static int
|
|
|
|
hysdn_log_close(struct inode *ino, struct file *filep)
|
|
|
|
{
|
|
|
|
struct log_data *inf;
|
|
|
|
struct procdata *pd;
|
|
|
|
hysdn_card *card;
|
|
|
|
int retval = 0;
|
|
|
|
|
2010-07-11 11:18:53 +00:00
|
|
|
mutex_lock(&hysdn_log_mutex);
|
2005-04-16 22:20:36 +00:00
|
|
|
if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
|
|
|
|
/* write only access -> write debug level written */
|
|
|
|
retval = 0; /* success */
|
|
|
|
} else {
|
|
|
|
/* read access -> log/debug read, mark one further file as closed */
|
|
|
|
|
|
|
|
pd = NULL;
|
|
|
|
inf = *((struct log_data **) filep->private_data); /* get first log entry */
|
|
|
|
if (inf)
|
|
|
|
pd = (struct procdata *) inf->proc_ctrl; /* still entries there */
|
|
|
|
else {
|
|
|
|
/* no info available -> search card */
|
|
|
|
card = card_root;
|
|
|
|
while (card) {
|
|
|
|
pd = card->proclog;
|
|
|
|
if (pd->log == PDE(ino))
|
|
|
|
break;
|
|
|
|
card = card->next; /* search next entry */
|
|
|
|
}
|
|
|
|
if (card)
|
|
|
|
pd = card->proclog; /* pointer to procfs log */
|
|
|
|
}
|
|
|
|
if (pd)
|
|
|
|
pd->if_used--; /* decrement interface usage count by one */
|
|
|
|
|
|
|
|
while (inf) {
|
|
|
|
inf->usage_cnt--; /* decrement usage count for buffers */
|
|
|
|
inf = inf->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pd)
|
|
|
|
if (pd->if_used <= 0) /* delete buffers if last file closed */
|
|
|
|
while (pd->log_head) {
|
|
|
|
inf = pd->log_head;
|
|
|
|
pd->log_head = pd->log_head->next;
|
|
|
|
kfree(inf);
|
|
|
|
}
|
|
|
|
} /* read access */
|
2010-07-11 11:18:53 +00:00
|
|
|
mutex_unlock(&hysdn_log_mutex);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return (retval);
|
|
|
|
} /* hysdn_log_close */
|
|
|
|
|
|
|
|
/*************************************************/
|
|
|
|
/* select/poll routine to be able using select() */
|
|
|
|
/*************************************************/
|
|
|
|
static unsigned int
|
2012-02-20 03:52:38 +00:00
|
|
|
hysdn_log_poll(struct file *file, poll_table *wait)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
unsigned int mask = 0;
|
2006-12-08 10:37:13 +00:00
|
|
|
struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
|
2005-04-16 22:20:36 +00:00
|
|
|
hysdn_card *card;
|
|
|
|
struct procdata *pd = NULL;
|
|
|
|
|
|
|
|
if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE)
|
|
|
|
return (mask); /* no polling for write supported */
|
|
|
|
|
|
|
|
/* we need to search the card */
|
|
|
|
card = card_root;
|
|
|
|
while (card) {
|
|
|
|
pd = card->proclog;
|
|
|
|
if (pd->log == pde)
|
|
|
|
break;
|
|
|
|
card = card->next; /* search next entry */
|
|
|
|
}
|
|
|
|
if (!card)
|
|
|
|
return (mask); /* card not found */
|
|
|
|
|
|
|
|
poll_wait(file, &(pd->rd_queue), wait);
|
|
|
|
|
|
|
|
if (*((struct log_data **) file->private_data))
|
|
|
|
mask |= POLLIN | POLLRDNORM;
|
|
|
|
|
|
|
|
return mask;
|
|
|
|
} /* hysdn_log_poll */
|
|
|
|
|
|
|
|
/**************************************************/
|
|
|
|
/* table for log filesystem functions defined above. */
|
|
|
|
/**************************************************/
|
2007-02-12 08:55:32 +00:00
|
|
|
static const struct file_operations log_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_log_read,
|
|
|
|
.write = hysdn_log_write,
|
|
|
|
.poll = hysdn_log_poll,
|
|
|
|
.open = hysdn_log_open,
|
2012-02-20 03:52:38 +00:00
|
|
|
.release = hysdn_log_close,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************************/
|
|
|
|
/* hysdn_proclog_init is called when the module is loaded after creating the cards */
|
|
|
|
/* conf files. */
|
|
|
|
/***********************************************************************************/
|
|
|
|
int
|
2012-02-20 03:52:38 +00:00
|
|
|
hysdn_proclog_init(hysdn_card *card)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct procdata *pd;
|
|
|
|
|
|
|
|
/* create a cardlog proc entry */
|
|
|
|
|
2006-12-08 10:39:35 +00:00
|
|
|
if ((pd = kzalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) {
|
2005-04-16 22:20:36 +00:00
|
|
|
sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid);
|
2008-04-29 08:02:30 +00:00
|
|
|
pd->log = proc_create(pd->log_name,
|
2012-02-20 03:52:38 +00:00
|
|
|
S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry,
|
|
|
|
&log_fops);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
init_waitqueue_head(&(pd->rd_queue));
|
|
|
|
|
|
|
|
card->proclog = (void *) pd; /* remember procfs structure */
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
} /* hysdn_proclog_init */
|
|
|
|
|
|
|
|
/************************************************************************************/
|
|
|
|
/* hysdn_proclog_release is called when the module is unloaded and before the cards */
|
|
|
|
/* conf file is released */
|
|
|
|
/* The module counter is assumed to be 0 ! */
|
|
|
|
/************************************************************************************/
|
|
|
|
void
|
2012-02-20 03:52:38 +00:00
|
|
|
hysdn_proclog_release(hysdn_card *card)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct procdata *pd;
|
|
|
|
|
|
|
|
if ((pd = (struct procdata *) card->proclog) != NULL) {
|
|
|
|
if (pd->log)
|
|
|
|
remove_proc_entry(pd->log_name, hysdn_proc_entry);
|
|
|
|
kfree(pd); /* release memory */
|
|
|
|
card->proclog = NULL;
|
|
|
|
}
|
|
|
|
} /* hysdn_proclog_release */
|