Skip to content

Commit

Permalink
core: kernel: dt_driver: reference output device reference as void *
Browse files Browse the repository at this point in the history
Changes dt_driver API function to reference device reference as
void * instead of void ** which could be confusing as the reference
can be a pointer to a device pointer (e.g. in clk_dt.c) or a pointer
to a structure (e.g. interrupt.c).

Signed-off-by: Etienne Carriere <[email protected]>
  • Loading branch information
etienne-lms committed Nov 6, 2023
1 parent e943f42 commit a528603
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
13 changes: 7 additions & 6 deletions core/include/kernel/dt_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ struct dt_pargs {
*
* @parg: phandle argument(s) referencing the device in the FDT.
* @data: driver private data registered in struct dt_driver.
* @device_ref: Output reference to device
* @res: Output result code of the operation:
* TEE_SUCCESS in case of success
* TEE_ERROR_DEFER_DRIVER_INIT if device driver is not yet initialized
Expand All @@ -111,7 +112,7 @@ struct dt_pargs {
* driver, or NULL if not found in which case @res provides the error code.
*/
typedef TEE_Result (*get_of_device_func)(struct dt_pargs *parg, void *data,
void **out_device);
void *device_ref);

/**
* dt_driver_register_provider - Register a driver provider
Expand Down Expand Up @@ -139,7 +140,7 @@ TEE_Result dt_driver_register_provider(const void *fdt, int nodeoffset,
* @nodeoffset: node offset in the FDT
* @prop_idx: index of the phandle data in the property
* @type: Driver type
* @out_device: output device opaque reference upon support, for example
* @device_ref: output device opaque reference upon support, for example
* a struct clk pointer for a clock driver.
* Return code:
Expand All @@ -153,7 +154,7 @@ TEE_Result dt_driver_device_from_node_idx_prop(const char *prop_name,
const void *fdt, int nodeoffset,
unsigned int prop_idx,
enum dt_driver_type type,
void **out_device);
void *device_ref);

/*
* dt_driver_device_from_parent - Return a device instance based on the parent.
Expand All @@ -163,7 +164,7 @@ TEE_Result dt_driver_device_from_node_idx_prop(const char *prop_name,
* @fdt: FDT base address
* @nodeoffset: node offset in the FDT
* @type: Driver type
* @dout_device: output device opaque reference upon success, for example
* @device_ref: output device opaque reference upon success, for example
* a struct i2c_dev pointer for a I2C bus driver
*
* Return code:
Expand All @@ -173,7 +174,7 @@ TEE_Result dt_driver_device_from_node_idx_prop(const char *prop_name,
*/
TEE_Result dt_driver_device_from_parent(const void *fdt, int nodeoffset,
enum dt_driver_type type,
void **out_device);
void *device_ref);

/*
* dt_driver_device_from_node_idx_prop_phandle() - Same as
Expand All @@ -190,7 +191,7 @@ TEE_Result dt_driver_device_from_node_idx_prop_phandle(const char *prop_name,
unsigned int prop_index,
enum dt_driver_type type,
uint32_t phandle,
void **out_device);
void *device_ref);

/*
* dt_driver_get_crypto() - Request crypto support for driver initialization
Expand Down
19 changes: 11 additions & 8 deletions core/kernel/dt_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ dt_driver_get_provider_by_phandle(uint32_t phandle, enum dt_driver_type type)

static TEE_Result device_from_provider_prop(struct dt_driver_provider *prv,
const void *fdt, int phandle_node,
const uint32_t *prop, void **device)
const uint32_t *prop,
void *device_ref)
{
TEE_Result res = TEE_ERROR_GENERIC;
struct dt_pargs *pargs = NULL;
Expand All @@ -266,15 +267,16 @@ static TEE_Result device_from_provider_prop(struct dt_driver_provider *prv,
for (n = 0; n < prv->provider_cells; n++)
pargs->args[n] = fdt32_to_cpu(prop[n]);

res = prv->get_of_device(pargs, prv->priv_data, device);
res = prv->get_of_device(pargs, prv->priv_data, device_ref);

free(pargs);

return res;
}

TEE_Result dt_driver_device_from_parent(const void *fdt, int nodeoffset,
enum dt_driver_type type, void **device)
enum dt_driver_type type,
void *device_ref)
{
int parent = -1;
struct dt_driver_provider *prv = NULL;
Expand All @@ -291,7 +293,8 @@ TEE_Result dt_driver_device_from_parent(const void *fdt, int nodeoffset,
return TEE_ERROR_DEFER_DRIVER_INIT;
}

return device_from_provider_prop(prv, fdt, nodeoffset, NULL, device);
return device_from_provider_prop(prv, fdt, nodeoffset, NULL,
device_ref);
}

TEE_Result dt_driver_device_from_node_idx_prop_phandle(const char *prop_name,
Expand All @@ -300,7 +303,7 @@ TEE_Result dt_driver_device_from_node_idx_prop_phandle(const char *prop_name,
unsigned int prop_index,
enum dt_driver_type type,
uint32_t phandle,
void **device)
void *device_ref)
{
int len = 0;
const uint32_t *prop = NULL;
Expand Down Expand Up @@ -328,14 +331,14 @@ TEE_Result dt_driver_device_from_node_idx_prop_phandle(const char *prop_name,
return TEE_ERROR_ITEM_NOT_FOUND;

return device_from_provider_prop(prv, fdt, phandle_node_unused,
prop + prop_index, device);
prop + prop_index, device_ref);
}

TEE_Result dt_driver_device_from_node_idx_prop(const char *prop_name,
const void *fdt, int nodeoffset,
unsigned int prop_idx,
enum dt_driver_type type,
void **device)
void *device_ref)
{
int len = 0;
int idx = 0;
Expand Down Expand Up @@ -399,7 +402,7 @@ TEE_Result dt_driver_device_from_node_idx_prop(const char *prop_name,
idx32++;

return device_from_provider_prop(prv, fdt, phandle_node,
prop + idx32, device);
prop + idx32, device_ref);
}

return TEE_ERROR_ITEM_NOT_FOUND;
Expand Down

0 comments on commit a528603

Please sign in to comment.