66fbaa74b0
git-svn-id: svn://kolibrios.org@7143 a494cfbc-eb01-0410-851d-a64ba20cac60
131 lines
3.0 KiB
C
131 lines
3.0 KiB
C
/*
|
|
* device.h - generic, centralized driver model
|
|
*
|
|
* Copyright (c) 2001-2003 Patrick Mochel <mochel@osdl.org>
|
|
* Copyright (c) 2004-2009 Greg Kroah-Hartman <gregkh@suse.de>
|
|
* Copyright (c) 2008-2009 Novell Inc.
|
|
*
|
|
* This file is released under the GPLv2
|
|
*
|
|
* See Documentation/driver-model/ for more information.
|
|
*/
|
|
|
|
#ifndef _DEVICE_H_
|
|
#define _DEVICE_H_
|
|
|
|
#include <linux/ioport.h>
|
|
#include <linux/kobject.h>
|
|
#include <linux/list.h>
|
|
#include <linux/compiler.h>
|
|
#include <linux/types.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/pm.h>
|
|
#include <linux/atomic.h>
|
|
#include <linux/gfp.h>
|
|
struct device;
|
|
enum probe_type {
|
|
PROBE_DEFAULT_STRATEGY,
|
|
PROBE_PREFER_ASYNCHRONOUS,
|
|
PROBE_FORCE_SYNCHRONOUS,
|
|
};
|
|
|
|
struct device_driver {
|
|
const char *name;
|
|
const char *mod_name; /* used for built-in modules */
|
|
|
|
bool suppress_bind_attrs; /* disables bind/unbind via sysfs */
|
|
enum probe_type probe_type;
|
|
};
|
|
|
|
struct device {
|
|
struct device *parent;
|
|
|
|
struct kobject kobj;
|
|
const char *init_name; /* initial name of the device */
|
|
struct device_driver *driver; /* which driver has allocated this
|
|
device */
|
|
void *platform_data; /* Platform specific data, device
|
|
core doesn't touch it */
|
|
void *driver_data; /* Driver data, set and get with
|
|
dev_set/get_drvdata */
|
|
#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN
|
|
struct irq_domain *msi_domain;
|
|
#endif
|
|
#ifdef CONFIG_PINCTRL
|
|
struct dev_pin_info *pins;
|
|
#endif
|
|
#ifdef CONFIG_GENERIC_MSI_IRQ
|
|
struct list_head msi_list;
|
|
#endif
|
|
|
|
#ifdef CONFIG_NUMA
|
|
int numa_node; /* NUMA node this device is close to */
|
|
#endif
|
|
u64 *dma_mask; /* dma mask (if dma'able device) */
|
|
u64 coherent_dma_mask;/* Like dma_mask, but for
|
|
alloc_coherent mappings as
|
|
not all hardware supports
|
|
64 bit addresses for consistent
|
|
allocations such descriptors. */
|
|
unsigned long dma_pfn_offset;
|
|
#ifdef CONFIG_DMA_CMA
|
|
struct cma *cma_area; /* contiguous memory area for dma
|
|
allocations */
|
|
#endif
|
|
};
|
|
|
|
static inline struct device *kobj_to_dev(struct kobject *kobj)
|
|
{
|
|
return container_of(kobj, struct device, kobj);
|
|
}
|
|
|
|
|
|
static inline const char *dev_name(const struct device *dev)
|
|
{
|
|
/* Use the init name until the kobject becomes available */
|
|
if (dev->init_name)
|
|
return dev->init_name;
|
|
|
|
return kobject_name(&dev->kobj);
|
|
}
|
|
|
|
extern __printf(2, 3)
|
|
int dev_set_name(struct device *dev, const char *name, ...);
|
|
|
|
#ifdef CONFIG_NUMA
|
|
static inline int dev_to_node(struct device *dev)
|
|
{
|
|
return dev->numa_node;
|
|
}
|
|
static inline void set_dev_node(struct device *dev, int node)
|
|
{
|
|
dev->numa_node = node;
|
|
}
|
|
#else
|
|
static inline int dev_to_node(struct device *dev)
|
|
{
|
|
return -1;
|
|
}
|
|
static inline void set_dev_node(struct device *dev, int node)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
|
|
static inline void *dev_get_drvdata(const struct device *dev)
|
|
{
|
|
return dev->driver_data;
|
|
}
|
|
|
|
static inline void dev_set_drvdata(struct device *dev, void *data)
|
|
{
|
|
dev->driver_data = data;
|
|
}
|
|
|
|
static inline __printf(2, 3)
|
|
void dev_notice(const struct device *dev, const char *fmt, ...)
|
|
{}
|
|
|
|
|
|
#endif /* _DEVICE_H_ */
|