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

parisc: remove klist iterators

commit 11c3b5c3e08f4d855cbef52883c266b9ab9df879
Author: Greg Kroah-Hartman <gregkh@suse.de>
Date: Tue Dec 16 12:24:56 2008 -0800

driver core: move klist_children into private structure

Broke our parisc build pretty badly because we touch the klists directly
in three cases (AGP, SBA and GSC). Although GregKH will revert this
patch, there's no reason we should be using the iterators directly, we
can just move to the standard device_for_each_child() API.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Tested-by: Helge Deller <deller@gmx.de>
Tested-by: Kyle McMartin <kyle@mcmartin.ca>
Signed-off-by: Kyle McMartin <kyle@mcmartin.ca>

authored by

James Bottomley and committed by
Kyle McMartin
bfe4f4f8 8980a7ba

+66 -53
+11 -12
drivers/char/agp/parisc-agp.c
··· 359 359 return error; 360 360 } 361 361 362 - static struct device *next_device(struct klist_iter *i) { 363 - struct klist_node * n = klist_next(i); 364 - return n ? container_of(n, struct device, knode_parent) : NULL; 362 + static int 363 + find_quicksilver(struct device *dev, void *data) 364 + { 365 + struct parisc_device **lba = data; 366 + struct parisc_device *padev = to_parisc_device(dev); 367 + 368 + if (IS_QUICKSILVER(padev)) 369 + *lba = padev; 370 + 371 + return 0; 365 372 } 366 373 367 374 static int ··· 379 372 int err = -1; 380 373 struct parisc_device *sba = NULL, *lba = NULL; 381 374 struct lba_device *lbadev = NULL; 382 - struct device *dev = NULL; 383 - struct klist_iter i; 384 375 385 376 if (!sba_list) 386 377 goto out; ··· 391 386 } 392 387 393 388 /* Now search our Pluto for our precious AGP device... */ 394 - klist_iter_init(&sba->dev.klist_children, &i); 395 - while ((dev = next_device(&i))) { 396 - struct parisc_device *padev = to_parisc_device(dev); 397 - if (IS_QUICKSILVER(padev)) 398 - lba = padev; 399 - } 400 - klist_iter_exit(&i); 389 + device_for_each_child(&sba->dev, &lba, find_quicksilver); 401 390 402 391 if (!lba) { 403 392 printk(KERN_INFO DRVPFX "No AGP devices found.\n");
+21 -16
drivers/parisc/gsc.c
··· 186 186 *irqp = irq; 187 187 } 188 188 189 - static struct device *next_device(struct klist_iter *i) 189 + struct gsc_fixup_struct { 190 + void (*choose_irq)(struct parisc_device *, void *); 191 + void *ctrl; 192 + }; 193 + 194 + static int gsc_fixup_irqs_callback(struct device *dev, void *data) 190 195 { 191 - struct klist_node * n = klist_next(i); 192 - return n ? container_of(n, struct device, knode_parent) : NULL; 196 + struct parisc_device *padev = to_parisc_device(dev); 197 + struct gsc_fixup_struct *gf = data; 198 + 199 + /* work-around for 715/64 and others which have parent 200 + at path [5] and children at path [5/0/x] */ 201 + if (padev->id.hw_type == HPHW_FAULTY) 202 + gsc_fixup_irqs(padev, gf->ctrl, gf->choose_irq); 203 + gf->choose_irq(padev, gf->ctrl); 204 + 205 + return 0; 193 206 } 194 207 195 208 void gsc_fixup_irqs(struct parisc_device *parent, void *ctrl, 196 209 void (*choose_irq)(struct parisc_device *, void *)) 197 210 { 198 - struct device *dev; 199 - struct klist_iter i; 211 + struct gsc_fixup_struct data = { 212 + .choose_irq = choose_irq, 213 + .ctrl = ctrl, 214 + }; 200 215 201 - klist_iter_init(&parent->dev.klist_children, &i); 202 - while ((dev = next_device(&i))) { 203 - struct parisc_device *padev = to_parisc_device(dev); 204 - 205 - /* work-around for 715/64 and others which have parent 206 - at path [5] and children at path [5/0/x] */ 207 - if (padev->id.hw_type == HPHW_FAULTY) 208 - return gsc_fixup_irqs(padev, ctrl, choose_irq); 209 - choose_irq(padev, ctrl); 210 - } 211 - klist_iter_exit(&i); 216 + device_for_each_child(&parent->dev, &data, gsc_fixup_irqs_callback); 212 217 } 213 218 214 219 int gsc_common_setup(struct parisc_device *parent, struct gsc_asic *gsc_asic)
+34 -25
drivers/parisc/sba_iommu.c
··· 1206 1206 return (void *) pdir_base; 1207 1207 } 1208 1208 1209 - static struct device *next_device(struct klist_iter *i) 1209 + struct ibase_data_struct { 1210 + struct ioc *ioc; 1211 + int ioc_num; 1212 + }; 1213 + 1214 + static int setup_ibase_imask_callback(struct device *dev, void *data) 1210 1215 { 1211 - struct klist_node * n = klist_next(i); 1212 - return n ? container_of(n, struct device, knode_parent) : NULL; 1216 + /* lba_set_iregs() is in drivers/parisc/lba_pci.c */ 1217 + extern void lba_set_iregs(struct parisc_device *, u32, u32); 1218 + struct parisc_device *lba = to_parisc_device(dev); 1219 + struct ibase_data_struct *ibd = data; 1220 + int rope_num = (lba->hpa.start >> 13) & 0xf; 1221 + if (rope_num >> 3 == ibd->ioc_num) 1222 + lba_set_iregs(lba, ibd->ioc->ibase, ibd->ioc->imask); 1223 + return 0; 1213 1224 } 1214 1225 1215 1226 /* setup Mercury or Elroy IBASE/IMASK registers. */ 1216 1227 static void 1217 1228 setup_ibase_imask(struct parisc_device *sba, struct ioc *ioc, int ioc_num) 1218 1229 { 1219 - /* lba_set_iregs() is in drivers/parisc/lba_pci.c */ 1220 - extern void lba_set_iregs(struct parisc_device *, u32, u32); 1221 - struct device *dev; 1222 - struct klist_iter i; 1230 + struct ibase_data_struct ibase_data = { 1231 + .ioc = ioc, 1232 + .ioc_num = ioc_num, 1233 + }; 1223 1234 1224 - klist_iter_init(&sba->dev.klist_children, &i); 1225 - while ((dev = next_device(&i))) { 1226 - struct parisc_device *lba = to_parisc_device(dev); 1227 - int rope_num = (lba->hpa.start >> 13) & 0xf; 1228 - if (rope_num >> 3 == ioc_num) 1229 - lba_set_iregs(lba, ioc->ibase, ioc->imask); 1230 - } 1231 - klist_iter_exit(&i); 1235 + device_for_each_child(&sba->dev, &ibase_data, 1236 + setup_ibase_imask_callback); 1232 1237 } 1238 + 1239 + #ifdef SBA_AGP_SUPPORT 1240 + static int 1241 + sba_ioc_find_quicksilver(struct device *dev, void *data) 1242 + { 1243 + int *agp_found = data; 1244 + struct parisc_device *lba = to_parisc_device(dev); 1245 + 1246 + if (IS_QUICKSILVER(lba)) 1247 + *agp_found = 1; 1248 + return 0; 1249 + } 1250 + #endif 1233 1251 1234 1252 static void 1235 1253 sba_ioc_init_pluto(struct parisc_device *sba, struct ioc *ioc, int ioc_num) ··· 1350 1332 WRITE_REG(ioc->ibase | 31, ioc->ioc_hpa + IOC_PCOM); 1351 1333 1352 1334 #ifdef SBA_AGP_SUPPORT 1353 - { 1354 - struct klist_iter i; 1355 - struct device *dev = NULL; 1356 1335 1357 1336 /* 1358 1337 ** If an AGP device is present, only use half of the IOV space ··· 1359 1344 ** We program the next pdir index after we stop w/ a key for 1360 1345 ** the GART code to handshake on. 1361 1346 */ 1362 - klist_iter_init(&sba->dev.klist_children, &i); 1363 - while ((dev = next_device(&i))) { 1364 - struct parisc_device *lba = to_parisc_device(dev); 1365 - if (IS_QUICKSILVER(lba)) 1366 - agp_found = 1; 1367 - } 1368 - klist_iter_exit(&i); 1347 + device_for_each_child(&sba->dev, &agp_found, sba_ioc_find_quicksilver); 1369 1348 1370 1349 if (agp_found && sba_reserve_agpgart) { 1371 1350 printk(KERN_INFO "%s: reserving %dMb of IOVA space for agpgart\n",