[PATCH 1/2] spi: introduce spi_get_master
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Fri Nov 2 12:17:39 EDT 2012
so we can request a master usefull for the spi command
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
drivers/spi/spi.c | 12 ++++++++++++
include/spi/spi.h | 2 ++
2 files changed, 14 insertions(+)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 44040e5..6a5bd6d 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -219,6 +219,18 @@ int spi_register_master(struct spi_master *master)
}
EXPORT_SYMBOL(spi_register_master);
+struct spi_master *spi_get_master(int bus)
+{
+ struct spi_master* m;
+
+ list_for_each_entry(m, &spi_master_list, list) {
+ if (m->bus_num == bus)
+ return m;
+ }
+
+ return NULL;
+}
+
int spi_sync(struct spi_device *spi, struct spi_message *message)
{
return spi->master->transfer(spi, message);
diff --git a/include/spi/spi.h b/include/spi/spi.h
index 1773ca2..d6570a4 100644
--- a/include/spi/spi.h
+++ b/include/spi/spi.h
@@ -432,6 +432,8 @@ static inline ssize_t spi_w8r8(struct spi_device *spi, u8 cmd)
extern struct bus_type spi_bus;
+struct spi_master *spi_get_master(int bus);
+
static inline int spi_register_driver(struct driver_d *drv)
{
drv->bus = &spi_bus;
--
1.7.10.4
More information about the barebox
mailing list