diff options
author | Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> | 2008-01-18 15:30:27 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-01-25 06:52:51 -0500 |
commit | e06bcf3cc3a6c45a16e9ffeb0401380aebfdea02 (patch) | |
tree | 32730587d3c795b881c1e4fb0de36e6831a0bc50 /arch/powerpc/platforms/ps3 | |
parent | 034e0ab54bfe57bc980452f991d3ab443f1b085a (diff) |
[POWERPC] PS3: Add ps3_repository_find_device_by_id()
The storage probe feature of the PS3 hypervisor returns device IDs. Add
the corresponding repository routine ps3_repository_find_device_by_id()
which can be used to retrieve the device info from the repository.
Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/platforms/ps3')
-rw-r--r-- | arch/powerpc/platforms/ps3/platform.h | 2 | ||||
-rw-r--r-- | arch/powerpc/platforms/ps3/repository.c | 77 |
2 files changed, 79 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/ps3/platform.h b/arch/powerpc/platforms/ps3/platform.h index aa9dddf50172..5c6d1b1db3df 100644 --- a/arch/powerpc/platforms/ps3/platform.h +++ b/arch/powerpc/platforms/ps3/platform.h | |||
@@ -153,6 +153,8 @@ static inline struct ps3_repository_device *ps3_repository_bump_device( | |||
153 | return repo; | 153 | return repo; |
154 | } | 154 | } |
155 | int ps3_repository_find_device(struct ps3_repository_device *repo); | 155 | int ps3_repository_find_device(struct ps3_repository_device *repo); |
156 | int ps3_repository_find_device_by_id(struct ps3_repository_device *repo, | ||
157 | u64 bus_id, u64 dev_id); | ||
156 | int ps3_repository_find_devices(enum ps3_bus_type bus_type, | 158 | int ps3_repository_find_devices(enum ps3_bus_type bus_type, |
157 | int (*callback)(const struct ps3_repository_device *repo)); | 159 | int (*callback)(const struct ps3_repository_device *repo)); |
158 | int ps3_repository_find_bus(enum ps3_bus_type bus_type, unsigned int from, | 160 | int ps3_repository_find_bus(enum ps3_bus_type bus_type, unsigned int from, |
diff --git a/arch/powerpc/platforms/ps3/repository.c b/arch/powerpc/platforms/ps3/repository.c index 8baf0503d92b..79dfa19613dc 100644 --- a/arch/powerpc/platforms/ps3/repository.c +++ b/arch/powerpc/platforms/ps3/repository.c | |||
@@ -389,6 +389,83 @@ int ps3_repository_find_device(struct ps3_repository_device *repo) | |||
389 | return 0; | 389 | return 0; |
390 | } | 390 | } |
391 | 391 | ||
392 | int ps3_repository_find_device_by_id(struct ps3_repository_device *repo, | ||
393 | u64 bus_id, u64 dev_id) | ||
394 | { | ||
395 | int result = -ENODEV; | ||
396 | struct ps3_repository_device tmp; | ||
397 | unsigned int num_dev; | ||
398 | |||
399 | pr_debug(" -> %s:%u: find device by id %lu:%lu\n", __func__, __LINE__, | ||
400 | bus_id, dev_id); | ||
401 | |||
402 | for (tmp.bus_index = 0; tmp.bus_index < 10; tmp.bus_index++) { | ||
403 | result = ps3_repository_read_bus_id(tmp.bus_index, | ||
404 | &tmp.bus_id); | ||
405 | if (result) { | ||
406 | pr_debug("%s:%u read_bus_id(%u) failed\n", __func__, | ||
407 | __LINE__, tmp.bus_index); | ||
408 | return result; | ||
409 | } | ||
410 | |||
411 | if (tmp.bus_id == bus_id) | ||
412 | goto found_bus; | ||
413 | |||
414 | pr_debug("%s:%u: skip, bus_id %lu\n", __func__, __LINE__, | ||
415 | tmp.bus_id); | ||
416 | } | ||
417 | pr_debug(" <- %s:%u: bus not found\n", __func__, __LINE__); | ||
418 | return result; | ||
419 | |||
420 | found_bus: | ||
421 | result = ps3_repository_read_bus_type(tmp.bus_index, &tmp.bus_type); | ||
422 | if (result) { | ||
423 | pr_debug("%s:%u read_bus_type(%u) failed\n", __func__, | ||
424 | __LINE__, tmp.bus_index); | ||
425 | return result; | ||
426 | } | ||
427 | |||
428 | result = ps3_repository_read_bus_num_dev(tmp.bus_index, &num_dev); | ||
429 | if (result) { | ||
430 | pr_debug("%s:%u read_bus_num_dev failed\n", __func__, | ||
431 | __LINE__); | ||
432 | return result; | ||
433 | } | ||
434 | |||
435 | for (tmp.dev_index = 0; tmp.dev_index < num_dev; tmp.dev_index++) { | ||
436 | result = ps3_repository_read_dev_id(tmp.bus_index, | ||
437 | tmp.dev_index, | ||
438 | &tmp.dev_id); | ||
439 | if (result) { | ||
440 | pr_debug("%s:%u read_dev_id(%u:%u) failed\n", __func__, | ||
441 | __LINE__, tmp.bus_index, tmp.dev_index); | ||
442 | return result; | ||
443 | } | ||
444 | |||
445 | if (tmp.dev_id == dev_id) | ||
446 | goto found_dev; | ||
447 | |||
448 | pr_debug("%s:%u: skip, dev_id %lu\n", __func__, __LINE__, | ||
449 | tmp.dev_id); | ||
450 | } | ||
451 | pr_debug(" <- %s:%u: dev not found\n", __func__, __LINE__); | ||
452 | return result; | ||
453 | |||
454 | found_dev: | ||
455 | result = ps3_repository_read_dev_type(tmp.bus_index, tmp.dev_index, | ||
456 | &tmp.dev_type); | ||
457 | if (result) { | ||
458 | pr_debug("%s:%u read_dev_type failed\n", __func__, __LINE__); | ||
459 | return result; | ||
460 | } | ||
461 | |||
462 | pr_debug(" <- %s:%u: found: type (%u:%u) index (%u:%u) id (%lu:%lu)\n", | ||
463 | __func__, __LINE__, tmp.bus_type, tmp.dev_type, tmp.bus_index, | ||
464 | tmp.dev_index, tmp.bus_id, tmp.dev_id); | ||
465 | *repo = tmp; | ||
466 | return 0; | ||
467 | } | ||
468 | |||
392 | int __devinit ps3_repository_find_devices(enum ps3_bus_type bus_type, | 469 | int __devinit ps3_repository_find_devices(enum ps3_bus_type bus_type, |
393 | int (*callback)(const struct ps3_repository_device *repo)) | 470 | int (*callback)(const struct ps3_repository_device *repo)) |
394 | { | 471 | { |