block: autoconvert trivial BKL users to private mutex
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / hv / blkvsc.c
blob929238a6ce80b88151c471ea4c6f2a1f5d6ad24d
1 /*
3 * Copyright (c) 2009, Microsoft Corporation.
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.
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.
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.
18 * Authors:
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
23 #include <linux/kernel.h>
24 #include <linux/mm.h>
25 #include "osd.h"
26 #include "storvsc.c"
28 static const char *gBlkDriverName = "blkvsc";
30 /* {32412632-86cb-44a2-9b5c-50d1417354f5} */
31 static const struct hv_guid gBlkVscDeviceType = {
32 .data = {
33 0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44,
34 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5
38 static int BlkVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo)
40 struct storvsc_device_info *deviceInfo;
41 int ret = 0;
43 deviceInfo = (struct storvsc_device_info *)AdditionalInfo;
45 ret = StorVscOnDeviceAdd(Device, AdditionalInfo);
46 if (ret != 0)
47 return ret;
50 * We need to use the device instance guid to set the path and target
51 * id. For IDE devices, the device instance id is formatted as
52 * <bus id> * - <device id> - 8899 - 000000000000.
54 deviceInfo->PathId = Device->deviceInstance.data[3] << 24 |
55 Device->deviceInstance.data[2] << 16 |
56 Device->deviceInstance.data[1] << 8 |
57 Device->deviceInstance.data[0];
59 deviceInfo->TargetId = Device->deviceInstance.data[5] << 8 |
60 Device->deviceInstance.data[4];
62 return ret;
65 int BlkVscInitialize(struct hv_driver *Driver)
67 struct storvsc_driver_object *storDriver;
68 int ret = 0;
70 storDriver = (struct storvsc_driver_object *)Driver;
72 /* Make sure we are at least 2 pages since 1 page is used for control */
73 /* ASSERT(storDriver->RingBufferSize >= (PAGE_SIZE << 1)); */
75 Driver->name = gBlkDriverName;
76 memcpy(&Driver->deviceType, &gBlkVscDeviceType, sizeof(struct hv_guid));
78 storDriver->RequestExtSize = sizeof(struct storvsc_request_extension);
81 * Divide the ring buffer data size (which is 1 page less than the ring
82 * buffer size since that page is reserved for the ring buffer indices)
83 * by the max request size (which is
84 * VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER + struct vstor_packet + u64)
86 storDriver->MaxOutstandingRequestsPerChannel =
87 ((storDriver->RingBufferSize - PAGE_SIZE) /
88 ALIGN_UP(MAX_MULTIPAGE_BUFFER_PACKET +
89 sizeof(struct vstor_packet) + sizeof(u64),
90 sizeof(u64)));
92 DPRINT_INFO(BLKVSC, "max io outstd %u",
93 storDriver->MaxOutstandingRequestsPerChannel);
95 /* Setup the dispatch table */
96 storDriver->Base.OnDeviceAdd = BlkVscOnDeviceAdd;
97 storDriver->Base.OnDeviceRemove = StorVscOnDeviceRemove;
98 storDriver->Base.OnCleanup = StorVscOnCleanup;
99 storDriver->OnIORequest = StorVscOnIORequest;
101 return ret;