Subversion Repositories Kolibri OS

Rev

Rev 6102 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6082 serge 1
/*
2
 * device.h - generic, centralized driver model
3
 *
4
 * Copyright (c) 2001-2003 Patrick Mochel 
5
 * Copyright (c) 2004-2009 Greg Kroah-Hartman 
6
 * Copyright (c) 2008-2009 Novell Inc.
7
 *
8
 * This file is released under the GPLv2
9
 *
10
 * See Documentation/driver-model/ for more information.
11
 */
12
 
13
#ifndef _DEVICE_H_
14
#define _DEVICE_H_
15
 
6102 serge 16
#include 
17
#include 
6082 serge 18
#include 
19
#include 
20
#include 
21
#include 
6102 serge 22
#include 
23
#include 
24
#include 
6082 serge 25
struct device;
26
enum probe_type {
27
	PROBE_DEFAULT_STRATEGY,
28
	PROBE_PREFER_ASYNCHRONOUS,
29
	PROBE_FORCE_SYNCHRONOUS,
30
};
31
 
32
struct device_driver {
33
	const char		*name;
34
	const char		*mod_name;	/* used for built-in modules */
35
 
36
	bool suppress_bind_attrs;	/* disables bind/unbind via sysfs */
37
	enum probe_type probe_type;
38
};
39
 
40
struct device {
41
	struct device		*parent;
42
 
6102 serge 43
	struct kobject kobj;
6082 serge 44
	const char		*init_name; /* initial name of the device */
45
	struct device_driver *driver;	/* which driver has allocated this
46
					   device */
47
	void		*platform_data;	/* Platform specific data, device
48
					   core doesn't touch it */
49
	void		*driver_data;	/* Driver data, set and get with
50
					   dev_set/get_drvdata */
51
#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
52
	struct irq_domain	*msi_domain;
53
#endif
54
#ifdef CONFIG_PINCTRL
55
	struct dev_pin_info	*pins;
56
#endif
57
#ifdef CONFIG_GENERIC_MSI_IRQ
58
	struct list_head	msi_list;
59
#endif
60
 
61
#ifdef CONFIG_NUMA
62
	int		numa_node;	/* NUMA node this device is close to */
63
#endif
6102 serge 64
	u64		*dma_mask;	/* dma mask (if dma'able device) */
65
	u64		coherent_dma_mask;/* Like dma_mask, but for
66
					     alloc_coherent mappings as
67
					     not all hardware supports
68
					     64 bit addresses for consistent
69
					     allocations such descriptors. */
70
	unsigned long	dma_pfn_offset;
6082 serge 71
#ifdef CONFIG_DMA_CMA
72
	struct cma *cma_area;		/* contiguous memory area for dma
73
					   allocations */
74
#endif
75
};
76
 
6102 serge 77
static inline struct device *kobj_to_dev(struct kobject *kobj)
78
{
79
	return container_of(kobj, struct device, kobj);
80
}
81
 
82
 
83
static inline const char *dev_name(const struct device *dev)
84
{
85
	/* Use the init name until the kobject becomes available */
86
	if (dev->init_name)
87
		return dev->init_name;
88
 
89
	return kobject_name(&dev->kobj);
90
}
91
 
6082 serge 92
extern __printf(2, 3)
93
int dev_set_name(struct device *dev, const char *name, ...);
94
 
95
#ifdef CONFIG_NUMA
96
static inline int dev_to_node(struct device *dev)
97
{
98
	return dev->numa_node;
99
}
100
static inline void set_dev_node(struct device *dev, int node)
101
{
102
	dev->numa_node = node;
103
}
104
#else
105
static inline int dev_to_node(struct device *dev)
106
{
107
	return -1;
108
}
109
static inline void set_dev_node(struct device *dev, int node)
110
{
111
}
112
#endif
113
 
114
 
115
static inline void *dev_get_drvdata(const struct device *dev)
116
{
117
	return dev->driver_data;
118
}
119
 
120
static inline void dev_set_drvdata(struct device *dev, void *data)
121
{
122
	dev->driver_data = data;
123
}
124
 
7143 serge 125
static inline __printf(2, 3)
126
void dev_notice(const struct device *dev, const char *fmt, ...)
127
{}
6082 serge 128
 
129
 
130
#endif /* _DEVICE_H_ */