]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - drivers/staging/meilhaus/metempl_device.h
Staging: remove me4000 driver.
[mirror_ubuntu-zesty-kernel.git] / drivers / staging / meilhaus / metempl_device.h
CommitLineData
3fedd148
DK
1/**
2 * @file metempl_device.h
3 *
4 * @brief template device class.
5 * @note Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
6 * @author Guenter Gebhardt
7 */
8
9/*
10 * Copyright (C) 2007 Meilhaus Electronic GmbH (support@meilhaus.de)
11 *
12 * This file is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26
27#ifndef _METEMPL_DEVICE_H
28#define _METEMPL_DEVICE_H
29
30#include <linux/pci.h>
31#include <linux/spinlock.h>
32
33#include "medevice.h"
34
35#ifdef __KERNEL__
36
37/**
38 * @brief Structure holding template device capabilities.
39 */
40typedef struct metempl_version {
41 uint16_t device_id;
42 unsigned int subdevices;
43} metempl_version_t;
44
45/**
46 * @brief Device capabilities.
47 */
48static metempl_version_t metempl_versions[] = {
49 {0xDEAD, 1},
50 {0},
51};
52
b6ac1613 53#define METEMPL_DEVICE_VERSIONS (ARRAY_SIZE(metempl_versions) - 1) /**< Returns the number of entries in #metempl_versions. */
3fedd148
DK
54
55/**
56 * @brief Returns the index of the device entry in #metempl_versions.
57 *
58 * @param device_id The PCI device id of the device to query.
59 * @return The index of the device in #metempl_versions.
60 */
61static inline unsigned int metempl_versions_get_device_index(uint16_t device_id)
62{
63 unsigned int i;
64 for (i = 0; i < METEMPL_DEVICE_VERSIONS; i++)
65 if (metempl_versions[i].device_id == device_id)
66 break;
67 return i;
68}
69
70/**
71 * @brief The template device class structure.
72 */
73typedef struct metempl_device {
74 me_device_t base; /**< The Meilhaus device base class. */
75
76 /* Child class attributes. */
77 spinlock_t ctrl_reg_lock;
78} metempl_device_t;
79
80/**
81 * @brief The template device class constructor.
82 *
83 * @param pci_device The pci device structure given by the PCI subsystem.
84 *
85 * @return On succes a new template device instance. \n
86 * NULL on error.
87 */
88me_device_t *metempl_pci_constructor(struct pci_dev *pci_device)
89 __attribute__ ((weak));
90
91#endif
92#endif