libdect: support allocating per-handle private space
Similar to other objects, support a private data area for libdect handles for applications dealing with multiple handles simultenously. Signed-off-by: Patrick McHardy <kaber@trash.net>
This commit is contained in:
parent
3c8698333b
commit
582a7d50c7
|
@ -127,6 +127,8 @@ struct dect_event_ops {
|
|||
* The DECT ops contain references to the individual ops of the libdect subsystems.
|
||||
*/
|
||||
struct dect_ops {
|
||||
size_t priv_size;
|
||||
|
||||
void *(*malloc)(size_t size);
|
||||
void (*free)(void *ptr);
|
||||
|
||||
|
@ -144,6 +146,8 @@ extern struct dect_handle *dect_open_handle(struct dect_ops *ops,
|
|||
const char *cluster);
|
||||
extern void dect_close_handle(struct dect_handle *dh);
|
||||
|
||||
extern void *dect_handle_priv(struct dect_handle *dh);
|
||||
|
||||
extern void dect_pp_set_ipui(struct dect_handle *dh,
|
||||
const struct dect_ipui *ipui);
|
||||
extern void dect_pp_set_tpui(struct dect_handle *dh,
|
||||
|
|
|
@ -53,6 +53,8 @@ struct dect_handle {
|
|||
struct list_head links;
|
||||
|
||||
struct list_head mme_list;
|
||||
|
||||
uint8_t priv[] __aligned(__alignof__(uint64_t));
|
||||
};
|
||||
|
||||
#endif /* _LIBDECT_H */
|
||||
|
|
|
@ -31,7 +31,7 @@ static struct dect_handle *dect_alloc_handle(struct dect_ops *ops)
|
|||
if (ops->free == NULL)
|
||||
ops->free = free;
|
||||
|
||||
dh = ops->malloc(sizeof(*dh));
|
||||
dh = ops->malloc(sizeof(*dh) + ops->priv_size);
|
||||
if (dh == NULL)
|
||||
return NULL;
|
||||
memset(dh, 0, sizeof(*dh));
|
||||
|
@ -92,4 +92,10 @@ void dect_close_handle(struct dect_handle *dh)
|
|||
}
|
||||
EXPORT_SYMBOL(dect_close_handle);
|
||||
|
||||
void *dect_handle_priv(struct dect_handle *dh)
|
||||
{
|
||||
return dh->priv;
|
||||
}
|
||||
EXPORT_SYMBOL(dect_handle_priv);
|
||||
|
||||
/** @} */
|
||||
|
|
Reference in New Issue