aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Stach <l.stach@pengutronix.de>2014-09-05 11:37:55 -0400
committerBjorn Helgaas <bhelgaas@google.com>2014-09-05 11:37:55 -0400
commit84a263f39403ca3b399af77499876e02e634b00b (patch)
tree780101865be4d2e993a45a482df09feb64552d03
parent8ddebc4103e6544bd31f0c97e55491387717a124 (diff)
PCI: designware: Check private_data validity in single place
The driver had checks for this sprinkled all over. As we call sys_to_pcie() before every instance of this check, we can move the check to this single location to make things clear. Removing the statements after BUG[_ON]() is safe as the kernel is halted at this point anyway. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Jingoo Han <jg1.han@samsung.com> Acked-by: Mohit Kumar <mohit.kumar@st.com>
-rw-r--r--drivers/pci/host/pcie-designware.c29
1 files changed, 2 insertions, 27 deletions
diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 538bbf310e44..12c42fcd7c35 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -73,6 +73,8 @@ static unsigned long global_io_offset;
73 73
74static inline struct pcie_port *sys_to_pcie(struct pci_sys_data *sys) 74static inline struct pcie_port *sys_to_pcie(struct pci_sys_data *sys)
75{ 75{
76 BUG_ON(!sys->private_data);
77
76 return sys->private_data; 78 return sys->private_data;
77} 79}
78 80
@@ -261,11 +263,6 @@ static int assign_irq(int no_irqs, struct msi_desc *desc, int *pos)
261 int irq, pos0, pos1, i; 263 int irq, pos0, pos1, i;
262 struct pcie_port *pp = sys_to_pcie(desc->dev->bus->sysdata); 264 struct pcie_port *pp = sys_to_pcie(desc->dev->bus->sysdata);
263 265
264 if (!pp) {
265 BUG();
266 return -EINVAL;
267 }
268
269 pos0 = find_first_zero_bit(pp->msi_irq_in_use, 266 pos0 = find_first_zero_bit(pp->msi_irq_in_use,
270 MAX_MSI_IRQS); 267 MAX_MSI_IRQS);
271 if (pos0 % no_irqs) { 268 if (pos0 % no_irqs) {
@@ -326,10 +323,6 @@ static void clear_irq(unsigned int irq)
326 /* get the port structure */ 323 /* get the port structure */
327 msi = irq_data_get_msi(data); 324 msi = irq_data_get_msi(data);
328 pp = sys_to_pcie(msi->dev->bus->sysdata); 325 pp = sys_to_pcie(msi->dev->bus->sysdata);
329 if (!pp) {
330 BUG();
331 return;
332 }
333 326
334 /* undo what was done in assign_irq */ 327 /* undo what was done in assign_irq */
335 pos = data->hwirq; 328 pos = data->hwirq;
@@ -350,11 +343,6 @@ static int dw_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev,
350 struct msi_msg msg; 343 struct msi_msg msg;
351 struct pcie_port *pp = sys_to_pcie(pdev->bus->sysdata); 344 struct pcie_port *pp = sys_to_pcie(pdev->bus->sysdata);
352 345
353 if (!pp) {
354 BUG();
355 return -EINVAL;
356 }
357
358 pci_read_config_word(pdev, desc->msi_attrib.pos+PCI_MSI_FLAGS, 346 pci_read_config_word(pdev, desc->msi_attrib.pos+PCI_MSI_FLAGS,
359 &msg_ctr); 347 &msg_ctr);
360 msgvec = (msg_ctr&PCI_MSI_FLAGS_QSIZE) >> 4; 348 msgvec = (msg_ctr&PCI_MSI_FLAGS_QSIZE) >> 4;
@@ -729,11 +717,6 @@ static int dw_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
729 struct pcie_port *pp = sys_to_pcie(bus->sysdata); 717 struct pcie_port *pp = sys_to_pcie(bus->sysdata);
730 int ret; 718 int ret;
731 719
732 if (!pp) {
733 BUG();
734 return -EINVAL;
735 }
736
737 if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0) { 720 if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0) {
738 *val = 0xffffffff; 721 *val = 0xffffffff;
739 return PCIBIOS_DEVICE_NOT_FOUND; 722 return PCIBIOS_DEVICE_NOT_FOUND;
@@ -758,11 +741,6 @@ static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
758 struct pcie_port *pp = sys_to_pcie(bus->sysdata); 741 struct pcie_port *pp = sys_to_pcie(bus->sysdata);
759 int ret; 742 int ret;
760 743
761 if (!pp) {
762 BUG();
763 return -EINVAL;
764 }
765
766 if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0) 744 if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0)
767 return PCIBIOS_DEVICE_NOT_FOUND; 745 return PCIBIOS_DEVICE_NOT_FOUND;
768 746
@@ -790,9 +768,6 @@ static int dw_pcie_setup(int nr, struct pci_sys_data *sys)
790 768
791 pp = sys_to_pcie(sys); 769 pp = sys_to_pcie(sys);
792 770
793 if (!pp)
794 return 0;
795
796 if (global_io_offset < SZ_1M && pp->config.io_size > 0) { 771 if (global_io_offset < SZ_1M && pp->config.io_size > 0) {
797 sys->io_offset = global_io_offset - pp->config.io_bus_addr; 772 sys->io_offset = global_io_offset - pp->config.io_bus_addr;
798 pci_ioremap_io(global_io_offset, pp->io_base); 773 pci_ioremap_io(global_io_offset, pp->io_base);