diff mbox

brcmfmac: wrap brcmf_fws_(de)init into bcdc layer

Message ID 20170321134422.888-1-zajec5@gmail.com (mailing list archive)
State Rejected
Delegated to: Kalle Valo
Headers show

Commit Message

Rafał Miłecki March 21, 2017, 1:44 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

fwsignal is only used by bcdc. Create new protocol interface functions
for core code to perform proto specific (de)initialization. This makes
core agnostic to the protocol which will allow further optimizations.
We will be able to avoid compiling unused protocols or modularize them.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c  | 12 ++++++++++++
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c  |  7 +++----
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h | 16 ++++++++++++++++
 3 files changed, 31 insertions(+), 4 deletions(-)

Comments

Arend Van Spriel March 22, 2017, 7:43 p.m. UTC | #1
On 21-3-2017 14:44, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> fwsignal is only used by bcdc. Create new protocol interface functions
> for core code to perform proto specific (de)initialization. This makes
> core agnostic to the protocol which will allow further optimizations.
> We will be able to avoid compiling unused protocols or modularize them.

Thanks, Rafał

Franky had tackled this with two patches, which are queued to be submitted.

Regards,
Arend
Rafał Miłecki March 29, 2017, 11:27 a.m. UTC | #2
On 03/22/2017 08:43 PM, Arend Van Spriel wrote:
> On 21-3-2017 14:44, Rafał Miłecki wrote:
>> From: Rafał Miłecki <rafal@milecki.pl>
>>
>> fwsignal is only used by bcdc. Create new protocol interface functions
>> for core code to perform proto specific (de)initialization. This makes
>> core agnostic to the protocol which will allow further optimizations.
>> We will be able to avoid compiling unused protocols or modularize them.
>
> Thanks, Rafał
>
> Franky had tackled this with two patches, which are queued to be submitted.

Given that your implementation (you now published) doesn't do any magic, is
there any real problem with my patch except of /not invented here/?

[0] https://en.wikipedia.org/wiki/Not_invented_here
Arend Van Spriel March 30, 2017, 9:33 a.m. UTC | #3
On 29-3-2017 13:27, Rafał Miłecki wrote:
> On 03/22/2017 08:43 PM, Arend Van Spriel wrote:
>> On 21-3-2017 14:44, Rafał Miłecki wrote:
>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>
>>> fwsignal is only used by bcdc. Create new protocol interface functions
>>> for core code to perform proto specific (de)initialization. This makes
>>> core agnostic to the protocol which will allow further optimizations.
>>> We will be able to avoid compiling unused protocols or modularize them.
>>
>> Thanks, Rafał
>>
>> Franky had tackled this with two patches, which are queued to be
>> submitted.
> 
> Given that your implementation (you now published) doesn't do any magic, is
> there any real problem with my patch except of /not invented here/?

You could see it like that, but no. These two patches were already
reviewed and I requested more testing as explained in another email
response. Your patch needed a bit of rework and you can safely assume
that my remarks on your patch would make it even more like the one we
already had queued up. So it seemed unreasonable to have Kalle apply
yours and then the two from Franky. It would only be for the sake of
kernel git stats, which is not something I want to factor in.

Regards,
Arend

> [0] https://en.wikipedia.org/wiki/Not_invented_here
diff mbox

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
index 92eafccf087b..bb27a5f3cbdf 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
@@ -106,6 +106,16 @@  struct brcmf_bcdc {
 };
 
 
+static int brcmf_proto_bcdc_init(struct brcmf_pub *pub)
+{
+	return brcmf_fws_init(pub);
+}
+
+static void brcmf_proto_bcdc_deinit(struct brcmf_pub *pub)
+{
+	return brcmf_fws_deinit(pub);
+}
+
 static int
 brcmf_proto_bcdc_msg(struct brcmf_pub *drvr, int ifidx, uint cmd, void *buf,
 		     uint len, bool set)
@@ -431,6 +441,8 @@  int brcmf_proto_bcdc_attach(struct brcmf_pub *drvr)
 		goto fail;
 	}
 
+	drvr->proto->init = brcmf_proto_bcdc_init;
+	drvr->proto->deinit = brcmf_proto_bcdc_deinit;
 	drvr->proto->hdrpull = brcmf_proto_bcdc_hdrpull;
 	drvr->proto->query_dcmd = brcmf_proto_bcdc_query_dcmd;
 	drvr->proto->set_dcmd = brcmf_proto_bcdc_set_dcmd;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 60c6c7839cc2..d2be20627b5c 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -32,7 +32,6 @@ 
 #include "p2p.h"
 #include "cfg80211.h"
 #include "fwil.h"
-#include "fwsignal.h"
 #include "feature.h"
 #include "proto.h"
 #include "pcie.h"
@@ -986,7 +985,7 @@  int brcmf_bus_started(struct device *dev)
 	}
 	brcmf_feat_attach(drvr);
 
-	ret = brcmf_fws_init(drvr);
+	ret = brcmf_proto_init(drvr);
 	if (ret < 0)
 		goto fail;
 
@@ -1036,7 +1035,7 @@  int brcmf_bus_started(struct device *dev)
 	}
 	if (drvr->fws) {
 		brcmf_proto_del_if(ifp->drvr, ifp);
-		brcmf_fws_deinit(drvr);
+		brcmf_proto_deinit(drvr);
 	}
 	brcmf_net_detach(ifp->ndev, false);
 	if (p2p_ifp)
@@ -1103,7 +1102,7 @@  void brcmf_detach(struct device *dev)
 
 	brcmf_cfg80211_detach(drvr->config);
 
-	brcmf_fws_deinit(drvr);
+	brcmf_proto_deinit(drvr);
 
 	brcmf_bus_stop(drvr->bus_if);
 
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h
index 3048ed529f95..2a5d691be562 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h
@@ -27,6 +27,8 @@  struct brcmf_skb_reorder_data {
 };
 
 struct brcmf_proto {
+	int (*init)(struct brcmf_pub *pub);
+	void (*deinit)(struct brcmf_pub *pub);
 	int (*hdrpull)(struct brcmf_pub *drvr, bool do_fws,
 		       struct sk_buff *skb, struct brcmf_if **ifp);
 	int (*query_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd,
@@ -54,6 +56,20 @@  struct brcmf_proto {
 int brcmf_proto_attach(struct brcmf_pub *drvr);
 void brcmf_proto_detach(struct brcmf_pub *drvr);
 
+static inline int brcmf_proto_init(struct brcmf_pub *pub)
+{
+	if (!pub->proto->init)
+		return 0;
+	return pub->proto->init(pub);
+}
+
+static inline void brcmf_proto_deinit(struct brcmf_pub *pub)
+{
+	if (!pub->proto->deinit)
+		return;
+	pub->proto->deinit(pub);
+}
+
 static inline int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws,
 				      struct sk_buff *skb,
 				      struct brcmf_if **ifp)