[PATCH] Add {css,ccw}_bus_type probe, remove, shutdown methods.

The following patch converts css_bus_type and ccw_bus_type to use
the new bus_type methods.

Signed-off-by: Cornelia Huck <huckc@de.ibm.com>
CC: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by Cornelia Huck and committed by Greg Kroah-Hartman 8bbace7e 348290a4

+62 -28
+34 -2
drivers/s390/cio/css.c
··· 542 542 return 0; 543 543 } 544 544 545 + static int 546 + css_probe (struct device *dev) 547 + { 548 + struct subchannel *sch; 549 + 550 + sch = to_subchannel(dev); 551 + sch->driver = container_of (dev->driver, struct css_driver, drv); 552 + return (sch->driver->probe ? sch->driver->probe(sch) : 0); 553 + } 554 + 555 + static int 556 + css_remove (struct device *dev) 557 + { 558 + struct subchannel *sch; 559 + 560 + sch = to_subchannel(dev); 561 + return (sch->driver->remove ? sch->driver->remove(sch) : 0); 562 + } 563 + 564 + static void 565 + css_shutdown (struct device *dev) 566 + { 567 + struct subchannel *sch; 568 + 569 + sch = to_subchannel(dev); 570 + if (sch->driver->shutdown) 571 + sch->driver->shutdown(sch); 572 + } 573 + 545 574 struct bus_type css_bus_type = { 546 - .name = "css", 547 - .match = &css_bus_match, 575 + .name = "css", 576 + .match = css_bus_match, 577 + .probe = css_probe, 578 + .remove = css_remove, 579 + .shutdown = css_shutdown, 548 580 }; 549 581 550 582 subsys_initcall(init_channel_subsystem);
+4
drivers/s390/cio/css.h
··· 115 115 * Currently, we only care about I/O subchannels (type 0), these 116 116 * have a ccw_device connected to them. 117 117 */ 118 + struct subchannel; 118 119 struct css_driver { 119 120 unsigned int subchannel_type; 120 121 struct device_driver drv; ··· 123 122 int (*notify)(struct device *, int); 124 123 void (*verify)(struct device *); 125 124 void (*termination)(struct device *); 125 + int (*probe)(struct subchannel *); 126 + int (*remove)(struct subchannel *); 127 + void (*shutdown)(struct subchannel *); 126 128 }; 127 129 128 130 /*
+24 -26
drivers/s390/cio/device.c
··· 107 107 return 0; 108 108 } 109 109 110 - struct bus_type ccw_bus_type = { 111 - .name = "ccw", 112 - .match = &ccw_bus_match, 113 - .uevent = &ccw_uevent, 114 - }; 110 + struct bus_type ccw_bus_type; 115 111 116 - static int io_subchannel_probe (struct device *); 117 - static int io_subchannel_remove (struct device *); 112 + static int io_subchannel_probe (struct subchannel *); 113 + static int io_subchannel_remove (struct subchannel *); 118 114 void io_subchannel_irq (struct device *); 119 115 static int io_subchannel_notify(struct device *, int); 120 116 static void io_subchannel_verify(struct device *); 121 117 static void io_subchannel_ioterm(struct device *); 122 - static void io_subchannel_shutdown(struct device *); 118 + static void io_subchannel_shutdown(struct subchannel *); 123 119 124 120 struct css_driver io_subchannel_driver = { 125 121 .subchannel_type = SUBCHANNEL_TYPE_IO, 126 122 .drv = { 127 123 .name = "io_subchannel", 128 124 .bus = &css_bus_type, 129 - .probe = &io_subchannel_probe, 130 - .remove = &io_subchannel_remove, 131 - .shutdown = &io_subchannel_shutdown, 132 125 }, 133 126 .irq = io_subchannel_irq, 134 127 .notify = io_subchannel_notify, 135 128 .verify = io_subchannel_verify, 136 129 .termination = io_subchannel_ioterm, 130 + .probe = io_subchannel_probe, 131 + .remove = io_subchannel_remove, 132 + .shutdown = io_subchannel_shutdown, 137 133 }; 138 134 139 135 struct workqueue_struct *ccw_device_work; ··· 799 803 } 800 804 801 805 static int 802 - io_subchannel_probe (struct device *pdev) 806 + io_subchannel_probe (struct subchannel *sch) 803 807 { 804 - struct subchannel *sch; 805 808 struct ccw_device *cdev; 806 809 int rc; 807 810 unsigned long flags; 808 811 809 - sch = to_subchannel(pdev); 810 812 if (sch->dev.driver_data) { 811 813 /* 812 814 * This subchannel already has an associated ccw_device. ··· 840 846 memset(cdev->private, 0, sizeof(struct ccw_device_private)); 841 847 atomic_set(&cdev->private->onoff, 0); 842 848 cdev->dev = (struct device) { 843 - .parent = pdev, 849 + .parent = &sch->dev, 844 850 .release = ccw_device_release, 845 851 }; 846 852 INIT_LIST_HEAD(&cdev->private->kick_work.entry); ··· 853 859 return -ENODEV; 854 860 } 855 861 856 - rc = io_subchannel_recog(cdev, to_subchannel(pdev)); 862 + rc = io_subchannel_recog(cdev, sch); 857 863 if (rc) { 858 864 spin_lock_irqsave(&sch->lock, flags); 859 865 sch->dev.driver_data = NULL; ··· 877 883 } 878 884 879 885 static int 880 - io_subchannel_remove (struct device *dev) 886 + io_subchannel_remove (struct subchannel *sch) 881 887 { 882 888 struct ccw_device *cdev; 883 889 unsigned long flags; 884 890 885 - if (!dev->driver_data) 891 + if (!sch->dev.driver_data) 886 892 return 0; 887 - cdev = dev->driver_data; 893 + cdev = sch->dev.driver_data; 888 894 /* Set ccw device to not operational and drop reference. */ 889 895 spin_lock_irqsave(cdev->ccwlock, flags); 890 - dev->driver_data = NULL; 896 + sch->dev.driver_data = NULL; 891 897 cdev->private->state = DEV_STATE_NOT_OPER; 892 898 spin_unlock_irqrestore(cdev->ccwlock, flags); 893 899 /* ··· 942 948 } 943 949 944 950 static void 945 - io_subchannel_shutdown(struct device *dev) 951 + io_subchannel_shutdown(struct subchannel *sch) 946 952 { 947 - struct subchannel *sch; 948 953 struct ccw_device *cdev; 949 954 int ret; 950 955 951 - sch = to_subchannel(dev); 952 - cdev = dev->driver_data; 956 + cdev = sch->dev.driver_data; 953 957 954 958 if (cio_is_console(sch->schid)) 955 959 return; ··· 1121 1129 return 0; 1122 1130 } 1123 1131 1132 + struct bus_type ccw_bus_type = { 1133 + .name = "ccw", 1134 + .match = ccw_bus_match, 1135 + .uevent = ccw_uevent, 1136 + .probe = ccw_device_probe, 1137 + .remove = ccw_device_remove, 1138 + }; 1139 + 1124 1140 int 1125 1141 ccw_driver_register (struct ccw_driver *cdriver) 1126 1142 { ··· 1136 1136 1137 1137 drv->bus = &ccw_bus_type; 1138 1138 drv->name = cdriver->name; 1139 - drv->probe = ccw_device_probe; 1140 - drv->remove = ccw_device_remove; 1141 1139 1142 1140 return driver_register(drv); 1143 1141 }