From: Kees Jongenburger Date: Fri, 13 Dec 2013 13:16:29 +0000 (+0100) Subject: arm:replace ifdef's by runtime checks in the i2c driver. X-Git-Tag: v3.3.0~658 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch10.html?a=commitdiff_plain;h=3b447ae1546c8245ebe2382be7592cedd6f361fe;p=minix.git arm:replace ifdef's by runtime checks in the i2c driver. Change-Id: I5cdff48d8be9bbe5a4734192b451dc45983fbef2 --- diff --git a/drivers/i2c/arch/earm/omap_i2c.c b/drivers/i2c/arch/earm/omap_i2c.c index 674a7fe48..cc571c509 100644 --- a/drivers/i2c/arch/earm/omap_i2c.c +++ b/drivers/i2c/arch/earm/omap_i2c.c @@ -12,6 +12,7 @@ #include #include #include +#include #include /* device headers */ @@ -782,6 +783,8 @@ omap_interface_setup(int (**process) (minix_i2c_ioctl_exec_t * ioctl_exec), int r; int i2c_rev, major, minor; struct minix_mem_range mr; + struct machine machine; + sys_getmachine(&machine); /* Fill in the function pointer */ @@ -789,15 +792,15 @@ omap_interface_setup(int (**process) (minix_i2c_ioctl_exec_t * ioctl_exec), /* Select the correct i2c definition for this SoC */ -#if defined(AM335X) - omap_i2c_buses = am335x_i2c_buses; - omap_i2c_nbuses = AM335X_OMAP_NBUSES; -#elif defined(DM37XX) - omap_i2c_buses = dm37xx_i2c_buses; - omap_i2c_nbuses = DM37XX_OMAP_NBUSES; -#else -#error /* Unsupported SoC */ -#endif + if (BOARD_IS_BBXM(machine.board_id)){ + omap_i2c_buses = dm37xx_i2c_buses; + omap_i2c_nbuses = DM37XX_OMAP_NBUSES; + } else if (BOARD_IS_BB(machine.board_id)){ + omap_i2c_buses = am335x_i2c_buses; + omap_i2c_nbuses = AM335X_OMAP_NBUSES; + } else { + return EINVAL; + } if (i2c_bus_id < 0 || i2c_bus_id >= omap_i2c_nbuses) { return EINVAL;