Skip to contentSkip to conversation

staging: vt6656: Remove flags fMP_POST_READS and fMP_POST_WRITES

PATCH New Malcolm Priestley 1 participant 8 messages Jul 24, 2014 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/8 staging: vt6656: Remove flags fMP_POST_READS and fMP_POST_WRITES

MP_IS_READY(fMP_DISCONNECTED) is used to block thread in vnt_tx_context

---
 drivers/staging/vt6656/device.h   | 2 --
 drivers/staging/vt6656/main_usb.c | 4 ----
 drivers/staging/vt6656/usbpipe.c  | 2 +-
 3 files changed, 1 insertion(+), 7 deletions(-)
drivers/staging/vt6656/device.h +0 -2
index 6b7bb8c..273c663 100644
@@ -406,8 +406,6 @@ struct vnt_private {
 }
 
 #define fMP_DISCONNECTED                    0x00000002
-#define fMP_POST_READS                      0x00000100
-#define fMP_POST_WRITES                     0x00000200
 
 #define MP_SET_FLAG(_M, _F)             ((_M)->Flags |= (_F))
 #define MP_CLEAR_FLAG(_M, _F)            ((_M)->Flags &= ~(_F))
drivers/staging/vt6656/main_usb.c +0 -4
index b99def7..f887bc0 100644
@@ -552,8 +552,6 @@ static int vnt_start(struct ieee80211_hw *hw)
 	}
 
 	MP_CLEAR_FLAG(priv, fMP_DISCONNECTED);
-	MP_SET_FLAG(priv, fMP_POST_READS);
-	MP_SET_FLAG(priv, fMP_POST_WRITES);
 
 	if (device_init_registers(priv) == false) {
 		dev_dbg(&priv->usb->dev, " init register fail\n");
@@ -601,8 +599,6 @@ static void vnt_stop(struct ieee80211_hw *hw)
 	ieee80211_stop_queues(hw);
 
 	MP_SET_FLAG(priv, fMP_DISCONNECTED);
-	MP_CLEAR_FLAG(priv, fMP_POST_WRITES);
-	MP_CLEAR_FLAG(priv, fMP_POST_READS);
 
 	cancel_delayed_work_sync(&priv->run_command_work);
 
drivers/staging/vt6656/usbpipe.c +1 -1
index 7b050ba..c23a509 100644
@@ -289,7 +289,7 @@ int vnt_tx_context(struct vnt_private *priv,
 	int status;
 	struct urb *urb;
 
-	if (!(MP_IS_READY(priv) && priv->Flags & fMP_POST_WRITES)) {
+	if (!(MP_IS_READY(priv))) {
 		context->in_use = false;
 		return STATUS_RESOURCES;
 	}
Signature · 1 line
2.0.1
#1 lore raw

PATCH 2/8 staging: vt6656: remove macro MP_IS_READY

Just test FLag and remove not.

---
 drivers/staging/vt6656/device.h  | 2 --
 drivers/staging/vt6656/usbpipe.c | 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/vt6656/device.h +0 -2
index 273c663..58fbaab 100644
@@ -411,8 +411,6 @@ struct vnt_private {
 #define MP_CLEAR_FLAG(_M, _F)            ((_M)->Flags &= ~(_F))
 #define MP_TEST_FLAGS(_M, _F)            (((_M)->Flags & (_F)) == (_F))
 
-#define MP_IS_READY(_M)        (((_M)->Flags & fMP_DISCONNECTED) == 0)
-
 int vnt_init(struct vnt_private *priv);
 
 #endif
drivers/staging/vt6656/usbpipe.c +1 -1
index c23a509..ab95a07 100644
@@ -289,7 +289,7 @@ int vnt_tx_context(struct vnt_private *priv,
 	int status;
 	struct urb *urb;
 
-	if (!(MP_IS_READY(priv))) {
+	if (priv->Flags & fMP_DISCONNECTED) {
 		context->in_use = false;
 		return STATUS_RESOURCES;
 	}
Signature · 1 line
2.0.1
#2 lore raw

PATCH 3/8 staging: vt6656: Remove unsed macro DEVICE_FLAGS_OPENED

In reply to Malcolm Priestley
---
 drivers/staging/vt6656/device.h   | 3 ---
 drivers/staging/vt6656/main_usb.c | 4 ----
 2 files changed, 7 deletions(-)
drivers/staging/vt6656/device.h +0 -3
index 58fbaab..ac4c748 100644
@@ -264,9 +264,6 @@ enum {
 /* flags for options */
 #define     DEVICE_FLAGS_UNPLUG          0x00000001UL
 
-/* flags for driver status */
-#define     DEVICE_FLAGS_OPENED          0x00010000UL
-
 struct vnt_private {
 	/* mac80211 */
 	struct ieee80211_hw *hw;
drivers/staging/vt6656/main_usb.c +0 -4
index f887bc0..3cfbd31 100644
@@ -562,8 +562,6 @@ static int vnt_start(struct ieee80211_hw *hw)
 
 	vnt_int_start_interrupt(priv);
 
-	priv->flags |= DEVICE_FLAGS_OPENED;
-
 	ieee80211_wake_queues(hw);
 
 	return 0;
@@ -604,8 +602,6 @@ static void vnt_stop(struct ieee80211_hw *hw)
 
 	priv->cmd_running = false;
 
-	priv->flags &= ~DEVICE_FLAGS_OPENED;
-
 	device_free_tx_bufs(priv);
 	device_free_rx_bufs(priv);
 	device_free_int_bufs(priv);
Signature · 1 line
2.0.1
#3 lore raw

PATCH 4/8 staging: vt6656: struct vnt_private merge flag and macros

In reply to Malcolm Priestley

merge u32 flag into unsigned long Flags

Replacing fMP_DISCONNECTED with DEVICE_FLAGS_DISCONNECTED

---
 drivers/staging/vt6656/device.h   | 14 ++++++--------
 drivers/staging/vt6656/main_usb.c |  6 +++---
 drivers/staging/vt6656/usbpipe.c  |  6 +++---
 drivers/staging/vt6656/wcmd.c     |  2 +-
 4 files changed, 13 insertions(+), 15 deletions(-)
drivers/staging/vt6656/device.h +6 -8
index ac4c748..fd7105e 100644
@@ -262,7 +262,8 @@ enum {
 };
 
 /* flags for options */
-#define     DEVICE_FLAGS_UNPLUG          0x00000001UL
+#define DEVICE_FLAGS_UNPLUG		BIT(0)
+#define DEVICE_FLAGS_DISCONNECTED	BIT(1)
 
 struct vnt_private {
 	/* mac80211 */
@@ -281,8 +282,7 @@ struct vnt_private {
 	spinlock_t lock;
 	struct mutex usb_lock;
 
-	u32 flags;
-	unsigned long Flags;
+	unsigned long flags;
 
 	/* USB */
 	struct urb *interrupt_urb;
@@ -402,11 +402,9 @@ struct vnt_private {
 		(uVar)++;				\
 }
 
-#define fMP_DISCONNECTED                    0x00000002
-
-#define MP_SET_FLAG(_M, _F)             ((_M)->Flags |= (_F))
-#define MP_CLEAR_FLAG(_M, _F)            ((_M)->Flags &= ~(_F))
-#define MP_TEST_FLAGS(_M, _F)            (((_M)->Flags & (_F)) == (_F))
+#define MP_SET_FLAG(_M, _F)             ((_M)->flags |= (_F))
+#define MP_CLEAR_FLAG(_M, _F)            ((_M)->flags &= ~(_F))
+#define MP_TEST_FLAGS(_M, _F)            (((_M)->flags & (_F)) == (_F))
 
 int vnt_init(struct vnt_private *priv);
 
drivers/staging/vt6656/main_usb.c +3 -3
index 3cfbd31..87feba5 100644
@@ -551,7 +551,7 @@ static int vnt_start(struct ieee80211_hw *hw)
 		return -ENOMEM;
 	}
 
-	MP_CLEAR_FLAG(priv, fMP_DISCONNECTED);
+	MP_CLEAR_FLAG(priv, DEVICE_FLAGS_DISCONNECTED);
 
 	if (device_init_registers(priv) == false) {
 		dev_dbg(&priv->usb->dev, " init register fail\n");
@@ -596,7 +596,7 @@ static void vnt_stop(struct ieee80211_hw *hw)
 
 	ieee80211_stop_queues(hw);
 
-	MP_SET_FLAG(priv, fMP_DISCONNECTED);
+	MP_SET_FLAG(priv, DEVICE_FLAGS_DISCONNECTED);
 
 	cancel_delayed_work_sync(&priv->run_command_work);
 
@@ -1025,7 +1025,7 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
 
 	usb_device_reset(priv);
 
-	MP_CLEAR_FLAG(priv, fMP_DISCONNECTED);
+	MP_CLEAR_FLAG(priv, DEVICE_FLAGS_DISCONNECTED);
 	vnt_reset_command_timer(priv);
 
 	vnt_schedule_command(priv, WLAN_CMD_INIT_MAC80211);
drivers/staging/vt6656/usbpipe.c +3 -3
index ab95a07..b2722b9 100644
@@ -52,7 +52,7 @@ int vnt_control_out(struct vnt_private *priv, u8 request, u16 value,
 {
 	int status = 0;
 
-	if (priv->Flags & fMP_DISCONNECTED)
+	if (priv->flags & DEVICE_FLAGS_DISCONNECTED)
 		return STATUS_FAILURE;
 
 	mutex_lock(&priv->usb_lock);
@@ -80,7 +80,7 @@ int vnt_control_in(struct vnt_private *priv, u8 request, u16 value,
 {
 	int status;
 
-	if (priv->Flags & fMP_DISCONNECTED)
+	if (priv->flags & DEVICE_FLAGS_DISCONNECTED)
 		return STATUS_FAILURE;
 
 	mutex_lock(&priv->usb_lock);
@@ -289,7 +289,7 @@ int vnt_tx_context(struct vnt_private *priv,
 	int status;
 	struct urb *urb;
 
-	if (priv->Flags & fMP_DISCONNECTED) {
+	if (priv->flags & DEVICE_FLAGS_DISCONNECTED) {
 		context->in_use = false;
 		return STATUS_RESOURCES;
 	}
drivers/staging/vt6656/wcmd.c +1 -1
index e4a5e2b..e5330e3 100644
@@ -97,7 +97,7 @@ void vnt_run_command(struct work_struct *work)
 	struct vnt_private *priv =
 		container_of(work, struct vnt_private, run_command_work.work);
 
-	if (priv->Flags & fMP_DISCONNECTED)
+	if (priv->flags & DEVICE_FLAGS_DISCONNECTED)
 		return;
 
 	if (priv->cmd_running != true)
Signature · 1 line
2.0.1
#4 lore raw

PATCH 5/8 staging: vt6656: use set_bit to set flags

In reply to Malcolm Priestley

Replacing MP_SET_FLAG

---
 drivers/staging/vt6656/device.h   | 1 -
 drivers/staging/vt6656/main_usb.c | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/staging/vt6656/device.h +0 -1
index fd7105e..5ac80d8 100644
@@ -402,7 +402,6 @@ struct vnt_private {
 		(uVar)++;				\
 }
 
-#define MP_SET_FLAG(_M, _F)             ((_M)->flags |= (_F))
 #define MP_CLEAR_FLAG(_M, _F)            ((_M)->flags &= ~(_F))
 #define MP_TEST_FLAGS(_M, _F)            (((_M)->flags & (_F)) == (_F))
 
drivers/staging/vt6656/main_usb.c +2 -2
index 87feba5..7798221 100644
@@ -596,7 +596,7 @@ static void vnt_stop(struct ieee80211_hw *hw)
 
 	ieee80211_stop_queues(hw);
 
-	MP_SET_FLAG(priv, DEVICE_FLAGS_DISCONNECTED);
+	set_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags);
 
 	cancel_delayed_work_sync(&priv->run_command_work);
 
@@ -1051,7 +1051,7 @@ static void vt6656_disconnect(struct usb_interface *intf)
 	usb_set_intfdata(intf, NULL);
 	usb_put_dev(interface_to_usbdev(intf));
 
-	priv->flags |= DEVICE_FLAGS_UNPLUG;
+	set_bit(DEVICE_FLAGS_UNPLUG, &priv->flags);
 
 	ieee80211_free_hw(priv->hw);
 }
Signature · 1 line
2.0.1
#5 lore raw

PATCH 6/8 staging: vt6656: use clear_bit to remove device flag

In reply to Malcolm Priestley

Replacing MP_CLEAR_FLAG

---
 drivers/staging/vt6656/device.h   | 1 -
 drivers/staging/vt6656/main_usb.c | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/staging/vt6656/device.h +0 -1
index 5ac80d8..21f810e 100644
@@ -402,7 +402,6 @@ struct vnt_private {
 		(uVar)++;				\
 }
 
-#define MP_CLEAR_FLAG(_M, _F)            ((_M)->flags &= ~(_F))
 #define MP_TEST_FLAGS(_M, _F)            (((_M)->flags & (_F)) == (_F))
 
 int vnt_init(struct vnt_private *priv);
drivers/staging/vt6656/main_usb.c +2 -2
index 7798221..d729d94 100644
@@ -551,7 +551,7 @@ static int vnt_start(struct ieee80211_hw *hw)
 		return -ENOMEM;
 	}
 
-	MP_CLEAR_FLAG(priv, DEVICE_FLAGS_DISCONNECTED);
+	clear_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags);
 
 	if (device_init_registers(priv) == false) {
 		dev_dbg(&priv->usb->dev, " init register fail\n");
@@ -1025,7 +1025,7 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
 
 	usb_device_reset(priv);
 
-	MP_CLEAR_FLAG(priv, DEVICE_FLAGS_DISCONNECTED);
+	clear_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags);
 	vnt_reset_command_timer(priv);
 
 	vnt_schedule_command(priv, WLAN_CMD_INIT_MAC80211);
Signature · 1 line
2.0.1
#6 lore raw

PATCH 7/8 staging: vt6656: Remove unused macro MP_TEST_FLAGS

In reply to Malcolm Priestley
---
 drivers/staging/vt6656/device.h | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/vt6656/device.h +0 -2
index 21f810e..2ec086c 100644
@@ -402,8 +402,6 @@ struct vnt_private {
 		(uVar)++;				\
 }
 
-#define MP_TEST_FLAGS(_M, _F)            (((_M)->flags & (_F)) == (_F))
-
 int vnt_init(struct vnt_private *priv);
 
 #endif
Signature · 1 line
2.0.1
#7 lore raw

PATCH 8/8 staging: vt6656: use test_bit to check flags status

In reply to Malcolm Priestley
---
 drivers/staging/vt6656/main_usb.c | 2 +-
 drivers/staging/vt6656/usbpipe.c  | 6 +++---
 drivers/staging/vt6656/wcmd.c     | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/vt6656/main_usb.c +1 -1
index d729d94..fdc5c7b 100644
@@ -591,7 +591,7 @@ static void vnt_stop(struct ieee80211_hw *hw)
 	/* clear all keys */
 	priv->key_entry_inuse = 0;
 
-	if ((priv->flags & DEVICE_FLAGS_UNPLUG) == false)
+	if (!test_bit(DEVICE_FLAGS_UNPLUG, &priv->flags))
 		vnt_mac_shutdown(priv);
 
 	ieee80211_stop_queues(hw);
drivers/staging/vt6656/usbpipe.c +3 -3
index b2722b9..f1969fe 100644
@@ -52,7 +52,7 @@ int vnt_control_out(struct vnt_private *priv, u8 request, u16 value,
 {
 	int status = 0;
 
-	if (priv->flags & DEVICE_FLAGS_DISCONNECTED)
+	if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags))
 		return STATUS_FAILURE;
 
 	mutex_lock(&priv->usb_lock);
@@ -80,7 +80,7 @@ int vnt_control_in(struct vnt_private *priv, u8 request, u16 value,
 {
 	int status;
 
-	if (priv->flags & DEVICE_FLAGS_DISCONNECTED)
+	if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags))
 		return STATUS_FAILURE;
 
 	mutex_lock(&priv->usb_lock);
@@ -289,7 +289,7 @@ int vnt_tx_context(struct vnt_private *priv,
 	int status;
 	struct urb *urb;
 
-	if (priv->flags & DEVICE_FLAGS_DISCONNECTED) {
+	if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) {
 		context->in_use = false;
 		return STATUS_RESOURCES;
 	}
drivers/staging/vt6656/wcmd.c +1 -1
index e5330e3..8f6417bc 100644
@@ -97,7 +97,7 @@ void vnt_run_command(struct work_struct *work)
 	struct vnt_private *priv =
 		container_of(work, struct vnt_private, run_command_work.work);
 
-	if (priv->flags & DEVICE_FLAGS_DISCONNECTED)
+	if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags))
 		return;
 
 	if (priv->cmd_running != true)
Signature · 1 line
2.0.1