Staging: hv: move VmbusChannelInterface.h
[safe/jmp/linux-2.6] / drivers / staging / hv / vmbus.h
1 /*
2  *
3  * Copyright (c) 2009, Microsoft Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16  * Place - Suite 330, Boston, MA 02111-1307 USA.
17  *
18  * Authors:
19  *   Haiyang Zhang <haiyangz@microsoft.com>
20  *   Hank Janssen  <hjanssen@microsoft.com>
21  *
22  */
23
24
25 #ifndef _VMBUS_H_
26 #define _VMBUS_H_
27
28 #include <linux/device.h>
29
30 #include "VmbusApi.h"
31
32 typedef int (*PFN_DRIVERINITIALIZE)(struct hv_driver *drv);
33 typedef int (*PFN_DRIVEREXIT)(struct hv_driver *drv);
34
35 struct driver_context {
36         struct hv_guid class_id;
37
38         struct device_driver driver;
39
40         /*
41          * Use these methods instead of the struct device_driver so 2.6 kernel
42          * stops complaining
43          * TODO - fix this!
44          */
45         int (*probe)(struct device *);
46         int (*remove)(struct device *);
47         void (*shutdown)(struct device *);
48 };
49
50 struct device_context {
51         struct work_struct probe_failed_work_item;
52         struct hv_guid class_id;
53         struct hv_guid device_id;
54         int probe_error;
55         struct device device;
56         struct hv_device device_obj;
57 };
58
59 static inline struct device_context *to_device_context(struct hv_device *d)
60 {
61         return container_of(d, struct device_context, device_obj);
62 }
63
64 static inline struct device_context *device_to_device_context(struct device *d)
65 {
66         return container_of(d, struct device_context, device);
67 }
68
69 static inline struct driver_context *driver_to_driver_context(struct device_driver *d)
70 {
71         return container_of(d, struct driver_context, driver);
72 }
73
74
75 /* Vmbus interface */
76
77 int vmbus_child_driver_register(struct driver_context *driver_ctx);
78 void vmbus_child_driver_unregister(struct driver_context *driver_ctx);
79 void vmbus_get_interface(struct vmbus_channel_interface *interface);
80
81 #endif /* _VMBUS_H_ */