From 5e74d2d05b5543eb7952806e80842a4645e7685a Mon Sep 17 00:00:00 2001 From: Roshni Shah Date: Sun, 5 Jan 2014 16:15:28 -0500 Subject: Quartz: Fixed Linux-MQX semaphore conflict in the i2c driver for multiple i2c registrations in Linux. --- arch/arm/mach-mvf/board-quartz.c | 7 ------- drivers/i2c/busses/i2c-imx.c | 15 +++++++++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/arm/mach-mvf/board-quartz.c b/arch/arm/mach-mvf/board-quartz.c index 7a916f6d5992..b94365d6a615 100644 --- a/arch/arm/mach-mvf/board-quartz.c +++ b/arch/arm/mach-mvf/board-quartz.c @@ -420,20 +420,13 @@ static void __init mvf_board_init(void) mvf_add_sdhci_esdhc_imx(1, &mvfa5_sd1_data); -#if 1 - /*FIXME: I2C driver needs a fix for Linux-MQX semaphore - * conflict - */ mvf_add_imx_i2c(2, &mvf600_i2c_data); i2c_register_board_info(2, mxc_i2c2_board_info, ARRAY_SIZE(mxc_i2c2_board_info)); -#endif -#if 0 mvf_add_imx_i2c(3, &mvf600_i2c_data); i2c_register_board_info(3, mxc_i2c3_board_info, ARRAY_SIZE(mxc_i2c3_board_info)); -#endif mvfa5_add_dcu(0, &mvf_dcu_pdata); diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index e13e020cab2e..8cd88b24a47c 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -59,6 +59,8 @@ /* This will be the driver name the kernel reports */ #define DRIVER_NAME "imx-i2c" +#define FALSE 0 +#define TRUE 1 /* Default value */ #define IMX_I2C_BIT_RATE 100000 /* 100kHz */ @@ -521,6 +523,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev) resource_size_t res_size; int irq; int ret; + static bool sema4Assigned = FALSE; dev_dbg(&pdev->dev, "<%s>\n", __func__); @@ -620,10 +623,14 @@ static int __init i2c_imx_probe(struct platform_device *pdev) platform_set_drvdata(pdev, i2c_imx); #ifdef CONFIG_ARCH_MVF - // for makeing sure not in use by MQX concurrently - if(mvf_sema4_assign(MVF_I2C_SEMAPHORE_NUMBER, &sema4)) { - dev_err(&pdev->dev, "could not assign MQX semaphore %d\n", MVF_I2C_SEMAPHORE_NUMBER); - goto fail5; + if(sema4Assigned == FALSE) + { + // for making sure the i2c port is not in use by MQX concurrently + if(mvf_sema4_assign(MVF_I2C_SEMAPHORE_NUMBER, &sema4)) { + dev_err(&pdev->dev, "could not assign MQX semaphore %d\n", MVF_I2C_SEMAPHORE_NUMBER); + goto fail5; + } + sema4Assigned = TRUE; } #endif -- cgit v1.2.3