aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/spi/spi.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 270e6211c2e3..6307428d2c94 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -366,7 +366,6 @@ spi_alloc_master(struct device *dev, unsigned size)
366 366
367 class_device_initialize(&master->cdev); 367 class_device_initialize(&master->cdev);
368 master->cdev.class = &spi_master_class; 368 master->cdev.class = &spi_master_class;
369 kobj_set_kset_s(&master->cdev, spi_master_class.subsys);
370 master->cdev.dev = get_device(dev); 369 master->cdev.dev = get_device(dev);
371 spi_master_set_devdata(master, &master[1]); 370 spi_master_set_devdata(master, &master[1]);
372 371
@@ -466,14 +465,20 @@ EXPORT_SYMBOL_GPL(spi_unregister_master);
466 */ 465 */
467struct spi_master *spi_busnum_to_master(u16 bus_num) 466struct spi_master *spi_busnum_to_master(u16 bus_num)
468{ 467{
469 char name[9]; 468 struct class_device *cdev;
470 struct kobject *bus; 469 struct spi_master *master = NULL;
471 470 struct spi_master *m;
472 snprintf(name, sizeof name, "spi%u", bus_num); 471
473 bus = kset_find_obj(&spi_master_class.subsys.kset, name); 472 down(&spi_master_class.sem);
474 if (bus) 473 list_for_each_entry(cdev, &spi_master_class.children, node) {
475 return container_of(bus, struct spi_master, cdev.kobj); 474 m = container_of(cdev, struct spi_master, cdev);
476 return NULL; 475 if (m->bus_num == bus_num) {
476 master = spi_master_get(m);
477 break;
478 }
479 }
480 up(&spi_master_class.sem);
481 return master;
477} 482}
478EXPORT_SYMBOL_GPL(spi_busnum_to_master); 483EXPORT_SYMBOL_GPL(spi_busnum_to_master);
479 484