From: Hoegeun Kwon Date: Wed, 17 Aug 2016 07:19:50 +0000 (+0900) Subject: sensors: brcm: use non atomic sleeps instead of atomic delays X-Git-Tag: accepted/tizen/common/20161219.151653~212 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6ad8c7530d23d78eb246880073181421bf44e468;p=platform%2Fkernel%2Flinux-exynos.git sensors: brcm: use non atomic sleeps instead of atomic delays Do not use mdelay in non atomic contexts, use the appropriate *sleep functions instead. mdelay should be used only in atomic contexts, out from atomic it keeps looping over the CPU wasting unnecessary resources. Replace the mdelay's with: - usleep_range for 10us - 20ms delays, - msleep for over 20ms Change-Id: Id03238f3918f43cb42c31ef258a12c3e7f4506a5 Reported-by: Andi Shyti Signed-off-by: Hoegeun Kwon --- diff --git a/drivers/sensors/brcm/bbdpl2/bbd.c b/drivers/sensors/brcm/bbdpl2/bbd.c index ee98fb7..6f5bac5 100644 --- a/drivers/sensors/brcm/bbdpl2/bbd.c +++ b/drivers/sensors/brcm/bbdpl2/bbd.c @@ -745,7 +745,7 @@ static int bbd_suspend(pm_message_t state) if (pssp_driver->driver.pm && pssp_driver->driver.pm->suspend) pssp_driver->driver.pm->suspend(&dummy_spi.dev); #endif - mdelay(20); + msleep(20); return 0; } diff --git a/drivers/sensors/brcm/bbdpl2/bcm_gps_spi.c b/drivers/sensors/brcm/bbdpl2/bcm_gps_spi.c index 8434aa15..cd95f32 100644 --- a/drivers/sensors/brcm/bbdpl2/bcm_gps_spi.c +++ b/drivers/sensors/brcm/bbdpl2/bcm_gps_spi.c @@ -302,16 +302,16 @@ static bool bcm4773_hello(struct bcm_spi_priv *priv) return false; } - mdelay(1); + usleep_range(1000, 1100); /*if awake, done */ if (gpio_get_value(priv->mcu_resp)) break; if (count%20==0 && retries++ < 3) { gpio_set_value(priv->mcu_req, 0); - mdelay(1); + usleep_range(1000, 1100); gpio_set_value(priv->mcu_req, 1); - mdelay(1); + usleep_range(1000, 1100); } } return true; diff --git a/drivers/sensors/brcm/factory/accel_icm20610.c b/drivers/sensors/brcm/factory/accel_icm20610.c index f3a443ac..531b1d2 100644 --- a/drivers/sensors/brcm/factory/accel_icm20610.c +++ b/drivers/sensors/brcm/factory/accel_icm20610.c @@ -176,7 +176,7 @@ static int accel_do_calibrate(struct ssp_data *data, int iEnable) iSum[0] += data->buf[ACCELEROMETER_SENSOR].x; iSum[1] += data->buf[ACCELEROMETER_SENSOR].y; iSum[2] += data->buf[ACCELEROMETER_SENSOR].z; - mdelay(10); + usleep_range(10000, 15000); } disable_accel_for_cal(data, iRet); diff --git a/drivers/sensors/brcm/factory/barcode_emul_tmg3992.c b/drivers/sensors/brcm/factory/barcode_emul_tmg3992.c index 9a8597e..d2d8088 100644 --- a/drivers/sensors/brcm/factory/barcode_emul_tmg3992.c +++ b/drivers/sensors/brcm/factory/barcode_emul_tmg3992.c @@ -125,7 +125,7 @@ retries: if (iReties++ < 2) { pr_err("[SSP] %s fail, retry\n", __func__); - mdelay(5); + usleep_range(5000, 5500); goto retries; } } else { diff --git a/drivers/sensors/brcm/factory/mcu_bcm4773.c b/drivers/sensors/brcm/factory/mcu_bcm4773.c index a65e0d9..22b4689 100644 --- a/drivers/sensors/brcm/factory/mcu_bcm4773.c +++ b/drivers/sensors/brcm/factory/mcu_bcm4773.c @@ -79,7 +79,7 @@ ssize_t mcu_dump_show(struct device *dev, set_big_data_start(data, BIG_TYPE_DUMP, 0); msleep(300); while (data->bDumping) { - mdelay(10); + usleep_range(10000, 15000); if (iDelaycnt++ > 1000) { status = 0; break; diff --git a/drivers/sensors/brcm/ssp_bbd.c b/drivers/sensors/brcm/ssp_bbd.c index 8af8ddf..f98c7f5 100644 --- a/drivers/sensors/brcm/ssp_bbd.c +++ b/drivers/sensors/brcm/ssp_bbd.c @@ -56,7 +56,7 @@ int bbd_do_transfer(struct ssp_data *data, struct ssp_msg *msg, if (ssp_down) { pr_err("[SSPBBD]: ssp_down == true. returning\n"); clean_msg(msg); - mdelay(5); + usleep_range(5000, 5500); return -1; } @@ -231,7 +231,7 @@ retries: ret = initialize_mcu(data); if (ret != SUCCESS) { data->uResetCnt++; - mdelay(100); + msleep(100); if(++retries > 3) { pr_err("[SSPBBD] fail to initialize mcu\n"); ssp_enable(data, false); diff --git a/drivers/sensors/brcm/ssp_c12sd.c b/drivers/sensors/brcm/ssp_c12sd.c index 5ee20c1..6156638 100644 --- a/drivers/sensors/brcm/ssp_c12sd.c +++ b/drivers/sensors/brcm/ssp_c12sd.c @@ -183,7 +183,7 @@ static ssize_t get_adc_value(struct device *dev, mutex_lock(&uv->read_lock); if (uv->pdata->power_on) uv->pdata->power_on(true); - mdelay(20); + usleep_range(20000, 21000); adc = uv->pdata->get_adc_value(); if (uv->pdata->power_on) uv->pdata->power_on(false); diff --git a/drivers/sensors/brcm/ssp_i2c.c b/drivers/sensors/brcm/ssp_i2c.c index 4cf68ed..395477d 100644 --- a/drivers/sensors/brcm/ssp_i2c.c +++ b/drivers/sensors/brcm/ssp_i2c.c @@ -422,7 +422,7 @@ retries: iRet = ssp_spi_sync(data, msg, 1000); if (buffer != DEVICE_ID && iReties++ < 2) { - mdelay(5); + usleep_range(5000, 5500); pr_err("[SSP] %s - get chip ID retry\n", __func__); goto retries; }