Commit 610a3048 authored by Rahix's avatar Rahix

chore(hw-locks): Rename to hwlock_acquire_timeout

Rename hwlock_acquire() to hwlock_acquire_timeout() in preparation for
future changes to the hw-lock API.  Change all uses of the hw-lock API
to reflect this change.

This commit does not introduce any functional changes, except getting
rid of the timeout usage warnings.  This change is no-op, because the
hwlock_acquire() implementation already replaces any non-zero timeout
value with portMAX_DELAY.
Signed-off-by: Rahix's avatarRahix <rahix@rahix.de>
parent 18202736
......@@ -135,7 +135,7 @@ int epic_bhi160_enable_sensor(
return -ENODEV;
}
result = hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(100));
result = hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY);
if (result < 0) {
return result;
}
......@@ -192,7 +192,7 @@ int epic_bhi160_disable_sensor(enum bhi160_sensor_type sensor_type)
return -ENODEV;
}
result = hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(100));
result = hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY);
if (result < 0) {
return result;
}
......@@ -347,7 +347,7 @@ static int bhi160_fetch_fifo(void)
/* Number of bytes left in BHI160's FIFO buffer */
uint16_t bytes_left_in_fifo = 1;
result = hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(100));
result = hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY);
if (result < 0) {
return result;
}
......@@ -433,7 +433,7 @@ void vBhi160Task(void *pvParameters)
*/
vTaskDelay(pdMS_TO_TICKS(3));
int lockret = hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(100));
int lockret = hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY);
if (lockret < 0) {
LOG_CRIT("bhi160", "Failed to acquire I2C lock!");
vTaskDelay(portMAX_DELAY);
......@@ -469,7 +469,7 @@ void vBhi160Task(void *pvParameters)
/* Wait for first interrupt */
hwlock_release(HWLOCK_I2C);
ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(100));
lockret = hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(100));
lockret = hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY);
if (lockret < 0) {
LOG_CRIT("bhi160", "Failed to acquire I2C lock!");
vTaskDelay(portMAX_DELAY);
......
......@@ -43,7 +43,7 @@ int epic_bme680_init()
return 0;
}
if (hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(100)) < 0) {
if (hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY) < 0) {
return -EBUSY;
}
......@@ -110,7 +110,7 @@ int epic_bme680_deinit()
return 0;
}
if (hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(100)) < 0) {
if (hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY) < 0) {
return -EBUSY;
}
......@@ -133,7 +133,7 @@ int epic_bme680_read_sensors(struct bme680_sensor_data *data)
return -EINVAL;
}
if (hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(100)) < 0) {
if (hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY) < 0) {
return -EBUSY;
}
......@@ -152,7 +152,7 @@ int epic_bme680_read_sensors(struct bme680_sensor_data *data)
*/
hwlock_release(HWLOCK_I2C);
vTaskDelay(pdMS_TO_TICKS(profile_dur));
if (hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(100)) < 0) {
if (hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY) < 0) {
return -EBUSY;
}
......
......@@ -17,7 +17,7 @@ uint8_t epic_buttons_read(uint8_t mask)
{
uint8_t ret = 0;
if (portexpander_detected() && (mask & 0x7)) {
if (hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(100)) < 0) {
if (hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY) < 0) {
LOG_ERR("buttons", "Can't acquire I2C bus");
return 0;
}
......
......@@ -137,7 +137,7 @@ int epic_gpio_read_pin(uint8_t pin)
} else if (cfg->func == GPIO_FUNC_IN) {
return GPIO_InGet(cfg) != 0;
} else if (cfg->func == GPIO_FUNC_ALT1) {
int rc = hwlock_acquire(HWLOCK_ADC, pdMS_TO_TICKS(10));
int rc = hwlock_acquire_timeout(HWLOCK_ADC, portMAX_DELAY);
if (!rc) {
ADC_StartConvert(s_adc_channels[pin], 0, 0);
uint16_t value;
......
......@@ -21,7 +21,7 @@ void hwlock_init(void)
}
}
int hwlock_acquire(enum hwlock_periph p, TickType_t wait)
int hwlock_acquire_timeout(enum hwlock_periph p, TickType_t wait)
{
assert(p < _HWLOCK_MAX);
......
......@@ -13,7 +13,7 @@
static void do_update()
{
while (hwlock_acquire(HWLOCK_LED, pdMS_TO_TICKS(1)) < 0) {
while (hwlock_acquire_timeout(HWLOCK_LED, portMAX_DELAY) < 0) {
vTaskDelay(pdMS_TO_TICKS(1));
}
......@@ -96,7 +96,7 @@ void epic_leds_dim_top(uint8_t value)
{
leds_set_dim_top(value);
if (personal_state_enabled() == 0) {
while (hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(1)) < 0) {
while (hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY) < 0) {
vTaskDelay(pdMS_TO_TICKS(1));
}
......@@ -110,7 +110,7 @@ void epic_leds_dim_bottom(uint8_t value)
{
leds_set_dim_bottom(value);
if (personal_state_enabled() == 0) {
while (hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(1)) < 0) {
while (hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY) < 0) {
vTaskDelay(pdMS_TO_TICKS(1));
}
......@@ -122,7 +122,7 @@ void epic_leds_dim_bottom(uint8_t value)
void epic_leds_set_rocket(int led, uint8_t value)
{
while (hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(1)) < 0) {
while (hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY) < 0) {
vTaskDelay(pdMS_TO_TICKS(1));
}
......@@ -135,7 +135,7 @@ void epic_leds_set_rocket(int led, uint8_t value)
int epic_leds_get_rocket(int led)
{
int ret = 0;
while (hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(1)) < 0) {
while (hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY) < 0) {
vTaskDelay(pdMS_TO_TICKS(1));
}
......@@ -146,7 +146,7 @@ int epic_leds_get_rocket(int led)
void epic_set_flashlight(bool power)
{
while (hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(1)) < 0) {
while (hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY) < 0) {
vTaskDelay(pdMS_TO_TICKS(1));
}
......@@ -162,7 +162,7 @@ void epic_leds_update(void)
void epic_leds_set_powersave(bool eco)
{
while (hwlock_acquire(HWLOCK_I2C, pdMS_TO_TICKS(1)) < 0) {
while (hwlock_acquire_timeout(HWLOCK_I2C, portMAX_DELAY) < 0) {
vTaskDelay(pdMS_TO_TICKS(1));
}
......
......@@ -29,7 +29,7 @@ static int light_sensor_init()
uint16_t epic_light_sensor_read()
{
if (hwlock_acquire(HWLOCK_ADC, pdMS_TO_TICKS(1000)) != 0) {
if (hwlock_acquire_timeout(HWLOCK_ADC, portMAX_DELAY) != 0) {
return 0;
}
......@@ -42,7 +42,7 @@ uint16_t epic_light_sensor_read()
static void readAdcCallback()
{
if (hwlock_acquire(HWLOCK_ADC, 0) != 0) {
if (hwlock_acquire_timeout(HWLOCK_ADC, 0) != 0) {
/* Can't do much about this here ... Retry next time */
return;
}
......@@ -57,7 +57,7 @@ int epic_light_sensor_run()
{
int ret = 0;
if (hwlock_acquire(HWLOCK_ADC, pdMS_TO_TICKS(500)) != 0) {
if (hwlock_acquire_timeout(HWLOCK_ADC, portMAX_DELAY) != 0) {
return -EBUSY;
}
......
......@@ -54,7 +54,7 @@ int epic_max30001_enable_sensor(struct max30001_sensor_config *config)
{
int result = 0;
result = hwlock_acquire(HWLOCK_SPI_ECG, pdMS_TO_TICKS(100));
result = hwlock_acquire_timeout(HWLOCK_SPI_ECG, portMAX_DELAY);
if (result < 0) {
return result;
}
......@@ -107,7 +107,7 @@ int epic_max30001_disable_sensor(void)
{
int result = 0;
result = hwlock_acquire(HWLOCK_SPI_ECG, pdMS_TO_TICKS(100));
result = hwlock_acquire_timeout(HWLOCK_SPI_ECG, portMAX_DELAY);
if (result < 0) {
return result;
}
......@@ -298,7 +298,7 @@ static int max30001_fetch_fifo(void)
{
int result = 0;
result = hwlock_acquire(HWLOCK_SPI_ECG, pdMS_TO_TICKS(100));
result = hwlock_acquire_timeout(HWLOCK_SPI_ECG, portMAX_DELAY);
if (result < 0) {
return result;
}
......@@ -376,7 +376,7 @@ void vMAX30001Task(void *pvParameters)
{
max30001_task_id = xTaskGetCurrentTaskHandle();
int lockret = hwlock_acquire(HWLOCK_SPI_ECG, pdMS_TO_TICKS(100));
int lockret = hwlock_acquire_timeout(HWLOCK_SPI_ECG, portMAX_DELAY);
if (lockret < 0) {
LOG_CRIT("max30001", "Failed to acquire SPI lock!");
vTaskDelay(portMAX_DELAY);
......
......@@ -97,7 +97,7 @@ enum hwlock_periph {
_HWLOCK_MAX,
};
int hwlock_acquire(enum hwlock_periph p, TickType_t wait);
int hwlock_acquire_timeout(enum hwlock_periph p, TickType_t wait);
void hwlock_release(enum hwlock_periph p);
/* ---------- Display ------------------------------------------------------ */
......
......@@ -31,7 +31,7 @@ int epic_personal_state_set(uint8_t state, bool persistent)
personal_state_persistent = persistent;
if (was_enabled && !_personal_state_enabled) {
while (hwlock_acquire(HWLOCK_LED, pdMS_TO_TICKS(1)) < 0) {
while (hwlock_acquire_timeout(HWLOCK_LED, portMAX_DELAY) < 0) {
vTaskDelay(pdMS_TO_TICKS(1));
}
......@@ -60,8 +60,8 @@ void vLedTask(void *pvParameters)
const int led_animation_rate = 1000 / 25; /* 25Hz -> 40ms*/
while (1) {
if (_personal_state_enabled) {
while (hwlock_acquire(HWLOCK_LED, pdMS_TO_TICKS(1)) <
0) {
while (hwlock_acquire_timeout(
HWLOCK_LED, portMAX_DELAY) < 0) {
vTaskDelay(pdMS_TO_TICKS(1));
}
......
......@@ -18,7 +18,7 @@
#include <stdio.h>
#include <string.h>
#define LOCK_WAIT pdMS_TO_TICKS(1000)
#define LOCK_WAIT portMAX_DELAY
/* Task ID for the pmic handler */
static TaskHandle_t pmic_task_id = NULL;
......@@ -53,12 +53,12 @@ int pmic_read_amux(enum pmic_amux_signal sig, float *result)
return -EINVAL;
}
int adc_ret = hwlock_acquire(HWLOCK_ADC, LOCK_WAIT);
int adc_ret = hwlock_acquire_timeout(HWLOCK_ADC, LOCK_WAIT);
if (adc_ret < 0) {
ret = adc_ret;
goto done;
}
i2c_ret = hwlock_acquire(HWLOCK_I2C, LOCK_WAIT);
i2c_ret = hwlock_acquire_timeout(HWLOCK_I2C, LOCK_WAIT);
if (i2c_ret < 0) {
ret = i2c_ret;
goto done;
......@@ -75,7 +75,7 @@ int pmic_read_amux(enum pmic_amux_signal sig, float *result)
hwlock_release(HWLOCK_I2C);
vTaskDelay(pdMS_TO_TICKS(5));
i2c_ret = hwlock_acquire(HWLOCK_I2C, LOCK_WAIT);
i2c_ret = hwlock_acquire_timeout(HWLOCK_I2C, LOCK_WAIT);
if (i2c_ret < 0) {
ret = i2c_ret;
goto done;
......@@ -138,7 +138,7 @@ done:
*/
static uint8_t pmic_poll_interrupts(void)
{
while (hwlock_acquire(HWLOCK_I2C, LOCK_WAIT) < 0) {
while (hwlock_acquire_timeout(HWLOCK_I2C, LOCK_WAIT) < 0) {
LOG_WARN("pmic", "Failed to acquire I2C. Retrying ...");
vTaskDelay(pdMS_TO_TICKS(100));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment