drivers: clock_control: Add subsys argument to the callback

Added subsys argument to the callback, updated one driver which
used it and test cases.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2020-02-03 12:54:34 +01:00 committed by Carles Cufí
commit ce766305b7
6 changed files with 34 additions and 15 deletions

View file

@ -45,7 +45,9 @@ static int total_cnt; /* Total number of calibrations. */
static int total_skips_cnt; /* Total number of skipped calibrations. */
/* Callback called on hfclk started. */
static void cal_hf_on_callback(struct device *dev, void *user_data);
static void cal_hf_on_callback(struct device *dev,
clock_control_subsys_t subsys,
void *user_data);
static struct clock_control_async_data cal_hf_on_data = {
.cb = cal_hf_on_callback
};
@ -238,7 +240,9 @@ out:
/* Called when HFCLK XTAL is on. Schedules temperature measurement or triggers
* calibration.
*/
static void cal_hf_on_callback(struct device *dev, void *user_data)
static void cal_hf_on_callback(struct device *dev,
clock_control_subsys_t subsys,
void *user_data)
{
int key = irq_lock();

View file

@ -281,7 +281,7 @@ static int clock_async_start(struct device *dev,
clock_irqs_enable();
if (already_started) {
data->cb(dev, data->user_data);
data->cb(dev, subsys, data->user_data);
}
}
@ -403,7 +403,8 @@ static void clkstarted_handle(struct device *dev,
sub_data->started = true;
while ((async_data = list_get(&sub_data->list)) != NULL) {
async_data->cb(dev, async_data->user_data);
async_data->cb(dev, (clock_control_subsys_t)type,
async_data->user_data);
}
}

View file

@ -26,7 +26,8 @@ struct temp_nrf5_data {
struct device *clk_dev;
};
static void hfclk_on_callback(struct device *dev, void *user_data)
static void hfclk_on_callback(struct device *dev, clock_control_subsys_t subsys,
void *user_data)
{
nrf_temp_task_trigger(NRF_TEMP, NRF_TEMP_TASK_START);
}

View file

@ -34,7 +34,6 @@ enum clock_control_status {
CLOCK_CONTROL_STATUS_UNKNOWN
};
typedef void (*clock_control_cb_t)(struct device *dev, void *user_data);
/**
* @cond INTERNAL_HIDDEN
@ -48,6 +47,23 @@ typedef void (*clock_control_cb_t)(struct device *dev, void *user_data);
* INTERNAL_HIDDEN @endcond
*/
/**
* clock_control_subsys_t is a type to identify a clock controller sub-system.
* Such data pointed is opaque and relevant only to the clock controller
* driver instance being used.
*/
typedef void *clock_control_subsys_t;
/** @brief Callback called on clock started.
*
* @param dev Device structure whose driver controls the clock.
* @param subsys Opaque data representing the clock.
* @param user_data User data.
*/
typedef void (*clock_control_cb_t)(struct device *dev,
clock_control_subsys_t subsys,
void *user_data);
/**
* Define and initialize clock_control async data.
*
@ -72,13 +88,6 @@ struct clock_control_async_data {
void *user_data;
};
/**
* clock_control_subsys_t is a type to identify a clock controller sub-system.
* Such data pointed is opaque and relevant only to the clock controller
* driver instance being used.
*/
typedef void *clock_control_subsys_t;
typedef int (*clock_control)(struct device *dev, clock_control_subsys_t sys);
typedef int (*clock_control_get)(struct device *dev,

View file

@ -206,7 +206,9 @@ static bool async_capable(const char *dev_name, clock_control_subsys_t subsys)
/*
* Test checks that callbacks are called after clock is started.
*/
static void clock_on_callback(struct device *dev, void *user_data)
static void clock_on_callback(struct device *dev,
clock_control_subsys_t subsys,
void *user_data)
{
bool *executed = (bool *)user_data;

View file

@ -27,7 +27,9 @@ static void turn_off_clock(struct device *dev, clock_control_subsys_t subsys)
} while (err == 0);
}
static void lfclk_started_cb(struct device *dev, void *user_data)
static void lfclk_started_cb(struct device *dev,
clock_control_subsys_t subsys,
void *user_data)
{
*(bool *)user_data = true;
}