OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [linux/] [notifier.h] - Diff between revs 1765 and 1782

Only display areas with differences | Details | Blame | View Log

Rev 1765 Rev 1782
/*
/*
 *      Routines to manage notifier chains for passing status changes to any
 *      Routines to manage notifier chains for passing status changes to any
 *      interested routines. We need this instead of hard coded call lists so
 *      interested routines. We need this instead of hard coded call lists so
 *      that modules can poke their nose into the innards. The network devices
 *      that modules can poke their nose into the innards. The network devices
 *      needed them so here they are for the rest of you.
 *      needed them so here they are for the rest of you.
 *
 *
 *                              Alan Cox <Alan.Cox@linux.org>
 *                              Alan Cox <Alan.Cox@linux.org>
 */
 */
 
 
#ifndef _LINUX_NOTIFIER_H
#ifndef _LINUX_NOTIFIER_H
#define _LINUX_NOTIFIER_H
#define _LINUX_NOTIFIER_H
#include <linux/errno.h>
#include <linux/errno.h>
 
 
struct notifier_block
struct notifier_block
{
{
        int (*notifier_call)(struct notifier_block *this, unsigned long, void *);
        int (*notifier_call)(struct notifier_block *this, unsigned long, void *);
        struct notifier_block *next;
        struct notifier_block *next;
        int priority;
        int priority;
};
};
 
 
 
 
#ifdef __KERNEL__
#ifdef __KERNEL__
 
 
#define NOTIFY_DONE             0x0000          /* Don't care */
#define NOTIFY_DONE             0x0000          /* Don't care */
#define NOTIFY_OK               0x0001          /* Suits me */
#define NOTIFY_OK               0x0001          /* Suits me */
#define NOTIFY_STOP_MASK        0x8000          /* Don't call further */
#define NOTIFY_STOP_MASK        0x8000          /* Don't call further */
#define NOTIFY_BAD              (NOTIFY_STOP_MASK|0x0002)       /* Bad/Veto action      */
#define NOTIFY_BAD              (NOTIFY_STOP_MASK|0x0002)       /* Bad/Veto action      */
 
 
extern __inline__ int notifier_chain_register(struct notifier_block **list, struct notifier_block *n)
extern __inline__ int notifier_chain_register(struct notifier_block **list, struct notifier_block *n)
{
{
        while(*list)
        while(*list)
        {
        {
                if(n->priority > (*list)->priority)
                if(n->priority > (*list)->priority)
                        break;
                        break;
                list= &((*list)->next);
                list= &((*list)->next);
        }
        }
        n->next = *list;
        n->next = *list;
        *list=n;
        *list=n;
        return 0;
        return 0;
}
}
 
 
/*
/*
 *      Warning to any non GPL module writers out there.. these functions are
 *      Warning to any non GPL module writers out there.. these functions are
 *      GPL'd
 *      GPL'd
 */
 */
 
 
extern __inline__ int notifier_chain_unregister(struct notifier_block **nl, struct notifier_block *n)
extern __inline__ int notifier_chain_unregister(struct notifier_block **nl, struct notifier_block *n)
{
{
        while((*nl)!=NULL)
        while((*nl)!=NULL)
        {
        {
                if((*nl)==n)
                if((*nl)==n)
                {
                {
                        *nl=n->next;
                        *nl=n->next;
                        return 0;
                        return 0;
                }
                }
                nl=&((*nl)->next);
                nl=&((*nl)->next);
        }
        }
        return -ENOENT;
        return -ENOENT;
}
}
 
 
/*
/*
 *      This is one of these things that is generally shorter inline
 *      This is one of these things that is generally shorter inline
 */
 */
 
 
extern __inline__ int notifier_call_chain(struct notifier_block **n, unsigned long val, void *v)
extern __inline__ int notifier_call_chain(struct notifier_block **n, unsigned long val, void *v)
{
{
        int ret=NOTIFY_DONE;
        int ret=NOTIFY_DONE;
        struct notifier_block *nb = *n;
        struct notifier_block *nb = *n;
        while(nb)
        while(nb)
        {
        {
                ret=nb->notifier_call(nb,val,v);
                ret=nb->notifier_call(nb,val,v);
                if(ret&NOTIFY_STOP_MASK)
                if(ret&NOTIFY_STOP_MASK)
                        return ret;
                        return ret;
                nb=nb->next;
                nb=nb->next;
        }
        }
        return ret;
        return ret;
}
}
 
 
 
 
/*
/*
 *      Declared notifiers so far. I can imagine quite a few more chains
 *      Declared notifiers so far. I can imagine quite a few more chains
 *      over time (eg laptop power reset chains, reboot chain (to clean
 *      over time (eg laptop power reset chains, reboot chain (to clean
 *      device units up), device [un]mount chain, module load/unload chain,
 *      device units up), device [un]mount chain, module load/unload chain,
 *      low memory chain, screenblank chain (for plug in modular screenblankers)
 *      low memory chain, screenblank chain (for plug in modular screenblankers)
 *      VC switch chains (for loadable kernel svgalib VC switch helpers) etc...
 *      VC switch chains (for loadable kernel svgalib VC switch helpers) etc...
 */
 */
 
 
/* netdevice notifier chain */
/* netdevice notifier chain */
#define NETDEV_UP       0x0001  /* For now you can't veto a device up/down */
#define NETDEV_UP       0x0001  /* For now you can't veto a device up/down */
#define NETDEV_DOWN     0x0002
#define NETDEV_DOWN     0x0002
#define NETDEV_REBOOT   0x0003  /* Tell a protocol stack a network interface
#define NETDEV_REBOOT   0x0003  /* Tell a protocol stack a network interface
                                   detected a hardware crash and restarted
                                   detected a hardware crash and restarted
                                   - we can use this eg to kick tcp sessions
                                   - we can use this eg to kick tcp sessions
                                   once done */
                                   once done */
#endif
#endif
#endif
#endif
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.