aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/pci
diff options
context:
space:
mode:
authorSebastian Ott <sebott@linux.vnet.ibm.com>2013-11-12 13:35:01 -0500
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2013-11-15 08:08:38 -0500
commit7d594322b2e65f7e44e82474d17b2d549e22087c (patch)
treea5f10be1ea5a095aef72bdbc7d03d25466973d44 /arch/s390/pci
parent7a572a3ab1d1d346fcde5243914a18b0218780e9 (diff)
s390/pci: implement pcibios_remove_bus
Implement pcibios_remove_bus to free arch specific data when a pci bus is deregistered. While at it remove a useless kzalloc/kfree wrapper. 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>
Diffstat (limited to 'arch/s390/pci')
-rw-r--r--arch/s390/pci/pci.c69
-rw-r--r--arch/s390/pci/pci_clp.c8
2 files changed, 39 insertions, 38 deletions
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index 63a086072edb..bf7c73d71eef 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -530,20 +530,6 @@ static void zpci_unmap_resources(struct zpci_dev *zdev)
530 } 530 }
531} 531}
532 532
533struct zpci_dev *zpci_alloc_device(void)
534{
535 struct zpci_dev *zdev;
536
537 /* Alloc memory for our private pci device data */
538 zdev = kzalloc(sizeof(*zdev), GFP_KERNEL);
539 return zdev ? : ERR_PTR(-ENOMEM);
540}
541
542void zpci_free_device(struct zpci_dev *zdev)
543{
544 kfree(zdev);
545}
546
547int pcibios_add_platform_entries(struct pci_dev *pdev) 533int pcibios_add_platform_entries(struct pci_dev *pdev)
548{ 534{
549 return zpci_sysfs_add_device(&pdev->dev); 535 return zpci_sysfs_add_device(&pdev->dev);
@@ -774,26 +760,6 @@ struct dev_pm_ops pcibios_pm_ops = {
774}; 760};
775#endif /* CONFIG_HIBERNATE_CALLBACKS */ 761#endif /* CONFIG_HIBERNATE_CALLBACKS */
776 762
777static int zpci_scan_bus(struct zpci_dev *zdev)
778{
779 LIST_HEAD(resources);
780 int ret;
781
782 ret = zpci_setup_bus_resources(zdev, &resources);
783 if (ret)
784 return ret;
785
786 zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
787 zdev, &resources);
788 if (!zdev->bus) {
789 zpci_cleanup_bus_resources(zdev);
790 return -EIO;
791 }
792
793 zdev->bus->max_bus_speed = zdev->max_bus_speed;
794 return 0;
795}
796
797static int zpci_alloc_domain(struct zpci_dev *zdev) 763static int zpci_alloc_domain(struct zpci_dev *zdev)
798{ 764{
799 spin_lock(&zpci_domain_lock); 765 spin_lock(&zpci_domain_lock);
@@ -814,6 +780,41 @@ static void zpci_free_domain(struct zpci_dev *zdev)
814 spin_unlock(&zpci_domain_lock); 780 spin_unlock(&zpci_domain_lock);
815} 781}
816 782
783void pcibios_remove_bus(struct pci_bus *bus)
784{
785 struct zpci_dev *zdev = get_zdev_by_bus(bus);
786
787 zpci_exit_slot(zdev);
788 zpci_cleanup_bus_resources(zdev);
789 zpci_free_domain(zdev);
790
791 spin_lock(&zpci_list_lock);
792 list_del(&zdev->entry);
793 spin_unlock(&zpci_list_lock);
794
795 kfree(zdev);
796}
797
798static int zpci_scan_bus(struct zpci_dev *zdev)
799{
800 LIST_HEAD(resources);
801 int ret;
802
803 ret = zpci_setup_bus_resources(zdev, &resources);
804 if (ret)
805 return ret;
806
807 zdev->bus = pci_scan_root_bus(NULL, ZPCI_BUS_NR, &pci_root_ops,
808 zdev, &resources);
809 if (!zdev->bus) {
810 zpci_cleanup_bus_resources(zdev);
811 return -EIO;
812 }
813
814 zdev->bus->max_bus_speed = zdev->max_bus_speed;
815 return 0;
816}
817
817int zpci_enable_device(struct zpci_dev *zdev) 818int zpci_enable_device(struct zpci_dev *zdev)
818{ 819{
819 int rc; 820 int rc;
diff --git a/arch/s390/pci/pci_clp.c b/arch/s390/pci/pci_clp.c
index 84147984224a..c747394029ee 100644
--- a/arch/s390/pci/pci_clp.c
+++ b/arch/s390/pci/pci_clp.c
@@ -155,9 +155,9 @@ int clp_add_pci_device(u32 fid, u32 fh, int configured)
155 int rc; 155 int rc;
156 156
157 zpci_dbg(3, "add fid:%x, fh:%x, c:%d\n", fid, fh, configured); 157 zpci_dbg(3, "add fid:%x, fh:%x, c:%d\n", fid, fh, configured);
158 zdev = zpci_alloc_device(); 158 zdev = kzalloc(sizeof(*zdev), GFP_KERNEL);
159 if (IS_ERR(zdev)) 159 if (!zdev)
160 return PTR_ERR(zdev); 160 return -ENOMEM;
161 161
162 zdev->fh = fh; 162 zdev->fh = fh;
163 zdev->fid = fid; 163 zdev->fid = fid;
@@ -178,7 +178,7 @@ int clp_add_pci_device(u32 fid, u32 fh, int configured)
178 return 0; 178 return 0;
179 179
180error: 180error:
181 zpci_free_device(zdev); 181 kfree(zdev);
182 return rc; 182 return rc;
183} 183}
184 184