Skip to contentSkip to conversation

caif: code cleanup

RFC In review Stephen Hemminger 2 participants 3 messages Oct 19, 2010 – Oct 29, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 caif: code cleanup

Cleanup of new CAIF code.
* make local functions static
* remove code that is never used
* expand get_caif_conf() since wrapper is no longer needed
* make args to comparison functions const
* rename connect_req_to_link_param to keep exported names consistent

Compile tested only.

---
 include/net/caif/caif_dev.h |   27 +-----
 include/net/caif/cfctrl.h   |   12 --
 include/net/caif/cfmuxl.h   |    2 
 include/net/caif/cfpkt.h    |   75 ------------------
 include/net/caif/cfsrvl.h   |    3 
 net/caif/caif_config_util.c |    6 -
 net/caif/caif_dev.c         |   24 +----
 net/caif/cfcnfg.c           |    2 
 net/caif/cfctrl.c           |   74 +-----------------
 net/caif/cfmuxl.c           |   35 --------
 net/caif/cfpkt_skbuff.c     |  178 +-------------------------------------------
 net/caif/cfsrvl.c           |    7 -
 12 files changed, 29 insertions(+), 416 deletions(-)
include/net/caif/caif_dev.h +5 -22
@@ -74,19 +74,8 @@ int caif_connect_client(struct caif_conn
 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.
+ * caif_connect_req_to_link_param - Translate configuration parameters
+ *				    from socket format to internal format.
  * @cnfg:	Pointer to configuration handler
  * @con_req:	Configuration parameters supplied in function
  *		caif_connect_client
@@ -94,14 +83,8 @@ void caif_release_client(struct cflayer
  *			 setting up channels.
  *
  */
-int connect_req_to_link_param(struct cfcnfg *cnfg,
-				struct caif_connect_request *con_req,
-				struct cfctrl_link_param *channel_setup_param);
-
-/**
- * get_caif_conf() - Get the configuration handler.
- */
-struct cfcnfg *get_caif_conf(void);
-
+int caif_connect_req_to_link_param(struct cfcnfg *cnfg,
+				   struct caif_connect_request *con_req,
+				   struct cfctrl_link_param *channel_setup_param);
 
 #endif /* CAIF_DEV_H_ */
include/net/caif/cfctrl.h +1 -11
@@ -121,19 +121,9 @@ int cfctrl_linkup_request(struct cflayer
 			   struct cflayer *user_layer);
 int  cfctrl_linkdown_req(struct cflayer *cfctrl, u8 linkid,
 			 struct cflayer *client);
-void cfctrl_sleep_req(struct cflayer *cfctrl);
-void cfctrl_wake_req(struct cflayer *cfctrl);
-void cfctrl_getstartreason_req(struct cflayer *cfctrl);
+
 struct cflayer *cfctrl_create(void);
-void cfctrl_set_dnlayer(struct cflayer *this, struct cflayer *dn);
-void cfctrl_set_uplayer(struct cflayer *this, struct cflayer *up);
 struct cfctrl_rsp *cfctrl_get_respfuncs(struct cflayer *layer);
-bool cfctrl_req_eq(struct cfctrl_request_info *r1,
-		   struct cfctrl_request_info *r2);
-void cfctrl_insert_req(struct cfctrl *ctrl,
-			      struct cfctrl_request_info *req);
-struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
-					      struct cfctrl_request_info *req);
 void cfctrl_cancel_req(struct cflayer *layr, struct cflayer *adap_layer);
 
 #endif				/* CFCTRL_H_ */
include/net/caif/cfpkt.h +0 -75

93 lines not on this page · raw message

net/caif/caif_dev.c +6 -18
@@ -257,7 +257,7 @@ static int caif_device_notify(struct not
 			break;
 		}
 		dev_hold(dev);
-		cfcnfg_add_phy_layer(get_caif_conf(),
+		cfcnfg_add_phy_layer(cfg,
 				     phy_type,
 				     dev,
 				     &caifd->layer,
@@ -300,7 +300,7 @@ static int caif_device_notify(struct not
 		if (atomic_read(&caifd->in_use))
 			netdev_warn(dev,
 				    "Unregistering an active CAIF device\n");
-		cfcnfg_del_phy_layer(get_caif_conf(), &caifd->layer);
+		cfcnfg_del_phy_layer(cfg, &caifd->layer);
 		dev_put(dev);
 		atomic_set(&caifd->state, what);
 		break;
@@ -320,24 +320,18 @@ static struct notifier_block caif_device
 	.priority = 0,
 };
 
-
-struct cfcnfg *get_caif_conf(void)
-{
-	return cfg;
-}
-EXPORT_SYMBOL(get_caif_conf);
-
 int caif_connect_client(struct caif_connect_request *conn_req,
 			struct cflayer *client_layer, int *ifindex,
 			int *headroom, int *tailroom)
 {
 	struct cfctrl_link_param param;
 	int ret;
-	ret = connect_req_to_link_param(get_caif_conf(), conn_req, &param);
+
+	ret = caif_connect_req_to_link_param(cfg, conn_req, &param);
 	if (ret)
 		return ret;
 	/* Hook up the adaptation layer. */
-	return cfcnfg_add_adaptation_layer(get_caif_conf(), &param,
+	return cfcnfg_add_adaptation_layer(cfg, &param,
 					client_layer, ifindex,
 					headroom, tailroom);
 }
@@ -345,16 +339,10 @@ EXPORT_SYMBOL(caif_connect_client);
 
 int caif_disconnect_client(struct cflayer *adap_layer)
 {
-       return cfcnfg_disconn_adapt_layer(get_caif_conf(), adap_layer);
+       return cfcnfg_disconn_adapt_layer(cfg, 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)
 {
net/caif/cfcnfg.c +1 -1
@@ -257,7 +257,7 @@ static void cfcnfg_linkdestroy_rsp(struc
 {
 }
 
-int protohead[CFCTRL_SRV_MASK] = {
+static const int protohead[CFCTRL_SRV_MASK] = {
 	[CFCTRL_SRV_VEI] = 4,
 	[CFCTRL_SRV_DATAGRAM] = 7,
 	[CFCTRL_SRV_UTIL] = 4,
net/caif/cfctrl.c +6 -68

110 lines not on this page · raw message

net/caif/cfmuxl.c +0 -35
@@ -71,41 +71,6 @@ int cfmuxl_set_uplayer(struct cflayer *l
 	return 0;
 }
 
-bool cfmuxl_is_phy_inuse(struct cflayer *layr, u8 phyid)
-{
-	struct list_head *node;
-	struct cflayer *layer;
-	struct cfmuxl *muxl = container_obj(layr);
-	bool match = false;
-	spin_lock(&muxl->receive_lock);
-
-	list_for_each(node, &muxl->srvl_list) {
-		layer = list_entry(node, struct cflayer, node);
-		if (cfsrvl_phyid_match(layer, phyid)) {
-			match = true;
-			break;
-		}
-
-	}
-	spin_unlock(&muxl->receive_lock);
-	return match;
-}
-
-u8 cfmuxl_get_phyid(struct cflayer *layr, u8 channel_id)
-{
-	struct cflayer *up;
-	int phyid;
-	struct cfmuxl *muxl = container_obj(layr);
-	spin_lock(&muxl->receive_lock);
-	up = get_up(muxl, channel_id);
-	if (up != NULL)
-		phyid = cfsrvl_getphyid(up);
-	else
-		phyid = 0;
-	spin_unlock(&muxl->receive_lock);
-	return phyid;
-}
-
 int cfmuxl_set_dnlayer(struct cflayer *layr, struct cflayer *dn, u8 phyid)
 {
 	struct cfmuxl *muxl = (struct cfmuxl *) layr;
net/caif/cfpkt_skbuff.c +5 -173

213 lines not on this page · raw message

net/caif/cfsrvl.c +1 -6
@@ -151,12 +151,7 @@ static int cfservl_modemcmd(struct cflay
 	return -EINVAL;
 }
 
-void cfservl_destroy(struct cflayer *layer)
-{
-	kfree(layer);
-}
-
-void cfsrvl_release(struct kref *kref)
+static void cfsrvl_release(struct kref *kref)
 {
 	struct cfsrvl *service = container_of(kref, struct cfsrvl, ref);
 	kfree(service);
include/net/caif/cfmuxl.h +0 -2
@@ -16,7 +16,5 @@ int cfmuxl_set_uplayer(struct cflayer *l
 struct cflayer *cfmuxl_remove_dnlayer(struct cflayer *layr, u8 phyid);
 int cfmuxl_set_dnlayer(struct cflayer *layr, struct cflayer *up, u8 phyid);
 struct cflayer *cfmuxl_remove_uplayer(struct cflayer *layr, u8 linkid);
-bool cfmuxl_is_phy_inuse(struct cflayer *layr, u8 phyid);
-u8 cfmuxl_get_phyid(struct cflayer *layr, u8 channel_id);
 
 #endif				/* CFMUXL_H_ */
include/net/caif/cfsrvl.h +1 -2
@@ -22,7 +22,6 @@ struct cfsrvl {
 	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,7 +30,7 @@ struct cflayer *cfrfml_create(u8 linkid,
 				int mtu_size);
 struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info);
 bool cfsrvl_phyid_match(struct cflayer *layer, int phyid);
-void cfservl_destroy(struct cflayer *layer);
+
 void cfsrvl_init(struct cfsrvl *service,
 			u8 channel_id,
 			struct dev_info *dev_info,
net/caif/caif_config_util.c +3 -3
@@ -10,9 +10,9 @@
 #include <net/caif/cfcnfg.h>
 #include <net/caif/caif_dev.h>
 
-int connect_req_to_link_param(struct cfcnfg *cnfg,
-				struct caif_connect_request *s,
-				struct cfctrl_link_param *l)
+int caif_connect_req_to_link_param(struct cfcnfg *cnfg,
+				   struct caif_connect_request *s,
+				   struct cfctrl_link_param *l)
 {
 	struct dev_info *dev_info;
 	enum cfcnfg_phy_preference pref;
#1 lore raw

Hi Stephen,

Quoted 8 lines · Stephen Hemminger

Cleanup of new CAIF code.
* make local functions static
* remove code that is never used
* expand get_caif_conf() since wrapper is no longer needed
* make args to comparison functions const
* rename connect_req_to_link_param to keep exported names consistent

Thank you for your patch.
We'll try to test this sometime next week,
and get back to you.

Regards,
Sjur

#2 lore raw
In reply to Stephen Hemminger

Hi Stephen,

Quoted 10 lines
Quoted 8 lines · Stephen Hemminger

Cleanup of new CAIF code.
* make local functions static
* remove code that is never used
* expand get_caif_conf() since wrapper is no longer needed
* make args to comparison functions const
* rename connect_req_to_link_param to keep exported names consistent

Quoted 3 lines

Thank you for your patch.
We'll try to test this sometime next week,
and get back to you.

Sorry for taking so long to respond.
We have passed our tests on your RFC.
I'll ack this if you send a patch.

Regards,
Sjur