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