Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/pci: cleanup hotplug code

Provide wrappers for the [de]configure operations, add some error
handling, and use pci_scan_slot instead of pci_scan_single_device.

Reviewed-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Sebastian Ott and committed by
Martin Schwidefsky
4bee2a5d 944239c5

+40 -33
-1
arch/s390/include/asm/pci.h
··· 143 143 int zpci_disable_device(struct zpci_dev *); 144 144 void zpci_stop_device(struct zpci_dev *); 145 145 void zpci_free_device(struct zpci_dev *); 146 - int zpci_scan_device(struct zpci_dev *); 147 146 int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64); 148 147 int zpci_unregister_ioat(struct zpci_dev *, u8); 149 148
-19
arch/s390/pci/pci.c
··· 974 974 } 975 975 EXPORT_SYMBOL_GPL(zpci_stop_device); 976 976 977 - int zpci_scan_device(struct zpci_dev *zdev) 978 - { 979 - zdev->pdev = pci_scan_single_device(zdev->bus, ZPCI_DEVFN); 980 - if (!zdev->pdev) { 981 - pr_err("pci_scan_single_device failed for fid: 0x%x\n", 982 - zdev->fid); 983 - goto out; 984 - } 985 - 986 - pci_bus_add_devices(zdev->bus); 987 - 988 - return 0; 989 - out: 990 - zpci_dma_exit_device(zdev); 991 - clp_disable_fh(zdev); 992 - return -EIO; 993 - } 994 - EXPORT_SYMBOL_GPL(zpci_scan_device); 995 - 996 977 static inline int barsize(u8 size) 997 978 { 998 979 return (size) ? (1 << size) >> 10 : 0;
+40 -13
drivers/pci/hotplug/s390_pci_hpc.c
··· 41 41 struct zpci_dev *zdev; 42 42 }; 43 43 44 + static inline int slot_configure(struct slot *slot) 45 + { 46 + int ret = sclp_pci_configure(slot->zdev->fid); 47 + 48 + zpci_dbg(3, "conf fid:%x, rc:%d\n", slot->zdev->fid, ret); 49 + if (!ret) 50 + slot->zdev->state = ZPCI_FN_STATE_CONFIGURED; 51 + 52 + return ret; 53 + } 54 + 55 + static inline int slot_deconfigure(struct slot *slot) 56 + { 57 + int ret = sclp_pci_deconfigure(slot->zdev->fid); 58 + 59 + zpci_dbg(3, "deconf fid:%x, rc:%d\n", slot->zdev->fid, ret); 60 + if (!ret) 61 + slot->zdev->state = ZPCI_FN_STATE_STANDBY; 62 + 63 + return ret; 64 + } 65 + 44 66 static int enable_slot(struct hotplug_slot *hotplug_slot) 45 67 { 46 68 struct slot *slot = hotplug_slot->private; ··· 71 49 if (slot->zdev->state != ZPCI_FN_STATE_STANDBY) 72 50 return -EIO; 73 51 74 - rc = sclp_pci_configure(slot->zdev->fid); 75 - zpci_dbg(3, "conf fid:%x, rc:%d\n", slot->zdev->fid, rc); 76 - if (!rc) { 77 - slot->zdev->state = ZPCI_FN_STATE_CONFIGURED; 78 - /* automatically scan the device after is was configured */ 79 - zpci_enable_device(slot->zdev); 80 - zpci_scan_device(slot->zdev); 81 - } 52 + rc = slot_configure(slot); 53 + if (rc) 54 + return rc; 55 + 56 + rc = zpci_enable_device(slot->zdev); 57 + if (rc) 58 + goto out_deconfigure; 59 + 60 + slot->zdev->state = ZPCI_FN_STATE_ONLINE; 61 + 62 + pci_scan_slot(slot->zdev->bus, ZPCI_DEVFN); 63 + pci_bus_add_devices(slot->zdev->bus); 64 + 65 + return rc; 66 + 67 + out_deconfigure: 68 + slot_deconfigure(slot); 82 69 return rc; 83 70 } 84 71 ··· 105 74 /* TODO: we rely on the user to unbind/remove the device, is that plausible 106 75 * or do we need to trigger that here? 107 76 */ 108 - rc = sclp_pci_deconfigure(slot->zdev->fid); 109 - zpci_dbg(3, "deconf fid:%x, rc:%d\n", slot->zdev->fid, rc); 110 - if (!rc) 111 - slot->zdev->state = ZPCI_FN_STATE_STANDBY; 112 - return rc; 77 + return slot_deconfigure(slot); 113 78 } 114 79 115 80 static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)