{
struct device *dev;
+ /* Special case for c*d0, we only create it once. */
+ if (drv_index == 0 && h->drv[drv_index].dev != NULL)
+ return 0;
+
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev)
return -ENOMEM;
/*
* Remove sysfs entries for a logical drive.
*/
-static void cciss_destroy_ld_sysfs_entry(struct ctlr_info *h, int drv_index)
+static void cciss_destroy_ld_sysfs_entry(struct ctlr_info *h, int drv_index,
+ int ctlr_exiting)
{
struct device *dev = h->drv[drv_index].dev;
+
+ /* special case for c*d0, we only destroy it on controller exit */
+ if (drv_index == 0 && !ctlr_exiting)
+ return;
+
device_del(dev);
put_device(dev); /* the "final" put. */
h->drv[drv_index].dev = NULL;
drv_index = cciss_find_free_drive_index(h->ctlr, controller_node);
if (drv_index == -1)
return -1;
+
/*Check if the gendisk needs to be allocated */
if (!h->gendisk[drv_index]) {
h->gendisk[drv_index] =
if (h->gendisk[0] != disk) {
struct request_queue *q = disk->queue;
if (disk->flags & GENHD_FL_UP) {
- cciss_destroy_ld_sysfs_entry(h, drv_index);
+ cciss_destroy_ld_sysfs_entry(h, drv_index, 0);
del_gendisk(disk);
}
if (q) {
* indicate that this element of the drive
* array is free.
*/
-
if (clear_all) {
/* check to see if it was the last disk */
if (drv == h->drv + h->highest_lun) {
struct request_queue *q = disk->queue;
if (disk->flags & GENHD_FL_UP) {
- cciss_destroy_ld_sysfs_entry(hba[i], j);
+ cciss_destroy_ld_sysfs_entry(hba[i], j, 1);
del_gendisk(disk);
}
if (q)