 /* @file privadata.h
  * 
  * @brief Holds definition for driver's private data and its manipulation functions. 
  * 
  * 
  * 
  */

/** @par LICENCE
 * 
 *  @verbatim
  Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
  
         ADDI-DATA GmbH
         Dieselstrasse 3
         D-77833 Ottersweier
         Tel: +19(0)7223/9493-0
         Fax: +49(0)7223/9493-92
         http://www.addi-data-com
         info@addi-data.com
 
 This library is free software; you can redistribute it and/or modify it under 
 the terms of the GNU Lesser General Public License as published by the 
 Free Software Foundation; either version 2.1 of the License, 
 or (at your option) any later version.
 
 This library is distributed in the hope that it will be useful, 
 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 or FITNESS FOR A PARTICULAR PURPOSE. 
 See the GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public License 
 along with this library; if not, write to the Free Software Foundation, 
 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 
 You also shoud find the complete LGPL in the LGPL.txt file accompanying 
 this source code.
 
 @endverbatim
**/

#ifndef __APCI1016_PRIVDATA_H_
#define __APCI1016_PRIVDATA_H_

#include <apci1016-kapi.h>
#include <linux/version.h>

/* internal driver data */
struct apci1016_str_BoardInformations
{
	spinlock_t lock; /**< protect the board data */

	/* Asynchronous IO signal implementation - send a SIGIO to all registered processes*/
	/* If using signal to inform user mode, uncomment following line: */
	// struct fasync_struct * async_queue; /* asynchronous readers */

	// FILLME

};

/** initialise board's private data - fill it when adding new members and ioctl handlers */
static __inline__ void apci1016_init_priv_data(struct apci1016_str_BoardInformations * data)
{
	/* Be carefull, don't put a memset data after spin_lock_init!! */
	// FILLME

	/* Asynchronous IO signal implementation - send a SIGIO to all registered processes*/
	/* If using signal to inform user mode, uncomment following line: */
	// data->async_queue = NULL;

	spin_lock_init(& (data->lock) );
}


/** return the private data field of a pci_dev structure.
 * @note The implementation of this function differs in 2.4 and 2.6 kernel
 */
static __inline__ struct apci1016_str_BoardInformations * APCI1016_PRIVDATA(struct pci_dev * pdev)
{
	return (struct apci1016_str_BoardInformations *) pci_get_drvdata(pdev);
}

/* lock the board private data */
static __inline__ void APCI1016_LOCK(struct pci_dev * pdev, unsigned long * flags)
{
	spin_lock_irqsave(& (APCI1016_PRIVDATA(pdev)->lock), *flags );
}

/* unlock the board private data */
static __inline__ void APCI1016_UNLOCK(struct pci_dev * pdev, unsigned long flags)
{
	spin_unlock_irqrestore(& (APCI1016_PRIVDATA(pdev)->lock), flags );
}


#endif // __APCI1016_PRIVDATA_H_
