aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2012-03-10 08:31:34 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-05-16 10:24:11 -0400
commit43ba990bb7bf741f4b2f405b35dc02823d68a682 (patch)
treec32201f703e096c2fcd98a76c217052de4e37d07
parentc23bfc3835173f5229b2503e3b616001a28affad (diff)
ARM: PCI: dove/kirkwood/mv78xx0: use sys->private_data
Use sys->private_data to store the PCIe port data structure. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/mach-dove/pcie.c23
-rw-r--r--arch/arm/mach-kirkwood/pcie.c15
-rw-r--r--arch/arm/mach-mv78xx0/pcie.c23
3 files changed, 20 insertions, 41 deletions
diff --git a/arch/arm/mach-dove/pcie.c b/arch/arm/mach-dove/pcie.c
index cebf6a30a5f1..47921b0cdc65 100644
--- a/arch/arm/mach-dove/pcie.c
+++ b/arch/arm/mach-dove/pcie.c
@@ -43,6 +43,7 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys)
43 return 0; 43 return 0;
44 44
45 pp = &pcie_port[nr]; 45 pp = &pcie_port[nr];
46 sys->private_data = pp;
46 pp->root_bus_nr = sys->busnr; 47 pp->root_bus_nr = sys->busnr;
47 48
48 /* 49 /*
@@ -93,19 +94,6 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys)
93 return 1; 94 return 1;
94} 95}
95 96
96static struct pcie_port *bus_to_port(int bus)
97{
98 int i;
99
100 for (i = num_pcie_ports - 1; i >= 0; i--) {
101 int rbus = pcie_port[i].root_bus_nr;
102 if (rbus != -1 && rbus <= bus)
103 break;
104 }
105
106 return i >= 0 ? pcie_port + i : NULL;
107}
108
109static int pcie_valid_config(struct pcie_port *pp, int bus, int dev) 97static int pcie_valid_config(struct pcie_port *pp, int bus, int dev)
110{ 98{
111 /* 99 /*
@@ -121,7 +109,8 @@ static int pcie_valid_config(struct pcie_port *pp, int bus, int dev)
121static int pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where, 109static int pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
122 int size, u32 *val) 110 int size, u32 *val)
123{ 111{
124 struct pcie_port *pp = bus_to_port(bus->number); 112 struct pci_sys_data *sys = bus->sysdata;
113 struct pcie_port *pp = sys->private_data;
125 unsigned long flags; 114 unsigned long flags;
126 int ret; 115 int ret;
127 116
@@ -140,7 +129,8 @@ static int pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
140static int pcie_wr_conf(struct pci_bus *bus, u32 devfn, 129static int pcie_wr_conf(struct pci_bus *bus, u32 devfn,
141 int where, int size, u32 val) 130 int where, int size, u32 val)
142{ 131{
143 struct pcie_port *pp = bus_to_port(bus->number); 132 struct pci_sys_data *sys = bus->sysdata;
133 struct pcie_port *pp = sys->private_data;
144 unsigned long flags; 134 unsigned long flags;
145 int ret; 135 int ret;
146 136
@@ -194,7 +184,8 @@ dove_pcie_scan_bus(int nr, struct pci_sys_data *sys)
194 184
195static int __init dove_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) 185static int __init dove_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
196{ 186{
197 struct pcie_port *pp = bus_to_port(dev->bus->number); 187 struct pci_sys_data *sys = dev->sysdata;
188 struct pcie_port *pp = sys->private_data;
198 189
199 return pp->index ? IRQ_DOVE_PCIE1 : IRQ_DOVE_PCIE0; 190 return pp->index ? IRQ_DOVE_PCIE1 : IRQ_DOVE_PCIE0;
200} 191}
diff --git a/arch/arm/mach-kirkwood/pcie.c b/arch/arm/mach-kirkwood/pcie.c
index b1034b028673..de373176ee67 100644
--- a/arch/arm/mach-kirkwood/pcie.c
+++ b/arch/arm/mach-kirkwood/pcie.c
@@ -44,12 +44,6 @@ struct pcie_port {
44static int pcie_port_map[2]; 44static int pcie_port_map[2];
45static int num_pcie_ports; 45static int num_pcie_ports;
46 46
47static inline struct pcie_port *bus_to_port(struct pci_bus *bus)
48{
49 struct pci_sys_data *sys = bus->sysdata;
50 return sys->private_data;
51}
52
53static int pcie_valid_config(struct pcie_port *pp, int bus, int dev) 47static int pcie_valid_config(struct pcie_port *pp, int bus, int dev)
54{ 48{
55 /* 49 /*
@@ -79,7 +73,8 @@ static int pcie_valid_config(struct pcie_port *pp, int bus, int dev)
79static int pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where, 73static int pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
80 int size, u32 *val) 74 int size, u32 *val)
81{ 75{
82 struct pcie_port *pp = bus_to_port(bus); 76 struct pci_sys_data *sys = bus->sysdata;
77 struct pcie_port *pp = sys->private_data;
83 unsigned long flags; 78 unsigned long flags;
84 int ret; 79 int ret;
85 80
@@ -98,7 +93,8 @@ static int pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
98static int pcie_wr_conf(struct pci_bus *bus, u32 devfn, 93static int pcie_wr_conf(struct pci_bus *bus, u32 devfn,
99 int where, int size, u32 val) 94 int where, int size, u32 val)
100{ 95{
101 struct pcie_port *pp = bus_to_port(bus); 96 struct pci_sys_data *sys = bus->sysdata;
97 struct pcie_port *pp = sys->private_data;
102 unsigned long flags; 98 unsigned long flags;
103 int ret; 99 int ret;
104 100
@@ -248,7 +244,8 @@ kirkwood_pcie_scan_bus(int nr, struct pci_sys_data *sys)
248static int __init kirkwood_pcie_map_irq(const struct pci_dev *dev, u8 slot, 244static int __init kirkwood_pcie_map_irq(const struct pci_dev *dev, u8 slot,
249 u8 pin) 245 u8 pin)
250{ 246{
251 struct pcie_port *pp = bus_to_port(dev->bus); 247 struct pci_sys_data *sys = dev->sysdata;
248 struct pcie_port *pp = sys->private_data;
252 249
253 return pp->irq; 250 return pp->irq;
254} 251}
diff --git a/arch/arm/mach-mv78xx0/pcie.c b/arch/arm/mach-mv78xx0/pcie.c
index 53f2fb5607f9..2e56e86b6d68 100644
--- a/arch/arm/mach-mv78xx0/pcie.c
+++ b/arch/arm/mach-mv78xx0/pcie.c
@@ -147,6 +147,7 @@ static int __init mv78xx0_pcie_setup(int nr, struct pci_sys_data *sys)
147 return 0; 147 return 0;
148 148
149 pp = &pcie_port[nr]; 149 pp = &pcie_port[nr];
150 sys->private_data = pp;
150 pp->root_bus_nr = sys->busnr; 151 pp->root_bus_nr = sys->busnr;
151 152
152 /* 153 /*
@@ -161,19 +162,6 @@ static int __init mv78xx0_pcie_setup(int nr, struct pci_sys_data *sys)
161 return 1; 162 return 1;
162} 163}
163 164
164static struct pcie_port *bus_to_port(int bus)
165{
166 int i;
167
168 for (i = num_pcie_ports - 1; i >= 0; i--) {
169 int rbus = pcie_port[i].root_bus_nr;
170 if (rbus != -1 && rbus <= bus)
171 break;
172 }
173
174 return i >= 0 ? pcie_port + i : NULL;
175}
176
177static int pcie_valid_config(struct pcie_port *pp, int bus, int dev) 165static int pcie_valid_config(struct pcie_port *pp, int bus, int dev)
178{ 166{
179 /* 167 /*
@@ -189,7 +177,8 @@ static int pcie_valid_config(struct pcie_port *pp, int bus, int dev)
189static int pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where, 177static int pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
190 int size, u32 *val) 178 int size, u32 *val)
191{ 179{
192 struct pcie_port *pp = bus_to_port(bus->number); 180 struct pci_sys_data *sys = bus->sysdata;
181 struct pcie_port *pp = sys->private_data;
193 unsigned long flags; 182 unsigned long flags;
194 int ret; 183 int ret;
195 184
@@ -208,7 +197,8 @@ static int pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
208static int pcie_wr_conf(struct pci_bus *bus, u32 devfn, 197static int pcie_wr_conf(struct pci_bus *bus, u32 devfn,
209 int where, int size, u32 val) 198 int where, int size, u32 val)
210{ 199{
211 struct pcie_port *pp = bus_to_port(bus->number); 200 struct pci_sys_data *sys = bus->sysdata;
201 struct pcie_port *pp = sys->private_data;
212 unsigned long flags; 202 unsigned long flags;
213 int ret; 203 int ret;
214 204
@@ -263,7 +253,8 @@ mv78xx0_pcie_scan_bus(int nr, struct pci_sys_data *sys)
263static int __init mv78xx0_pcie_map_irq(const struct pci_dev *dev, u8 slot, 253static int __init mv78xx0_pcie_map_irq(const struct pci_dev *dev, u8 slot,
264 u8 pin) 254 u8 pin)
265{ 255{
266 struct pcie_port *pp = bus_to_port(dev->bus->number); 256 struct pci_sys_data *sys = dev->bus->sysdata;
257 struct pcie_port *pp = sys->private_data;
267 258
268 return IRQ_MV78XX0_PCIE_00 + (pp->maj << 2) + pp->min; 259 return IRQ_MV78XX0_PCIE_00 + (pp->maj << 2) + pp->min;
269} 260}