Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: pressure: bmp280: Make time vars intuitive and move to fsleep

Move sleep functions to the new fsleep() implementation. While at it,
add time unit abbreviation as a suffix of time describing variables to
make them more intuitive.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20241202181907.21471-4-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Vasileios Amoiridis and committed by
Jonathan Cameron
ca569513 7666baba

+22 -21
+20 -19
drivers/iio/pressure/bmp280-core.c
··· 1002 1002 * after resetting, the device uses the complete power-on sequence so 1003 1003 * it needs to wait for the defined start-up time. 1004 1004 */ 1005 - fsleep(data->start_up_time); 1005 + fsleep(data->start_up_time_us); 1006 1006 1007 1007 ret = regmap_read(data->regmap, BMP280_REG_STATUS, &reg); 1008 1008 if (ret) ··· 1161 1161 .chip_id = bmp280_chip_ids, 1162 1162 .num_chip_id = ARRAY_SIZE(bmp280_chip_ids), 1163 1163 .regmap_config = &bmp280_regmap_config, 1164 - .start_up_time = 2000, 1164 + .start_up_time_us = 2000, 1165 1165 .channels = bmp280_channels, 1166 1166 .num_channels = ARRAY_SIZE(bmp280_channels), 1167 1167 .avail_scan_masks = bmp280_avail_scan_masks, ··· 1347 1347 .chip_id = bme280_chip_ids, 1348 1348 .num_chip_id = ARRAY_SIZE(bme280_chip_ids), 1349 1349 .regmap_config = &bme280_regmap_config, 1350 - .start_up_time = 2000, 1350 + .start_up_time_us = 2000, 1351 1351 .channels = bme280_channels, 1352 1352 .num_channels = ARRAY_SIZE(bme280_channels), 1353 1353 .avail_scan_masks = bme280_avail_scan_masks, ··· 1414 1414 return ret; 1415 1415 } 1416 1416 /* Wait for 2ms for command to be processed */ 1417 - usleep_range(data->start_up_time, data->start_up_time + 100); 1417 + fsleep(data->start_up_time_us); 1418 1418 /* Check for command processing error */ 1419 1419 ret = regmap_read(data->regmap, BMP380_REG_ERROR, &reg); 1420 1420 if (ret) { ··· 1806 1806 * formula in datasheet section 3.9.2 with an offset of ~+15% 1807 1807 * as it seen as well in table 3.9.1. 1808 1808 */ 1809 - msleep(150); 1809 + fsleep(150 * USEC_PER_MSEC); 1810 1810 1811 1811 /* Check config error flag */ 1812 1812 ret = regmap_read(data->regmap, BMP380_REG_ERROR, &tmp); ··· 1957 1957 .num_chip_id = ARRAY_SIZE(bmp380_chip_ids), 1958 1958 .regmap_config = &bmp380_regmap_config, 1959 1959 .spi_read_extra_byte = true, 1960 - .start_up_time = 2000, 1960 + .start_up_time_us = 2000, 1961 1961 .channels = bmp380_channels, 1962 1962 .num_channels = ARRAY_SIZE(bmp380_channels), 1963 1963 .avail_scan_masks = bmp280_avail_scan_masks, ··· 2006 2006 dev_err(data->dev, "failed to send reset command to device\n"); 2007 2007 return ret; 2008 2008 } 2009 - usleep_range(2000, 2500); 2009 + /* From datasheet's table 4: electrical characteristics */ 2010 + fsleep(2000); 2010 2011 2011 2012 /* Dummy read of chip_id */ 2012 2013 ret = regmap_read(data->regmap, BMP580_REG_CHIP_ID, &reg); ··· 2209 2208 goto exit; 2210 2209 } 2211 2210 /* Wait standby transition time */ 2212 - usleep_range(2500, 3000); 2211 + fsleep(2500); 2213 2212 2214 2213 while (bytes >= sizeof(*dst)) { 2215 2214 addr = bmp580_nvmem_addrs[offset / sizeof(*dst)]; ··· 2275 2274 goto exit; 2276 2275 } 2277 2276 /* Wait standby transition time */ 2278 - usleep_range(2500, 3000); 2277 + fsleep(2500); 2279 2278 2280 2279 while (bytes >= sizeof(*buf)) { 2281 2280 addr = bmp580_nvmem_addrs[offset / sizeof(*buf)]; ··· 2459 2458 return ret; 2460 2459 } 2461 2460 /* From datasheet's table 4: electrical characteristics */ 2462 - usleep_range(2500, 3000); 2461 + fsleep(2500); 2463 2462 2464 2463 /* Set default DSP mode settings */ 2465 2464 reg_val = FIELD_PREP(BMP580_DSP_COMP_MASK, BMP580_DSP_PRESS_TEMP_COMP_EN) | ··· 2650 2649 .chip_id = bmp580_chip_ids, 2651 2650 .num_chip_id = ARRAY_SIZE(bmp580_chip_ids), 2652 2651 .regmap_config = &bmp580_regmap_config, 2653 - .start_up_time = 2000, 2652 + .start_up_time_us = 2000, 2654 2653 .channels = bmp580_channels, 2655 2654 .num_channels = ARRAY_SIZE(bmp580_channels), 2656 2655 .avail_scan_masks = bmp280_avail_scan_masks, ··· 2721 2720 delay_us = 2722 2721 conversion_time_max[data->oversampling_press]; 2723 2722 2724 - usleep_range(delay_us, delay_us + 1000); 2723 + fsleep(delay_us); 2725 2724 } 2726 2725 2727 2726 ret = regmap_read(data->regmap, BMP280_REG_CTRL_MEAS, &ctrl); ··· 2989 2988 .chip_id = bmp180_chip_ids, 2990 2989 .num_chip_id = ARRAY_SIZE(bmp180_chip_ids), 2991 2990 .regmap_config = &bmp180_regmap_config, 2992 - .start_up_time = 2000, 2991 + .start_up_time_us = 2000, 2993 2992 .channels = bmp280_channels, 2994 2993 .num_channels = ARRAY_SIZE(bmp280_channels), 2995 2994 .avail_scan_masks = bmp280_avail_scan_masks, ··· 3067 3066 .chip_id = bmp180_chip_ids, 3068 3067 .num_chip_id = ARRAY_SIZE(bmp180_chip_ids), 3069 3068 .regmap_config = &bmp180_regmap_config, 3070 - .start_up_time = 2000, 3069 + .start_up_time_us = 2000, 3071 3070 .channels = bmp280_channels, 3072 3071 .num_channels = ARRAY_SIZE(bmp280_channels), 3073 3072 .avail_scan_masks = bmp280_avail_scan_masks, ··· 3176 3175 data->oversampling_temp = chip_info->oversampling_temp_default; 3177 3176 data->iir_filter_coeff = chip_info->iir_filter_coeff_default; 3178 3177 data->sampling_freq = chip_info->sampling_freq_default; 3179 - data->start_up_time = chip_info->start_up_time; 3178 + data->start_up_time_us = chip_info->start_up_time_us; 3180 3179 3181 3180 /* Bring up regulators */ 3182 3181 regulator_bulk_set_supply_names(data->supplies, ··· 3202 3201 return ret; 3203 3202 3204 3203 /* Wait to make sure we started up properly */ 3205 - usleep_range(data->start_up_time, data->start_up_time + 100); 3204 + fsleep(data->start_up_time_us); 3206 3205 3207 3206 /* Bring chip out of reset if there is an assigned GPIO line */ 3208 3207 gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); ··· 3288 3287 * Set autosuspend to two orders of magnitude larger than the 3289 3288 * start-up time. 3290 3289 */ 3291 - pm_runtime_set_autosuspend_delay(dev, data->start_up_time / 10); 3290 + pm_runtime_set_autosuspend_delay(dev, data->start_up_time_us / 10); 3292 3291 pm_runtime_use_autosuspend(dev); 3293 3292 pm_runtime_put(dev); 3294 3293 ··· 3307 3306 3308 3307 data->chip_info->set_mode(data, BMP280_SLEEP); 3309 3308 3310 - fsleep(data->start_up_time); 3309 + fsleep(data->start_up_time_us); 3311 3310 return regulator_bulk_disable(BMP280_NUM_SUPPLIES, data->supplies); 3312 3311 } 3313 3312 ··· 3321 3320 if (ret) 3322 3321 return ret; 3323 3322 3324 - usleep_range(data->start_up_time, data->start_up_time + 100); 3323 + fsleep(data->start_up_time_us); 3325 3324 3326 3325 ret = data->chip_info->chip_config(data); 3327 3326 if (ret)
+2 -2
drivers/iio/pressure/bmp280.h
··· 434 434 struct bmp380_calib bmp380; 435 435 } calib; 436 436 struct regulator_bulk_data supplies[BMP280_NUM_SUPPLIES]; 437 - unsigned int start_up_time; /* in microseconds */ 437 + unsigned int start_up_time_us; 438 438 439 439 /* log of base 2 of oversampling rate */ 440 440 u8 oversampling_press; ··· 490 490 491 491 const struct iio_chan_spec *channels; 492 492 int num_channels; 493 - unsigned int start_up_time; 493 + unsigned int start_up_time_us; 494 494 const unsigned long *avail_scan_masks; 495 495 496 496 const int *oversampling_temp_avail;