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

Commit 49dce689 authored by Tony Jones's avatar Tony Jones Committed by Linus Torvalds
Browse files

spi doesn't need class_device



Make the SPI framework and drivers stop using class_device.  Update docs
accordingly ...  highlighting just which sysfs paths should be
"safe"/stable.

Signed-off-by: default avatarTony Jones <tonyj@suse.de>
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent cd58310d
Loading
Loading
Loading
Loading
+17 −8
Original line number Diff line number Diff line
@@ -156,21 +156,29 @@ using the driver model to connect controller and protocol drivers using
device tables provided by board specific initialization code.  SPI
shows up in sysfs in several locations:

   /sys/devices/.../CTLR ... physical node for a given SPI controller

   /sys/devices/.../CTLR/spiB.C ... spi_device on bus "B",
	chipselect C, accessed through CTLR.

   /sys/bus/spi/devices/spiB.C ... symlink to that physical
   	.../CTLR/spiB.C device

   /sys/devices/.../CTLR/spiB.C/modalias ... identifies the driver
	that should be used with this device (for hotplug/coldplug)

   /sys/bus/spi/devices/spiB.C ... symlink to the physical
   	spiB.C device

   /sys/bus/spi/drivers/D ... driver for one or more spi*.* devices

   /sys/class/spi_master/spiB ... class device for the controller
	managing bus "B".  All the spiB.* devices share the same
   /sys/class/spi_master/spiB ... symlink (or actual device node) to
	a logical node which could hold class related state for the
	controller managing bus "B".  All spiB.* devices share one
	physical SPI bus segment, with SCLK, MOSI, and MISO.

Note that the actual location of the controller's class state depends
on whether you enabled CONFIG_SYSFS_DEPRECATED or not.  At this time,
the only class-specific state is the bus number ("B" in "spiB"), so
those /sys/class entries are only useful to quickly identify busses.


How does board-specific init code declare SPI devices?
------------------------------------------------------
@@ -337,7 +345,8 @@ SPI protocol drivers somewhat resemble platform device drivers:

The driver core will autmatically attempt to bind this driver to any SPI
device whose board_info gave a modalias of "CHIP".  Your probe() code
might look like this unless you're creating a class_device:
might look like this unless you're creating a device which is managing
a bus (appearing under /sys/class/spi_master).

	static int __devinit CHIP_probe(struct spi_device *spi)
	{
@@ -442,7 +451,7 @@ An SPI controller will probably be registered on the platform_bus; write
a driver to bind to the device, whichever bus is involved.

The main task of this type of driver is to provide an "spi_master".
Use spi_alloc_master() to allocate the master, and class_get_devdata()
Use spi_alloc_master() to allocate the master, and spi_master_get_devdata()
to get the driver-private data allocated for that device.

	struct spi_master	*master;
@@ -452,7 +461,7 @@ to get the driver-private data allocated for that device.
	if (!master)
		return -ENODEV;

	c = class_get_devdata(&master->cdev);
	c = spi_master_get_devdata(master);

The driver will initialize the fields of that spi_master, including the
bus number (maybe the same as the platform device ID) and three methods
+2 −2
Original line number Diff line number Diff line
@@ -1280,8 +1280,8 @@ static int mmc_spi_probe(struct spi_device *spi)
	if (!host->data)
		goto fail_nobuf1;

	if (spi->master->cdev.dev->dma_mask) {
		struct device	*dev = spi->master->cdev.dev;
	if (spi->master->dev.parent->dma_mask) {
		struct device	*dev = spi->master->dev.parent;

		host->dma_dev = dev;
		host->ones_dma = dma_map_single(dev, ones,
+7 −7
Original line number Diff line number Diff line
@@ -211,7 +211,7 @@ static void atmel_spi_next_message(struct spi_master *master)
	msg = list_entry(as->queue.next, struct spi_message, queue);
	spi = msg->spi;

	dev_dbg(master->cdev.dev, "start message %p for %s\n",
	dev_dbg(master->dev.parent, "start message %p for %s\n",
			msg, spi->dev.bus_id);

	/* select chip if it's not still active */
@@ -266,10 +266,10 @@ static void atmel_spi_dma_unmap_xfer(struct spi_master *master,
				     struct spi_transfer *xfer)
{
	if (xfer->tx_dma != INVALID_DMA_ADDRESS)
		dma_unmap_single(master->cdev.dev, xfer->tx_dma,
		dma_unmap_single(master->dev.parent, xfer->tx_dma,
				 xfer->len, DMA_TO_DEVICE);
	if (xfer->rx_dma != INVALID_DMA_ADDRESS)
		dma_unmap_single(master->cdev.dev, xfer->rx_dma,
		dma_unmap_single(master->dev.parent, xfer->rx_dma,
				 xfer->len, DMA_FROM_DEVICE);
}

@@ -285,7 +285,7 @@ atmel_spi_msg_done(struct spi_master *master, struct atmel_spi *as,
	list_del(&msg->queue);
	msg->status = status;

	dev_dbg(master->cdev.dev,
	dev_dbg(master->dev.parent,
		"xfer complete: %u bytes transferred\n",
		msg->actual_length);

@@ -348,7 +348,7 @@ atmel_spi_interrupt(int irq, void *dev_id)
		if (xfer->delay_usecs)
			udelay(xfer->delay_usecs);

		dev_warn(master->cdev.dev, "fifo overrun (%u/%u remaining)\n",
		dev_warn(master->dev.parent, "fifo overrun (%u/%u remaining)\n",
			 spi_readl(as, TCR), spi_readl(as, RCR));

		/*
@@ -363,7 +363,7 @@ atmel_spi_interrupt(int irq, void *dev_id)
			if (spi_readl(as, SR) & SPI_BIT(TXEMPTY))
				break;
		if (!timeout)
			dev_warn(master->cdev.dev,
			dev_warn(master->dev.parent,
				 "timeout waiting for TXEMPTY");
		while (spi_readl(as, SR) & SPI_BIT(RDRF))
			spi_readl(as, RDR);
@@ -526,7 +526,7 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *msg)
	struct atmel_spi	*as;
	struct spi_transfer	*xfer;
	unsigned long		flags;
	struct device		*controller = spi->master->cdev.dev;
	struct device		*controller = spi->master->dev.parent;

	as = spi_master_get_devdata(spi->master);

+1 −1
Original line number Diff line number Diff line
@@ -503,7 +503,7 @@ static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr,
	INIT_LIST_HEAD(&mps->queue);

	mps->workqueue = create_singlethread_workqueue(
		master->cdev.dev->bus_id);
		master->dev.parent->bus_id);
	if (mps->workqueue == NULL) {
		ret = -EBUSY;
		goto free_irq;
+1 −1
Original line number Diff line number Diff line
@@ -1242,7 +1242,7 @@ static int __init init_queue(struct driver_data *drv_data)

	INIT_WORK(&drv_data->pump_messages, pump_messages);
	drv_data->workqueue = create_singlethread_workqueue(
					drv_data->master->cdev.dev->bus_id);
					drv_data->master->dev.parent->bus_id);
	if (drv_data->workqueue == NULL)
		return -EBUSY;

Loading