@@ -545,14 +545,6 @@ int spi_add_device(struct spi_device *spi)
goto done;
}
- /* Device may be bound to an active driver when this returns */
- status = device_add(&spi->dev);
- if (status < 0)
- dev_err(dev, "can't add %s, status %d\n",
- dev_name(&spi->dev), status);
- else
- dev_dbg(dev, "registered child %s\n", dev_name(&spi->dev));
-
done:
mutex_unlock(&spi_add_lock);
return status;
@@ -614,6 +606,9 @@ struct spi_device *spi_new_device(struct spi_master *master,
status = spi_add_device(proxy);
if (status < 0)
goto err_remove_props;
+ status = device_add(&proxy->dev);
+ if (status < 0)
+ goto err_remove_props;
return proxy;
@@ -1663,12 +1658,19 @@ of_register_spi_device(struct spi_master
*master, struct device_node *nc)
*/
static void of_register_spi_devices(struct spi_master *master)
{
+ struct spi_device_list_elem {
+ struct spi_device *spi_dev;
+ struct list_head list;
+ };
+ struct spi_device_list_elem *spi_dev_elem;
struct spi_device *spi;
struct device_node *nc;
+ struct list_head spi_devices, *elem, *tmp;
if (!master->dev.of_node)
return;
+ INIT_LIST_HEAD(&spi_devices);
for_each_available_child_of_node(master->dev.of_node, nc) {
if (of_node_test_and_set_flag(nc, OF_POPULATED))