aboutsummaryrefslogtreecommitdiff
path: root/drivers/input/misc/bstclass.h
blob: 50ae688528550ce7785f1b21f447e0d46b6ce514 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*!
 * @section LICENSE
 * (C) Copyright 2013 Bosch Sensortec GmbH All Rights Reserved
 *
 * This software program is licensed subject to the GNU General
 * Public License (GPL).Version 2,June 1991,
 * available at http://www.fsf.org/copyleft/gpl.html
 *
 * @filename bstclass.h
 * @date     "Fri Aug 2 17:41:45 2013 +0800"
 * @id       "644147c"
 *
 * @brief
 * The core code of bst device driver
*/

#ifndef _BSTCLASS_H
#define _BSTCLASS_H

#ifdef __KERNEL__
#include <linux/time.h>
#include <linux/list.h>
#else
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <linux/types.h>
#endif

#include <linux/device.h>
#include <linux/fs.h>
#include <linux/mod_devicetable.h>

struct bst_dev {
	const char *name;

	int (*open)(struct bst_dev *dev);
	void (*close)(struct bst_dev *dev);
	struct mutex mutex;
	struct device dev;
	struct list_head node;
};

#define to_bst_dev(d) container_of(d, struct bst_dev, dev)

struct bst_dev *bst_allocate_device(void);
void bst_free_device(struct bst_dev *dev);

static inline struct bst_dev *bst_get_device(struct bst_dev *dev)
{
	return dev ? to_bst_dev(get_device(&dev->dev)) : NULL;
}

static inline void bst_put_device(struct bst_dev *dev)
{
	if (dev)
		put_device(&dev->dev);
}

static inline void *bst_get_drvdata(struct bst_dev *dev)
{
	return dev_get_drvdata(&dev->dev);
}

static inline void bst_set_drvdata(struct bst_dev *dev, void *data)
{
	dev_set_drvdata(&dev->dev, data);
}

int __must_check bst_register_device(struct bst_dev *);
void bst_unregister_device(struct bst_dev *);

void bst_reset_device(struct bst_dev *);


extern struct class bst_class;

#endif