diff options
Diffstat (limited to 'drivers/block/virtio_blk.c')
-rw-r--r-- | drivers/block/virtio_blk.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 0bdde8fba397..8ad21a25bc0d 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c | |||
@@ -696,7 +696,7 @@ static const struct device_attribute dev_attr_cache_type_rw = | |||
696 | __ATTR(cache_type, S_IRUGO|S_IWUSR, | 696 | __ATTR(cache_type, S_IRUGO|S_IWUSR, |
697 | virtblk_cache_type_show, virtblk_cache_type_store); | 697 | virtblk_cache_type_show, virtblk_cache_type_store); |
698 | 698 | ||
699 | static int __devinit virtblk_probe(struct virtio_device *vdev) | 699 | static int virtblk_probe(struct virtio_device *vdev) |
700 | { | 700 | { |
701 | struct virtio_blk *vblk; | 701 | struct virtio_blk *vblk; |
702 | struct request_queue *q; | 702 | struct request_queue *q; |
@@ -885,10 +885,11 @@ out: | |||
885 | return err; | 885 | return err; |
886 | } | 886 | } |
887 | 887 | ||
888 | static void __devexit virtblk_remove(struct virtio_device *vdev) | 888 | static void virtblk_remove(struct virtio_device *vdev) |
889 | { | 889 | { |
890 | struct virtio_blk *vblk = vdev->priv; | 890 | struct virtio_blk *vblk = vdev->priv; |
891 | int index = vblk->index; | 891 | int index = vblk->index; |
892 | int refc; | ||
892 | 893 | ||
893 | /* Prevent config work handler from accessing the device. */ | 894 | /* Prevent config work handler from accessing the device. */ |
894 | mutex_lock(&vblk->config_lock); | 895 | mutex_lock(&vblk->config_lock); |
@@ -903,11 +904,15 @@ static void __devexit virtblk_remove(struct virtio_device *vdev) | |||
903 | 904 | ||
904 | flush_work(&vblk->config_work); | 905 | flush_work(&vblk->config_work); |
905 | 906 | ||
907 | refc = atomic_read(&disk_to_dev(vblk->disk)->kobj.kref.refcount); | ||
906 | put_disk(vblk->disk); | 908 | put_disk(vblk->disk); |
907 | mempool_destroy(vblk->pool); | 909 | mempool_destroy(vblk->pool); |
908 | vdev->config->del_vqs(vdev); | 910 | vdev->config->del_vqs(vdev); |
909 | kfree(vblk); | 911 | kfree(vblk); |
910 | ida_simple_remove(&vd_index_ida, index); | 912 | |
913 | /* Only free device id if we don't have any users */ | ||
914 | if (refc == 1) | ||
915 | ida_simple_remove(&vd_index_ida, index); | ||
911 | } | 916 | } |
912 | 917 | ||
913 | #ifdef CONFIG_PM | 918 | #ifdef CONFIG_PM |
@@ -961,19 +966,14 @@ static unsigned int features[] = { | |||
961 | VIRTIO_BLK_F_WCE, VIRTIO_BLK_F_TOPOLOGY, VIRTIO_BLK_F_CONFIG_WCE | 966 | VIRTIO_BLK_F_WCE, VIRTIO_BLK_F_TOPOLOGY, VIRTIO_BLK_F_CONFIG_WCE |
962 | }; | 967 | }; |
963 | 968 | ||
964 | /* | 969 | static struct virtio_driver virtio_blk = { |
965 | * virtio_blk causes spurious section mismatch warning by | ||
966 | * simultaneously referring to a __devinit and a __devexit function. | ||
967 | * Use __refdata to avoid this warning. | ||
968 | */ | ||
969 | static struct virtio_driver __refdata virtio_blk = { | ||
970 | .feature_table = features, | 970 | .feature_table = features, |
971 | .feature_table_size = ARRAY_SIZE(features), | 971 | .feature_table_size = ARRAY_SIZE(features), |
972 | .driver.name = KBUILD_MODNAME, | 972 | .driver.name = KBUILD_MODNAME, |
973 | .driver.owner = THIS_MODULE, | 973 | .driver.owner = THIS_MODULE, |
974 | .id_table = id_table, | 974 | .id_table = id_table, |
975 | .probe = virtblk_probe, | 975 | .probe = virtblk_probe, |
976 | .remove = __devexit_p(virtblk_remove), | 976 | .remove = virtblk_remove, |
977 | .config_changed = virtblk_config_changed, | 977 | .config_changed = virtblk_config_changed, |
978 | #ifdef CONFIG_PM | 978 | #ifdef CONFIG_PM |
979 | .freeze = virtblk_freeze, | 979 | .freeze = virtblk_freeze, |