Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12b15e83 authored by Anatolij Gustschin's avatar Anatolij Gustschin Committed by Grant Likely
Browse files

of/spi: call of_register_spi_devices() from spi core code



Move of_register_spi_devices() call from drivers to
spi_register_master(). Also change the function to use
the struct device_node pointer from master spi device
instead of passing it as function argument.

Signed-off-by: default avatarAnatolij Gustschin <agust@denx.de>
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent 559e2b7e
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -15,12 +15,11 @@
/**
 * of_register_spi_devices - Register child devices onto the SPI bus
 * @master:	Pointer to spi_master device
 * @np:		parent node of SPI device nodes
 *
 * Registers an spi_device for each child node of 'np' which has a 'reg'
 * Registers an spi_device for each child node of master node which has a 'reg'
 * property.
 */
void of_register_spi_devices(struct spi_master *master, struct device_node *np)
void of_register_spi_devices(struct spi_master *master)
{
	struct spi_device *spi;
	struct device_node *nc;
@@ -28,7 +27,10 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np)
	int rc;
	int len;

	for_each_child_of_node(np, nc) {
	if (!master->dev.of_node)
		return;

	for_each_child_of_node(master->dev.of_node, nc) {
		/* Alloc an spi_device */
		spi = spi_alloc_device(master);
		if (!spi) {
+1 −0
Original line number Diff line number Diff line
@@ -440,6 +440,7 @@ static int __init mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
	master->setup = mpc512x_psc_spi_setup;
	master->transfer = mpc512x_psc_spi_transfer;
	master->cleanup = mpc512x_psc_spi_cleanup;
	master->dev.of_node = dev->of_node;

	tempp = ioremap(regaddr, size);
	if (!tempp) {
+2 −8
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/of_platform.h>
#include <linux/of_spi.h>
#include <linux/workqueue.h>
#include <linux/completion.h>
#include <linux/io.h>
@@ -398,6 +397,7 @@ static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr,
	master->setup = mpc52xx_psc_spi_setup;
	master->transfer = mpc52xx_psc_spi_transfer;
	master->cleanup = mpc52xx_psc_spi_cleanup;
	master->dev.of_node = dev->of_node;

	mps->psc = ioremap(regaddr, size);
	if (!mps->psc) {
@@ -470,7 +470,6 @@ static int __init mpc52xx_psc_spi_of_probe(struct of_device *op,
	const u32 *regaddr_p;
	u64 regaddr64, size64;
	s16 id = -1;
	int rc;

	regaddr_p = of_get_address(op->dev.of_node, 0, &size64, NULL);
	if (!regaddr_p) {
@@ -491,13 +490,8 @@ static int __init mpc52xx_psc_spi_of_probe(struct of_device *op,
		id = *psc_nump + 1;
	}

	rc = mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64,
	return mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64,
				irq_of_parse_and_map(op->dev.of_node, 0), id);
	if (rc == 0)
		of_register_spi_devices(dev_get_drvdata(&op->dev),
					op->dev.of_node);

	return rc;
}

static int __exit mpc52xx_psc_spi_of_remove(struct of_device *op)
+1 −2
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/spi/spi.h>
#include <linux/of_spi.h>
#include <linux/io.h>
#include <linux/of_gpio.h>
#include <linux/slab.h>
@@ -439,6 +438,7 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
	master->setup = mpc52xx_spi_setup;
	master->transfer = mpc52xx_spi_transfer;
	master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
	master->dev.of_node = op->dev.of_node;

	dev_set_drvdata(&op->dev, master);

@@ -512,7 +512,6 @@ static int __devinit mpc52xx_spi_probe(struct of_device *op,
	if (rc)
		goto err_register;

	of_register_spi_devices(master, op->dev.of_node);
	dev_info(&ms->master->dev, "registered MPC5200 SPI bus\n");

	return rc;
+4 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <linux/slab.h>
#include <linux/mod_devicetable.h>
#include <linux/spi/spi.h>
#include <linux/of_spi.h>


/* SPI bustype and spi_master class are registered after board init code
@@ -540,6 +541,9 @@ int spi_register_master(struct spi_master *master)
	/* populate children from any spi device tables */
	scan_boardinfo(master);
	status = 0;

	/* Register devices from the device tree */
	of_register_spi_devices(master);
done:
	return status;
}
Loading