diff options
author | Dave Young <hidave.darkstar@gmail.com> | 2008-01-22 02:14:18 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-01-24 23:40:45 -0500 |
commit | 5ed2c832ed256b18d90c2462369c62fd79312e6c (patch) | |
tree | 3afce805114d8a580e66f9101ca36256d8c4c2dd /drivers/spi | |
parent | 9c7701088a61cc0cf8a6e1c68d1e74e3cc2ee0b7 (diff) |
spi: use class iteration api
Convert to use the class iteration api.
Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
Acked-by: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 93e9de46977a..682a6a48fec3 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -485,6 +485,15 @@ void spi_unregister_master(struct spi_master *master) | |||
485 | } | 485 | } |
486 | EXPORT_SYMBOL_GPL(spi_unregister_master); | 486 | EXPORT_SYMBOL_GPL(spi_unregister_master); |
487 | 487 | ||
488 | static int __spi_master_match(struct device *dev, void *data) | ||
489 | { | ||
490 | struct spi_master *m; | ||
491 | u16 *bus_num = data; | ||
492 | |||
493 | m = container_of(dev, struct spi_master, dev); | ||
494 | return m->bus_num == *bus_num; | ||
495 | } | ||
496 | |||
488 | /** | 497 | /** |
489 | * spi_busnum_to_master - look up master associated with bus_num | 498 | * spi_busnum_to_master - look up master associated with bus_num |
490 | * @bus_num: the master's bus number | 499 | * @bus_num: the master's bus number |
@@ -499,17 +508,12 @@ struct spi_master *spi_busnum_to_master(u16 bus_num) | |||
499 | { | 508 | { |
500 | struct device *dev; | 509 | struct device *dev; |
501 | struct spi_master *master = NULL; | 510 | struct spi_master *master = NULL; |
502 | struct spi_master *m; | 511 | |
503 | 512 | dev = class_find_device(&spi_master_class, &bus_num, | |
504 | down(&spi_master_class.sem); | 513 | __spi_master_match); |
505 | list_for_each_entry(dev, &spi_master_class.children, node) { | 514 | if (dev) |
506 | m = container_of(dev, struct spi_master, dev); | 515 | master = container_of(dev, struct spi_master, dev); |
507 | if (m->bus_num == bus_num) { | 516 | /* reference got in class_find_device */ |
508 | master = spi_master_get(m); | ||
509 | break; | ||
510 | } | ||
511 | } | ||
512 | up(&spi_master_class.sem); | ||
513 | return master; | 517 | return master; |
514 | } | 518 | } |
515 | EXPORT_SYMBOL_GPL(spi_busnum_to_master); | 519 | EXPORT_SYMBOL_GPL(spi_busnum_to_master); |