aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/sunvdc.c97
1 files changed, 10 insertions, 87 deletions
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c
index 0f5e3caf85d7..2288b55d916f 100644
--- a/drivers/block/sunvdc.c
+++ b/drivers/block/sunvdc.c
@@ -45,8 +45,6 @@ struct vdc_req_entry {
45struct vdc_port { 45struct vdc_port {
46 struct vio_driver_state vio; 46 struct vio_driver_state vio;
47 47
48 struct vdc *vp;
49
50 struct gendisk *disk; 48 struct gendisk *disk;
51 49
52 struct vdc_completion *cmp; 50 struct vdc_completion *cmp;
@@ -72,8 +70,6 @@ struct vdc_port {
72 70
73 struct vio_disk_geom geom; 71 struct vio_disk_geom geom;
74 struct vio_disk_vtoc label; 72 struct vio_disk_vtoc label;
75
76 struct list_head list;
77}; 73};
78 74
79static inline struct vdc_port *to_vdc_port(struct vio_driver_state *vio) 75static inline struct vdc_port *to_vdc_port(struct vio_driver_state *vio)
@@ -81,15 +77,6 @@ static inline struct vdc_port *to_vdc_port(struct vio_driver_state *vio)
81 return container_of(vio, struct vdc_port, vio); 77 return container_of(vio, struct vdc_port, vio);
82} 78}
83 79
84struct vdc {
85 /* Protects prot_list. */
86 spinlock_t lock;
87
88 struct vio_dev *dev;
89
90 struct list_head port_list;
91};
92
93/* Ordered from largest major to lowest */ 80/* Ordered from largest major to lowest */
94static struct vio_version vdc_versions[] = { 81static struct vio_version vdc_versions[] = {
95 { .major = 1, .minor = 0 }, 82 { .major = 1, .minor = 0 },
@@ -747,21 +734,23 @@ static struct vio_driver_ops vdc_vio_ops = {
747 .handshake_complete = vdc_handshake_complete, 734 .handshake_complete = vdc_handshake_complete,
748}; 735};
749 736
737static void print_version(void)
738{
739 static int version_printed;
740
741 if (version_printed++ == 0)
742 printk(KERN_INFO "%s", version);
743}
744
750static int __devinit vdc_port_probe(struct vio_dev *vdev, 745static int __devinit vdc_port_probe(struct vio_dev *vdev,
751 const struct vio_device_id *id) 746 const struct vio_device_id *id)
752{ 747{
753 struct mdesc_handle *hp; 748 struct mdesc_handle *hp;
754 struct vdc_port *port; 749 struct vdc_port *port;
755 unsigned long flags;
756 struct vdc *vp;
757 const u64 *port_id; 750 const u64 *port_id;
758 int err; 751 int err;
759 752
760 vp = dev_get_drvdata(vdev->dev.parent); 753 print_version();
761 if (!vp) {
762 printk(KERN_ERR PFX "Cannot find port parent vdc.\n");
763 return -ENODEV;
764 }
765 754
766 hp = mdesc_grab(); 755 hp = mdesc_grab();
767 756
@@ -783,7 +772,6 @@ static int __devinit vdc_port_probe(struct vio_dev *vdev,
783 goto err_out_release_mdesc; 772 goto err_out_release_mdesc;
784 } 773 }
785 774
786 port->vp = vp;
787 port->dev_no = *port_id; 775 port->dev_no = *port_id;
788 776
789 if (port->dev_no >= 26) 777 if (port->dev_no >= 26)
@@ -818,12 +806,6 @@ static int __devinit vdc_port_probe(struct vio_dev *vdev,
818 if (err) 806 if (err)
819 goto err_out_free_tx_ring; 807 goto err_out_free_tx_ring;
820 808
821 INIT_LIST_HEAD(&port->list);
822
823 spin_lock_irqsave(&vp->lock, flags);
824 list_add(&port->list, &vp->port_list);
825 spin_unlock_irqrestore(&vp->lock, flags);
826
827 dev_set_drvdata(&vdev->dev, port); 809 dev_set_drvdata(&vdev->dev, port);
828 810
829 mdesc_release(hp); 811 mdesc_release(hp);
@@ -879,58 +861,6 @@ static struct vio_driver vdc_port_driver = {
879 } 861 }
880}; 862};
881 863
882static int __devinit vdc_probe(struct vio_dev *vdev,
883 const struct vio_device_id *id)
884{
885 static int vdc_version_printed;
886 struct vdc *vp;
887
888 if (vdc_version_printed++ == 0)
889 printk(KERN_INFO "%s", version);
890
891 vp = kzalloc(sizeof(struct vdc), GFP_KERNEL);
892 if (!vp)
893 return -ENOMEM;
894
895 spin_lock_init(&vp->lock);
896 vp->dev = vdev;
897 INIT_LIST_HEAD(&vp->port_list);
898
899 dev_set_drvdata(&vdev->dev, vp);
900
901 return 0;
902}
903
904static int vdc_remove(struct vio_dev *vdev)
905{
906
907 struct vdc *vp = dev_get_drvdata(&vdev->dev);
908
909 if (vp) {
910 kfree(vp);
911 dev_set_drvdata(&vdev->dev, NULL);
912 }
913 return 0;
914}
915
916static struct vio_device_id vdc_match[] = {
917 {
918 .type = "block",
919 },
920 {},
921};
922MODULE_DEVICE_TABLE(vio, vdc_match);
923
924static struct vio_driver vdc_driver = {
925 .id_table = vdc_match,
926 .probe = vdc_probe,
927 .remove = vdc_remove,
928 .driver = {
929 .name = "vdc",
930 .owner = THIS_MODULE,
931 }
932};
933
934static int __init vdc_init(void) 864static int __init vdc_init(void)
935{ 865{
936 int err; 866 int err;
@@ -940,19 +870,13 @@ static int __init vdc_init(void)
940 goto out_err; 870 goto out_err;
941 871
942 vdc_major = err; 872 vdc_major = err;
943 err = vio_register_driver(&vdc_driver);
944 if (err)
945 goto out_unregister_blkdev;
946 873
947 err = vio_register_driver(&vdc_port_driver); 874 err = vio_register_driver(&vdc_port_driver);
948 if (err) 875 if (err)
949 goto out_unregister_vdc; 876 goto out_unregister_blkdev;
950 877
951 return 0; 878 return 0;
952 879
953out_unregister_vdc:
954 vio_unregister_driver(&vdc_driver);
955
956out_unregister_blkdev: 880out_unregister_blkdev:
957 unregister_blkdev(vdc_major, VDCBLK_NAME); 881 unregister_blkdev(vdc_major, VDCBLK_NAME);
958 vdc_major = 0; 882 vdc_major = 0;
@@ -964,7 +888,6 @@ out_err:
964static void __exit vdc_exit(void) 888static void __exit vdc_exit(void)
965{ 889{
966 vio_unregister_driver(&vdc_port_driver); 890 vio_unregister_driver(&vdc_port_driver);
967 vio_unregister_driver(&vdc_driver);
968 unregister_blkdev(vdc_major, VDCBLK_NAME); 891 unregister_blkdev(vdc_major, VDCBLK_NAME);
969} 892}
970 893