Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b208656 authored by Sjur Braendeland's avatar Sjur Braendeland Committed by David S. Miller
Browse files

caif: Add reference counting to service layer



Changes:
o Added functions cfsrvl_get and cfsrvl_put.
o Added support release_client to use by socket and net device.
o Increase reference counting for in-flight packets from cfmuxl

Signed-off-by: default avatarSjur Braendeland <sjur.brandeland@stericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e539d83c
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -69,6 +69,17 @@ int caif_connect_client(struct caif_connect_request *config,
 */
int caif_disconnect_client(struct cflayer *client_layer);

/**
 * caif_release_client - Release adaptation layer reference to client.
 *
 * @client_layer: Client layer.
 *
 * Releases a client/adaptation layer use of the caif stack.
 * This function must be used after caif_disconnect_client to
 * decrease the reference count of the service layer.
 */
void caif_release_client(struct cflayer *client_layer);

/**
 * connect_req_to_link_param - Translate configuration parameters
 *				from socket format to internal format.
+7 −0
Original line number Diff line number Diff line
@@ -96,6 +96,13 @@ int cfcnfg_del_phy_layer(struct cfcnfg *cnfg, struct cflayer *phy_layer);
int cfcnfg_disconn_adapt_layer(struct cfcnfg *cnfg,
			struct cflayer *adap_layer);

/**
 * cfcnfg_release_adap_layer - Used by client to release the adaptation layer.
 *
 * @adap_layer: Adaptation layer.
 */
void cfcnfg_release_adap_layer(struct cflayer *adap_layer);

/**
 * cfcnfg_add_adaptation_layer - Add an adaptation layer to the CAIF stack.
 *
+22 −0
Original line number Diff line number Diff line
@@ -9,14 +9,18 @@
#include <linux/list.h>
#include <linux/stddef.h>
#include <linux/types.h>
#include <linux/kref.h>

struct cfsrvl {
	struct cflayer layer;
	bool open;
	bool phy_flow_on;
	bool modem_flow_on;
	struct dev_info dev_info;
	struct kref ref;
};

void cfsrvl_release(struct kref *kref);
struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info);
struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info);
struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info);
@@ -31,4 +35,22 @@ void cfsrvl_init(struct cfsrvl *service,
bool cfsrvl_ready(struct cfsrvl *service, int *err);
u8 cfsrvl_getphyid(struct cflayer *layer);

static inline void cfsrvl_get(struct cflayer *layr)
{
	struct cfsrvl *s;
	if (layr == NULL)
		return;
	s = container_of(layr, struct cfsrvl, layer);
	kref_get(&s->ref);
}

static inline void cfsrvl_put(struct cflayer *layr)
{
	struct cfsrvl *s;
	if (layr == NULL)
		return;
	s = container_of(layr, struct cfsrvl, layer);
	kref_put(&s->ref, cfsrvl_release);
}

#endif				/* CFSRVL_H_ */
+6 −0
Original line number Diff line number Diff line
@@ -346,6 +346,12 @@ int caif_disconnect_client(struct cflayer *adap_layer)
}
EXPORT_SYMBOL(caif_disconnect_client);

void caif_release_client(struct cflayer *adap_layer)
{
       cfcnfg_release_adap_layer(adap_layer);
}
EXPORT_SYMBOL(caif_release_client);

/* Per-namespace Caif devices handling */
static int caif_init_net(struct net *net)
{
+7 −0
Original line number Diff line number Diff line
@@ -247,6 +247,13 @@ int cfcnfg_disconn_adapt_layer(struct cfcnfg *cnfg, struct cflayer *adap_layer)
}
EXPORT_SYMBOL(cfcnfg_disconn_adapt_layer);

void cfcnfg_release_adap_layer(struct cflayer *adap_layer)
{
	if (adap_layer->dn)
		cfsrvl_put(adap_layer->dn);
}
EXPORT_SYMBOL(cfcnfg_release_adap_layer);

static void cfcnfg_linkdestroy_rsp(struct cflayer *layer, u8 channel_id,
				  struct cflayer *client_layer)
{
Loading