blob: d47b291bbe615a38b248a03cbadb461773619724 [file] [log] [blame]
Hank Janssenab057782009-07-13 15:19:28 -07001/*
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
Greg Kroah-Hartman870cde82009-08-19 16:21:28 -070030#include "include/VmbusApi.h"
Hank Janssenab057782009-07-13 15:19:28 -070031
Nicolas Palix775ef252009-07-29 14:09:45 +020032typedef int (*PFN_DRIVERINITIALIZE)(struct hv_driver *drv);
33typedef int (*PFN_DRIVEREXIT)(struct hv_driver *drv);
Hank Janssenab057782009-07-13 15:19:28 -070034
35struct driver_context {
Greg Kroah-Hartmancaf26a32009-08-19 16:17:03 -070036 struct hv_guid class_id;
Hank Janssenab057782009-07-13 15:19:28 -070037
Greg Kroah-Hartman08978652009-08-19 16:23:45 -070038 struct device_driver driver;
Hank Janssenab057782009-07-13 15:19:28 -070039
Greg Kroah-Hartman08978652009-08-19 16:23:45 -070040 /*
41 * Use these methods instead of the struct device_driver so 2.6 kernel
42 * stops complaining
43 * TODO - fix this!
44 */
Hank Janssenab057782009-07-13 15:19:28 -070045 int (*probe)(struct device *);
46 int (*remove)(struct device *);
47 void (*shutdown)(struct device *);
48};
49
50struct device_context {
Greg Kroah-Hartman08978652009-08-19 16:23:45 -070051 struct work_struct probe_failed_work_item;
Greg Kroah-Hartmancaf26a32009-08-19 16:17:03 -070052 struct hv_guid class_id;
53 struct hv_guid device_id;
Greg Kroah-Hartman08978652009-08-19 16:23:45 -070054 int probe_error;
55 struct device device;
Nicolas Palix3d3b5512009-07-28 17:32:53 +020056 struct hv_device device_obj;
Hank Janssenab057782009-07-13 15:19:28 -070057};
58
Greg Kroah-Hartman08978652009-08-19 16:23:45 -070059static inline struct device_context *to_device_context(struct hv_device *d)
Hank Janssenab057782009-07-13 15:19:28 -070060{
Greg Kroah-Hartman08978652009-08-19 16:23:45 -070061 return container_of(d, struct device_context, device_obj);
Hank Janssenab057782009-07-13 15:19:28 -070062}
63
Greg Kroah-Hartman08978652009-08-19 16:23:45 -070064static inline struct device_context *device_to_device_context(struct device *d)
Hank Janssenab057782009-07-13 15:19:28 -070065{
Greg Kroah-Hartman08978652009-08-19 16:23:45 -070066 return container_of(d, struct device_context, device);
Hank Janssenab057782009-07-13 15:19:28 -070067}
68
Greg Kroah-Hartman08978652009-08-19 16:23:45 -070069static inline struct driver_context *driver_to_driver_context(struct device_driver *d)
Hank Janssenab057782009-07-13 15:19:28 -070070{
Greg Kroah-Hartman08978652009-08-19 16:23:45 -070071 return container_of(d, struct driver_context, driver);
Hank Janssenab057782009-07-13 15:19:28 -070072}
73
Bill Pemberton454f18a2009-07-27 16:47:24 -040074
75/* Vmbus interface */
76
Greg Kroah-Hartman08978652009-08-19 16:23:45 -070077int vmbus_child_driver_register(struct driver_context *driver_ctx);
78void vmbus_child_driver_unregister(struct driver_context *driver_ctx);
Greg Kroah-Hartmanee3d7dd2009-08-20 12:17:36 -070079void vmbus_get_interface(struct vmbus_channel_interface *interface);
Hank Janssenab057782009-07-13 15:19:28 -070080
Bill Pemberton454f18a2009-07-27 16:47:24 -040081#endif /* _VMBUS_H_ */