Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modules: low-speed-spidev will not load if MinnowBoard is not detected. #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions modules/low-speed-spidev/low-speed-spidev.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/spi/spi.h>
#include <linux/dmi.h>

#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
Expand All @@ -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)
Expand Down