aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@infradead.org>2018-06-11 15:41:25 -0400
committerMatthew Wilcox <willy@infradead.org>2018-08-21 23:54:17 -0400
commit5963e78d0cb6d5950cb22c1c0a9a31067483933d (patch)
tree3f6599b8033fc0a9bb44fe62a6875f9dc987dc24
parent9401508012e2044ce841a57bc453c5746b671851 (diff)
osd: Convert to new IDA API
Slightly simpler code. Signed-off-by: Matthew Wilcox <willy@infradead.org>
-rw-r--r--drivers/scsi/osd/osd_uld.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
index 0e56f1eb05dc..eaf36ccf58db 100644
--- a/drivers/scsi/osd/osd_uld.c
+++ b/drivers/scsi/osd/osd_uld.c
@@ -423,19 +423,11 @@ static int osd_probe(struct device *dev)
423 if (scsi_device->type != TYPE_OSD) 423 if (scsi_device->type != TYPE_OSD)
424 return -ENODEV; 424 return -ENODEV;
425 425
426 do { 426 minor = ida_alloc_max(&osd_minor_ida, SCSI_OSD_MAX_MINOR, GFP_KERNEL);
427 if (!ida_pre_get(&osd_minor_ida, GFP_KERNEL)) 427 if (minor == -ENOSPC)
428 return -ENODEV; 428 return -EBUSY;
429 429 if (minor < 0)
430 error = ida_get_new(&osd_minor_ida, &minor); 430 return -ENODEV;
431 } while (error == -EAGAIN);
432
433 if (error)
434 return error;
435 if (minor >= SCSI_OSD_MAX_MINOR) {
436 error = -EBUSY;
437 goto err_retract_minor;
438 }
439 431
440 error = -ENOMEM; 432 error = -ENOMEM;
441 oud = kzalloc(sizeof(*oud), GFP_KERNEL); 433 oud = kzalloc(sizeof(*oud), GFP_KERNEL);
@@ -499,7 +491,7 @@ static int osd_probe(struct device *dev)
499err_free_osd: 491err_free_osd:
500 put_device(&oud->class_dev); 492 put_device(&oud->class_dev);
501err_retract_minor: 493err_retract_minor:
502 ida_remove(&osd_minor_ida, minor); 494 ida_free(&osd_minor_ida, minor);
503 return error; 495 return error;
504} 496}
505 497
@@ -514,7 +506,7 @@ static int osd_remove(struct device *dev)
514 } 506 }
515 507
516 cdev_device_del(&oud->cdev, &oud->class_dev); 508 cdev_device_del(&oud->cdev, &oud->class_dev);
517 ida_remove(&osd_minor_ida, oud->minor); 509 ida_free(&osd_minor_ida, oud->minor);
518 put_device(&oud->class_dev); 510 put_device(&oud->class_dev);
519 511
520 return 0; 512 return 0;