From 357e8c0a9bb6b37518b2308035b45ca8c17b1b69 Mon Sep 17 00:00:00 2001 From: Henry Bruce Date: Fri, 11 Nov 2016 10:24:15 -0800 Subject: [PATCH] modules: low-speed-spidev will not load if MinnowBoard is not detected. Signed-off-by: Henry Bruce --- modules/low-speed-spidev/low-speed-spidev.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/low-speed-spidev/low-speed-spidev.c b/modules/low-speed-spidev/low-speed-spidev.c index 9bdb9ff..cb9e31e 100644 --- a/modules/low-speed-spidev/low-speed-spidev.c +++ b/modules/low-speed-spidev/low-speed-spidev.c @@ -20,12 +20,14 @@ #include #include #include +#include #if (!defined(CONFIG_SPI_SPIDEV_MODULE) && !defined(CONFIG_SPI_SPIDEV)) #error SPI_SPIDEV is required. #endif /* Change these values to what your board uses. */ +#define BOARD_NAME "MinnowBoard" #define LOW_SPEED_SPIDEV_SPI_BUS 0 #define LOW_SPEED_SPIDEV_SPI_CS 0 #define LOW_SPEED_SPIDEV_MAX_CLK_HZ 1000000 @@ -48,6 +50,14 @@ static int __init low_speed_spidev_module_init(void) err = -ENODEV; + const char* board_name = dmi_get_system_info(DMI_BOARD_NAME); + pr_info("board name=%s\n", board_name); + + if (strncmp(board_name, BOARD_NAME, strlen(BOARD_NAME)) != 0) { + pr_info("%s not detected\n", BOARD_NAME); + goto out; + } + master = spi_busnum_to_master(LOW_SPEED_SPIDEV_SPI_BUS); pr_info("master=%p\n", master); if (!master)