]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/staging/hv/storvsc.c
Staging: hv: vmbus_drv: Include the contents of hv_api.h in hyperv_vmbus.h
[mirror_ubuntu-artful-kernel.git] / drivers / staging / hv / storvsc.c
CommitLineData
bef4a34a 1/*
bef4a34a
HJ
2 * Copyright (c) 2009, Microsoft Corporation.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307 USA.
16 *
17 * Authors:
18 * Haiyang Zhang <haiyangz@microsoft.com>
19 * Hank Janssen <hjanssen@microsoft.com>
6028210e 20 * K. Y. Srinivasan <kys@microsoft.com>
1f91bca8 21 *
bef4a34a 22 */
5654e932 23#include <linux/kernel.h>
0c3b7b2f 24#include <linux/sched.h>
93958465 25#include <linux/completion.h>
0ffa63b0 26#include <linux/string.h>
5a0e3ad6 27#include <linux/slab.h>
0ffa63b0 28#include <linux/mm.h>
b4362c9c 29#include <linux/delay.h>
3f335ea2
S
30
31#include "hyperv.h"
bb969793 32#include "storvsc_api.h"
2dd88b51 33#include "vstorage.h"
bef4a34a
HJ
34
35
f638859e 36static inline struct storvsc_device *alloc_stor_device(struct hv_device *device)
bef4a34a 37{
f638859e 38 struct storvsc_device *stor_device;
bef4a34a 39
f638859e
HJ
40 stor_device = kzalloc(sizeof(struct storvsc_device), GFP_KERNEL);
41 if (!stor_device)
bef4a34a
HJ
42 return NULL;
43
454f18a9 44 /* Set to 2 to allow both inbound and outbound traffics */
3d8cdf22 45 /* (ie get_stor_device() and must_get_stor_device()) to proceed. */
f638859e 46 atomic_cmpxchg(&stor_device->ref_count, 0, 2);
bef4a34a 47
604df37d 48 init_waitqueue_head(&stor_device->waiting_to_drain);
f638859e 49 stor_device->device = device;
ca623ad3 50 device->ext = stor_device;
bef4a34a 51
f638859e 52 return stor_device;
bef4a34a
HJ
53}
54
f638859e 55static inline void free_stor_device(struct storvsc_device *device)
bef4a34a 56{
f638859e 57 kfree(device);
bef4a34a
HJ
58}
59
454f18a9 60/* Get the stordevice object iff exists and its refcount > 0 */
02e37db7 61static inline struct storvsc_device *must_get_stor_device(
f638859e 62 struct hv_device *device)
bef4a34a 63{
f638859e 64 struct storvsc_device *stor_device;
bef4a34a 65
ca623ad3 66 stor_device = (struct storvsc_device *)device->ext;
f638859e
HJ
67 if (stor_device && atomic_read(&stor_device->ref_count))
68 atomic_inc(&stor_device->ref_count);
bef4a34a 69 else
f638859e 70 stor_device = NULL;
bef4a34a 71
f638859e 72 return stor_device;
bef4a34a
HJ
73}
74
02e37db7
HJ
75/* Drop ref count to 1 to effectively disable get_stor_device() */
76static inline struct storvsc_device *release_stor_device(
f638859e 77 struct hv_device *device)
bef4a34a 78{
f638859e 79 struct storvsc_device *stor_device;
bef4a34a 80
ca623ad3 81 stor_device = (struct storvsc_device *)device->ext;
bef4a34a 82
454f18a9 83 /* Busy wait until the ref drop to 2, then set it to 1 */
f638859e 84 while (atomic_cmpxchg(&stor_device->ref_count, 2, 1) != 2)
b4362c9c 85 udelay(100);
bef4a34a 86
f638859e 87 return stor_device;
bef4a34a
HJ
88}
89
f638859e 90/* Drop ref count to 0. No one can use stor_device object. */
02e37db7 91static inline struct storvsc_device *final_release_stor_device(
f638859e 92 struct hv_device *device)
bef4a34a 93{
f638859e 94 struct storvsc_device *stor_device;
bef4a34a 95
ca623ad3 96 stor_device = (struct storvsc_device *)device->ext;
bef4a34a 97
454f18a9 98 /* Busy wait until the ref drop to 1, then set it to 0 */
f638859e 99 while (atomic_cmpxchg(&stor_device->ref_count, 1, 0) != 1)
b4362c9c 100 udelay(100);
bef4a34a 101
ca623ad3 102 device->ext = NULL;
f638859e 103 return stor_device;
bef4a34a
HJ
104}
105
3fa22517 106static int storvsc_channel_init(struct hv_device *device)
bef4a34a 107{
f638859e 108 struct storvsc_device *stor_device;
d7a1bdb9 109 struct hv_storvsc_request *request;
f638859e 110 struct vstor_packet *vstor_packet;
93958465 111 int ret, t;
bef4a34a 112
f638859e 113 stor_device = get_stor_device(device);
5f61ec34 114 if (!stor_device)
bef4a34a 115 return -1;
bef4a34a 116
f638859e
HJ
117 request = &stor_device->init_request;
118 vstor_packet = &request->vstor_packet;
bef4a34a 119
068c5df2
GKH
120 /*
121 * Now, initiate the vsc/vsp initialization protocol on the open
122 * channel
123 */
d7a1bdb9 124 memset(request, 0, sizeof(struct hv_storvsc_request));
93958465 125 init_completion(&request->wait_event);
f638859e
HJ
126 vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
127 vstor_packet->flags = REQUEST_COMPLETION_FLAG;
bef4a34a 128
bef4a34a
HJ
129 DPRINT_INFO(STORVSC, "BEGIN_INITIALIZATION_OPERATION...");
130
f638859e 131 ret = vmbus_sendpacket(device->channel, vstor_packet,
b60d71e2
GKH
132 sizeof(struct vstor_packet),
133 (unsigned long)request,
415f2287 134 VM_PKT_DATA_INBAND,
b60d71e2 135 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
5f61ec34 136 if (ret != 0)
0c3b7b2f 137 goto cleanup;
0c3b7b2f 138
93958465
S
139 t = wait_for_completion_timeout(&request->wait_event, HZ);
140 if (t == 0) {
0c3b7b2f
S
141 ret = -ETIMEDOUT;
142 goto cleanup;
bef4a34a
HJ
143 }
144
f638859e 145 if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
5f61ec34 146 vstor_packet->status != 0)
0c3b7b2f 147 goto cleanup;
bef4a34a
HJ
148
149 DPRINT_INFO(STORVSC, "QUERY_PROTOCOL_VERSION_OPERATION...");
150
454f18a9 151 /* reuse the packet for version range supported */
f638859e
HJ
152 memset(vstor_packet, 0, sizeof(struct vstor_packet));
153 vstor_packet->operation = VSTOR_OPERATION_QUERY_PROTOCOL_VERSION;
154 vstor_packet->flags = REQUEST_COMPLETION_FLAG;
bef4a34a 155
f638859e
HJ
156 vstor_packet->version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT;
157 FILL_VMSTOR_REVISION(vstor_packet->version.revision);
bef4a34a 158
f638859e 159 ret = vmbus_sendpacket(device->channel, vstor_packet,
b60d71e2
GKH
160 sizeof(struct vstor_packet),
161 (unsigned long)request,
415f2287 162 VM_PKT_DATA_INBAND,
b60d71e2 163 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
5f61ec34 164 if (ret != 0)
0c3b7b2f 165 goto cleanup;
bef4a34a 166
93958465
S
167 t = wait_for_completion_timeout(&request->wait_event, HZ);
168 if (t == 0) {
0c3b7b2f
S
169 ret = -ETIMEDOUT;
170 goto cleanup;
171 }
bef4a34a 172
454f18a9 173 /* TODO: Check returned version */
f638859e 174 if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
5f61ec34 175 vstor_packet->status != 0)
0c3b7b2f 176 goto cleanup;
bef4a34a 177
454f18a9 178 /* Query channel properties */
bef4a34a
HJ
179 DPRINT_INFO(STORVSC, "QUERY_PROPERTIES_OPERATION...");
180
f638859e
HJ
181 memset(vstor_packet, 0, sizeof(struct vstor_packet));
182 vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES;
183 vstor_packet->flags = REQUEST_COMPLETION_FLAG;
184 vstor_packet->storage_channel_properties.port_number =
185 stor_device->port_number;
bef4a34a 186
f638859e 187 ret = vmbus_sendpacket(device->channel, vstor_packet,
b60d71e2
GKH
188 sizeof(struct vstor_packet),
189 (unsigned long)request,
415f2287 190 VM_PKT_DATA_INBAND,
b60d71e2 191 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
068c5df2 192
5f61ec34 193 if (ret != 0)
0c3b7b2f 194 goto cleanup;
bef4a34a 195
93958465
S
196 t = wait_for_completion_timeout(&request->wait_event, HZ);
197 if (t == 0) {
0c3b7b2f
S
198 ret = -ETIMEDOUT;
199 goto cleanup;
200 }
bef4a34a 201
454f18a9 202 /* TODO: Check returned version */
f638859e 203 if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
5f61ec34 204 vstor_packet->status != 0)
0c3b7b2f 205 goto cleanup;
bef4a34a 206
f638859e
HJ
207 stor_device->path_id = vstor_packet->storage_channel_properties.path_id;
208 stor_device->target_id
209 = vstor_packet->storage_channel_properties.target_id;
bef4a34a 210
bef4a34a
HJ
211 DPRINT_INFO(STORVSC, "END_INITIALIZATION_OPERATION...");
212
f638859e
HJ
213 memset(vstor_packet, 0, sizeof(struct vstor_packet));
214 vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION;
215 vstor_packet->flags = REQUEST_COMPLETION_FLAG;
bef4a34a 216
f638859e 217 ret = vmbus_sendpacket(device->channel, vstor_packet,
b60d71e2
GKH
218 sizeof(struct vstor_packet),
219 (unsigned long)request,
415f2287 220 VM_PKT_DATA_INBAND,
b60d71e2 221 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
068c5df2 222
5f61ec34 223 if (ret != 0)
0c3b7b2f 224 goto cleanup;
bef4a34a 225
93958465
S
226 t = wait_for_completion_timeout(&request->wait_event, HZ);
227 if (t == 0) {
0c3b7b2f
S
228 ret = -ETIMEDOUT;
229 goto cleanup;
230 }
bef4a34a 231
f638859e 232 if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO ||
5f61ec34 233 vstor_packet->status != 0)
0c3b7b2f 234 goto cleanup;
bef4a34a
HJ
235
236 DPRINT_INFO(STORVSC, "**** storage channel up and running!! ****");
237
0c3b7b2f 238cleanup:
f638859e 239 put_stor_device(device);
bef4a34a
HJ
240 return ret;
241}
242
a38b94f9 243static void storvsc_on_io_completion(struct hv_device *device,
f638859e 244 struct vstor_packet *vstor_packet,
d7a1bdb9 245 struct hv_storvsc_request *request)
163680b4 246{
f638859e 247 struct storvsc_device *stor_device;
a617e395 248 struct vstor_packet *stor_pkt;
163680b4 249
f638859e 250 stor_device = must_get_stor_device(device);
5f61ec34 251 if (!stor_device)
163680b4 252 return;
163680b4 253
a617e395 254 stor_pkt = &request->vstor_packet;
163680b4 255
163680b4
GKH
256
257 /* Copy over the status...etc */
a617e395
S
258 stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status;
259 stor_pkt->vm_srb.srb_status = vstor_packet->vm_srb.srb_status;
260 stor_pkt->vm_srb.sense_info_length =
261 vstor_packet->vm_srb.sense_info_length;
163680b4 262
6dc3f0a7 263 if (vstor_packet->vm_srb.scsi_status != 0 ||
5f61ec34 264 vstor_packet->vm_srb.srb_status != 1){
163680b4
GKH
265 DPRINT_WARN(STORVSC,
266 "cmd 0x%x scsi status 0x%x srb status 0x%x\n",
a617e395 267 stor_pkt->vm_srb.cdb[0],
373dd8a9 268 vstor_packet->vm_srb.scsi_status,
f638859e 269 vstor_packet->vm_srb.srb_status);
163680b4
GKH
270 }
271
6dc3f0a7 272 if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) {
163680b4 273 /* CHECK_CONDITION */
f638859e 274 if (vstor_packet->vm_srb.srb_status & 0x80) {
163680b4
GKH
275 /* autosense data available */
276 DPRINT_WARN(STORVSC, "storvsc pkt %p autosense data "
d7a1bdb9 277 "valid - len %d\n", request,
f638859e 278 vstor_packet->vm_srb.sense_info_length);
163680b4 279
d7a1bdb9 280 memcpy(request->sense_buffer,
f638859e
HJ
281 vstor_packet->vm_srb.sense_data,
282 vstor_packet->vm_srb.sense_info_length);
163680b4 283
163680b4
GKH
284 }
285 }
286
a617e395
S
287 stor_pkt->vm_srb.data_transfer_length =
288 vstor_packet->vm_srb.data_transfer_length;
163680b4 289
d7a1bdb9 290 request->on_io_completion(request);
163680b4 291
604df37d
S
292 if (atomic_dec_and_test(&stor_device->num_outstanding_req) &&
293 stor_device->drain_notify)
294 wake_up(&stor_device->waiting_to_drain);
295
163680b4 296
f638859e 297 put_stor_device(device);
163680b4
GKH
298}
299
8e6766f8 300static void storvsc_on_receive(struct hv_device *device,
f638859e 301 struct vstor_packet *vstor_packet,
d7a1bdb9 302 struct hv_storvsc_request *request)
163680b4 303{
f638859e 304 switch (vstor_packet->operation) {
d2aaba45 305 case VSTOR_OPERATION_COMPLETE_IO:
a38b94f9 306 storvsc_on_io_completion(device, vstor_packet, request);
163680b4 307 break;
d2aaba45 308 case VSTOR_OPERATION_REMOVE_DEVICE:
163680b4
GKH
309 DPRINT_INFO(STORVSC, "REMOVE_DEVICE_OPERATION");
310 /* TODO: */
311 break;
312
313 default:
314 DPRINT_INFO(STORVSC, "Unknown operation received - %d",
f638859e 315 vstor_packet->operation);
163680b4
GKH
316 break;
317 }
318}
319
24d9aab0 320static void storvsc_on_channel_callback(void *context)
163680b4
GKH
321{
322 struct hv_device *device = (struct hv_device *)context;
f638859e
HJ
323 struct storvsc_device *stor_device;
324 u32 bytes_recvd;
325 u64 request_id;
73509681 326 unsigned char packet[ALIGN(sizeof(struct vstor_packet), 8)];
d7a1bdb9 327 struct hv_storvsc_request *request;
163680b4
GKH
328 int ret;
329
163680b4 330
f638859e 331 stor_device = must_get_stor_device(device);
5f61ec34 332 if (!stor_device)
163680b4 333 return;
163680b4
GKH
334
335 do {
50ea95df 336 ret = vmbus_recvpacket(device->channel, packet,
73509681 337 ALIGN(sizeof(struct vstor_packet), 8),
f638859e
HJ
338 &bytes_recvd, &request_id);
339 if (ret == 0 && bytes_recvd > 0) {
163680b4 340
d7a1bdb9 341 request = (struct hv_storvsc_request *)
f638859e 342 (unsigned long)request_id;
163680b4 343
f638859e
HJ
344 if ((request == &stor_device->init_request) ||
345 (request == &stor_device->reset_request)) {
163680b4 346
3d8cdf22 347 memcpy(&request->vstor_packet, packet,
163680b4 348 sizeof(struct vstor_packet));
93958465 349 complete(&request->wait_event);
163680b4 350 } else {
8e6766f8 351 storvsc_on_receive(device,
163680b4
GKH
352 (struct vstor_packet *)packet,
353 request);
354 }
355 } else {
163680b4
GKH
356 break;
357 }
358 } while (1);
359
02e37db7 360 put_stor_device(device);
163680b4
GKH
361 return;
362}
363
fa4d123a 364static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size)
bef4a34a 365{
b3715ee4 366 struct vmstorage_channel_properties props;
068c5df2 367 int ret;
bef4a34a 368
8c960e49 369 memset(&props, 0, sizeof(struct vmstorage_channel_properties));
bef4a34a 370
454f18a9 371 /* Open the channel */
f638859e 372 ret = vmbus_open(device->channel,
fa4d123a
S
373 ring_size,
374 ring_size,
60f841ac
GKH
375 (void *)&props,
376 sizeof(struct vmstorage_channel_properties),
24d9aab0 377 storvsc_on_channel_callback, device);
068c5df2 378
5f61ec34 379 if (ret != 0)
bef4a34a 380 return -1;
bef4a34a 381
3fa22517 382 ret = storvsc_channel_init(device);
bef4a34a
HJ
383
384 return ret;
385}
386
2ac5dad1 387int storvsc_dev_add(struct hv_device *device,
f638859e 388 void *additional_info)
163680b4 389{
f638859e 390 struct storvsc_device *stor_device;
f638859e 391 struct storvsc_device_info *device_info;
163680b4
GKH
392 int ret = 0;
393
f638859e
HJ
394 device_info = (struct storvsc_device_info *)additional_info;
395 stor_device = alloc_stor_device(device);
396 if (!stor_device) {
163680b4 397 ret = -1;
0c3b7b2f 398 goto cleanup;
163680b4
GKH
399 }
400
401 /* Save the channel properties to our storvsc channel */
163680b4
GKH
402
403 /* FIXME: */
404 /*
405 * If we support more than 1 scsi channel, we need to set the
406 * port number here to the scsi channel but how do we get the
407 * scsi channel prior to the bus scan
408 */
409
f638859e 410 stor_device->port_number = device_info->port_number;
163680b4 411 /* Send it back up */
fa4d123a 412 ret = storvsc_connect_to_vsp(device, device_info->ring_buffer_size);
163680b4 413
f638859e
HJ
414 device_info->path_id = stor_device->path_id;
415 device_info->target_id = stor_device->target_id;
163680b4 416
0c3b7b2f 417cleanup:
163680b4
GKH
418 return ret;
419}
bef4a34a 420
cb706b04 421int storvsc_dev_remove(struct hv_device *device)
bef4a34a 422{
f638859e 423 struct storvsc_device *stor_device;
bef4a34a 424
068c5df2 425 DPRINT_INFO(STORVSC, "disabling storage device (%p)...",
ca623ad3 426 device->ext);
bef4a34a 427
f638859e 428 stor_device = release_stor_device(device);
bef4a34a 429
454f18a9
BP
430 /*
431 * At this point, all outbound traffic should be disable. We
432 * only allow inbound traffic (responses) to proceed so that
433 * outstanding requests can be completed.
434 */
19fc2f2a
S
435
436 storvsc_wait_to_drain(stor_device);
bef4a34a 437
f638859e 438 stor_device = final_release_stor_device(device);
bef4a34a 439
454f18a9 440 /* Close the channel */
f638859e 441 vmbus_close(device->channel);
bef4a34a 442
f638859e 443 free_stor_device(stor_device);
068c5df2 444 return 0;
454f18a9 445}
bef4a34a 446
bb465926 447int storvsc_do_io(struct hv_device *device,
f638859e 448 struct hv_storvsc_request *request)
bef4a34a 449{
f638859e 450 struct storvsc_device *stor_device;
f638859e 451 struct vstor_packet *vstor_packet;
068c5df2 452 int ret = 0;
bef4a34a 453
d7a1bdb9 454 vstor_packet = &request->vstor_packet;
f638859e 455 stor_device = get_stor_device(device);
bef4a34a 456
5f61ec34 457 if (!stor_device)
bef4a34a 458 return -2;
bef4a34a 459
bef4a34a 460
d7a1bdb9 461 request->device = device;
bef4a34a 462
a617e395 463
f638859e 464 vstor_packet->flags |= REQUEST_COMPLETION_FLAG;
bef4a34a 465
f638859e 466 vstor_packet->vm_srb.length = sizeof(struct vmscsi_request);
bef4a34a 467
bef4a34a 468
f638859e 469 vstor_packet->vm_srb.sense_info_length = SENSE_BUFFER_SIZE;
bef4a34a 470
bef4a34a 471
e9e936c6 472 vstor_packet->vm_srb.data_transfer_length =
d7a1bdb9 473 request->data_buffer.len;
bef4a34a 474
f638859e 475 vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB;
bef4a34a 476
d7a1bdb9 477 if (request->data_buffer.len) {
f638859e 478 ret = vmbus_sendpacket_multipagebuffer(device->channel,
d7a1bdb9 479 &request->data_buffer,
f638859e 480 vstor_packet,
b3715ee4 481 sizeof(struct vstor_packet),
d7a1bdb9 482 (unsigned long)request);
068c5df2 483 } else {
f638859e 484 ret = vmbus_sendpacket(device->channel, vstor_packet,
b60d71e2 485 sizeof(struct vstor_packet),
d7a1bdb9 486 (unsigned long)request,
415f2287 487 VM_PKT_DATA_INBAND,
b60d71e2 488 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
bef4a34a
HJ
489 }
490
5f61ec34
S
491 if (ret != 0)
492 return ret;
bef4a34a 493
f638859e 494 atomic_inc(&stor_device->num_outstanding_req);
bef4a34a 495
f638859e 496 put_stor_device(device);
bef4a34a
HJ
497 return ret;
498}
499
1f91bca8
S
500/*
501 * The channel properties uniquely specify how the device is to be
502 * presented to the guest. Map this information for use by the block
503 * driver. For Linux guests on Hyper-V, we emulate a scsi HBA in the guest
504 * (storvsc_drv) and so scsi devices in the guest are handled by
505 * native upper level Linux drivers. Consequently, Hyper-V
506 * block driver, while being a generic block driver, presently does not
507 * deal with anything other than devices that would need to be presented
508 * to the guest as an IDE disk.
509 *
510 * This function maps the channel properties as embedded in the input
511 * parameter device_info onto information necessary to register the
512 * corresponding block device.
513 *
514 * Currently, there is no way to stop the emulation of the block device
515 * on the host side. And so, to prevent the native IDE drivers in Linux
516 * from taking over these devices (to be managedby Hyper-V block
517 * driver), we will take over if need be the major of the IDE controllers.
518 *
519 */
520
43c51f7d 521int storvsc_get_major_info(struct storvsc_device_info *device_info,
1f91bca8
S
522 struct storvsc_major_info *major_info)
523{
524 static bool ide0_registered;
525 static bool ide1_registered;
526
527 /*
528 * For now we only support IDE disks.
529 */
530 major_info->devname = "ide";
531 major_info->diskname = "hd";
532
533 if (device_info->path_id) {
534 major_info->major = 22;
e46ee8ef 535 if (!ide1_registered) {
1f91bca8 536 major_info->do_register = true;
1f91bca8 537 ide1_registered = true;
e46ee8ef
S
538 } else
539 major_info->do_register = false;
540
1f91bca8
S
541 if (device_info->target_id)
542 major_info->index = 3;
e46ee8ef 543 else
1f91bca8
S
544 major_info->index = 2;
545
546 return 0;
547 } else {
548 major_info->major = 3;
e46ee8ef 549 if (!ide0_registered) {
1f91bca8 550 major_info->do_register = true;
1f91bca8 551 ide0_registered = true;
e46ee8ef
S
552 } else
553 major_info->do_register = false;
554
1f91bca8
S
555 if (device_info->target_id)
556 major_info->index = 1;
557 else
558 major_info->index = 0;
559
560 return 0;
561 }
562
563 return -ENODEV;
564}
565