@@ -176,14 +176,48 @@ static u32 *find_pci_config_dword(struct aer_error *err, int where,
176
176
return target ;
177
177
}
178
178
179
+ static int aer_inj_read (struct pci_bus * bus , unsigned int devfn , int where ,
180
+ int size , u32 * val )
181
+ {
182
+ struct pci_ops * ops , * my_ops ;
183
+ int rv ;
184
+
185
+ ops = __find_pci_bus_ops (bus );
186
+ if (!ops )
187
+ return -1 ;
188
+
189
+ my_ops = bus -> ops ;
190
+ bus -> ops = ops ;
191
+ rv = ops -> read (bus , devfn , where , size , val );
192
+ bus -> ops = my_ops ;
193
+
194
+ return rv ;
195
+ }
196
+
197
+ static int aer_inj_write (struct pci_bus * bus , unsigned int devfn , int where ,
198
+ int size , u32 val )
199
+ {
200
+ struct pci_ops * ops , * my_ops ;
201
+ int rv ;
202
+
203
+ ops = __find_pci_bus_ops (bus );
204
+ if (!ops )
205
+ return -1 ;
206
+
207
+ my_ops = bus -> ops ;
208
+ bus -> ops = ops ;
209
+ rv = ops -> write (bus , devfn , where , size , val );
210
+ bus -> ops = my_ops ;
211
+
212
+ return rv ;
213
+ }
214
+
179
215
static int aer_inj_read_config (struct pci_bus * bus , unsigned int devfn ,
180
216
int where , int size , u32 * val )
181
217
{
182
218
u32 * sim ;
183
219
struct aer_error * err ;
184
220
unsigned long flags ;
185
- struct pci_ops * ops ;
186
- struct pci_ops * my_ops ;
187
221
int domain ;
188
222
int rv ;
189
223
@@ -204,18 +238,7 @@ static int aer_inj_read_config(struct pci_bus *bus, unsigned int devfn,
204
238
return 0 ;
205
239
}
206
240
out :
207
- ops = __find_pci_bus_ops (bus );
208
- /*
209
- * pci_lock must already be held, so we can directly
210
- * manipulate bus->ops. Many config access functions,
211
- * including pci_generic_config_read() require the original
212
- * bus->ops be installed to function, so temporarily put them
213
- * back.
214
- */
215
- my_ops = bus -> ops ;
216
- bus -> ops = ops ;
217
- rv = ops -> read (bus , devfn , where , size , val );
218
- bus -> ops = my_ops ;
241
+ rv = aer_inj_read (bus , devfn , where , size , val );
219
242
spin_unlock_irqrestore (& inject_lock , flags );
220
243
return rv ;
221
244
}
@@ -227,8 +250,6 @@ static int aer_inj_write_config(struct pci_bus *bus, unsigned int devfn,
227
250
struct aer_error * err ;
228
251
unsigned long flags ;
229
252
int rw1cs ;
230
- struct pci_ops * ops ;
231
- struct pci_ops * my_ops ;
232
253
int domain ;
233
254
int rv ;
234
255
@@ -252,18 +273,7 @@ static int aer_inj_write_config(struct pci_bus *bus, unsigned int devfn,
252
273
return 0 ;
253
274
}
254
275
out :
255
- ops = __find_pci_bus_ops (bus );
256
- /*
257
- * pci_lock must already be held, so we can directly
258
- * manipulate bus->ops. Many config access functions,
259
- * including pci_generic_config_write() require the original
260
- * bus->ops be installed to function, so temporarily put them
261
- * back.
262
- */
263
- my_ops = bus -> ops ;
264
- bus -> ops = ops ;
265
- rv = ops -> write (bus , devfn , where , size , val );
266
- bus -> ops = my_ops ;
276
+ rv = aer_inj_write (bus , devfn , where , size , val );
267
277
spin_unlock_irqrestore (& inject_lock , flags );
268
278
return rv ;
269
279
}
0 commit comments