Search Linux Wireless

[RFC v2 07/12] mac80211: allow drv_add_chanctx to fail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Johannes Berg <johannes.berg@xxxxxxxxx>

The driver might need to do some operations to the
device that could fail, so allow drv_add_chanctx()
to fail and propagate that error.

Signed-off-by: Johannes Berg <johannes.berg@xxxxxxxxx>
---
 include/net/mac80211.h    |    4 ++--
 net/mac80211/chan.c       |    7 +++++--
 net/mac80211/driver-ops.h |   12 ++++++++----
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 4d955c1..d6111a1 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -2508,8 +2508,8 @@ struct ieee80211_ops {
 	void	(*mgd_prepare_tx)(struct ieee80211_hw *hw,
 				  struct ieee80211_vif *vif);
 
-	void (*add_chanctx)(struct ieee80211_hw *hw,
-			    struct ieee80211_chanctx_conf *ctx);
+	int (*add_chanctx)(struct ieee80211_hw *hw,
+			   struct ieee80211_chanctx_conf *ctx);
 	void (*remove_chanctx)(struct ieee80211_hw *hw,
 			       struct ieee80211_chanctx_conf *ctx);
 	void (*change_chanctx)(struct ieee80211_hw *hw,
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index e77da88..95c4a5f 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -234,9 +234,12 @@ ieee80211_new_chanctx(struct ieee80211_local *local,
 	ctx->conf.channel_type = channel_type;
 	ctx->mode = mode;
 
-	list_add(&ctx->list, &local->chanctx_list);
+	if (drv_add_chanctx(local, ctx)) {
+		kfree(ctx);
+		return NULL;
+	}
 
-	drv_add_chanctx(local, ctx);
+	list_add(&ctx->list, &local->chanctx_list);
 
 	return ctx;
 }
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h
index aa34cb5..0526d9f 100644
--- a/net/mac80211/driver-ops.h
+++ b/net/mac80211/driver-ops.h
@@ -872,13 +872,17 @@ static inline void drv_mgd_prepare_tx(struct ieee80211_local *local,
 	trace_drv_return_void(local);
 }
 
-static inline void drv_add_chanctx(struct ieee80211_local *local,
-				   struct ieee80211_chanctx *ctx)
+static inline int drv_add_chanctx(struct ieee80211_local *local,
+				  struct ieee80211_chanctx *ctx)
 {
+	int ret = -EOPNOTSUPP;
+
 	trace_drv_add_chanctx(local, ctx);
 	if (local->ops->add_chanctx)
-		local->ops->add_chanctx(&local->hw, &ctx->conf);
-	trace_drv_return_void(local);
+		ret = local->ops->add_chanctx(&local->hw, &ctx->conf);
+	trace_drv_return_int(local, ret);
+
+	return ret;
 }
 
 static inline void drv_remove_chanctx(struct ieee80211_local *local,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux