summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2008-05-15 16:50:22 -0600
committerGrant Likely <grant.likely@secretlab.ca>2008-07-25 22:34:29 -0400
commitdc87c98e8f635a718f1abb2c3e15fc77c0001651 (patch)
tree283a50fb43f798fe9871fe3ba038221f78c3fd6b /include
parent3f07af494dfa6de43137dae430431c9fbf929c0c (diff)
downloadop-kernel-dev-dc87c98e8f635a718f1abb2c3e15fc77c0001651.zip
op-kernel-dev-dc87c98e8f635a718f1abb2c3e15fc77c0001651.tar.gz
spi: split up spi_new_device() to allow two stage registration.
spi_new_device() allocates and registers an spi device all in one swoop. If the driver needs to add extra data to the spi_device before it is registered, then this causes problems. This is needed for OF device tree support so that the SPI device tree helper can add a pointer to the device node after the device is allocated, but before the device is registered. OF aware SPI devices can then retrieve data out of the device node to populate a platform data structure. This patch splits the allocation and registration portions of code out of spi_new_device() and creates two new functions; spi_alloc_device() and spi_register_device(). spi_new_device() is modified to use the new functions for allocation and registration. None of the existing users of spi_new_device() should be affected by this change. Drivers using the new API can forego the use of spi_board_info structure to describe the device layout and populate data into the spi_device structure directly. This change is in preparation for adding an OF device tree parser to generate spi_devices based on data in the device tree. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/spi/spi.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index a9cc29d..4be01bb 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -778,8 +778,20 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n)
* use spi_new_device() to describe each device. You can also call
* spi_unregister_device() to start making that device vanish, but
* normally that would be handled by spi_unregister_master().
+ *
+ * You can also use spi_alloc_device() and spi_add_device() to use a two
+ * stage registration sequence for each spi_device. This gives the caller
+ * some more control over the spi_device structure before it is registered,
+ * but requires that caller to initialize fields that would otherwise
+ * be defined using the board info.
*/
extern struct spi_device *
+spi_alloc_device(struct spi_master *master);
+
+extern int
+spi_add_device(struct spi_device *spi);
+
+extern struct spi_device *
spi_new_device(struct spi_master *, struct spi_board_info *);
static inline void
OpenPOWER on IntegriCloud