hysdn_conf_open(struct inode *ino, struct file *filep)
{
hysdn_card *card;
- struct proc_dir_entry *pd;
struct conf_writedata *cnf;
char *cp, *tmp;
/* now search the addressed card */
mutex_lock(&hysdn_conf_mutex);
- card = card_root;
- while (card) {
- pd = card->procconf;
- if (pd == PDE(ino))
- break;
- card = card->next; /* search next entry */
- }
- if (!card) {
- mutex_unlock(&hysdn_conf_mutex);
- return (-ENODEV); /* device is unknown/invalid */
- }
+ card = PDE(ino)->data;
if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL))
hysdn_addlog(card, "config open for uid=%d gid=%d mode=0x%x",
filep->f_cred->fsuid, filep->f_cred->fsgid,
hysdn_card *card;
struct conf_writedata *cnf;
int retval = 0;
- struct proc_dir_entry *pd;
mutex_lock(&hysdn_conf_mutex);
- /* search the addressed card */
- card = card_root;
- while (card) {
- pd = card->procconf;
- if (pd == PDE(ino))
- break;
- card = card->next; /* search next entry */
- }
- if (!card) {
- mutex_unlock(&hysdn_conf_mutex);
- return (-ENODEV); /* device is unknown/invalid */
- }
+ card = PDE(ino)->data;
if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL))
hysdn_addlog(card, "config close for uid=%d gid=%d mode=0x%x",
filep->f_cred->fsuid, filep->f_cred->fsgid,
while (card) {
sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid);
- if ((card->procconf = (void *) proc_create(conf_name,
+ if ((card->procconf = (void *) proc_create_data(conf_name,
S_IFREG | S_IRUGO | S_IWUSR,
hysdn_proc_entry,
- &conf_fops)) != NULL) {
+ &conf_fops,
+ card)) != NULL) {
hysdn_proclog_init(card); /* init the log file entry */
}
card = card->next; /* next entry */
{
struct log_data *inf;
int len;
- struct proc_dir_entry *pde = PDE(file_inode(file));
- struct procdata *pd = NULL;
- hysdn_card *card;
+ hysdn_card *card = PDE(file_inode(file))->data;
if (!*((struct log_data **) file->private_data)) {
+ struct procdata *pd = card->proclog;
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);
-
+ interruptible_sleep_on(&(pd->rd_queue));
}
if (!(inf = *((struct log_data **) file->private_data)))
return (0);
static int
hysdn_log_open(struct inode *ino, struct file *filep)
{
- hysdn_card *card;
- struct procdata *pd = NULL;
- unsigned long flags;
+ hysdn_card *card = PDE(ino)->data;
mutex_lock(&hysdn_log_mutex);
- card = card_root;
- while (card) {
- pd = card->proclog;
- if (pd->log == PDE(ino))
- break;
- card = card->next; /* search next entry */
- }
- if (!card) {
- mutex_unlock(&hysdn_log_mutex);
- 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 */
+ filep->private_data = card; /* remember our own card */
} else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
+ struct procdata *pd = card->proclog;
+ unsigned long flags;
/* read access -> log/debug read */
spin_lock_irqsave(&card->hysdn_lock, flags);
} 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 */
+ card = PDE(file_inode(filep))->data;
+ pd = card->proclog; /* pointer to procfs log */
}
if (pd)
pd->if_used--; /* decrement interface usage count by one */
hysdn_log_poll(struct file *file, poll_table *wait)
{
unsigned int mask = 0;
- struct proc_dir_entry *pde = PDE(file_inode(file));
- hysdn_card *card;
- struct procdata *pd = NULL;
+ hysdn_card *card = PDE(file_inode(file))->data;
+ struct procdata *pd = card->proclog;
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))
if ((pd = kzalloc(sizeof(struct procdata), GFP_KERNEL)) != NULL) {
sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid);
- pd->log = proc_create(pd->log_name,
+ pd->log = proc_create_data(pd->log_name,
S_IFREG | S_IRUGO | S_IWUSR, hysdn_proc_entry,
- &log_fops);
+ &log_fops, card);
init_waitqueue_head(&(pd->rd_queue));