]> git.proxmox.com Git - mirror_spl-debian.git/blob - include/spl-device.h
6c3789cd771ab3d72af517b8288e9ae0c796330e
[mirror_spl-debian.git] / include / spl-device.h
1 /*****************************************************************************\
2 * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 * Copyright (C) 2007 The Regents of the University of California.
4 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
5 * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
6 * UCRL-CODE-235197
7 *
8 * This file is part of the SPL, Solaris Porting Layer.
9 * For details, see <http://github.com/behlendorf/spl/>.
10 *
11 * The SPL is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 * The SPL is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with the SPL. If not, see <http://www.gnu.org/licenses/>.
23 \*****************************************************************************/
24
25 #ifndef _SPL_DEVICE_H
26 #define _SPL_DEVICE_H
27
28 #include <linux/device.h>
29
30 /*
31 * Preferred API from 2.6.18 to 2.6.26+
32 */
33 #ifdef HAVE_DEVICE_CREATE
34
35 typedef struct class spl_class;
36 typedef struct device spl_device;
37
38 #define spl_class_create(mod, name) class_create(mod, name)
39 #define spl_class_destroy(cls) class_destroy(cls)
40
41 # ifdef HAVE_5ARGS_DEVICE_CREATE
42 # define spl_device_create(cls, parent, devt, drvdata, fmt, args...) \
43 device_create(cls, parent, devt, drvdata, fmt, ## args)
44 # else
45 # define spl_device_create(cls, parent, devt, drvdata, fmt, args...) \
46 device_create(cls, parent, devt, fmt, ## args)
47 # endif
48
49 #define spl_device_destroy(cls, cls_dev, devt) \
50 device_destroy(cls, devt)
51
52 /*
53 * Preferred API from 2.6.13 to 2.6.17
54 * Depricated in 2.6.18
55 * Removed in 2.6.26
56 */
57 #else
58 #ifdef HAVE_CLASS_DEVICE_CREATE
59
60 typedef struct class spl_class;
61 typedef struct class_device spl_device;
62
63 #define spl_class_create(mod, name) class_create(mod, name)
64 #define spl_class_destroy(cls) class_destroy(cls)
65 #define spl_device_create(cls, parent, devt, device, fmt, args...) \
66 class_device_create(cls, parent, devt, device, fmt, ## args)
67 #define spl_device_destroy(cls, cls_dev, devt) \
68 class_device_unregister(cls_dev)
69
70 /*
71 * Prefered API from 2.6.0 to 2.6.12
72 * Depricated in 2.6.13
73 * Removed in 2.6.13
74 */
75 #else /* Legacy API */
76
77 typedef struct class_simple spl_class;
78 typedef struct class_device spl_class_device;
79
80 #define spl_class_create(mod, name) class_simple_create(mod, name)
81 #define spl_class_destroy(cls) class_simple_destroy(cls)
82 #define spl_device_create(cls, parent, devt, device, fmt, args...) \
83 class_simple_device_add(cls, devt, device, fmt, ## args)
84 #define spl_device_destroy(cls, cls_dev, devt) \
85 class_simple_device_remove(devt)
86
87 #endif /* HAVE_CLASS_DEVICE_CREATE */
88 #endif /* HAVE_DEVICE_CREATE */
89
90 #endif /* _SPL_DEVICE_H */