]> git.proxmox.com Git - mirror_spl.git/blame - include/spl-device.h
Simplify hostid logic
[mirror_spl.git] / include / spl-device.h
CommitLineData
716154c5
BB
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.
3d6af2dd 9 * For details, see <http://zfsonlinux.org/>.
716154c5
BB
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
46c685d0 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
35typedef struct class spl_class;
25557fd8 36typedef struct device spl_device;
46c685d0 37
38#define spl_class_create(mod, name) class_create(mod, name)
39#define spl_class_destroy(cls) class_destroy(cls)
8123ac4f
BB
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...) \
46c685d0 46 device_create(cls, parent, devt, fmt, ## args)
8123ac4f
BB
47# endif
48
25557fd8 49#define spl_device_destroy(cls, cls_dev, devt) \
50 device_destroy(cls, devt)
46c685d0 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
60typedef struct class spl_class;
25557fd8 61typedef struct class_device spl_device;
46c685d0 62
63#define spl_class_create(mod, name) class_create(mod, name)
64#define spl_class_destroy(cls) class_destroy(cls)
25557fd8 65#define spl_device_create(cls, parent, devt, device, fmt, args...) \
fe457392 66 class_device_create(cls, parent, devt, device, fmt, ## args)
25557fd8 67#define spl_device_destroy(cls, cls_dev, devt) \
68 class_device_unregister(cls_dev)
46c685d0 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
77typedef struct class_simple spl_class;
25557fd8 78typedef struct class_device spl_class_device;
46c685d0 79
80#define spl_class_create(mod, name) class_simple_create(mod, name)
81#define spl_class_destroy(cls) class_simple_destroy(cls)
25557fd8 82#define spl_device_create(cls, parent, devt, device, fmt, args...) \
46c685d0 83 class_simple_device_add(cls, devt, device, fmt, ## args)
25557fd8 84#define spl_device_destroy(cls, cls_dev, devt) \
85 class_simple_device_remove(devt)
46c685d0 86
fe457392
BB
87#endif /* HAVE_CLASS_DEVICE_CREATE */
88#endif /* HAVE_DEVICE_CREATE */
46c685d0 89
90#endif /* _SPL_DEVICE_H */